|
@ -34,57 +34,34 @@ class DeliveryManager |
|
|
throw new Exception('保存物流信息失败'); |
|
|
throw new Exception('保存物流信息失败'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*发货商品数据*/ |
|
|
|
|
|
self::deliveryGoods($delivery->id, $order, $deliveryGoods); |
|
|
|
|
|
|
|
|
|
|
|
$transaction->commit(); |
|
|
|
|
|
return ['status' => true]; |
|
|
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
$transaction->rollBack(); |
|
|
|
|
|
return ['status' => false, 'info' => $e->getMessage()]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$order->status = Order::STATUS_SHIPMENT_ALL; |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $deliveryId |
|
|
|
|
|
* @param $order |
|
|
|
|
|
* @param $deliveryGoods |
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
* 发货商品数据 |
|
|
|
|
|
*/ |
|
|
|
|
|
public static function deliveryGoods($deliveryId, $order, $deliveryGoods) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
/*发货商品数据*/ |
|
|
foreach ($deliveryGoods as $k => $value) { |
|
|
foreach ($deliveryGoods as $k => $value) { |
|
|
$model = new DeliveryGoods(); |
|
|
$model = new DeliveryGoods(); |
|
|
$model->delivery_id = $deliveryId; |
|
|
|
|
|
|
|
|
$model->delivery_id = $delivery->id; |
|
|
$model->order_goods_id = $value->id; |
|
|
$model->order_goods_id = $value->id; |
|
|
$model->goods_id = $value->goods_id; |
|
|
$model->goods_id = $value->goods_id; |
|
|
$model->goods_name = $value->goods_name; |
|
|
$model->goods_name = $value->goods_name; |
|
|
$model->goods_number = $value->goods_number; |
|
|
$model->goods_number = $value->goods_number; |
|
|
if ($model->goods_number < $value->lack_number) { |
|
|
if ($model->goods_number < $value->lack_number) { |
|
|
$order->status = Order::STATUS_SHIPMENT_PORTION; |
|
|
$order->status = Order::STATUS_SHIPMENT_PORTION; |
|
|
} else { |
|
|
|
|
|
$order->status = Order::STATUS_SHIPMENT_ALL; |
|
|
|
|
|
} |
|
|
|
|
|
if (!$order->save()) { |
|
|
|
|
|
throw new Exception('order shipping_status update false'); |
|
|
|
|
|
} |
|
|
} |
|
|
if (!$model->save()) { |
|
|
if (!$model->save()) { |
|
|
throw new Exception('delivery_goods save false'); |
|
|
throw new Exception('delivery_goods save false'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $order |
|
|
|
|
|
* @param $goodsStatus |
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
* @name '修改发货状态' |
|
|
|
|
|
*/ |
|
|
|
|
|
public function updateShippedStatus($order, $goodsStatus){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$order->save()) { |
|
|
|
|
|
throw new Exception('order shipping_status update false'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$transaction->commit(); |
|
|
|
|
|
return ['status' => true]; |
|
|
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
$transaction->rollBack(); |
|
|
|
|
|
return ['status' => false, 'info' => $e->getMessage()]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -185,11 +162,14 @@ class DeliveryManager |
|
|
$deliveryInfo = []; |
|
|
$deliveryInfo = []; |
|
|
$delivery = Delivery::findAll(['order_id' => $order_id]); |
|
|
$delivery = Delivery::findAll(['order_id' => $order_id]); |
|
|
foreach ($delivery as $k => $value) { |
|
|
foreach ($delivery as $k => $value) { |
|
|
$expressTemplate = ExpressTemplate::find()->select('name')->where(['id' => $value->shipping_id])->one(); |
|
|
|
|
|
$deliveryInfo[$k]['logisticInfo'] = [ |
|
|
|
|
|
'exp_name'=> $expressTemplate ? $expressTemplate->name : '', |
|
|
|
|
|
'invoice_no'=> $value->invoice_no |
|
|
|
|
|
]; //物流公司和运单号
|
|
|
|
|
|
|
|
|
// $expressTemplate = ExpressTemplate::find()
|
|
|
|
|
|
// ->select('name')
|
|
|
|
|
|
// ->where(['id' => $value->shipping_id])
|
|
|
|
|
|
// ->one();
|
|
|
|
|
|
// $deliveryInfo[$k]['logisticInfo'] = [
|
|
|
|
|
|
// 'exp_name'=> $expressTemplate ? $expressTemplate->name : '',
|
|
|
|
|
|
// 'invoice_no'=> $value->invoice_no
|
|
|
|
|
|
// ]; //物流公司和运单号
|
|
|
$deliveryInfo[$k]['goodsInfo'] = self::getDeliverGoodsInfo($value->id); //获取商品信息
|
|
|
$deliveryInfo[$k]['goodsInfo'] = self::getDeliverGoodsInfo($value->id); //获取商品信息
|
|
|
} |
|
|
} |
|
|
return $deliveryInfo; |
|
|
return $deliveryInfo; |
|
@ -227,10 +207,10 @@ class DeliveryManager |
|
|
'id' => $orderGoods->id, |
|
|
'id' => $orderGoods->id, |
|
|
'goods_id' => $orderGoods->goods_id, |
|
|
'goods_id' => $orderGoods->goods_id, |
|
|
'goods_name' => $orderGoods->goods_name, |
|
|
'goods_name' => $orderGoods->goods_name, |
|
|
'shop_price' => $orderGoods->shop_price, |
|
|
|
|
|
'goods_number' => $orderGoods->goods_number, |
|
|
|
|
|
|
|
|
'shop_price' => $orderGoods->price, |
|
|
|
|
|
'goods_number' => $orderGoods->goods_count, |
|
|
'goods_img' => $orderGoods->goods_img, |
|
|
'goods_img' => $orderGoods->goods_img, |
|
|
'sku_type' => $orderGoods->sku_type, |
|
|
|
|
|
|
|
|
'sku_value' => $orderGoods->sku_value, |
|
|
]; |
|
|
]; |
|
|
return $goodsData; |
|
|
return $goodsData; |
|
|
} else { |
|
|
} else { |
|
|