|
|
@@ -3217,27 +3217,37 @@ class StoreOrderRepository extends BaseRepository
|
|
|
public function verifyPartOrder($order, array $data, $serviceId = 0)
|
|
|
{
|
|
|
// 构建待核销商品的数量映射
|
|
|
- foreach ($data['data'] as $v) {
|
|
|
+ $stauts = 2;
|
|
|
+ foreach ($data as $v) {
|
|
|
$splitData[$v['id']] = $v['num'];
|
|
|
+ $cart_info = StoreCart::where(['cart_id' => $v['id'],'product_id'=>$v['product_id']])->find();
|
|
|
+ $verify_num = bcadd($cart_info['verify_num'],$v['num'],0);
|
|
|
+ if ($verify_num>$cart_info['cart_num']){
|
|
|
+ throw new ValidateException('核销数量不能大于购买数量');
|
|
|
+ }
|
|
|
+ if ($verify_num<$cart_info['cart_num']){ //核销数量小于购买数量
|
|
|
+ $stauts = 1;
|
|
|
+ }
|
|
|
}
|
|
|
// 调用订单分割函数进行订单核销操作,并更新订单对象
|
|
|
- $spl = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData, $serviceId, 1);
|
|
|
- if ($spl) $order = $spl;
|
|
|
+// $spl = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData, $serviceId, 1);
|
|
|
+// if ($spl) $order = $spl;
|
|
|
|
|
|
// 更新订单状态为已核销,并设置核销时间和服务人员ID
|
|
|
$order->status = 2;
|
|
|
+ $order->verify_status = $stauts;
|
|
|
$order->verify_time = date('Y-m-d H:i:s');
|
|
|
$order->verify_service_id = $serviceId;
|
|
|
|
|
|
// 触发订单核销前的事件
|
|
|
- event('order.verify.before', compact('order'));
|
|
|
+// event('order.verify.before', compact('order'));
|
|
|
|
|
|
// 实例化订单状态仓库,用于后续订单状态的变更记录
|
|
|
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
|
// 使用事务处理订单状态的更新和订单变更日志的记录
|
|
|
- Db::transaction(function () use ($order, $storeOrderStatusRepository, $serviceId) {
|
|
|
+ Db::transaction(function () use ($order, $storeOrderStatusRepository, $serviceId,$data) {
|
|
|
// 执行订单核销后的处理逻辑
|
|
|
- $this->takeAfter($order, $order->user);
|
|
|
+// $this->takeAfter($order, $order->user);
|
|
|
// 保存更新后的订单信息
|
|
|
$order->save();
|
|
|
// 构建订单状态变更信息
|
|
|
@@ -3248,6 +3258,9 @@ class StoreOrderRepository extends BaseRepository
|
|
|
'change_message' => '订单已核销',
|
|
|
'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE,
|
|
|
];
|
|
|
+ foreach ($data as $v) {
|
|
|
+ StoreCart::where(['cart_id' => $v['id'],'product_id'=>$v['product_id']])->update(['verify_num'=>bcadd($v['num'],$v['num'],0)]);
|
|
|
+ }
|
|
|
// 根据服务人员ID是否存在,分别记录服务人员日志或管理员日志
|
|
|
if ($serviceId) {
|
|
|
$storeOrderStatusRepository->createServiceLog($serviceId, $orderStatus);
|
|
|
@@ -3257,10 +3270,10 @@ class StoreOrderRepository extends BaseRepository
|
|
|
});
|
|
|
|
|
|
// 触发订单核销完成后的事件
|
|
|
- event('order.verify', compact('order'));
|
|
|
+// event('order.verify', compact('order'));
|
|
|
// 触发小程序发货管理事件,用于后续的发货操作
|
|
|
// 小程序发货管理
|
|
|
- event('mini_order_shipping', ['product', $order, 7, '', '']);
|
|
|
+// event('mini_order_shipping', ['product', $order, 7, '', '']);
|
|
|
// $this->confirmOil($order);
|
|
|
}
|
|
|
/**
|