Browse Source

fix: 部分发货功能修改

wechat_public_accounts
travis 5 years ago
parent
commit
8e14d803fe
  1. 10
      backend/modules/shop/logic/delivery/DeliveryManager.php
  2. 2
      backend/modules/shop/models/ars/Delivery.php

10
backend/modules/shop/logic/delivery/DeliveryManager.php

@ -44,6 +44,7 @@ class DeliveryManager
$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_count = $value->goods_count; $model->goods_count = $value->goods_count;
/*如果是部分发货*/
if ($model->goods_count < $value->lack_number) { if ($model->goods_count < $value->lack_number) {
$order->status = Order::STATUS_SHIPMENT_PORTION; $order->status = Order::STATUS_SHIPMENT_PORTION;
} }
@ -51,10 +52,17 @@ class DeliveryManager
throw new Exception('delivery_goods save false'); throw new Exception('delivery_goods save false');
} }
} }
if (!$order->save()) { if (!$order->save()) {
throw new Exception('order shipping_status update false'); throw new Exception('order shipping_status update false');
} }
if ($order->status == Order::STATUS_SHIPMENT_PORTION|| Delivery::findOne(['!=', 'id', $delivery->id])) {
$delivery->type = Delivery::TYPE_SHIPMENT_PORTION;
} else {
$delivery->type = Delivery::TYPE_SHIPMENT_ALL;
}
if (!$delivery->save()) {
throw new Exception('保存物流信息失败');
}
$transaction->commit(); $transaction->commit();
return ['status' => true]; return ['status' => true];

2
backend/modules/shop/models/ars/Delivery.php

@ -21,6 +21,8 @@ use yii\behaviors\TimestampBehavior;
*/ */
class Delivery extends \yii\db\ActiveRecord class Delivery extends \yii\db\ActiveRecord
{ {
const TYPE_SHIPMENT_ALL = 1;
const TYPE_SHIPMENT_PORTION = 2;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

Loading…
Cancel
Save