mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: #10000 代码优化
This commit is contained in:
parent
a941fe6a1a
commit
16e120fa1f
@ -46,9 +46,9 @@ class Test extends Command
|
||||
// $this->info('全部下架');
|
||||
// exit();
|
||||
// 1-7 11
|
||||
// $shop = Shop::query()->find(11);
|
||||
// $business = BusinessFactory::init()->make($shop->plat_id);
|
||||
// $business->setShop($shop);
|
||||
$shop = Shop::query()->find(1);
|
||||
$business = BusinessFactory::init()->make($shop->plat_id);
|
||||
$business->setShop($shop);
|
||||
// 下载商品列表
|
||||
// $business->downloadGoodsListAndBind();
|
||||
|
||||
@ -59,9 +59,9 @@ class Test extends Command
|
||||
// $business->incrQuantity(1);
|
||||
|
||||
// 订单下载
|
||||
// $beginTime = DateTimeUtils::getMicroTime('2022-08-23 00:00:00');
|
||||
// $endTime = DateTimeUtils::getMicroTime('2022-08-24 00:00:00');
|
||||
// $business->downloadOrdersAndSave($beginTime, $endTime);
|
||||
$beginTime = DateTimeUtils::getMicroTime('2022-08-30 19:17:03');
|
||||
$endTime = DateTimeUtils::getMicroTime('2022-08-30 19:19:03');
|
||||
$business->downloadOrdersAndSave($beginTime, $endTime);
|
||||
|
||||
// $shops = Shop::query()->where('status', 1)->get();
|
||||
// $that = $this;
|
||||
|
||||
@ -11,6 +11,7 @@ use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BusinessOrdersUpdate
|
||||
{
|
||||
@ -42,6 +43,7 @@ class BusinessOrdersUpdate
|
||||
})
|
||||
->first();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('事件库存更新失败: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
if ($this->goodsSku) {
|
||||
|
||||
@ -9,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Events\BusinessOrdersUpdate;
|
||||
use App\Jobs\BusinessGoodsSkuIncrQuantity;
|
||||
use Illuminate\Support\Facades\Log as LogFile;
|
||||
|
||||
class UpdateBusinessGoodsStock implements ShouldQueue
|
||||
{
|
||||
@ -50,6 +51,7 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
||||
}
|
||||
$shops = Shop::query()->where('id', '<>', $event->businessOrderItem['shop_id'])->whereNotIn('status', [0, 3])->get(['id', 'plat_id']);
|
||||
if (empty($shops)) {
|
||||
LogFile::info('可操作店铺为空');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ abstract class BusinessClient
|
||||
$orderRecord->update($order);
|
||||
}
|
||||
foreach ($order['sub_order_list'] as $item) {
|
||||
$item['update_time'] = $item['updated_at'];
|
||||
unset($item['updated_at']);
|
||||
$item['shop_id'] = $shopId;
|
||||
$orderItem = BusinessOrderItem::firstOrNew(['shop_id' => $shopId, 'business_order_id' => $orderRecord->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], $item);
|
||||
$num = 0;
|
||||
@ -141,7 +143,6 @@ abstract class BusinessClient
|
||||
$res = (new Client())->request($method, $url, $headers);
|
||||
$size = $res->getBody()->getSize();
|
||||
$res = json_decode($res->getBody()->getContents(), true);
|
||||
if (!in_array($params['type'], ['pdd.ktt.increment.order.query', 'pdd.ktt.order.list'], true)) {
|
||||
$log = new Log();
|
||||
$log->module = 'plat';
|
||||
$log->action = $method;
|
||||
@ -149,13 +150,12 @@ abstract class BusinessClient
|
||||
$log->target_id = $this->getShop()->id;
|
||||
$log->target_field = $params['type'];
|
||||
$log->user_id = Auth::id() ?? 999;
|
||||
if ($size < 64000) {
|
||||
$log->message = json_encode($res, 256);
|
||||
}
|
||||
if ('pdd.ktt.goods.incr.quantity' === $params['type']) {
|
||||
$log->message .= json_encode($params, 256);
|
||||
if ($size < 48000) {
|
||||
$log->message = json_encode($res, 256) . '=====' . json_encode($params, 256);
|
||||
}
|
||||
$log->save();
|
||||
if (isset($res['error_response'])) {
|
||||
throw new \RuntimeException($res['error_response']['error_msg']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Services\Business\KuaiTuanTuan;
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Services\Business\BusinessClient;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class KuaiTuanTuan extends BusinessClient
|
||||
{
|
||||
|
||||
@ -38,6 +38,7 @@ class CreateBusinessOrderItemsTable extends Migration
|
||||
$table->bigInteger('theoretically_refund_amount')->nullable();
|
||||
$table->string('thumb_url')->nullable();
|
||||
$table->integer('verification_number')->nullable();
|
||||
$table->bigInteger('update_time')->nullable();
|
||||
$table->timestamps();
|
||||
// 索引
|
||||
$table->index(['shop_id', 'business_order_id', 'goods_id', 'sku_id']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user