|
@ -43,8 +43,8 @@ class DeliveryManager |
|
|
$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; |
|
|
|
|
|
if ($model->goods_number < $value->lack_number) { |
|
|
|
|
|
|
|
|
$model->goods_count = $value->goods_count; |
|
|
|
|
|
if ($model->goods_count < $value->lack_number) { |
|
|
$order->status = Order::STATUS_SHIPMENT_PORTION; |
|
|
$order->status = Order::STATUS_SHIPMENT_PORTION; |
|
|
} |
|
|
} |
|
|
if (!$model->save()) { |
|
|
if (!$model->save()) { |
|
@ -89,12 +89,12 @@ class DeliveryManager |
|
|
for ($i = 0; $i < count($deliveryGoods); $i++) { |
|
|
for ($i = 0; $i < count($deliveryGoods); $i++) { |
|
|
$orderGoodsId = $deliveryGoods[$i]['order_goods_id']; |
|
|
$orderGoodsId = $deliveryGoods[$i]['order_goods_id']; |
|
|
//以orderGoods的id为键名,以orderGoods的数量为键值,先保存到filter数组中
|
|
|
//以orderGoods的id为键名,以orderGoods的数量为键值,先保存到filter数组中
|
|
|
$filter[$orderGoodsId] = $deliveryGoods[$i]['goods_number']; |
|
|
|
|
|
|
|
|
$filter[$orderGoodsId] = $deliveryGoods[$i]['goods_count']; |
|
|
for ($j = 0; $j < count($deliveryGoods); $j++) { |
|
|
for ($j = 0; $j < count($deliveryGoods); $j++) { |
|
|
//如果发货商品中有其他相同orderGoods的商品
|
|
|
//如果发货商品中有其他相同orderGoods的商品
|
|
|
if ($orderGoodsId == $deliveryGoods[$j]['order_goods_id'] && $i !== $j) { |
|
|
if ($orderGoodsId == $deliveryGoods[$j]['order_goods_id'] && $i !== $j) { |
|
|
//商品数量叠加起来并保存
|
|
|
//商品数量叠加起来并保存
|
|
|
$filter[$orderGoodsId] += $deliveryGoods[$j]['goods_number']; |
|
|
|
|
|
|
|
|
$filter[$orderGoodsId] += $deliveryGoods[$j]['goods_count']; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -108,7 +108,7 @@ class DeliveryManager |
|
|
* @return array |
|
|
* @return array |
|
|
* 首次发货直接获取orderGoods的内容 |
|
|
* 首次发货直接获取orderGoods的内容 |
|
|
*/ |
|
|
*/ |
|
|
public static function firstDelivery($order_id) |
|
|
|
|
|
|
|
|
private static function firstDelivery($order_id) |
|
|
{ |
|
|
{ |
|
|
$unShippedGoods = []; |
|
|
$unShippedGoods = []; |
|
|
$orderGoods = OrderGoods::find()->where(['order_id' => $order_id])->all(); |
|
|
$orderGoods = OrderGoods::find()->where(['order_id' => $order_id])->all(); |
|
@ -118,9 +118,7 @@ class DeliveryManager |
|
|
'goods_id' => $v->goods_id, |
|
|
'goods_id' => $v->goods_id, |
|
|
'goods_img' => $v->goods_img, |
|
|
'goods_img' => $v->goods_img, |
|
|
'goods_name' => $v->goods_name, |
|
|
'goods_name' => $v->goods_name, |
|
|
'price' => $v->price, |
|
|
|
|
|
'market_price' => $v->market_price, |
|
|
|
|
|
'goods_number' => $v->goods_count, |
|
|
|
|
|
|
|
|
'goods_count' => $v->goods_count, |
|
|
'lack_number' => $v->goods_count, |
|
|
'lack_number' => $v->goods_count, |
|
|
'sku_value' => $v->sku_value, |
|
|
'sku_value' => $v->sku_value, |
|
|
]; |
|
|
]; |
|
@ -135,15 +133,15 @@ class DeliveryManager |
|
|
* @throws Exception |
|
|
* @throws Exception |
|
|
* 获取订单已发的商品和未发的商品 |
|
|
* 获取订单已发的商品和未发的商品 |
|
|
*/ |
|
|
*/ |
|
|
public static function getDeliveryGoodsInfo($filter,$order_id) |
|
|
|
|
|
|
|
|
public static function getDeliveryGoodsInfo($filter, $order_id) |
|
|
{ |
|
|
{ |
|
|
$unShipped = []; //未发货商品
|
|
|
$unShipped = []; //未发货商品
|
|
|
foreach ($filter as $k => $value) { //键名为ordergoods_id,键值为对应的已发货数量
|
|
|
|
|
|
|
|
|
foreach ($filter as $k => $value) { //键名为order_goods_id,键值为对应的已发货数量
|
|
|
$goodsData = self::getOrderGoodsInfo($k); |
|
|
$goodsData = self::getOrderGoodsInfo($k); |
|
|
if ($value < $goodsData['goods_number']) { //如果已发货数量未达到order_goods里的数量
|
|
|
|
|
|
$lack_number = $goodsData['goods_number'] - $value; |
|
|
|
|
|
|
|
|
if ($value < $goodsData['goods_count']) { //如果已发货数量未达到order_goods里的数量
|
|
|
|
|
|
$lack_number = $goodsData['goods_count'] - $value; |
|
|
$goodsData['lack_number'] = $lack_number; |
|
|
$goodsData['lack_number'] = $lack_number; |
|
|
$goodsData['goods_number'] = $lack_number; |
|
|
|
|
|
|
|
|
$goodsData['goods_count'] = $lack_number; |
|
|
$unShipped[] = $goodsData; |
|
|
$unShipped[] = $goodsData; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -155,7 +153,7 @@ class DeliveryManager |
|
|
* @param $order_id |
|
|
* @param $order_id |
|
|
* @return array |
|
|
* @return array |
|
|
* @throws Exception |
|
|
* @throws Exception |
|
|
* 通过订单号获取发货信息 |
|
|
|
|
|
|
|
|
* 通过订单id获取发货信息 |
|
|
*/ |
|
|
*/ |
|
|
public static function getDeliveryInfo($order_id) |
|
|
public static function getDeliveryInfo($order_id) |
|
|
{ |
|
|
{ |
|
@ -184,31 +182,33 @@ class DeliveryManager |
|
|
public static function getDeliverGoodsInfo($delivery_id) |
|
|
public static function getDeliverGoodsInfo($delivery_id) |
|
|
{ |
|
|
{ |
|
|
$goodsInfo = []; |
|
|
$goodsInfo = []; |
|
|
$deliveryGoods = DeliveryGoods::find()->where(['delivery_id'=>$delivery_id])->andWhere(['>','goods_number',0])->all(); |
|
|
|
|
|
|
|
|
$deliveryGoods = DeliveryGoods::find() |
|
|
|
|
|
->where(['delivery_id' => $delivery_id]) |
|
|
|
|
|
->andWhere(['>', 'goods_count', 0]) |
|
|
|
|
|
->all(); |
|
|
foreach ($deliveryGoods as $value) { |
|
|
foreach ($deliveryGoods as $value) { |
|
|
$goodsData = self::getOrderGoodsInfo($value->order_goods_id); |
|
|
$goodsData = self::getOrderGoodsInfo($value->order_goods_id); |
|
|
$goodsData['delivery_number'] = $value->goods_number; |
|
|
|
|
|
|
|
|
$goodsData['delivery_number'] = $value->goods_count; |
|
|
$goodsInfo[] = $goodsData; |
|
|
$goodsInfo[] = $goodsData; |
|
|
} |
|
|
} |
|
|
return $goodsInfo; |
|
|
return $goodsInfo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param $orderGoodsId |
|
|
|
|
|
|
|
|
* @param $order_goods_id |
|
|
* @return array |
|
|
* @return array |
|
|
* @throws Exception |
|
|
* @throws Exception |
|
|
* 获取订单商品信息 |
|
|
* 获取订单商品信息 |
|
|
*/ |
|
|
*/ |
|
|
private static function getOrderGoodsInfo($orderGoodsId) |
|
|
|
|
|
|
|
|
private static function getOrderGoodsInfo($order_goods_id) |
|
|
{ |
|
|
{ |
|
|
$orderGoods = OrderGoods::findOne($orderGoodsId); //通过orderGoods_id找到订单商品
|
|
|
|
|
|
|
|
|
$orderGoods = OrderGoods::findOne($order_goods_id); //通过orderGoods_id找到订单商品
|
|
|
if ($orderGoods) { |
|
|
if ($orderGoods) { |
|
|
$goodsData = [ |
|
|
$goodsData = [ |
|
|
'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->price, |
|
|
|
|
|
'goods_number' => $orderGoods->goods_count, |
|
|
|
|
|
|
|
|
'goods_count' => $orderGoods->goods_count, |
|
|
'goods_img' => $orderGoods->goods_img, |
|
|
'goods_img' => $orderGoods->goods_img, |
|
|
'sku_value' => $orderGoods->sku_value, |
|
|
'sku_value' => $orderGoods->sku_value, |
|
|
]; |
|
|
]; |
|
|