|
@@ -28,19 +28,15 @@ class FxSyncMjOrderStatus extends Command {
|
28
|
28
|
$this->SyncMjOrderStatus();
|
29
|
29
|
// $this->SyncFxOrderStatus();
|
30
|
30
|
}catch (\Exception $exception){
|
31
|
|
- echo $exception->getMessage();
|
32
|
31
|
}
|
33
|
32
|
}
|
34
|
33
|
public function SyncMjOrderStatus(){
|
35
|
34
|
|
36
|
35
|
$orders = Order::select('id', 'outerCode', 'admin_id')->where('orderCode','>',0)->where('status', '<', 3)->where('warehouse', 3)->where('is_del', 0)->orderBy('id', 'desc')->get();
|
37
|
36
|
$orders = json_decode(json_encode($orders), true);
|
38
|
|
- Log::errorLog($orders,[],"order/mjApi",1,'');
|
39
|
37
|
foreach($orders as $k=>$order){
|
40
|
38
|
$result = $this->getMjOrder($order['id'], $order['outerCode']);
|
41
|
|
- Log::errorLog($result,[],"order/mjApi",1,'');
|
42
|
39
|
if( !empty($result) ){
|
43
|
|
- Log::errorLog(1,[],"order/orderUpdate",1,'');
|
44
|
40
|
$data = array();
|
45
|
41
|
if( isset($result['expressCode']) && !empty($result['expressCode']) ){
|
46
|
42
|
$data['is_cannot_del'] = 1;
|
|
@@ -48,7 +44,6 @@ class FxSyncMjOrderStatus extends Command {
|
48
|
44
|
|
49
|
45
|
$status = $result['status'];
|
50
|
46
|
if($status == '已发货' || $status == '已完成'){
|
51
|
|
- Log::errorLog(2,[],"order/orderUpdate",1,'');
|
52
|
47
|
$data['status'] = 3;
|
53
|
48
|
$data['logistics_id'] = $result['expressCode'];
|
54
|
49
|
$data['send_time'] = !empty($result['deliveryTime']) ? date('Y-m-d', substr($result['deliveryTime'], 0, 10) ) : date('Y-m-d');
|
|
@@ -56,7 +51,6 @@ class FxSyncMjOrderStatus extends Command {
|
56
|
51
|
#计算成本
|
57
|
52
|
//if($sku_info->referenceCost) $cost += $sku_info->referenceCost * $gnum[$k];
|
58
|
53
|
foreach($result['skuList'] as $key=>$sku){
|
59
|
|
- Log::errorLog(3,[],"order/orderUpdate",1,'');
|
60
|
54
|
$skuCode = $sku['skuCode'];
|
61
|
55
|
$code_arr = explode('|', $skuCode);
|
62
|
56
|
$sku_id = $code_arr[1];
|
|
@@ -65,17 +59,12 @@ class FxSyncMjOrderStatus extends Command {
|
65
|
59
|
|
66
|
60
|
// $order_sku_cost = $cost->outPrice * $quantity; //对应规格总成本
|
67
|
61
|
$data['cost'] += $cost->outPrice * $quantity; //对应规格总成本
|
68
|
|
- Log::errorLog(4,[],"order/orderUpdate",1,'');
|
69
|
62
|
#更新order_sku
|
70
|
63
|
OrderGoodsSkus::where('order_id', $order['id'])->where('sku_id', $sku_id)->update(['send_num'=>$quantity, 'cost'=>$cost->outPrice]);
|
71
|
|
- Log::errorLog(5,[],"order/orderUpdate",1,'');
|
72
|
64
|
}
|
73
|
65
|
$data['cost'] = round($data['cost'], 2);
|
74
|
66
|
}
|
75
|
|
- Log::errorLog($data,[],"order/orderUpdate",1,'');
|
76
|
67
|
if(!empty($data)){
|
77
|
|
- Log::errorLog($data,[],"order/orderUpdate",1,'');
|
78
|
|
-
|
79
|
68
|
Order::where('id', $order['id'])->update($data);
|
80
|
69
|
}
|
81
|
70
|
}
|