WIN-2308041133\Administrator 4 months ago
parent
commit
9f90a89b9f
1 changed files with 17 additions and 1 deletions
  1. 17 1
      app/common/repositories/store/order/StoreOrderRepository.php

+ 17 - 1
app/common/repositories/store/order/StoreOrderRepository.php

@@ -1279,9 +1279,25 @@ class StoreOrderRepository extends BaseRepository
         $order_award_range=0;
         if ($user['spread_uid']>0){
             $make = app()->make(UserBillRepository::class);
+
             switch ($type) {
                 case 0:  //普通商品
-                    $after=0;
+                    $award_integral = User::where('uid',$user['spread_uid'])->value('award_integral');
+                    $order_award_range = bcmul($order['pay_price'], 0.06, 2);
+                    if ($order_award_range>0){
+                        $order_award_range = bcdiv($order_award_range,$price['price'],2);  //业绩除以积分价格得到分红积分
+                        $after = bcadd($award_integral, $order_award_range, 2);
+                        $make->incBill($user['spread_uid'], 'award_integral', 'ordinary_integral', [
+                            'number' => $order_award_range,
+                            'title' => '下单普通商品获得分红积分',
+                            'balance' => $after,
+                            'status' => 1,
+                            'link_id' => $order['order_id'],
+                            'mark' => $user['nickname'] . '成功消费普通商品' . floatval($order['pay_price']) . '元,奖励上级分红积分' . $order_award_range.'(积分价格:'.$price['price'].')',
+                        ]);
+                    }
+                    @file_put_contents('quanju.txt', "-村上春树78\r\n", 8);
+                    break;
                     break;
                 case 5:  //节能油商品
                     $award_integral = User::where('uid',$user['spread_uid'])->value('award_integral');