Просмотр исходного кода

退货申请审核通过时,将订单未生效的佣金、复购金、养老金、贡献值、pv值、积分设置为失效

sunxiaobiao 1 год назад
Родитель
Сommit
350966e1f2

+ 53 - 0
app/common/repositories/store/order/StoreRefundOrderRepository.php

@@ -1516,4 +1516,57 @@ class StoreRefundOrderRepository extends BaseRepository
1516 1516
         });
1517 1517
         return true;
1518 1518
     }
1519
+
1520
+    /**
1521
+     * 取消订单福利
1522
+     * @param $id
1523
+     * @throws \think\db\exception\DbException
1524
+     */
1525
+    public function cancelOrderBonus($id)
1526
+    {
1527
+
1528
+        // //分配逻辑
1529
+        // $store_order_data = Db::name('store_order')->where('group_order_id',$group_order_id)->find();
1530
+        //
1531
+        // //找到对应的商品id(product_id)
1532
+        // $store_order_product_data = Db::name('store_order_product')->where('order_id',$store_order_data['order_id'])->find();
1533
+        // //找到对应的商品让利金额或比例
1534
+        // $store_product_data = Db::name('store_product')->where('product_id',$store_order_product_data['product_id'])->find();
1535
+        // //下单用户
1536
+        // $user_data = Db::name('user')->where('uid',$store_order_data['uid'])->find();
1537
+        // $concession_pri =  $store_order_data['con_pri'];
1538
+
1539
+
1540
+        $refundOrder = $this -> dao -> getWhere(['refund_order_id' => $id]);
1541
+        if(!$refundOrder){
1542
+            return ['code'=>-6,'message'=>'找不到退款订单'];
1543
+        }
1544
+        $refundOrder = $refundOrder -> toArray();
1545
+        $orderId = $refundOrder['order_id'];
1546
+
1547
+        Db::name("user_bill")
1548
+            ->where('link_id', $orderId)
1549
+            ->where('status', 0)
1550
+            ->update(['status' => -1]);
1551
+
1552
+        Db::name("user_sign_fugou")
1553
+            ->where('order_id', $orderId)
1554
+            ->where('status', -1)
1555
+            ->update(['status' => 0]);
1556
+
1557
+        Db::name("user_sign_score")
1558
+            ->where('order_id', $orderId)
1559
+            ->where('status', -1)
1560
+            ->update(['status' => 0]);
1561
+
1562
+        Db::name("user_sign_gongxian")
1563
+            ->where('order_id', $orderId)
1564
+            ->where('status', -1)
1565
+            ->update(['status' => 0]);
1566
+
1567
+        Db::name("user_pv_log")
1568
+            ->where('order_id', $orderId)
1569
+            ->where('status', -1)
1570
+            ->update(['status' => 0]);
1571
+    }
1519 1572
 }

+ 2 - 0
app/controller/merchant/store/order/RefundOrder.php

@@ -136,6 +136,8 @@ class RefundOrder extends BaseController
136 136
 
137 137
             $this->repository->set_consult(2,$id);//协商记录
138 138
         }
139
+        // 取消 订单所发放的福利
140
+        $this->repository->cancelOrderBonus($id);
139 141
         return app('json')->success('审核成功');
140 142
     }
141 143
     public function switchStatusjhm($id)