diff --git a/backend/modules/shop/logic/delivery/DeliveryManager.php b/backend/modules/shop/logic/delivery/DeliveryManager.php index 45451e3..46428e7 100644 --- a/backend/modules/shop/logic/delivery/DeliveryManager.php +++ b/backend/modules/shop/logic/delivery/DeliveryManager.php @@ -34,8 +34,27 @@ class DeliveryManager throw new Exception('保存物流信息失败'); } + $order->status = Order::STATUS_SHIPMENT_ALL; + /*发货商品数据*/ - self::deliveryGoods($delivery->id, $order, $deliveryGoods); + foreach ($deliveryGoods as $k => $value) { + $model = new DeliveryGoods(); + $model->delivery_id = $delivery->id; + $model->order_goods_id = $value->id; + $model->goods_id = $value->goods_id; + $model->goods_name = $value->goods_name; + $model->goods_number = $value->goods_number; + if ($model->goods_number < $value->lack_number) { + $order->status = Order::STATUS_SHIPMENT_PORTION; + } + if (!$model->save()) { + throw new Exception('delivery_goods save false'); + } + } + + if (!$order->save()) { + throw new Exception('order shipping_status update false'); + } $transaction->commit(); return ['status' => true]; @@ -45,48 +64,6 @@ class DeliveryManager } } - /** - * @param $deliveryId - * @param $order - * @param $deliveryGoods - * @throws Exception - * 发货商品数据 - */ - public static function deliveryGoods($deliveryId, $order, $deliveryGoods) - { - foreach ($deliveryGoods as $k => $value) { - $model = new DeliveryGoods(); - $model->delivery_id = $deliveryId; - $model->order_goods_id = $value->id; - $model->goods_id = $value->goods_id; - $model->goods_name = $value->goods_name; - $model->goods_number = $value->goods_number; - if ($model->goods_number < $value->lack_number) { - $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()) { - throw new Exception('delivery_goods save false'); - } - } - } - - - /** - * @param $order - * @param $goodsStatus - * @throws Exception - * @name '修改发货状态' - */ - public function updateShippedStatus($order, $goodsStatus){ - - - } - /** * @param $order_id * @return array @@ -185,11 +162,14 @@ class DeliveryManager $deliveryInfo = []; $delivery = Delivery::findAll(['order_id' => $order_id]); 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); //获取商品信息 } return $deliveryInfo; @@ -227,10 +207,10 @@ class DeliveryManager 'id' => $orderGoods->id, 'goods_id' => $orderGoods->goods_id, '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, - 'sku_type' => $orderGoods->sku_type, + 'sku_value' => $orderGoods->sku_value, ]; return $goodsData; } else { diff --git a/backend/modules/shop/views/order/delivery_goods.php b/backend/modules/shop/views/order/delivery_goods.php index ff240cd..215f633 100644 --- a/backend/modules/shop/views/order/delivery_goods.php +++ b/backend/modules/shop/views/order/delivery_goods.php @@ -43,8 +43,9 @@ //初始化订单商品数据 var data = ; console.log(data); + var unShipped = {}; function init() { - var unShipped = data.unShipped; + unShipped = data.unShipped; showUnShipped(unShipped); if(data.shipped){ var shipped = data.shipped; @@ -83,15 +84,15 @@ '发货数量' + '\n' + ''; - var div = document.createElement('div'); - div.innerText = '运单号:' + item.logisticInfo.invoice_no + '快递公司:'+ item.logisticInfo.exp_name; - $('.shipped-box').append(div); + // var div = document.createElement('div'); + // div.innerText = '运单号:' + item.logisticInfo.invoice_no + '快递公司:'+ item.logisticInfo.exp_name; + // $('.shipped-box').append(div); $('.shipped-box').append(table); table = $('.shipped-table').eq(index); item.goodsInfo.forEach(function (item,index) { var tr = "" + "" + item.goods_name + "" + - "" + item.sku_type + "" + + "" + item.sku_value + "" + "" + item.delivery_number + "" + ""; $(table).append(tr);