WIN-2308041133\Administrator 4 months ago
parent
commit
5db0a56fbd

+ 15 - 6
app/common/repositories/store/order/StoreOrderRepository.php

@@ -1099,6 +1099,7 @@ class StoreOrderRepository extends BaseRepository
         }elseif ($is_gift == 1){
             $type = 6;
         }
+        $price = app()->make(AwardIntegralPriceRepository::class)->awardIntegralPrice();  //分红积分价格
         // 创建用户账单仓库实例
         $make = app()->make(UserBillRepository::class);
         $user = User::where('uid', $order['uid'])->find();
@@ -1185,6 +1186,7 @@ class StoreOrderRepository extends BaseRepository
         $award_integral = $user['award_integral'];
         if ($order['pay_price'] >= $number2) {
             $order_award_range = bcmul($order['pay_price'], 0.2, 2);
+            $order_award_range = bcdiv($order_award_range,$price['price'],2);  //20%的业绩除以积分价格得到分红积分
             $after2 = bcadd($award_integral, $order_award_range, 2);
             $make->incBill($order['uid'], 'award_integral', $integral_type, [
                 'number' => $order_award_range,
@@ -1242,14 +1244,17 @@ class StoreOrderRepository extends BaseRepository
 //        $AwardLake = app()->make(AwardLake::class);
         $awardLake = app()->make(AwardLake::class);
         if ($type==5){
-            @file_put_contents('quanju.txt', "-村上春树4\r\n", 8);
             $oil = app()->make(OilLevel::class);
             $oil->checkLevel($order['uid']);
-            $awardLake->addOrderLakes(1,$order['pay_price'],$order['order_id']);
+            $ratio = systemConfig('energy_saving_oil_ratio', 10);
+            $jackpot = bcmul($order['pay_price'], $ratio, 2);
+            $awardLake->addOrderLakes(1,$jackpot,$order['order_id']);
         }elseif ($type==6){
             $gift = app()->make(GiftLevel::class);
             $gift->checkLevel($order['uid']);
-            $awardLake->addOrderLakes(2,$order['pay_price'],$order['order_id']);
+            $ratio = systemConfig('gift_pack_ratio', 10);
+            $jackpot = bcmul($order['pay_price'], $ratio, 2);
+            $awardLake->addOrderLakes(2,$jackpot,$order['order_id']);
         }
     }
 
@@ -1263,6 +1268,7 @@ class StoreOrderRepository extends BaseRepository
 //  上级推荐奖励的分红积分
     public function getSpreadIntegral($order, $type,$user)
     {
+        $price = app()->make(AwardIntegralPriceRepository::class)->awardIntegralPrice();  //分红积分价格
 //        $spread_uid = User::where('uid', $order['uid'])->value('spread_uid');
         $order_award_range=0;
         if ($user['spread_uid']!=0){
@@ -1275,6 +1281,7 @@ class StoreOrderRepository extends BaseRepository
                     $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', 'spread_oil_integral', [
                             'number' => $order_award_range,
@@ -1303,6 +1310,7 @@ class StoreOrderRepository extends BaseRepository
                             break;
                     }
                     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', 'spread_oil_integral', [
                             'number' => $order_award_range,
@@ -1332,15 +1340,16 @@ class StoreOrderRepository extends BaseRepository
     }
 //    服务中心核销节能油
     public function confirmOil($order){
+        $price = app()->make(AwardIntegralPriceRepository::class)->awardIntegralPrice();  //分红积分价格
         $MerchantRepository = app()->make(MerchantRepository::class);
         $uid = Merchant::where('mer_id',$order['mer_id'])->value('uid');
         $award_integral = User::where('uid',$uid)->value('award_integral');
         $integral_prcie =app()->make(AwardIntegralPriceRepository::class)->getPrice();  //积分价格
-        $integral =bcmul(bcdiv(2,$integral_prcie,2),$order['total_num'],2);  //价值2元的积分
+        $integral =bcmul(bcdiv(2,$integral_prcie['price'],2),$order['total_num'],2);  //价值2元的积分
         $make = app()->make(UserBillRepository::class);
         $after = bcadd($award_integral, $integral, 2);
         $make->incBill($uid, 'award_integral', 'confirm_oil_integral', [
-            'number' => $order['pay_price'],
+            'number' => $integral,
             'title' => '核销节能油获得分红积分',
             'balance' => $after,
             'status' => 1,
@@ -1360,7 +1369,7 @@ class StoreOrderRepository extends BaseRepository
             if ($user['unclaimed_range']>0){
                 $after=bcadd($user['award_range'], $user['unclaimed_range'], 2);
                 $make = app()->make(UserBillRepository::class);
-                $make->incBill($user['spread_uid'], 'award_unclaimed_range', 'spread_oil_integral', [
+                $make->incBill($user['spread_uid'], 'award_unclaimed_range', 'thaw_brokerage', [
                     'number' => $user['unclaimed_range'],
                     'title' => '推荐订单解冻分红额度',
                     'balance' => 0,

+ 1 - 1
app/common/repositories/user/AwardIntegralPriceRepository.php

@@ -167,7 +167,7 @@ class AwardIntegralPriceRepository extends BaseRepository
 
         // 查询满足条件的数据列表,带有 'label' 关联数据,按 'label_rule_id' 倒序排列
         // 分页查询,返回当前页码的 $limit 条数据,并将结果转换为数组形式
-        $list = $query->page($page, $limit)->select()->toArray();
+        $list = $query->page($page, $limit)->order('add_time DESC')->select()->toArray();
         // 返回包含数据总数和数据列表的数组
         return compact('count', 'list');
     }

+ 7 - 6
app/common/repositories/user/UserRepository.php

@@ -2748,16 +2748,16 @@ class UserRepository extends BaseRepository
             'balance' => $freeze_brokerage
         ]);
 //        根据价格重新转为分红积分
-        $num = bcmul($num, $integral_prcie, 2);
+        $integral = bcmul($num, $integral_prcie, 2);
         $userBillRepository->incBill($uid, 'award_integral', 'extract_award', [
             'link_id' => 0,
             'status' => 1,
             'title' => '提取分红积分',
-            'number' => $num,
-            'mark' => '用户获得分红份额' . $info['award_range'] . '元,冻结对应奖金,扣除分红积分' . $num . '分',
-            'balance' => bcsub($info['award_integral'], $num, 2)
+            'number' => $integral,
+            'mark' => '用户获得分红份额' . $info['award_range'] . '元,冻结对应奖金,转为分红积分' . $integral . '(积分价格:'.$integral_prcie.')',
+            'balance' => bcsub($info['award_integral'], $integral, 2)
         ]);
-
+        $after_integral = bcsub($info['award_integral'], $integral, 2);
 
 ////        扣除分红额度
 //        $userBillRepository->decBill($uid, 'award_range', 'thaw_brokerage', [
@@ -2768,7 +2768,8 @@ class UserRepository extends BaseRepository
 //            'mark' => '用户获得分红份额' . $info['award_range'] . '元,冻结对应奖金',
 //            'balance' => $freeze_brokerage
 //        ]);
-        User::where('uid', $uid)->update(['freeze_brokerage' => $freeze_brokerage, 'award_integral' => $range]);
+        User::where('uid', $uid)->update(['freeze_brokerage' => $freeze_brokerage, 'award_integral' => $after_integral]);
+        app()->make(UserRepository::class)->extractIntegral($uid);  //冻结奖金转为分红积分后再判断
     }
 
     /**

+ 5 - 1
app/controller/admin/user/Award.php

@@ -82,7 +82,11 @@ class Award extends BaseController
     {
         [$page, $limit] = $this->getPage();
         $where = $this->request->params(['type','pm']);
-        return app('json')->success($this->repository->getLakeLogList($where, $page, $limit));
+        $list=$this->repository->getLakeLogList($where, $page, $limit);
+        foreach ($list['list'] as $k=>&$v){
+            $list['list'][$k]['add_time'] = date('Y-m-d H:i:s',$list['list'][$k]['add_time']);
+        }
+        return app('json')->success();
     }
     /**
      *  列表