!263 发货状态同步
Merge pull request !263 from 杨建炊/fix-release-1.0.0/yjc-migrate
This commit is contained in:
commit
d355d30583
@ -16,7 +16,7 @@ class KttOrderSyncStatus extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ktt:order_sync_status';
|
||||
protected $signature = 'ktt:order_sync_status {ids?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@ -43,20 +43,25 @@ class KttOrderSyncStatus extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$ids = $this->argument('ids');
|
||||
if (!empty($ids)) {
|
||||
$ids = explode(",", $ids);
|
||||
}
|
||||
$startTime = Carbon::now()->subDays(15)->getPreciseTimestamp(3);
|
||||
$shops = Shop::query()->where('plat_id', Shop::$PLAT_KTT)->where('status', Shop::$STATUS_AUTHORIZED)->get();
|
||||
BusinessOrder::query()->where('confirm_at', '>=', $startTime)
|
||||
->where('shipping_status',BusinessOrderShippingStatus::UNSHIP)
|
||||
->where('cancel_status',0)
|
||||
->chunk(200, function ($orders) use ($shops) {
|
||||
BusinessOrder::query()->when($ids, function ($query) use ($ids) {
|
||||
$query->whereIn('id',$ids);
|
||||
})
|
||||
->where('confirm_at', '>=', $startTime)
|
||||
->where('shipping_status', BusinessOrderShippingStatus::UNSHIP)
|
||||
->where('cancel_status', 0)
|
||||
->chunk(200, function ($orders) {
|
||||
foreach ($orders as $order) {
|
||||
$shop = $shops->where('id',$order['shop_id'])->first();
|
||||
if(!empty($shop)){
|
||||
$shop = Shop::query()->find($order['shop_id']);
|
||||
if (!empty($shop)) {
|
||||
BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->queryStatusAndSync($order);
|
||||
usleep(10);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,6 +196,11 @@ class KuaiTuanTuan extends BusinessClient
|
||||
$order->cancel_status = $queryOrder['cancel_status'];
|
||||
$needUpdate = true;
|
||||
}
|
||||
if ($order->after_sales_status!= $queryOrder['cancel_status']) {
|
||||
//售后状态更新
|
||||
$order->after_sales_status = $queryOrder['after_sales_status'];
|
||||
$needUpdate = true;
|
||||
}
|
||||
if ($needUpdate) {
|
||||
$goodsSkuNum = 0;
|
||||
foreach ($queryOrder['sub_order_list'] as $item) {
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
namespace App\Services\Business\MiaoXuan;
|
||||
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\BusinessOrderItem;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Services\Business\BusinessClient;
|
||||
|
||||
class MiaoXuan extends BusinessClient
|
||||
@ -33,12 +35,52 @@ class MiaoXuan extends BusinessClient
|
||||
{
|
||||
}
|
||||
|
||||
public function downloadAfterSaleOrdersAndSave($beginTime, $endTime, $page = 1){
|
||||
public function downloadAfterSaleOrdersAndSave($beginTime, $endTime, $page = 1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function queryStatusAndSync($order){
|
||||
public function queryStatusAndSync($order)
|
||||
{
|
||||
$appendParams = ["order_sn" => $order->order_sn, "type" => "erpQuery"];
|
||||
$url = 'http://shop.dev.chutang66.com/miaoxuan/queryOrder';
|
||||
$queryOrder = $this->formDataPostRequest($url, $appendParams);
|
||||
$needUpdate = false;
|
||||
if ($order->shipping_status != $queryOrder['shipping_status']) {
|
||||
$order->shipping_status = $queryOrder['shipping_status'];
|
||||
$needUpdate = true;
|
||||
}
|
||||
if ($order->cancel_status != $queryOrder['cancel_status']) {
|
||||
$order->cancel_status = $queryOrder['cancel_status'];
|
||||
$needUpdate = true;
|
||||
}
|
||||
if ($order->after_sales_status!= $queryOrder['cancel_status']) {
|
||||
//售后状态更新
|
||||
$order->after_sales_status = $queryOrder['after_sales_status'];
|
||||
$needUpdate = true;
|
||||
}
|
||||
if ($needUpdate) {
|
||||
$goodsSkuNum = 0;
|
||||
foreach ($queryOrder['sub_order_list'] as $item) {
|
||||
$orderItem = BusinessOrderItem::firstOrNew(['shop_id' => $order->shop_id, 'business_order_id' => $order->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], $item);
|
||||
if ($item['external_sku_id']) {
|
||||
$goodsSku = GoodsSku::query()
|
||||
->with('combinationGoods')
|
||||
->where('external_sku_id', $item['external_sku_id'])
|
||||
->first('external_sku_id');
|
||||
$combinationNum = $goodsSku ? ($goodsSku->combinationGoods->count() ?: 1) : 1;
|
||||
$goodsSkuNum += $combinationNum;
|
||||
} else {
|
||||
$goodsSkuNum++;
|
||||
}
|
||||
|
||||
if (!empty($orderItem->id)) {
|
||||
$orderItem->update($item);
|
||||
}
|
||||
}
|
||||
$order->goods_sku_num = $goodsSkuNum;
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function batchIncrQuantity($businessGoodsSkus, $num, $incremental)
|
||||
|
||||
@ -121,7 +121,8 @@ class GoodSkuService
|
||||
->select("external_sku_id", DB::raw("SUM(goods_number) - SUM(already_cancel_number) as number"))
|
||||
->whereIn("external_sku_id", $externalSkuIds)
|
||||
->where("b.shipping_status", "=", BusinessOrderShippingStatus::UNSHIP)
|
||||
->where("business_order_items.created_at", ">=", $startTime)->where("b.cancel_status", "=", 0)
|
||||
->where("b.after_sales_status", "!=", 2)
|
||||
->where("business_order_items.created_at", ">=", $startTime)->where("business_order_items.cancel_status", "=", 0)
|
||||
->groupBy('external_sku_id')->get()->toArray();
|
||||
|
||||
Log::info("盘点未发货数据",[$unshippedDataCollect]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user