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

Merge branch 'sxb-dev-01' into sxb-dev

sunxiaobiao 1 год назад
Родитель
Сommit
46e0abe874
32 измененных файлов с 1853 добавлено и 532 удалено
  1. 37 33
      app/command/CinemaSchedCommand.php
  2. 87 0
      app/command/HuafeiOrderIndependentAccount.php
  3. 365 230
      app/command/PensionTasks.php
  4. 48 0
      app/common/dao/user/UserIdentityDao.php
  5. 2 2
      app/common/model/movie/cinema/Cinema.php
  6. 37 0
      app/common/model/movie/cinema/CinemaSched.php
  7. 38 0
      app/common/model/user/UserIdentity.php
  8. 56 26
      app/common/repositories/merchant/order/OrderMerchantRepository.php
  9. 15 1
      app/common/repositories/movie/CinemaRepository.php
  10. 162 0
      app/common/repositories/movie/CinemaSchedRepository.php
  11. 8 3
      app/common/repositories/movie/DouHuoMallFilmApiRequest.php
  12. 96 49
      app/common/repositories/movie/MovieRepository.php
  13. 131 35
      app/common/repositories/store/order/StoreOrderRepository.php
  14. 45 2
      app/common/repositories/store/product/ProductReplyRepository.php
  15. 39 33
      app/common/repositories/store/product/ProductRepository.php
  16. 9 9
      app/common/repositories/system/merchant/MerchantRepository.php
  17. 110 0
      app/common/repositories/user/UserIdentityRepository.php
  18. 8 2
      app/common/repositories/user/UserOfflineRechargeRepository.php
  19. 203 2
      app/common/repositories/user/UserRepository.php
  20. 94 0
      app/controller/admin/system/config/Identity.php
  21. 6 5
      app/controller/api/Auth.php
  22. 37 21
      app/controller/api/Notify.php
  23. 68 37
      app/controller/api/movie/Movie.php
  24. 104 16
      app/controller/api/user/User.php
  25. 11 6
      app/controller/api/user/UserMp.php
  26. 9 3
      app/controller/merchant/Common.php
  27. 3 1
      app/controller/merchant/store/shipping/ShippingTemplate.php
  28. 6 6
      app/view/index/index.html
  29. 1 0
      config/console.php
  30. 4 4
      crmeb/listens/GongListen.php
  31. 6 0
      route/admin.php
  32. 8 6
      route/api.php

+ 37 - 33
app/command/CinemaSchedCommand.php

@@ -3,6 +3,7 @@
3 3
 namespace app\command;
4 4
 
5 5
 use app\common\repositories\movie\CinemaRepository;
6
+use app\common\repositories\movie\CinemaSchedRepository;
6 7
 use app\common\repositories\movie\FilmRepository;
7 8
 use app\common\repositories\movie\MovieRepository;
8 9
 use crmeb\services\ApiResponseService;
@@ -19,7 +20,7 @@ class CinemaSchedCommand extends Command
19 20
     protected function configure()
20 21
     {
21 22
         // 指令配置
22
-        $this->setName('cinema_sched')->setDescription('电影-影院场次列表');
23
+        $this->setName('cinema_film_sched')->setDescription('电影-影院场次列表');
23 24
     }
24 25
 
25 26
     protected function execute(Input $input, Output $output)
@@ -36,6 +37,8 @@ class CinemaSchedCommand extends Command
36 37
             foreach ($result['cinema_list'] as $key => $value) {
37 38
                 foreach ($filmResult['film_list'] as $subKey => $subValue) {
38 39
                     $this->doCinemaSched($subValue, $value);
40
+//                    if ($subValue['film_sign'] == 'F6556061D4' && $value['cinema_sign'] == 'CCB622D8D8') {
41
+//                    }
39 42
                 }
40 43
             }
41 44
         } catch (\Exception $exception) {
@@ -56,9 +59,7 @@ class CinemaSchedCommand extends Command
56 59
         $cinema_filmRepository = app()->make(MovieRepository::class);
57 60
         $cinema_sched = $cinema_filmRepository->getCinemaSched($film['film_sign'], $cinema['cinema_sign']);
58 61
 
59
-        if (isset($cinema_sched['code']) && ($cinema_sched['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) {
60
-            $this->createCinemaSched($cinema_sched['data']['list'], $cinema);
61
-        }
62
+        $this->createCinemaSched($cinema_sched, $cinema);
62 63
     }
63 64
 
64 65
     /**
@@ -71,35 +72,38 @@ class CinemaSchedCommand extends Command
71 72
      */
72 73
     private function createCinemaSched($list, $cinema)
73 74
     {
74
-        foreach ($list as $key => $value) {
75
-            $params = [
76
-                'relation_id' => $value['relation_id'],
77
-                'sched_sign' => $value['sched_sign'],
78
-                'film_sign' => $value['film_sign'],
79
-                'film_name' => $value['film_name'],
80
-                'show_date' => strtotime(date('Y') . '-' . $value['show_date']),
81
-                'show_time' => trim($value['show_time']),
82
-                'cinema_sign' => $cinema['cinema_sign'],
83
-                'cinema_name' => $cinema['cinema_name'],
84
-                'address' => $cinema['address'],
85
-                'longitude' => $cinema['longitude'],
86
-                'latitude' => $cinema['latitude'],
87
-                'hall_sign' => $value['hall_sign'],
88
-                'hall_name' => $value['hall_name'],
89
-                'stop_sell_time' => $value['stop_sell_time'],
90
-                'cost_price' => $value['cost_price'],
91
-                'channel_price' => json_encode($value['channel_price'], JSON_FORCE_OBJECT)
92
-            ];
93
-            $where = [
94
-                'relation_id' => $value['relation_id'], 'sched_sign' => $value['sched_sign'], 'film_sign' => $value['film_sign'], 'cinema_sign' => $params['cinema_sign']
95
-            ];
96
-            $model = Db::name('movie_cinema_sched')->where($where)->find();
97
-            if (empty($model)) {
98
-                $params['create_time'] = time();
99
-                Db::name('movie_cinema_sched')->insert($params);
100
-            } else {
101
-                $params['update_time'] = time();
102
-                Db::name('movie_cinema_sched')->where('id', $model['id'])->update($params);
75
+        foreach ($list as $key => $sched) {
76
+            foreach ($sched as $subKey => $value) {
77
+                $params = [
78
+                    'relation_id' => $value['relation_id'],
79
+                    'sched_sign' => $value['sched_sign'],
80
+                    'film_sign' => $value['film_sign'],
81
+                    'film_name' => $value['film_name'],
82
+                    'show_date' => strtotime(date('Y') . '-' . $value['show_date']),
83
+                    'show_time' => trim($value['show_time']),
84
+                    'cinema_sign' => $cinema['cinema_sign'],
85
+                    'cinema_name' => $cinema['cinema_name'],
86
+                    'address' => $cinema['address'],
87
+                    'longitude' => $cinema['longitude'],
88
+                    'latitude' => $cinema['latitude'],
89
+                    'hall_sign' => $value['hall_sign'],
90
+                    'hall_name' => $value['hall_name'],
91
+                    'stop_sell_time' => strtotime($value['stop_sell_time']),
92
+                    'price' => $value['price'], // 原价
93
+                    'cost_price' => $value['cost_price'], // 销售价
94
+                    'channel_price' => json_encode($value['channel_price'], JSON_FORCE_OBJECT)
95
+                ];
96
+                $where = [
97
+                    'relation_id' => $value['relation_id'], 'sched_sign' => $value['sched_sign'], 'film_sign' => $value['film_sign'], 'cinema_sign' => $params['cinema_sign']
98
+                ];
99
+                $model = Db::name('movie_cinema_sched')->where($where)->find();
100
+                if (empty($model)) {
101
+                    $params['create_time'] = time();
102
+                    Db::name('movie_cinema_sched')->insert($params);
103
+                } else {
104
+                    $params['update_time'] = time();
105
+                    Db::name('movie_cinema_sched')->where('id', $model['id'])->update($params);
106
+                }
103 107
             }
104 108
         }
105 109
     }

+ 87 - 0
app/command/HuafeiOrderIndependentAccount.php

@@ -0,0 +1,87 @@
1
+<?php
2
+
3
+namespace app\command;
4
+
5
+use app\common\model\store\order\StoreOrder;
6
+use app\common\model\user\UserCertification;
7
+use app\common\repositories\merchant\order\OrderGzcRepository;
8
+use app\common\repositories\merchant\order\OrderMerchantRepository;
9
+use app\common\repositories\store\order\StoreOrderRepository;
10
+use app\common\repositories\store\order\StoreOrderStatusRepository;
11
+use app\common\repositories\user\UserBillRepository;
12
+use app\common\repositories\user\UserRepository;
13
+use Carbon\Carbon;
14
+use think\console\Command;
15
+use think\console\Input;
16
+use think\console\Output;
17
+use think\facade\Db;
18
+use think\facade\Log;
19
+
20
+class HuafeiOrderIndependentAccount extends Command
21
+{
22
+    protected function configure()
23
+    {
24
+        // 指令配置
25
+        $this->setName('huafei-order-independent-account')
26
+            ->setDescription('话费订单分账');
27
+    }
28
+
29
+    protected function execute(Input $input, Output $output)
30
+    {
31
+        // @todo 精彩生活区订单分账
32
+        $this->doHuafeiOrderIndependentAccount();
33
+    }
34
+
35
+    /**
36
+     * 会员专区、精彩生活区订单分账
37
+     *
38
+     * @param $merId
39
+     * @param $timeLimit
40
+     * @return void
41
+     * @throws \think\db\exception\DataNotFoundException
42
+     * @throws \think\db\exception\DbException
43
+     * @throws \think\db\exception\ModelNotFoundException
44
+     */
45
+    private function doHuafeiOrderIndependentAccount($timeLimit = 1)
46
+    {
47
+        $dst_mer_id = systemConfig('mer_365');
48
+
49
+        // 商户信息
50
+        $merchants = [];
51
+
52
+        $time = time();
53
+        // 订单状态(0:待发货;1:待收货;2:待评价;3:已完成;4已申请退款;-1:已退款)5未支付 6已取消'
54
+        $status = [2];
55
+        // 普通订单
56
+        $cursor = Db::table('rrx_order_huafei')->where('is_independentaccount', 0)->whereIn('status', $status)->cursor();
57
+
58
+        /** @var StoreOrderRepository $storeOrderRepository */
59
+        $storeOrderRepository = app()->make(StoreOrderRepository::class);
60
+
61
+        foreach ($cursor as $key => $value) {
62
+            $settlement_period_time = strtotime($value['create_time']) + $timeLimit * 24 * 3600;
63
+            // @todo 下单后第{$timeLimit}天后可分账
64
+            if ($settlement_period_time >= $time) {
65
+                $merchants['496'] = Db::name('merchant')->where('mer_id', 496)->find();
66
+                $order_huafei_hf = Db::name('order_huafei_hf')->where('order_no', $value['order_sn'])->find();
67
+                if(!$order_huafei_hf) continue;
68
+                $value['mer_id'] = 496;
69
+                $order_huafei_hf['mer_id'] = 496;
70
+
71
+                // 分账账号 496:表示{会员专区}账户,分账到{会员专区}账户
72
+                $independentAccount = $storeOrderRepository->getIndependentAccountHuafei($order_huafei_hf, $dst_mer_id, $merchants['496']['hf_member_id']);
73
+
74
+                // @todo 预分账处理 分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
75
+                $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccountHuafei(
76
+                    $value, $order_huafei_hf, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['pay_price'], 0
77
+                );
78
+
79
+                if ($isSuccessed) {
80
+                    Db::name("log")->insert(array('data' => '话费-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));//日志记录
81
+                    Db::table('rrx_order_huafei')->where('order_sn', $value['order_sn'])->update(['is_independentaccount' => 1]);
82
+                }
83
+            }
84
+        }
85
+    }
86
+
87
+}

+ 365 - 230
app/command/PensionTasks.php

@@ -12,6 +12,7 @@ use app\common\repositories\merchant\order\OrderMerchantRepository;
12 12
 use app\common\repositories\store\order\StoreOrderStatusRepository;
13 13
 use app\common\repositories\store\product\ProductRepository;
14 14
 use app\common\repositories\user\UserBillRepository;
15
+use app\common\repositories\user\UserRepository;
15 16
 use app\traits\GzcApiRequest;
16 17
 use Carbon\Carbon;
17 18
 use think\console\Command;
@@ -58,6 +59,7 @@ class PensionTasks extends Command
58 59
             $this->doThridVipOrderGzc($nowTime, $timeLimit = 2);
59 60
             $this->doThridDyOrderGzc($nowTime, $timeLimit = 2);
60 61
             $this->doThridHfOrderGzc($nowTime, $timeLimit = 2);
62
+            $this->billGzcAdd($nowTime);
61 63
             //升级
62 64
 //            $this -> doUpgrade();
63 65
         } catch (\Throwable $e) {
@@ -68,6 +70,109 @@ class PensionTasks extends Command
68 70
         $output->writeln('pensiontask');
69 71
     }
70 72
 
73
+
74
+    /**
75
+     * 线下支付订单公证处IN10入账
76
+     * @param $nowTime
77
+     * author: php迷途小书童
78
+     * created: 2021/3/20 9:26
79
+     */
80
+    public function billGzcAdd($nowTime)
81
+    {
82
+        $OrderGzcRepository      = app()->make(OrderGzcRepository::class);
83
+        $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
84
+        $StoreOrderRepository    = app()->make(StoreOrderRepository::class);
85
+        $cursor = Db::table('user_bill')
86
+        ->where('status', 1)
87
+        ->where('is_gzc', 0)
88
+        ->where('commission_type', 5)
89
+        ->select()->toArray();
90
+        foreach ($cursor as $bill) {
91
+            $type_shop = $bill['type_shop'] ?? 0;
92
+
93
+            switch ($type_shop){
94
+                case "0":
95
+                    $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
96
+                    break;
97
+                case "1":
98
+                    $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
99
+                    break;
100
+                case "2":
101
+                    $online =  Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
102
+                    break;
103
+                case "3":
104
+                    $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
105
+                    break;
106
+                case "4":
107
+                    $online = '';
108
+                    break;
109
+                case "5":
110
+                    $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
111
+                    break;
112
+                case "6":
113
+                    $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
114
+                    break;
115
+                case "7":
116
+                    $online = '';
117
+                    break;
118
+                case "8":
119
+                    $online = '';
120
+                    break;
121
+                case "9":
122
+                    $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
123
+                    break;
124
+                default:
125
+                    $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
126
+            }
127
+
128
+            if (!$online) {
129
+                Log::info($bill['uid'] . '查询不到订单');
130
+                continue;
131
+            }   
132
+
133
+            $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
134
+            if (!$certification) {
135
+                Log::info($online['uid'] . '没有实名认证');
136
+                continue;
137
+            }   
138
+
139
+            $pension = $bill['number'] ?? 0;
140
+            if ($pension <= 0) {
141
+                Log::info($online['order_sn'] . 'pension' . $pension);
142
+                continue;
143
+            }
144
+
145
+            //新增入账明细记录
146
+            $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
147
+            $create    = [
148
+                'uid'          => $online['uid'],
149
+                'platform_no'  => $orderId,
150
+                'account_type' => $online['pay_type'] == 1 ? 3 : 2,
151
+                'user_name'    => $certification['user_name'],
152
+                'mobile'       => $certification['mobile'],
153
+                'user_card'    => $certification['user_card'],
154
+                'pension'      => $pension,
155
+                'order_type'   => 2,
156
+                'out_trade_no' => $online['order_sn'],
157
+                'link_id'=> $bill['bill_id']
158
+            ];
159
+            $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
160
+            $check     = Db::name("gzc_logs")->where("link_id", $bill['id'])->where("order_type", 2)->count();
161
+            if ($test_user == 0 && $check <= 0) {
162
+                $OrderGzcRepository->create($create);
163
+                Db::name('user_bill')
164
+                ->where('bill_id', $bill['bill_id'])
165
+                ->where('commission_type', 5)
166
+                ->update([
167
+                    'is_gzc'          => 1
168
+                ]);
169
+            }
170
+        }
171
+
172
+    }
173
+
174
+
175
+
71 176
     /**
72 177
      * 线下支付订单公证处IN10入账
73 178
      * @param $nowTime
@@ -108,56 +213,52 @@ class PensionTasks extends Command
108 213
                 Log::info($offline['pay_user_id'] . '未绑定用户');
109 214
                 continue;
110 215
             }
111
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
112
-            if (!$certification) {
113
-                Log::info($offline['pay_user_id'] . '未实名认证');
114
-                continue;
115
-            }
216
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
217
+            // if (!$certification) {
218
+            //     Log::info($offline['pay_user_id'] . '未实名认证');
219
+            //     continue;
220
+            // }
116 221
             //查询养老金金额
117 222
             $UserBillRepository = app()->make(UserBillRepository::class);
118 223
             $bill               = $UserBillRepository->getWhere(['uid' => $uid, 'link_id' => $offline['id'], 'order_sn' => $offline['out_trade_no'], 'title' => '养老金']);
119 224
 
120
-//            if ($bill->status == 0) {
121
-//                Log::info($offline['out_trade_no'] . 'pension未交年费');
122
-//                continue;
123
-//            }
124
-
125 225
             $pension = $bill->number ?? 0;
126
-            if ($pension <= 0) {
127
-                Log::info($offline['out_trade_no'] . 'pension' . $pension);
128
-                continue;
129
-            }
226
+            // if ($pension <= 0) {
227
+            //     Log::info($offline['out_trade_no'] . 'pension' . $pension);
228
+            //     continue;
229
+            // }
130 230
 
131
-            Db::transaction(function () use ($uid, $certification, $accountType, $offline, $OrderGzcRepository, $OrderMerchantRepository, $pension, $StoreOrderRepository) {
231
+            // Db::transaction(function () use ($uid, $certification, $accountType, $offline, $OrderGzcRepository, $OrderMerchantRepository, $pension, $StoreOrderRepository) {
232
+            Db::transaction(function () use ($uid, $accountType, $offline, $OrderGzcRepository, $OrderMerchantRepository, $pension, $StoreOrderRepository) {
132 233
                 $order                  = OrderMerchant::getInstance()->find($offline['id']);
133 234
                 $order->gzc             = 1;
134 235
                 $order->is_settlement   = 1;
135 236
                 $order->settlement_time = date('Y-m-d H:i:s');
136 237
                 $order->save();
137 238
                 //新增入账明细记录
138
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
139
-                $create    = [
140
-                    'uid'          => $uid,
141
-                    'platform_no'  => $orderId,
142
-                    'account_type' => $accountType,
143
-                    'user_name'    => $certification['user_name'],
144
-                    'mobile'       => $certification['mobile'],
145
-                    'user_card'    => $certification['user_card'],
146
-                    'pension'      => $pension,
147
-                    'order_type'   => 1,
148
-                    'out_trade_no' => $offline['out_trade_no']
149
-                ];
150
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
151
-                if ($test_user == 0) {
152
-                    $OrderGzcRepository->create($create);
153
-                }
154
-                // 养老金区域奖励
155
-                $order_data = [
156
-                    'pay_price'        => $pension,
157
-                    'user_address_ids' => $offline['user_address_ids'],
158
-                    'uid'              => $offline['uid'],
159
-                    'order_sn'         => $offline['out_trade_no']
160
-                ];
239
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
240
+                // $create    = [
241
+                //     'uid'          => $uid,
242
+                //     'platform_no'  => $orderId,
243
+                //     'account_type' => $accountType,
244
+                //     'user_name'    => $certification['user_name'],
245
+                //     'mobile'       => $certification['mobile'],
246
+                //     'user_card'    => $certification['user_card'],
247
+                //     'pension'      => $pension,
248
+                //     'order_type'   => 1,
249
+                //     'out_trade_no' => $offline['out_trade_no']
250
+                // ];
251
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
252
+                // if ($test_user == 0) {
253
+                //     $OrderGzcRepository->create($create);
254
+                // }
255
+                // // 养老金区域奖励
256
+                // $order_data = [
257
+                //     'pay_price'        => $pension,
258
+                //     'user_address_ids' => $offline['user_address_ids'],
259
+                //     'uid'              => $offline['uid'],
260
+                //     'order_sn'         => $offline['out_trade_no']
261
+                // ];
161 262
 //                $StoreOrderRepository->area_manage_details($order_data, 0, 2);
162 263
 
163 264
 
@@ -424,6 +525,9 @@ class PensionTasks extends Command
424 525
                             'status'          => 1,
425 526
                             'settlement_time' => date('Y-m-d H:i:s')
426 527
                         ]);
528
+                    /** @var UserRepository $userRepository */
529
+                    $userRepository = app()->make(UserRepository::class);
530
+                    $userRepository->setUserIdentity($user_sign_gongxian['uid']);
427 531
                 }
428 532
 
429 533
             });
@@ -469,48 +573,53 @@ class PensionTasks extends Command
469 573
                 }
470 574
             }
471 575
 
472
-            $certification = UserCertification::getInstance()->where('uid', $online['uid'])->find();
473
-            if (!$certification) {
474
-                Log::info($online['uid'] . '没有实名认证');
475
-                continue;
476
-            }
576
+            // $certification = UserCertification::getInstance()->where('uid', $online['uid'])->find();
577
+            // if (!$certification) {
578
+            //     Log::info($online['uid'] . '没有实名认证');
579
+            //     continue;
580
+            // }   
477 581
             //查询养老金金额
478 582
             $UserBillRepository = app()->make(UserBillRepository::class);
479 583
             $bill               = $UserBillRepository->getWhere(['uid' => $online['uid'], 'link_id' => $online['order_id'], 'order_sn' => $online['order_sn'], 'commission_type' => 5]);
480 584
 
481 585
             $pension = $bill->number ?? 0;
482
-            if ($pension <= 0) {
483
-                Log::info($online['order_sn'] . 'pension' . $pension);
484
-                continue;
485
-            }
586
+            // if ($pension <= 0) {
587
+            //     Log::info($online['order_sn'] . 'pension' . $pension);
588
+            //     continue;
589
+            // }
486 590
             //首信易分账
487
-            $StoreOrderRepository = app()->make(StoreOrderRepository::class);
488
-            if ($online['pay_type'] > 0) {
489
-                $StoreOrderRepository->splitOrder($online);
490
-            }
591
+            // $StoreOrderRepository = app()->make(StoreOrderRepository::class);
592
+            // if ($online['pay_type'] > 0) {
593
+            //     $StoreOrderRepository->splitOrder($online);
594
+            // }
491 595
 
492
-            Db::transaction(function () use ($certification, $online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
596
+            Db::transaction(function () use ($online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
493 597
                 //新增入账明细记录
494
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
495
-                $create    = [
496
-                    'uid'          => $online['uid'],
497
-                    'platform_no'  => $orderId,
498
-                    'account_type' => $online['pay_type'] == 1 ? 3 : 2,
499
-                    'user_name'    => $certification['user_name'],
500
-                    'mobile'       => $certification['mobile'],
501
-                    'user_card'    => $certification['user_card'],
502
-                    'pension'      => $pension,
503
-                    'order_type'   => 2,
504
-                    'out_trade_no' => $online['order_sn']
505
-                ];
506
-                $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
507
-                $check     = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
508
-                if ($test_user == 0 && $check <= 0) {
509
-                    $OrderGzcRepository->create($create);
510
-                }
598
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
599
+                // $create    = [
600
+                //     'uid'          => $online['uid'],
601
+                //     'platform_no'  => $orderId,
602
+                //     'account_type' => $online['pay_type'] == 1 ? 3 : 2,
603
+                //     'user_name'    => $certification['user_name'],
604
+                //     'mobile'       => $certification['mobile'],
605
+                //     'user_card'    => $certification['user_card'],
606
+                //     'pension'      => $pension,
607
+                //     'order_type'   => 2,
608
+                //     'out_trade_no' => $online['order_sn']
609
+                // ];
610
+                // $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
611
+                // $check     = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
612
+                // if ($test_user == 0 && $check <= 0) {
613
+                //     $OrderGzcRepository->create($create);
614
+                // }
511 615
                 $order                  = StoreOrder::getInstance()->find($online['order_id']);
512 616
                 $order->gzc             = 1;
513 617
                 $order->save();
618
+                Db::name('user_bill')
619
+                ->where('order_sn', $online['order_sn'])
620
+                ->where('commission_type', 5)
621
+                ->update(['status'=> 1]);
622
+
514 623
                 // 养老金区域奖励
515 624
 //                $order_data = [
516 625
 //                    'pay_price'        => $pension,
@@ -523,7 +632,7 @@ class PensionTasks extends Command
523 632
             });
524 633
         }
525 634
 
526
-        // 普通订单(红包,积分,京东,佣金,复购金,养老金,贡献值)
635
+        // 普通订单(红包,积分,京东,佣金,复购金,贡献值)
527 636
         $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->cursor();
528 637
         $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
529 638
         $OrderMerchantRepository    = app()->make(OrderMerchantRepository::class);
@@ -667,6 +776,9 @@ class PensionTasks extends Command
667 776
                             'status'          => 1,
668 777
                             'settlement_time' => date('Y-m-d H:i:s')
669 778
                         ]);
779
+                    /** @var UserRepository $userRepository */
780
+                    $userRepository = app()->make(UserRepository::class);
781
+                    $userRepository->setUserIdentity($user_sign_gongxian['uid']);
670 782
                 }
671 783
 
672 784
                 
@@ -743,33 +855,36 @@ class PensionTasks extends Command
743 855
             $uid = $thrid['uid'];
744 856
             if (!$uid)
745 857
                 continue;
746
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
747
-            if (!$certification) {
748
-                Log::info('用户ID' . $uid . '未实名认证');
749
-                continue;
750
-            }
858
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
859
+            // if (!$certification) {
860
+            //     Log::info('用户ID' . $uid . '未实名认证');
861
+            //     continue;
862
+            // }
751 863
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
752
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
864
+            Db::transaction(function () use ($uid,  $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
753 865
                 //新增入账明细记录
754
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
755
-                $create    = [
756
-                    'uid'          => $uid,
757
-                    'platform_no'  => $orderId,
758
-                    'user_name'    => $certification['user_name'],
759
-                    'mobile'       => $certification['mobile'],
760
-                    'user_card'    => $certification['user_card'],
761
-                    'pension'      => $pension,
762
-                    'order_type'   => 3,
763
-                    'out_trade_no' => $thrid['order_sn']
764
-                ];
765
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
766
-                if ($test_user == 0) {
767
-                    $OrderGzcRepository->create($create);
768
-                }
866
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
867
+                // $create    = [
868
+                //     'uid'          => $uid,
869
+                //     'platform_no'  => $orderId,
870
+                //     'user_name'    => $certification['user_name'],
871
+                //     'mobile'       => $certification['mobile'],
872
+                //     'user_card'    => $certification['user_card'],
873
+                //     'pension'      => $pension,
874
+                //     'order_type'   => 3,
875
+                //     'out_trade_no' => $thrid['order_sn']
876
+                // ];
877
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
878
+                // if ($test_user == 0) {
879
+                //     $OrderGzcRepository->create($create);
880
+                // }
769 881
 //                $OrderGzcRepository->create($create);
770 882
                 Db::table('rrx_order_pdd')
771 883
                     ->update(['gzc' => 1, 'order_pdd_id' => $thrid['order_pdd_id']]);
772
-
884
+                Db::name('user_bill')
885
+                    ->where('order_sn', $thrid['order_sn'])
886
+                    ->where('commission_type', 5)
887
+                    ->update(['status'=> 1]);
773 888
                 // 养老金区域奖励
774 889
                 $order_data = [
775 890
                     'pay_price'        => $pension,
@@ -807,39 +922,43 @@ class PensionTasks extends Command
807 922
             $uid = $thrid['uid'];
808 923
             if (!$uid)
809 924
                 continue;
810
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
811
-            if (!$certification) {
812
-                Log::info('用户ID' . $uid . '未实名认证');
813
-                continue;
814
-            }
925
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
926
+            // if (!$certification) {
927
+            //     Log::info('用户ID' . $uid . '未实名认证');
928
+            //     continue;
929
+            // }
815 930
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
816
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
931
+            Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
817 932
                 //新增入账明细记录
818
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
819
-                $create    = [
820
-                    'uid'          => $uid,
821
-                    'platform_no'  => $orderId,
822
-                    'user_name'    => $certification['user_name'],
823
-                    'mobile'       => $certification['mobile'],
824
-                    'user_card'    => $certification['user_card'],
825
-                    'pension'      => $pension,
826
-                    'order_type'   => 4,
827
-                    'out_trade_no' => $thrid['order_sn']
828
-                ];
829
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
830
-                if ($test_user == 0) {
831
-                    $OrderGzcRepository->create($create);
832
-                }
933
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
934
+                // $create    = [
935
+                //     'uid'          => $uid,
936
+                //     'platform_no'  => $orderId,
937
+                //     'user_name'    => $certification['user_name'],
938
+                //     'mobile'       => $certification['mobile'],
939
+                //     'user_card'    => $certification['user_card'],
940
+                //     'pension'      => $pension,
941
+                //     'order_type'   => 4,
942
+                //     'out_trade_no' => $thrid['order_sn']
943
+                // ];
944
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
945
+                // if ($test_user == 0) {
946
+                //     $OrderGzcRepository->create($create);
947
+                // }
833 948
 //                $OrderGzcRepository->create($create);
834 949
                 Db::table('rrx_order_jd')
835 950
                     ->update(['gzc' => 1, 'order_jd_id' => $thrid['order_jd_id']]);
951
+                Db::name('user_bill')
952
+                ->where('order_sn', $thrid['order_sn'])
953
+                ->where('commission_type', 5)
954
+                ->update(['status'=> 1]);
836 955
                 // 养老金区域奖励
837
-                $order_data = [
838
-                    'pay_price'        => $pension,
839
-                    'user_address_ids' => $thrid['user_address_ids'],
840
-                    'uid'              => $thrid['uid'],
841
-                    'order_sn'         => $thrid['order_sn']
842
-                ];
956
+                // $order_data = [
957
+                //     'pay_price'        => $pension,
958
+                //     'user_address_ids' => $thrid['user_address_ids'],
959
+                //     'uid'              => $thrid['uid'],
960
+                //     'order_sn'         => $thrid['order_sn']
961
+                // ];
843 962
 //                $StoreOrderRepository->area_manage_details($order_data, 6, 2);
844 963
             });
845 964
         }
@@ -868,33 +987,36 @@ class PensionTasks extends Command
868 987
             $uid = $thrid['uid'];
869 988
             if (!$uid)
870 989
                 continue;
871
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
872
-            if (!$certification) {
873
-                Log::info('用户ID' . $uid . '未实名认证');
874
-                continue;
875
-            }
990
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
991
+            // if (!$certification) {
992
+            //     Log::info('用户ID' . $uid . '未实名认证');
993
+            //     continue;
994
+            // }
876 995
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
877
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
996
+            Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
878 997
                 //新增入账明细记录
879
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
880
-                $create    = [
881
-                    'uid'          => $uid,
882
-                    'platform_no'  => $orderId,
883
-                    'user_name'    => $certification['user_name'],
884
-                    'mobile'       => $certification['mobile'],
885
-                    'user_card'    => $certification['user_card'],
886
-                    'pension'      => $pension,
887
-                    'order_type'   => 5,
888
-                    'out_trade_no' => $thrid['order_sn']
889
-                ];
890
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
891
-                if ($test_user == 0) {
892
-                    $OrderGzcRepository->create($create);
893
-                }
998
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
999
+                // $create    = [
1000
+                //     'uid'          => $uid,
1001
+                //     'platform_no'  => $orderId,
1002
+                //     'user_name'    => $certification['user_name'],
1003
+                //     'mobile'       => $certification['mobile'],
1004
+                //     'user_card'    => $certification['user_card'],
1005
+                //     'pension'      => $pension,
1006
+                //     'order_type'   => 5,
1007
+                //     'out_trade_no' => $thrid['order_sn']
1008
+                // ];
1009
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1010
+                // if ($test_user == 0) {
1011
+                //     $OrderGzcRepository->create($create);
1012
+                // }
894 1013
 //                $OrderGzcRepository->create($create);
895 1014
                 Db::table('rrx_order_su')
896 1015
                     ->update(['gzc' => 1, 'order_su_id' => $thrid['order_su_id']]);
897
-
1016
+                Db::name('user_bill')
1017
+                ->where('order_sn', $thrid['order_sn'])
1018
+                ->where('commission_type', 5)
1019
+                ->update(['status'=> 1]);
898 1020
                 // 养老金区域奖励
899 1021
                 $order_data = [
900 1022
                     'pay_price'        => $pension,
@@ -931,30 +1053,34 @@ class PensionTasks extends Command
931 1053
             $uid = $thrid['uid'];
932 1054
             if (!$uid)
933 1055
                 continue;
934
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
935
-            if (!$certification) {
936
-                Log::info('用户ID' . $uid . '未实名认证');
937
-                continue;
938
-            }
1056
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
1057
+            // if (!$certification) {
1058
+            //     Log::info('用户ID' . $uid . '未实名认证');
1059
+            //     continue;
1060
+            // }
939 1061
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
940
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository) {
941
-                //新增入账明细记录
942
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
943
-                $create    = [
944
-                    'uid'          => $uid,
945
-                    'platform_no'  => $orderId,
946
-                    'user_name'    => $certification['user_name'],
947
-                    'mobile'       => $certification['mobile'],
948
-                    'user_card'    => $certification['user_card'],
949
-                    'pension'      => $pension,
950
-                    'order_type'   => 6,
951
-                    'out_trade_no' => $thrid['order_sn']
952
-                ];
953
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
954
-                if ($test_user == 0) {
955
-                    $OrderGzcRepository->create($create);
956
-                }
1062
+            Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository) {
1063
+                // //新增入账明细记录
1064
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1065
+                // $create    = [
1066
+                //     'uid'          => $uid,
1067
+                //     'platform_no'  => $orderId,
1068
+                //     'user_name'    => $certification['user_name'],
1069
+                //     'mobile'       => $certification['mobile'],
1070
+                //     'user_card'    => $certification['user_card'],
1071
+                //     'pension'      => $pension,
1072
+                //     'order_type'   => 6,
1073
+                //     'out_trade_no' => $thrid['order_sn']
1074
+                // ];
1075
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1076
+                // if ($test_user == 0) {
1077
+                //     $OrderGzcRepository->create($create);
1078
+                // }
957 1079
                 Db::table('rrx_order_huafei')->update(['gzc' => 1, 'order_tb_id' => $thrid['order_tb_id']]);
1080
+                Db::name('user_bill')
1081
+                ->where('order_sn', $thrid['order_sn'])
1082
+                ->where('commission_type', 5)
1083
+                ->update(['status'=> 1]);
958 1084
             });
959 1085
         }
960 1086
     }
@@ -984,33 +1110,36 @@ class PensionTasks extends Command
984 1110
             $uid = $thrid['uid'];
985 1111
             if (!$uid)
986 1112
                 continue;
987
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
988
-            if (!$certification) {
989
-                Log::info('用户ID' . $uid . '未实名认证');
990
-                continue;
991
-            }
1113
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
1114
+            // if (!$certification) {
1115
+            //     Log::info('用户ID' . $uid . '未实名认证');
1116
+            //     continue;
1117
+            // }
992 1118
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
993
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
1119
+            Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
994 1120
                 //新增入账明细记录
995
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
996
-                $create    = [
997
-                    'uid'          => $uid,
998
-                    'platform_no'  => $orderId,
999
-                    'user_name'    => $certification['user_name'],
1000
-                    'mobile'       => $certification['mobile'],
1001
-                    'user_card'    => $certification['user_card'],
1002
-                    'pension'      => $pension,
1003
-                    'order_type'   => 6,
1004
-                    'out_trade_no' => $thrid['order_sn']
1005
-                ];
1006
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1007
-                if ($test_user == 0) {
1008
-                    $OrderGzcRepository->create($create);
1009
-                }
1121
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1122
+                // $create    = [
1123
+                //     'uid'          => $uid,
1124
+                //     'platform_no'  => $orderId,
1125
+                //     'user_name'    => $certification['user_name'],
1126
+                //     'mobile'       => $certification['mobile'],
1127
+                //     'user_card'    => $certification['user_card'],
1128
+                //     'pension'      => $pension,
1129
+                //     'order_type'   => 6,
1130
+                //     'out_trade_no' => $thrid['order_sn']
1131
+                // ];
1132
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1133
+                // if ($test_user == 0) {
1134
+                //     $OrderGzcRepository->create($create);
1135
+                // }
1010 1136
 //                $OrderGzcRepository->create($create);
1011 1137
                 Db::table('rrx_order_tb')
1012 1138
                     ->update(['gzc' => 1, 'order_tb_id' => $thrid['order_tb_id']]);
1013
-
1139
+                Db::name('user_bill')
1140
+                ->where('order_sn', $thrid['order_sn'])
1141
+                ->where('commission_type', 5)
1142
+                ->update(['status'=> 1]);
1014 1143
                 // 养老金区域奖励
1015 1144
                 $order_data = [
1016 1145
                     'pay_price'        => $pension,
@@ -1046,33 +1175,36 @@ class PensionTasks extends Command
1046 1175
             $uid = $thrid['uid'];
1047 1176
             if (!$uid)
1048 1177
                 continue;
1049
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
1050
-            if (!$certification) {
1051
-                Log::info('用户ID' . $uid . '未实名认证');
1052
-                continue;
1053
-            }
1178
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
1179
+            // if (!$certification) {
1180
+            //     Log::info('用户ID' . $uid . '未实名认证');
1181
+            //     continue;
1182
+            // }
1054 1183
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
1055
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
1184
+            Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
1056 1185
                 //新增入账明细记录
1057
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1058
-                $create    = [
1059
-                    'uid'          => $uid,
1060
-                    'platform_no'  => $orderId,
1061
-                    'user_name'    => $certification['user_name'],
1062
-                    'mobile'       => $certification['mobile'],
1063
-                    'user_card'    => $certification['user_card'],
1064
-                    'pension'      => $pension,
1065
-                    'order_type'   => 7,
1066
-                    'out_trade_no' => $thrid['order_sn']
1067
-                ];
1068
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1069
-                if ($test_user == 0) {
1070
-                    $OrderGzcRepository->create($create);
1071
-                }
1186
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1187
+                // $create    = [
1188
+                //     'uid'          => $uid,
1189
+                //     'platform_no'  => $orderId,
1190
+                //     'user_name'    => $certification['user_name'],
1191
+                //     'mobile'       => $certification['mobile'],
1192
+                //     'user_card'    => $certification['user_card'],
1193
+                //     'pension'      => $pension,
1194
+                //     'order_type'   => 7,
1195
+                //     'out_trade_no' => $thrid['order_sn']
1196
+                // ];
1197
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1198
+                // if ($test_user == 0) {
1199
+                //     $OrderGzcRepository->create($create);
1200
+                // }
1072 1201
 //                $OrderGzcRepository->create($create);
1073 1202
                 Db::table('rrx_order_vip')
1074 1203
                     ->update(['gzc' => 1, 'order_vip_id' => $thrid['order_vip_id']]);
1075
-
1204
+                Db::name('user_bill')
1205
+                    ->where('order_sn', $thrid['order_sn'])
1206
+                    ->where('commission_type', 5)
1207
+                    ->update(['status'=> 1]);
1076 1208
                 // 养老金区域奖励
1077 1209
                 $order_data = [
1078 1210
                     'pay_price'        => $pension,
@@ -1108,32 +1240,35 @@ class PensionTasks extends Command
1108 1240
             $uid = $thrid['uid'];
1109 1241
             if (!$uid)
1110 1242
                 continue;
1111
-            $certification = UserCertification::getInstance()->where('uid', $uid)->find();
1112
-            if (!$certification) {
1113
-                Log::info('用户ID' . $uid . '未实名认证');
1114
-                continue;
1115
-            }
1243
+            // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
1244
+            // if (!$certification) {
1245
+            //     Log::info('用户ID' . $uid . '未实名认证');
1246
+            //     continue;
1247
+            // }
1116 1248
             $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
1117
-            Db::transaction(function () use ($uid, $certification, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
1118
-                //新增入账明细记录
1119
-                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1120
-                $create    = [
1121
-                    'uid'          => $uid,
1122
-                    'platform_no'  => $orderId,
1123
-                    'user_name'    => $certification['user_name'],
1124
-                    'mobile'       => $certification['mobile'],
1125
-                    'user_card'    => $certification['user_card'],
1126
-                    'pension'      => $pension,
1127
-                    'order_type'   => 8,
1128
-                    'out_trade_no' => $thrid['order_sn']
1129
-                ];
1130
-                $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1131
-                if ($test_user == 0) {
1132
-                    $OrderGzcRepository->create($create);
1133
-                }
1249
+            Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
1250
+                // //新增入账明细记录
1251
+                // $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1252
+                // $create    = [
1253
+                //     'uid'          => $uid,
1254
+                //     'platform_no'  => $orderId,
1255
+                //     'user_name'    => $certification['user_name'],
1256
+                //     'mobile'       => $certification['mobile'],
1257
+                //     'user_card'    => $certification['user_card'],
1258
+                //     'pension'      => $pension,
1259
+                //     'order_type'   => 8,
1260
+                //     'out_trade_no' => $thrid['order_sn']
1261
+                // ];
1262
+                // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
1263
+                // if ($test_user == 0) {
1264
+                //     $OrderGzcRepository->create($create);
1265
+                // }
1134 1266
                 Db::table('rrx_order_dy')
1135 1267
                     ->update(['gzc' => 1, 'order_dy_id' => $thrid['order_dy_id']]);
1136
-
1268
+                Db::name('user_bill')
1269
+                    ->where('order_sn', $thrid['order_sn'])
1270
+                    ->where('commission_type', 5)
1271
+                    ->update(['status'=> 1]);
1137 1272
                 // 养老金区域奖励
1138 1273
                 $order_data = [
1139 1274
                     'pay_price'        => $pension,

+ 48 - 0
app/common/dao/user/UserIdentityDao.php

@@ -0,0 +1,48 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\dao\user;
12
+
13
+
14
+use app\common\dao\BaseDao;
15
+use app\common\model\BaseModel;
16
+use app\common\model\user\UserIdentity;
17
+use think\db\BaseQuery;
18
+
19
+/**
20
+ * Class UserIdentityDao
21
+ * @package app\common\dao\user
22
+ */
23
+class UserIdentityDao extends BaseDao
24
+{
25
+
26
+    /**
27
+     * @return BaseModel
28
+     * @author xaboy
29
+     * @day 2020-03-30
30
+     */
31
+    protected function getModel(): string
32
+    {
33
+        return UserIdentity::class;
34
+    }
35
+
36
+
37
+    /**
38
+     * @param array $where
39
+     * @return BaseQuery
40
+     * @author xaboy
41
+     * @day 2020-05-06
42
+     */
43
+    public function search(array $where = [])
44
+    {
45
+        return UserIdentity::getDB();
46
+    }
47
+
48
+}

+ 2 - 2
app/common/model/movie/cinema/Cinema.php

@@ -24,8 +24,8 @@ class Cinema extends BaseModel
24 24
 
25 25
         return $model->when(isset($where['cinema_name']) && $where['cinema_name'], function ($query) use ($where) {
26 26
             $query->where('cinema_name', 'like', "%{$where['cinema_name']}%");
27
-        })->when(isset($where['cate_one_id']) && $where['cate_one_id'], function ($query) use ($where) {
28
-            $query->where('cate_one_id', $where['cate_one_id']);
27
+        })->when(isset($where['cinema_sign']) && $where['cinema_sign'], function ($query) use ($where) {
28
+            $query->where('cinema_sign', $where['cinema_sign']);
29 29
         })->when(isset($where['cate_two_id']) && $where['cate_two_id'], function ($query) use ($where) {
30 30
             $query->where('cate_two_id', $where['cate_two_id']);
31 31
         })->when(isset($where['city']) && $where['city'], function ($query) use ($where) {

+ 37 - 0
app/common/model/movie/cinema/CinemaSched.php

@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+namespace app\common\model\movie\cinema;
4
+
5
+use app\model\BaseModel;
6
+
7
+class CinemaSched extends BaseModel
8
+{
9
+    protected $name = 'movie_cinema_sched';
10
+
11
+    public static function tablePk(): ?string
12
+    {
13
+        return 'id';
14
+    }
15
+
16
+    /**
17
+     * @param $model
18
+     * @param array $where
19
+     * @return CinemaSched
20
+     */
21
+    public function search($model = null, array $where = [])
22
+    {
23
+        $model = $model ?? new self();
24
+
25
+        return $model->when(isset($where['film_sign']) && $where['film_sign'], function ($query) use ($where) {
26
+            $query->where('film_sign', $where['film_sign']);
27
+        })->when(isset($where['cinema_sign']) && $where['cinema_sign'], function ($query) use ($where) {
28
+            $query->where('cinema_sign', $where['cinema_sign']);
29
+        })->when(isset($where['show_date']) && $where['show_date'], function ($query) use ($where) {
30
+            $query->where('show_date', $where['show_date']);
31
+        })->when(isset($where['relation_id']) && $where['relation_id'], function ($query) use ($where) {
32
+            $query->where('relation_id', $where['relation_id']);
33
+        })->when(isset($where['sched_sign']) && $where['sched_sign'], function ($query) use ($where) {
34
+            $query->where('sched_sign', $where['sched_sign']);
35
+        });
36
+    }
37
+}

+ 38 - 0
app/common/model/user/UserIdentity.php

@@ -0,0 +1,38 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\model\user;
12
+
13
+
14
+use app\common\model\BaseModel;
15
+
16
+class UserIdentity extends BaseModel
17
+{
18
+
19
+    /**
20
+     * @return string
21
+     * @author xaboy
22
+     * @day 2020-03-30
23
+     */
24
+    public static function tablePk(): string
25
+    {
26
+        return 'user_group_id';
27
+    }
28
+
29
+    /**
30
+     * @return string
31
+     * @author xaboy
32
+     * @day 2020-03-30
33
+     */
34
+    public static function tableName(): string
35
+    {
36
+        return 'user_identity';
37
+    }
38
+}

+ 56 - 26
app/common/repositories/merchant/order/OrderMerchantRepository.php

@@ -359,7 +359,7 @@ class OrderMerchantRepository extends BaseRepository
359 359
                 }
360 360
             }
361 361
             if ($paramOrder['avatar'] == null) {
362
-                $paramOrder['avatar'] = 'http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png';
362
+                $paramOrder['avatar'] = 'https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png';
363 363
             }
364 364
             $order = Db::transaction(function () use ($paramOrder) {
365 365
                 $merchantOrder = $this->dao->create($paramOrder);
@@ -425,7 +425,7 @@ class OrderMerchantRepository extends BaseRepository
425 425
         }
426 426
 //        Db::name('log')->insert(['data' => json_encode($paramOrder)]);
427 427
         if ($paramOrder['avatar'] == null) {
428
-            $paramOrder['avatar'] = 'http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png';
428
+            $paramOrder['avatar'] = 'https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png';
429 429
         }
430 430
         $order = Db::transaction(function () use ($paramOrder) {
431 431
             $merchantOrder = $this->dao->create($paramOrder);
@@ -902,7 +902,7 @@ class OrderMerchantRepository extends BaseRepository
902 902
                     $unionData = [
903 903
                         'unionid' => $order->pay_user_id,
904 904
                         'nickname' => $order->nickname ?: time(),
905
-                        'avatar' => $order->avatar ?: 'http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png',
905
+                        'avatar' => $order->avatar ?: 'https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png',
906 906
                         'is_lock' => 1,
907 907
                         'lock_mer_id' => $order->mer_id,
908 908
                         'lock_time' => date('Y-m-d H:i:s'),
@@ -917,7 +917,7 @@ class OrderMerchantRepository extends BaseRepository
917 917
                     } else {
918 918
                         $updateData = [
919 919
                             'nickname' => $order->nickname ?: time(),
920
-                            'avatar' => $order->avatar ?: 'http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png',
920
+                            'avatar' => $order->avatar ?: 'https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png',
921 921
                             'balance' => Db::raw('balance+' . $order->money),
922 922
                             'give_money' => Db::raw('give_money+' . $order->give_money),
923 923
                             'pension' => Db::raw('pension+' . $order->pension),
@@ -1583,6 +1583,8 @@ class OrderMerchantRepository extends BaseRepository
1583 1583
         //可分总佣金
1584 1584
         $divisible_commission = bcmul($order['pay_price'], bcdiv($mer_fanyongbili, '100', 2), 2);//让利部分
1585 1585
         $pv = bcmul($divisible_commission, '0.7', 2);//商家让利部分30%给消费者做养老金,70%做业绩PV
1586
+        //更新值
1587
+        Db::name("order_merchant")->where('id', $order_id)->where('out_trade_no', $order_sn)->update(['available'=>$divisible_commission]);
1586 1588
 
1587 1589
         /**
1588 1590
          * 各自的比例开始
@@ -1598,6 +1600,34 @@ class OrderMerchantRepository extends BaseRepository
1598 1600
          * 各自的比例结束
1599 1601
          */
1600 1602
 
1603
+        $gongxian = Db::name('user_sign_gongxian')->where('order_id', $order_id)->find();
1604
+        if(!$gongxian){
1605
+            ///用户可以拿到PV等值贡献值
1606
+            if ($pv >= 0.01) {
1607
+                //贡献值
1608
+                $gongxian_data = [
1609
+                    "uid"           =>$order["uid"]??0,
1610
+                    "number"  =>    $pv,
1611
+                    "addtime"       =>time(),
1612
+                    "status"        =>1,
1613
+                    "order_type"    =>1,
1614
+                    "order_id"      =>$order_id,
1615
+                    "mark"          =>"扫码消费获得赠送贡献值",
1616
+                    "desc"          =>'',
1617
+                    "surplus"       =>$pv,
1618
+                    "type"          =>1,
1619
+                    'settlement_time' => date('Y-m-d H:i:s')
1620
+                ];
1621
+                Db::name("user_sign_gongxian")->insert($gongxian_data);//添加记录
1622
+            } else {
1623
+                Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . '付款额度较低或 商家、平台设置的返佣比例较低,积分和贡献值低于0.01无法入库 特此记录!']);
1624
+            }
1625
+        }
1626
+
1627
+
1628
+
1629
+
1630
+
1601 1631
         // 商户---------------------------------------------------------------------------------------------------------------
1602 1632
 
1603 1633
         $mer_data = Db::name('merchant')->where('mer_id', $order['mer_id'])->field('uid,mer_id')->find();
@@ -1605,28 +1635,28 @@ class OrderMerchantRepository extends BaseRepository
1605 1635
         $merchant_user = $userRepository->getOne(['uid' => $mer_data["uid"]]);
1606 1636
 
1607 1637
         //商户得到的(京豆和贡献值奖励的倍,后台设置)
1608
-        $gongxian = bcmul($divisible_commission, $mer_gonxian, 2);
1609
-        if ($gongxian >= 0.01) {
1610
-            $gongxian_data = [
1611
-                "uid"           =>$mer_data["uid"],
1612
-                "mer_id"        =>$order["mer_id"],
1613
-                "pv"            =>$pv,
1614
-                "number"  =>    $gongxian,
1615
-                "addtime"       =>time(),
1616
-                "status"        =>1,
1617
-                "order_type"    =>2,
1618
-                "order_id"      =>$order_id,
1619
-                "mark"          =>"用户消费商家获得赠送贡献值",
1620
-                "desc"          =>'',
1621
-                "surplus"       =>$gongxian,
1622
-                "type"          =>1
1623
-            ];
1624
-            Db::name("user_sign_gongxian")->insert($gongxian_data);//添加记录
1625
-            $merchant_user->contribute = bcadd($merchant_user->contribute, (float)$gongxian,2);
1626
-            $merchant_user->save();
1627
-        } else {
1628
-            Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . '付款额度较低或 商家、平台设置的返佣比例较低,贡献值低于0.01无法入库 特此记录!']);
1629
-        }
1638
+        // $gongxian = bcmul($divisible_commission, $mer_gonxian, 2);
1639
+        // if ($gongxian >= 0.01) {
1640
+            // $gongxian_data = [
1641
+            //     "uid"           =>$mer_data["uid"],
1642
+            //     "mer_id"        =>$order["mer_id"],
1643
+            //     "pv"            =>$pv,
1644
+            //     "number"  =>    $gongxian,
1645
+            //     "addtime"       =>time(),
1646
+            //     "status"        =>1,
1647
+            //     "order_type"    =>2,
1648
+            //     "order_id"      =>$order_id,
1649
+            //     "mark"          =>"用户消费商家获得赠送贡献值",
1650
+            //     "desc"          =>'',
1651
+            //     "surplus"       =>$gongxian,
1652
+            //     "type"          =>1
1653
+            // ];
1654
+            // Db::name("user_sign_gongxian")->insert($gongxian_data);//添加记录
1655
+        //     $merchant_user->contribute = bcadd($merchant_user->contribute, (float)$gongxian,2);
1656
+        //     $merchant_user->save();
1657
+        // // } else {
1658
+        //     Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . '付款额度较低或 商家、平台设置的返佣比例较低,贡献值低于0.01无法入库 特此记录!']);
1659
+        // }
1630 1660
 
1631 1661
         //商户得到的(京豆和贡献值奖励的倍,后台设置)
1632 1662
         $jd = bcmul($divisible_commission, $mer_jd, 2);

+ 15 - 1
app/common/repositories/movie/CinemaRepository.php

@@ -16,7 +16,7 @@ use think\facade\Db;
16 16
  * Class CinemaRepository
17 17
  * @package app\common\repositories\movie
18 18
  * @author xaboy
19
- * @mixin MovieOrderDao
19
+ * @mixin Cinema
20 20
  */
21 21
 class CinemaRepository extends BaseRepository
22 22
 {
@@ -85,4 +85,18 @@ class CinemaRepository extends BaseRepository
85 85
         return "(round(6378137 * 2 * asin(sqrt(pow(sin(((latitude * pi()) / 180 - ({$latitude} * pi()) / 180) / 2), 2) 
86 86
         + cos(({$latitude} * pi()) / 180) * cos((latitude * pi()) / 180) * pow(sin(((longitude * pi()) / 180 - ({$longitude} * pi()) / 180) / 2), 2))))) AS distance";
87 87
     }
88
+
89
+    /**
90
+     * 获取影院信息
91
+     *
92
+     * @param $cinema_sign
93
+     * @return Cinema|array|\think\Model|null
94
+     * @throws \think\db\exception\DataNotFoundException
95
+     * @throws \think\db\exception\DbException
96
+     * @throws \think\db\exception\ModelNotFoundException
97
+     */
98
+    public function getCinemaInfo($cinema_sign)
99
+    {
100
+        return $this->dao->search(null, ['cinema_sign' => $cinema_sign])->find();
101
+    }
88 102
 }

+ 162 - 0
app/common/repositories/movie/CinemaSchedRepository.php

@@ -0,0 +1,162 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ * @Author: Qinii
5
+ * @Date: 2020/5/8
6
+ */
7
+
8
+namespace app\common\repositories\movie;
9
+
10
+use app\common\model\movie\cinema\CinemaSched;
11
+use app\common\repositories\BaseRepository;
12
+use think\facade\Db;
13
+
14
+/**
15
+ * Class CinemaSchedRepository
16
+ * @package app\common\repositories\movie
17
+ * @author xaboy
18
+ * @mixin CinemaSched
19
+ */
20
+class CinemaSchedRepository extends BaseRepository
21
+{
22
+    protected $dao;
23
+
24
+    /**
25
+     * ProductRepository constructor.
26
+     * @param CinemaSched $dao
27
+     */
28
+    public function __construct(CinemaSched $dao)
29
+    {
30
+        $this->dao = $dao;
31
+    }
32
+
33
+    /**
34
+     * @param $film_sign
35
+     * @return array
36
+     * @throws \think\db\exception\DataNotFoundException
37
+     * @throws \think\db\exception\DbException
38
+     * @throws \think\db\exception\ModelNotFoundException
39
+     */
40
+    public function getFilmSchedDate($film_sign)
41
+    {
42
+        $field = 'show_date';
43
+        $where = ['film_sign' => $film_sign];
44
+
45
+        $show_date = $this->dao->search(null, $where)->field([$field])->order('show_date asc')->group('show_date')->select()->toArray();
46
+        foreach ($show_date as $key => $value) {
47
+            $show_date[$key]['date'] = date('m-d', $value['show_date']);
48
+        }
49
+
50
+        return $show_date;
51
+    }
52
+
53
+    /**
54
+     * @param $page
55
+     * @param $limit
56
+     * @param $longitude
57
+     * @param $latitude
58
+     * @param $show_date
59
+     * @param $with
60
+     * @param $order
61
+     * @return array
62
+     * @throws \think\db\exception\DataNotFoundException
63
+     * @throws \think\db\exception\DbException
64
+     * @throws \think\db\exception\ModelNotFoundException
65
+     */
66
+    public function getFilmSched($page, $limit, $film_sign, $longitude, $latitude, $show_date, $with = [], $order = 1)
67
+    {
68
+        $field = 'sched_sign,cinema_sign,cinema_name,address,show_date,price,longitude,latitude';
69
+        $where = ['film_sign' => $film_sign, 'show_date' => $show_date];
70
+
71
+        $cinema_sched = $this->dao->search(null, $where)->when($with, function ($query) use ($with) {
72
+            $query->with($with);
73
+        })->when($latitude && $longitude, function ($query) use ($field, $longitude, $latitude) {
74
+            $query->field([$field, $this->distance($latitude, $longitude)]);
75
+        })->when($page && $limit, function ($query) use ($page, $limit) {
76
+            $query->page($page, $limit);
77
+        })->when(!is_null($order), function ($query) use ($order) {
78
+            if ($order == 1) {//距离最近
79
+                $query->order('distance asc');
80
+            } else {//播放日期
81
+                $query->order('show_date desc');
82
+            }
83
+        })->field([$field])->select()->toArray();
84
+        foreach ($cinema_sched as $key => $value) {
85
+            $cinema_sched[$key]['distance'] = isset($value['distance']) ? round($value['distance'] / 1000, 2) : 0.00;
86
+            $cinema_sched[$key]['show_date'] = date('m-d', $value['show_date']);
87
+
88
+            $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price']);
89
+            $cinema_sched[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
90
+        }
91
+
92
+        $count = $this->dao->search(null, $where)->when($with, function ($query) use ($with) {
93
+            $query->with($with);
94
+        })->when($latitude && $longitude, function ($query) use ($field, $longitude, $latitude) {
95
+            $query->field([$field, $this->distance($latitude, $longitude)]);
96
+        })->count();
97
+
98
+        return compact('cinema_sched', 'count');
99
+    }
100
+
101
+    /**
102
+     * @param $page
103
+     * @param $limit
104
+     * @param $cinema_sign
105
+     * @param $film_sign
106
+     * @param $show_date
107
+     * @return array
108
+     * @throws \think\db\exception\DataNotFoundException
109
+     * @throws \think\db\exception\DbException
110
+     * @throws \think\db\exception\ModelNotFoundException
111
+     */
112
+    public function getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, $show_date)
113
+    {
114
+        $field = 'relation_id,sched_sign,film_sign,film_name,show_date,show_time,cinema_sign,cinema_name,hall_sign,hall_name,price';
115
+        $where = ['cinema_sign' => $cinema_sign, 'film_sign' => $film_sign, 'show_date' => strtotime($show_date)];
116
+
117
+        $cinema_sched = $this->dao->search(null, $where)
118
+            ->when($page && $limit, function ($query) use ($page, $limit) {
119
+                $query->page($page, $limit);
120
+            })->order('show_time asc')->field([$field])->select()->toArray();
121
+        foreach ($cinema_sched as $key => $value) {
122
+            $pcYanglaojinGongxian = MovieRepository::getPvYanglaojinScore($value['price']);
123
+
124
+            $cinema_sched[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
125
+            $cinema_sched[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
126
+            $cinema_sched[$key]['pv'] = $pcYanglaojinGongxian['pv'];
127
+            $cinema_sched[$key]['score'] = $pcYanglaojinGongxian['score'];
128
+            $cinema_sched[$key]['gongxian'] = $pcYanglaojinGongxian['gongxian'];
129
+        }
130
+
131
+        $count = $this->dao->search(null, $where)->count();
132
+
133
+        return compact('cinema_sched', 'count');
134
+    }
135
+
136
+    /**
137
+     * 经纬度排序计算
138
+     * @param string $latitude
139
+     * @param string $longitude
140
+     * @return string
141
+     */
142
+    private function distance(string $latitude, string $longitude)
143
+    {
144
+        return "(round(6378137 * 2 * asin(sqrt(pow(sin(((latitude * pi()) / 180 - ({$latitude} * pi()) / 180) / 2), 2) 
145
+        + cos(({$latitude} * pi()) / 180) * cos((latitude * pi()) / 180) * pow(sin(((longitude * pi()) / 180 - ({$longitude} * pi()) / 180) / 2), 2))))) AS distance";
146
+    }
147
+
148
+    /**
149
+     * 获取影片场次详情
150
+     *
151
+     * @param $relation_id
152
+     * @param $sched_sign
153
+     * @return CinemaSched|array|\think\Model|null
154
+     * @throws \think\db\exception\DataNotFoundException
155
+     * @throws \think\db\exception\DbException
156
+     * @throws \think\db\exception\ModelNotFoundException
157
+     */
158
+    public function getCinemaSchedInfo($relation_id, $sched_sign)
159
+    {
160
+        return $this->dao->search(null, ['relation_id' => $relation_id, 'sched_sign' => $sched_sign])->find();
161
+    }
162
+}

+ 8 - 3
app/common/repositories/movie/DouHuoMallFilmApiRequest.php

@@ -203,11 +203,15 @@ class DouHuoMallFilmApiRequest
203 203
     /**
204 204
      * 锁座订单
205 205
      *
206
-     * @param $relation_id
206
+     * @param $phone
207
+     * @param $channel_type
207 208
      * @param $sched_sign
209
+     * @param $seat_sign
210
+     * @param $third_order
211
+     * @param $order_price
208 212
      * @return mixed|string
209 213
      */
210
-    public static function submitOrder($phone, $channel_type, $sched_sign, $third_order, $order_price)
214
+    public static function submitOrder($phone, $channel_type, $sched_sign, $seat_sign, $third_order, $order_price)
211 215
     {
212 216
         $url = '/openapi/Movie/submitOrder';
213 217
         $body = [
@@ -216,7 +220,8 @@ class DouHuoMallFilmApiRequest
216 220
             'sched_sign' => $sched_sign,
217 221
             'third_order' => $third_order,
218 222
             'order_price' => $order_price,
219
-            'phone' => $phone
223
+            'phone' => $phone,
224
+            'seat_sign' => $seat_sign
220 225
         ];
221 226
 
222 227
         $res = self::curl_post(self::$path . $url, $body);

+ 96 - 49
app/common/repositories/movie/MovieRepository.php

@@ -28,10 +28,10 @@ class MovieRepository extends BaseRepository
28 28
 
29 29
     protected $dao;
30 30
 
31
-    private $premium_ratio = 0.2;//溢价比例
32
-    private $yanglaojin_ratio = 0.3;
31
+    const premium_ratio = 0.2;//溢价比例
32
+    const yanglaojin_ratio = 0.3;
33 33
 
34
-    private $pv_ratio = 0.7;
34
+    const pv_ratio = 0.7;
35 35
 
36 36
     /**
37 37
      * ProductRepository constructor.
@@ -99,15 +99,15 @@ class MovieRepository extends BaseRepository
99 99
             ? $result['data']['list'] : [];
100 100
         foreach ($cinemaSchedList as $dateDay => &$fileSchedValue) {
101 101
             foreach ($fileSchedValue as $key => $value) {
102
-                $premium = round($value['cost_price'] * $this->premium_ratio, 2);
102
+                $pcYanglaojinGongxian = static::getPvYanglaojinScore($value['cost_price']);
103 103
 
104
-                $fileSchedValue[$key]['cost_price'] = bcadd((string)$value['cost_price'], (string)$premium, 2);
104
+                $fileSchedValue[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
105
+                $fileSchedValue[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
106
+                $fileSchedValue[$key]['pv'] = $pcYanglaojinGongxian['pv'];
107
+                $fileSchedValue[$key]['score'] = $pcYanglaojinGongxian['score'];
108
+                $fileSchedValue[$key]['gongxian'] = $pcYanglaojinGongxian['gongxian'];
105 109
 
106
-                $pv = bcmul((string)$premium, $this->pv_ratio, 2);
107
-                $fileSchedValue[$key]['yanglaojin'] = bcmul((string)$premium, $this->yanglaojin_ratio, 2);
108
-                $fileSchedValue[$key]['pv'] = $fileSchedValue[$key]['score'] = $fileSchedValue[$key]['gongxian'] = $pv;
109
-
110
-                unset($fileSchedValue[$key]['channel_price']);
110
+//                unset($fileSchedValue[$key]['channel_price']);
111 111
             }
112 112
         }
113 113
 
@@ -121,18 +121,41 @@ class MovieRepository extends BaseRepository
121 121
      */
122 122
     public function getSchedSeat($relation_id = '', $sched_sign = '')
123 123
     {
124
-        return DouHuoMallFilmApiRequest::getSchedSeat($relation_id, $sched_sign);
124
+        $result = DouHuoMallFilmApiRequest::getSchedSeat($relation_id, $sched_sign);
125
+
126
+        $schedSeatList = (isset($result['code']) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) ? $result['data'] : [];
127
+        foreach ($schedSeatList as $key => $value) {
128
+            $tmpprice = [];
129
+            foreach ($value['price'] as $pKey => $pValue) {
130
+                $tmpprice[$pValue] = ['channel_type' => $pKey, 'price' => $pValue];
131
+            }
132
+            ksort($tmpprice);
133
+            $tmpprice = array_shift($tmpprice);
134
+            unset($schedSeatList[$key]['price']);
135
+
136
+            $pcYanglaojinGongxian = self::getPvYanglaojinScore($tmpprice['price']);
137
+            $schedSeatList[$key]['channel_type'] = $tmpprice['channel_type'];
138
+            $schedSeatList[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
139
+            $schedSeatList[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
140
+            $schedSeatList[$key]['pv'] = $pcYanglaojinGongxian['pv'];
141
+            $schedSeatList[$key]['score'] = $pcYanglaojinGongxian['score'];
142
+            $schedSeatList[$key]['gongxian'] = $pcYanglaojinGongxian['gongxian'];
143
+            $schedSeatList[$key]['relation_id'] = $relation_id; // 场次ID
144
+            $schedSeatList[$key]['sched_sign'] = $sched_sign; // 场次编码
145
+        }
146
+
147
+        return $schedSeatList;
125 148
     }
126 149
 
127 150
     /**
128 151
      * 锁座订单
129
-     * @param $sched_sign
130
-     * @param $seat_sign
131
-     * @param $channel_type
132
-     * @param $third_order
133
-     * @param $order_price
134
-     * @param $phone
135
-     * @return mixed|string
152
+     *
153
+     * @param $userinfo
154
+     * @param $params
155
+     * @return mixed
156
+     * @throws \think\db\exception\DataNotFoundException
157
+     * @throws \think\db\exception\DbException
158
+     * @throws \think\db\exception\ModelNotFoundException
136 159
      */
137 160
     public function submitOrder($userinfo, $params)
138 161
     {
@@ -140,49 +163,57 @@ class MovieRepository extends BaseRepository
140 163
         $storeOrder = app()->make(StoreOrderRepository::class);
141 164
         $order_sn = $storeOrder->getNewOrderId() . '0';
142 165
 
143
-        $order_price = round($params['number'] * $params['price'], 2);
144
-        $submitOrder = DouHuoMallFilmApiRequest::submitOrder($userinfo->phone, $params['channel_type'], $params['sched_sign'], $order_sn, $order_price);
145
-        if (!empty($submitOrder) && isset($submitOrder['code']) && ($submitOrder['code'] == 200) && isset($submitOrder['data']['plat_order'])) {
166
+        /** @var CinemaSchedRepository $cinemaSchedRepository */
167
+        $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
168
+        $sched = $cinemaSchedRepository->getCinemaSchedInfo($params['relation_id'], $params['sched_sign']);
169
+        if (empty($sched)) throw new ValidateException('观影场次不存在');
170
+
171
+        $seat_sign = json_decode($params['seat_sign'], true);
172
+        $order_price = round($sched['price'] * count($seat_sign), 2);
173
+        $submitOrder = DouHuoMallFilmApiRequest::submitOrder($userinfo->phone, $params['channel_type'], $params['sched_sign'], $seat_sign, $order_sn, $order_price);
174
+        if (!empty($submitOrder) && isset($submitOrder['code']) && ($submitOrder['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE) && isset($submitOrder['data']['plat_order'])) {
175
+            /** @var CinemaRepository $cinemaRepository */
176
+            $cinemaRepository = app()->make(CinemaRepository::class);
177
+            $cinema = $cinemaRepository->getCinemaInfo($sched['cinema_sign']);
178
+
146 179
             $_order = [
147 180
                 'uid' => $userinfo->uid,
148 181
                 'mobile' => $userinfo->phone,
149 182
                 'order_sn' => $order_sn,
150 183
                 'plat_order' => $submitOrder['data']['plat_order'],
151
-                'price' => $params['price'],
152
-                'number' => $params['number'],
184
+                'price' => $sched['price'],
185
+                'number' => count($seat_sign),
153 186
                 'order_price' => $order_price,
154 187
                 'channel_type' => $params['channel_type'],
155
-                'pay_type' => $params['pay_type'],
156
-                'city_sign' => $params['city_sign'],
157
-                'city_name' => $params['city_name'],
158
-                'area_code' => $params['area_code'],
159
-                'area_name' => $params['area_name'],
160
-                'cinema_sign' => $params['cinema_sign'],
161
-                'cinema_name' => $params['cinema_name'],
162
-                'address' => $params['address'],
163
-                'longitude' => $params['longitude'],
164
-                'latitude' => $params['latitude'],
165
-                'hall_sign' => $params['hall_sign'],
166
-                'hall_name' => $params['hall_name'],
167
-                'relation_id' => $params['relation_id'],
168
-                'sched_sign' => $params['sched_sign'],
169
-                'film_sign' => $params['film_sign'],
170
-                'film_name' => $params['film_name'],
171
-                'show_date' => $params['show_date'],
172
-                'show_time' => $params['show_time'],
173
-                'sched_seat' => $params['sched_seat'],
188
+                'city_sign' => $cinema['city_sign'],
189
+                'city_name' => $cinema['city_name'],
190
+                'area_code' => $cinema['area_sign'],
191
+                'area_name' => $cinema['area_name'],
192
+                'cinema_sign' => $cinema['cinema_sign'],
193
+                'cinema_name' => $cinema['cinema_name'],
194
+                'address' => $cinema['address'],
195
+                'longitude' => $cinema['longitude'],
196
+                'latitude' => $cinema['latitude'],
197
+                'hall_sign' => $sched['hall_sign'],
198
+                'hall_name' => $sched['hall_name'],
199
+                'relation_id' => $sched['relation_id'],
200
+                'sched_sign' => $sched['sched_sign'],
201
+                'film_sign' => $sched['film_sign'],
202
+                'film_name' => $sched['film_name'],
203
+                'show_date' => $sched['show_date'],
204
+                'show_time' => $sched['show_time'],
205
+                'sched_seat' => $sched['sched_seat'],
174 206
                 'create_time' => time()
175 207
             ];
176 208
 
177
-            $group = Db::transaction(function () use ($userinfo, $_order) {
209
+            $order_sn = Db::transaction(function () use ($userinfo, $_order) {
178 210
                 $_order = $this->dao->create($_order);
179
-                if ($_order) return ['code' => ApiResponseService::DEFAULT_SUCCESS_CODE, 'msg' => '下单成功', 'data' => ['order_sn' => $_order['order_sn']]];
180
-
181
-                throw new ValidateException('下单失败');
211
+                if ($_order) return $_order['order_sn'];
212
+                throw new ValidateException('锁座下单失败');
182 213
             });
183
-            return $group;
214
+            return $order_sn;
184 215
         } else {
185
-            return $submitOrder;
216
+            throw new ValidateException('锁座下单失败');
186 217
         }
187 218
     }
188 219
 
@@ -202,7 +233,7 @@ class MovieRepository extends BaseRepository
202 233
 //                return $this->pay(
203 234
 //                    $_order['pay_type'], $userinfo->wechat_user_id, $_order, $_order['film_name'], env('APP_URL') . "/api/hf_notify/movie",
204 235
 //                    'delay');
205
-        return DouHuoMallFilmApiRequest::confirmOrder($third_order, $order_price);
236
+        return DouHuoMallFilmApiRequest::confirmOrder($orderinfo['order_sn'], $orderinfo['order_price']);
206 237
     }
207 238
 
208 239
     /**
@@ -315,4 +346,20 @@ class MovieRepository extends BaseRepository
315 346
 
316 347
         return compact('city_name', 'initial');
317 348
     }
349
+
350
+    /**
351
+     * 获取pv、养老金、售价、积分
352
+     *
353
+     * @param $cost_price
354
+     * @return array
355
+     */
356
+    public static function getPvYanglaojinScore($cost_price)
357
+    {
358
+        $premium = round($cost_price * self::premium_ratio, 2);
359
+        $cost_price = bcadd((string)$cost_price, (string)$premium, 2);
360
+        $pv = $gongxian = $score = bcmul((string)$premium, self::pv_ratio, 2);
361
+        $yanglaojin = bcmul((string)$premium, self::yanglaojin_ratio, 2);
362
+
363
+        return compact('premium', 'cost_price', 'pv', 'yanglaojin', 'gongxian', 'score');
364
+    }
318 365
 }

+ 131 - 35
app/common/repositories/store/order/StoreOrderRepository.php

@@ -1134,14 +1134,7 @@ class StoreOrderRepository extends BaseRepository
1134 1134
                             /** @var UserThirdRepository $orderThird */
1135 1135
                             $orderThird = app()->make(\app\common\repositories\user\UserThirdRepository::class);
1136 1136
                             //预估养老金
1137
-//                            $orderThird->yuguOrder(
1138
-//                                $_order->order_id,
1139
-//                                $commissionMoney,
1140
-//                                $uid,
1141
-//                                $_order->order_sn,
1142
-//                                $type_shop,
1143
-//                                'order_fugou'
1144
-//                            );
1137
+
1145 1138
                             //复购区 - 预估养老金
1146 1139
                             $orderThird->repurchaseAreaEstimateAnnuityOrder(
1147 1140
                                 $_order->order_id,
@@ -7442,9 +7435,13 @@ class StoreOrderRepository extends BaseRepository
7442 7435
                 ->whereIn('status', [0, 1, 2, 3])
7443 7436
                 ->sum('pay_price');
7444 7437
 //            if ($pay_price >= 365) {
7445
-            Db::name('user')->where('uid', $uid)->whereNotIn('user_group', [3, 4, 5, 6])->update([
7446
-                'user_group' => 2
7447
-            ]);
7438
+//            Db::name('user')->where('uid', $uid)->whereNotIn('user_group', [3, 4, 5, 6])->update([
7439
+//                'user_group' => 2
7440
+//            ]);
7441
+            // 设置用户 身份
7442
+            /** @var UserRepository $userRepository */
7443
+            $userRepository = app()->make(UserRepository::class);
7444
+            $userRepository->setUserIdentity($uid);
7448 7445
         }
7449 7446
 
7450 7447
         $shouxufei = systemConfig('online_yanglao');
@@ -7473,9 +7470,12 @@ class StoreOrderRepository extends BaseRepository
7473 7470
         }
7474 7471
 
7475 7472
         if ($product_id == 15323) {
7476
-            Db::name('user')->where('uid', $uid)->whereNotIn('user_group', [3, 4, 5, 6])->update([
7477
-                'user_group' => 4//升級創客
7478
-            ]);
7473
+//            Db::name('user')->where('uid', $uid)->whereNotIn('user_group', [3, 4, 5, 6])->update([
7474
+//                'user_group' => 4//升級創客
7475
+//            ]);
7476
+            /** @var UserRepository $userRepository */
7477
+            $userRepository = app()->make(UserRepository::class);
7478
+            $userRepository->setUserIdentity($uid);
7479 7479
         }
7480 7480
 
7481 7481
         Db::name('store_order')->where('order_id', $order_id)
@@ -9553,7 +9553,7 @@ class StoreOrderRepository extends BaseRepository
9553 9553
 
9554 9554
                 // Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,"contribute"=>$con,"score"=>$score]);
9555 9555
 
9556
-                $this->bill_user_log($user_data['uid'], $ylj_pri, $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . $ylj_pri, $store_order_data['mer_id'], 0);
9556
+                $this->bill_user_log($user_data['uid'], $ylj_pri, $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . $ylj_pri, $store_order_data['mer_id'], 0);
9557 9557
                 // 贡献值
9558 9558
                 $this->con_log($user_data['uid'], $pv, $store_order_data['order_id'], 11, "购买精彩生活商品赠送贡献值");
9559 9559
                 // 积分
@@ -9665,9 +9665,9 @@ class StoreOrderRepository extends BaseRepository
9665 9665
                         //积分
9666 9666
                         $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 11, "精彩生活区商品赠送积分");
9667 9667
                         // //推广佣金
9668
-                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9668
+                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9669 9669
                         //养老金
9670
-                        $this->bill_user_log($spread_data['uid'], round($pv * 0.05, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
9670
+                        $this->bill_user_log($spread_data['uid'], round($pv * 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
9671 9671
                     }
9672 9672
 
9673 9673
                     //普通用户推广人
@@ -9691,7 +9691,7 @@ class StoreOrderRepository extends BaseRepository
9691 9691
 
9692 9692
                         //推广养老金
9693 9693
                         //推广佣金
9694
-                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9694
+                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9695 9695
                         // 贡献值
9696 9696
                         $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值");
9697 9697
                         //积分
@@ -9720,7 +9720,7 @@ class StoreOrderRepository extends BaseRepository
9720 9720
 
9721 9721
                         // Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
9722 9722
                         //推广佣金
9723
-                        $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9723
+                        $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9724 9724
 
9725 9725
                     }
9726 9726
 
@@ -9774,8 +9774,7 @@ class StoreOrderRepository extends BaseRepository
9774 9774
 
9775 9775
             // Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,'contribute'=> $gxz_amount_mine,'score'=> $jf_amount_mine]);
9776 9776
 
9777
-            $this->bill_user_log($user_data['uid'], round($pv * 0.035, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9778
-
9777
+            $this->bill_user_log($user_data['uid'], round($pv * 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9779 9778
             $this->con_log($user_data['uid'], $gx_jf, $store_order_data['order_id'], 11, "购买会员专区商品赠送贡献值", 1);
9780 9779
             $this->score_log($user_data['uid'], $gx_jf, $store_order_data['order_id'], 11, "购买会员专区商品赠送积分", 1);
9781 9780
 
@@ -9890,16 +9889,16 @@ class StoreOrderRepository extends BaseRepository
9890 9889
                     $this->con_log($spread_data['uid'], round($gx_jf, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1);
9891 9890
 
9892 9891
                     //养老金
9893
-                    $this->bill_user_log($spread_data['uid'], round($pv * 0.035, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9892
+                    $this->bill_user_log($spread_data['uid'], round($pv * 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9894 9893
                     //佣金
9895
-                    $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id']);
9894
+                    $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id']);
9896 9895
                     //复购金
9897 9896
                     $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9898 9897
 
9899 9898
                 }
9900 9899
 
9901 9900
                 //普通的用户推广人
9902
-                if ($spread_data['user_group'] == 1) {
9901
+                if ($spread_data['user_group'] == 1) {  
9903 9902
 
9904 9903
                     //获取贡献值和积分和佣金
9905 9904
                     $gx_jf = $spread_data['contribute'] + round($pv * 0.21, 2);
@@ -9914,10 +9913,10 @@ class StoreOrderRepository extends BaseRepository
9914 9913
 
9915 9914
 
9916 9915
                     //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $gx_jf,'score'=> $gx_jf,'brokerage_price'=> $yj_amount,'fugou'=>$fgj_amount]);
9917
-                    $this->con_log($spread_data['uid'], round($pv * 0.21, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1);
9918
-                    $this->score_log($spread_data['uid'], round($pv * 0.21, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9916
+                    $this->con_log($spread_data['uid'], round($pv * 0.3, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1);
9917
+                    $this->score_log($spread_data['uid'], round($pv * 0.3, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9919 9918
                     //推广佣金
9920
-                    $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id']);
9919
+                    $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id']);
9921 9920
                 }
9922 9921
 
9923 9922
 
@@ -9938,9 +9937,9 @@ class StoreOrderRepository extends BaseRepository
9938 9937
 
9939 9938
                 $this->con_log($spread_data['uid'], round($gx_jf, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1);
9940 9939
                 //养老金
9941
-                $this->bill_user_log($spread_data['uid'], round($pv * 0.035, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9940
+                $this->bill_user_log($spread_data['uid'], round($pv * 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9942 9941
                 //佣金
9943
-                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id']);
9942
+                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id']);
9944 9943
                 //复购金
9945 9944
                 $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9946 9945
 
@@ -10009,20 +10008,20 @@ class StoreOrderRepository extends BaseRepository
10009 10008
 
10010 10009
                 $merchant_user_data = Db::name('user')->where('uid', $merchant_data['uid'])->find();
10011 10010
 
10012
-                if (!empty($merchant_user_data)) {
10011
+                if (!empty($merchant_data) && !empty($merchant_user_data)) {
10013 10012
 
10014 10013
 
10015 10014
                     $yj_amount_90 = round($pv * 0.035, 2) * 0.9;
10016 10015
                     $fgj_amount_10 = round($pv * 0.035, 2) * 0.1;//推广者的佣金抽10%到个人复购金
10017 10016
 
10018
-                    $yj_amount = $merchant_data['brokerage_price'] + $yj_amount_90;
10019
-                    $fgj_amount = $merchant_data['fugou'] + $fgj_amount_10;
10017
+                    $yj_amount = $merchant_user_data['brokerage_price'] + $yj_amount_90;
10018
+                    $fgj_amount = $merchant_user_data['fugou'] + $fgj_amount_10;
10020 10019
                     $this->fugou_user_log($merchant_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
10021 10020
 
10022 10021
 
10023 10022
                     // Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
10024 10023
                     //推广佣金
10025
-                    $this->bill_user_log($merchant_data['uid'], round($pv * 0.35, 2), $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . round($pv * 0.35, 2), $store_order_data['mer_id']);
10024
+                    $this->bill_user_log($merchant_data['uid'], round($pv * 0.35, 2), $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得拥金' . round($pv * 0.35, 2), $store_order_data['mer_id']);
10026 10025
                 }
10027 10026
 
10028 10027
             }
@@ -10044,12 +10043,18 @@ class StoreOrderRepository extends BaseRepository
10044 10043
             if ($totalPayPrice >= 1180 && $totalPayPrice < 11800) {
10045 10044
 
10046 10045
                 if ($userdata['user_group'] <= 1) {
10047
-                    Db::name("user")->where("uid", $store_order_data['uid'])->update(["user_group" => 2]);
10046
+//                    Db::name("user")->where("uid", $store_order_data['uid'])->update(["user_group" => 2]);
10047
+                    /** @var UserRepository $userRepository */
10048
+                    $userRepository = app()->make(UserRepository::class);
10049
+                    $userRepository->setUserIdentity($store_order_data['uid']);
10048 10050
                 }
10049 10051
 
10050 10052
             } else if ($totalPayPrice >= 11800) {
10051 10053
                 if ($userdata['user_group'] <= 2) {
10052
-                    Db::name("user")->where("uid", $store_order_data['uid'])->update(["user_group" => 3]);
10054
+//                    Db::name("user")->where("uid", $store_order_data['uid'])->update(["user_group" => 3]);
10055
+                    /** @var UserRepository $userRepository */
10056
+                    $userRepository = app()->make(UserRepository::class);
10057
+                    $userRepository->setUserIdentity($store_order_data['uid']);
10053 10058
                 }
10054 10059
             }
10055 10060
 
@@ -10555,6 +10560,40 @@ class StoreOrderRepository extends BaseRepository
10555 10560
         return compact('hf_member_id', 'hf_platform_member_id', 'api_key');
10556 10561
     }
10557 10562
 
10563
+
10564
+    /**
10565
+     * 获取分账账号信息话费专用
10566
+     *
10567
+     * @param $order
10568
+     * @param $dst_mer_id
10569
+     * @param $alhf_member_id
10570
+     * @return array
10571
+     */
10572
+    public function getIndependentAccountHuafei($order, $dst_mer_id, $alhf_member_id)
10573
+    {
10574
+        if ($order['pay_type'] == 1) {
10575
+            $hf_member_id = Db::name('merchant_member')->where('mer_id', $order['mer_id'])->where("type", 3)->value('member_id');
10576
+            $api_key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
10577
+            $type = 3;
10578
+
10579
+            // 平台特殊账户
10580
+            $hf_platform_member_id = Db::name('merchant_member')->where(['mer_id' => $dst_mer_id, 'type' => $type])->value('member_id');
10581
+        } else {
10582
+            //支付宝
10583
+            $hf_member_id = $alhf_member_id;
10584
+            $api_key = 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9';
10585
+
10586
+            // 平台特殊账户
10587
+            $hf_platform_member_id = Db::name('merchant_member')->where(['mer_id' => $dst_mer_id, 'type' => 1])->value('member_id');
10588
+        }
10589
+
10590
+        return compact('hf_member_id', 'hf_platform_member_id', 'api_key');
10591
+    }
10592
+
10593
+
10594
+
10595
+
10596
+
10558 10597
     /**
10559 10598
      * 预分账处理
10560 10599
      *
@@ -10607,6 +10646,63 @@ class StoreOrderRepository extends BaseRepository
10607 10646
         return false;
10608 10647
     }
10609 10648
 
10649
+
10650
+
10651
+
10652
+    /**
10653
+     * 预分账处理话费专用
10654
+     *
10655
+     * @param $order
10656
+     * @param $api_key
10657
+     * @param $hf_member_id
10658
+     * @param $hf_platform_member_id
10659
+     * @param $merchant_profit
10660
+     * @param $platform_profit
10661
+     * @param $dst_mer_id
10662
+     * @return bool
10663
+     * @throws DbException
10664
+     */
10665
+    public function prepareExecuteIndependentAccountHuafei($order, $group_order, $api_key, $hf_member_id, $hf_platform_member_id, $merchant_profit, $platform_profit, $dst_mer_id = 0)
10666
+    {
10667
+        $members[] = [
10668
+            'member_id' => $hf_member_id,
10669
+            'amount' => $merchant_profit,
10670
+            'fee_flag' => 'Y'
10671
+        ];
10672
+        if (!empty($hf_platform_member_id) && ($platform_profit > 0)) {
10673
+            $members[] = [
10674
+                'member_id' => $hf_platform_member_id,
10675
+                'amount' => $platform_profit,
10676
+                'fee_flag' => 'N'
10677
+            ];
10678
+        }
10679
+
10680
+        $requestId = ShouxinyiApiRequest::getOrderNumber('split');
10681
+        $params = [
10682
+            'payment_id' => $group_order['hf_pay_id'],
10683
+            'order_no' => $requestId,
10684
+            'confirm_amt' => $group_order['pay_price'],
10685
+            'div_members' => $members
10686
+        ];
10687
+
10688
+        $params['api_key'] = $api_key;
10689
+
10690
+        // 记录分账订单
10691
+        $this->recordIndependentAccount($order['mer_id'], $dst_mer_id, $group_order, $requestId, $merchant_profit, $platform_profit);
10692
+
10693
+        Db::name("log")->insert(array('data' => '汇付分账参数-----' . json_encode($params, JSON_FORCE_OBJECT)));//日志记录
10694
+        $res = $this->payment_confirm_create_traits($params);
10695
+        Db::name("log")->insert(array('data' => '汇付分账结果-----' . json_encode($res, JSON_FORCE_OBJECT)));//日志记录
10696
+        if ($res['status'] == 'succeeded') {
10697
+            Db::name("store_split_order")->where('requestId', $requestId)->update(['status' => 1, 'hf_pay_id' => $res['id']]);
10698
+            return true;
10699
+        }
10700
+        return false;
10701
+    }
10702
+
10703
+
10704
+
10705
+
10610 10706
     /**
10611 10707
      * 记录分账订单
10612 10708
      *

+ 45 - 2
app/common/repositories/store/product/ProductReplyRepository.php

@@ -256,8 +256,51 @@ class ProductReplyRepository extends BaseRepository
256 256
 
257 257
     /*用户评价列表*/
258 258
     public function  getReplyList($where=[],$page=1, $limit=10){
259
-        $count =  Db::name("store_product_reply")->where($where)->count();
260
-        $list = Db::name("store_product_reply")->page($page, $limit)->where($where)->select();
259
+        $count = Db::name("store_product_reply")
260
+            ->where($where)
261
+            ->count();
262
+        $list = Db::name("store_product_reply")
263
+            //            ->alias('spr')  // 给主表起个别名
264
+            //            ->join('store_order_product rsop', 'spr.order_product_id = rsop.order_product_id', 'LEFT')  // 左连接
265
+            //            ->field('spr.*, rsop.*')
266
+            ->where($where)
267
+            ->page($page, $limit)
268
+            ->select()
269
+            ->toArray();
270
+
271
+        $order_product_id_list = array_column($list,'order_product_id');
272
+        $order_product_info_list = Db::name("store_order_product")
273
+            ->whereIn('order_product_id',$order_product_id_list)
274
+            ->select()
275
+            ->toArray();
276
+        $order_product_info_map = array_column($order_product_info_list, null, 'order_product_id');
277
+
278
+        $mer_id_list = array_column($list,'mer_id');
279
+        $mer_info_list = Db::name("merchant")
280
+            ->whereIn('mer_id',$mer_id_list)
281
+            ->select()
282
+            ->toArray();
283
+        $mer_info_map = array_column($mer_info_list, null, 'mer_id');
284
+
285
+        foreach ($list as &$item) {
286
+            if (!empty($order_product_info_map[$item['order_product_id']])) {
287
+                if (!empty($order_product_info_map[$item['order_product_id']]['cart_info'])) {
288
+                    $cart_info = json_decode($order_product_info_map[$item['order_product_id']]['cart_info']);
289
+                    if (json_last_error() == JSON_ERROR_NONE) {
290
+                        $order_product_info_map[$item['order_product_id']]['cart_info'] = $cart_info;
291
+                    }
292
+                }
293
+                $item['order_product_info'] = $order_product_info_map[$item['order_product_id']];
294
+            } else {
295
+                $item['order_product_info'] = new \stdClass();
296
+            }
297
+
298
+            if (!empty($mer_info_map[$item['mer_id']])) {
299
+                $item['mer_info'] = $mer_info_map[$item['mer_id']];
300
+            } else {
301
+                $item['mer_info'] = new \stdClass();
302
+            }
303
+        }
261 304
         return compact('count', 'list');
262 305
     }
263 306
 }

+ 39 - 33
app/common/repositories/store/product/ProductRepository.php

@@ -381,6 +381,12 @@ class ProductRepository extends BaseRepository
381 381
         $pric = $stock = $ot_price = $cost = $dc_price = $concession_pri = 0;
382 382
         if (isset($data['attrValue']) && is_array($data['attrValue'])) {
383 383
             foreach ($data['attrValue'] as $value) {
384
+
385
+                $value['cost'] = bcsub($value['price'], bcmul($value['price'], $value['extension_one'] / 100, 2), 2);
386
+                $value['gong_mer_profit'] = bcmul($value['price'], $value['extension_one'] / 100, 2);
387
+                $value['gong_market_price'] = bcadd($value['cost'], $value['gong_mer_profit'], 2);
388
+                $value['plate_mer_profit'] = $value['gong_mer_profit'];
389
+
384 390
                 $sku = '';
385 391
                 if (isset($value['detail']) && is_array($value['detail'])) {
386 392
                     $sku = implode(',', $value['detail']);
@@ -1019,7 +1025,7 @@ class ProductRepository extends BaseRepository
1019 1025
                 $s = 8000;
1020 1026
             }
1021 1027
 
1022
-            $res['yanglao'] = round($s * 0.035,2);
1028
+            $res['yanglao'] = bcmul($s, 0.035, 2);  
1023 1029
         }
1024 1030
 
1025 1031
 
@@ -1695,8 +1701,8 @@ class ProductRepository extends BaseRepository
1695 1701
 
1696 1702
             if($product['mer_id'] == 496){
1697 1703
 
1698
-                $yanglao = round($num_yl * 0.035, 2);
1699
-                $pv=$num_yl *0.7;
1704
+                $yanglao = bcmul($num_yl, 0.035, 2);
1705
+                $pv = bcmul($num_yl, 0.7, 2);
1700 1706
                 //$v['vr']=$v['price'];
1701 1707
                 //1:为会员专区,
1702 1708
 
@@ -1709,24 +1715,24 @@ class ProductRepository extends BaseRepository
1709 1715
 
1710 1716
             }else if($product['mer_id'] == 439){
1711 1717
                 //精彩生活和商贸区
1712
-                $jf = $product['price'] - round($product['concession_pri']*0.3, 2) . ' + ' . round($product['concession_pri']*0.3, 2);
1713
-                $jd = $product['price'] - round($product['concession_pri']*0.35, 2) . ' + ' . round($product['concession_pri']*0.35, 2);
1718
+                $jf = $product['price'] - bcmul($product['concession_pri'], 0.3, 2) . ' + ' . bcmul($product['concession_pri'],0.3, 2);
1719
+                $jd = $product['price'] - bcmul($product['concession_pri'], 0.35, 2) . ' + ' . bcmul($product['concession_pri'],0.35, 2);
1714 1720
                 if($product['concession_pri'] !=null || $product['concession_pri'] !=0){
1715
-                    $yanglao = round($product['concession_pri'] * 0.3, 2);
1716
-                    $pv = round($product['concession_pri'] * 0.35, 2);
1721
+                    $yanglao = bcmul($product['concession_pri'], 0.3, 2);
1722
+                    $pv = bcmul($product['concession_pri'], 0.35, 2);
1717 1723
                     $srtArry['jfduihuan'] =$jf;
1718 1724
                     $srtArry['jdduihuan'] = $jd;
1719
-                    $jifen = round($product['concession_pri'] * 0.35, 2);
1720
-                    $gongxian = round($product['concession_pri'] * 0.35, 2);
1725
+                    $jifen = bcmul($product['concession_pri'], 0.35, 2);
1726
+                    $gongxian = bcmul($product['concession_pri'], 0.35, 2);
1721 1727
 
1722
-                    $jcvr = $product['price'] - round($product['concession_pri']*0.3, 2);
1723
-                    $jcjf = round($product['concession_pri']*0.3, 2);
1724
-                    $jcprice = $product['price'] - round($product['concession_pri']*0.3, 2);
1725
-                    $jcjf1 = round($product['concession_pri']*0.3, 2);
1726
-                    $jcvr1 = $product['price'] - round($product['concession_pri']*0.35, 2);
1727
-                    $jcjd = round($product['concession_pri']*0.35, 2);
1728
-                    $jcprice1 = $product['price'] - round($product['concession_pri']*0.35, 2);
1729
-                    $jcjd1 = round($product['concession_pri']*0.35, 2);
1728
+                    $jcvr = $product['price'] - bcmul($product['concession_pri'], 0.3, 2);
1729
+                    $jcjf = bcmul($product['concession_pri'], 0.3, 2);
1730
+                    $jcprice = $product['price'] - bcmul($product['concession_pri'], 0.3, 2);
1731
+                    $jcjf1 = bcmul($product['concession_pri'], 0.3, 2);
1732
+                    $jcvr1 = $product['price'] - bcmul($product['concession_pri'], 0.35, 2);
1733
+                    $jcjd = bcmul($product['concession_pri'], 0.35, 2);
1734
+                    $jcprice1 = $product['price'] - bcmul($product['concession_pri'], 0.35, 2);
1735
+                    $jcjd1 = bcmul($product['concession_pri'], 0.35, 2);
1730 1736
 
1731 1737
 
1732 1738
                     //支付组合
@@ -1758,7 +1764,7 @@ class ProductRepository extends BaseRepository
1758 1764
                 // 获取商品sku
1759 1765
                 $productSku = Db::name('store_product_attr_value')->where('product_id', $good_id)->order('price asc')->find();
1760 1766
                 $pv = $productSku['plate_mer_profit']??0.00;
1761
-                $yanglao = round($pv * 0.5, 2);
1767
+                $yanglao = bcmul($pv, 0.5, 2);
1762 1768
                 //$v['vr']=$v['price'];
1763 1769
                 //1:为会员专区,
1764 1770
 
@@ -1777,24 +1783,24 @@ class ProductRepository extends BaseRepository
1777 1783
                 // 1企业2个体3个人
1778 1784
                 if ($merchantInfo && in_array($merchantInfo['type'],[2,3])) {
1779 1785
                     //商贸区
1780
-                    $jf = $product['price'] - round($product['concession_pri']*0.3, 2) . ' + ' . round($product['concession_pri']*0.3, 2);
1781
-                    $jd = $product['price'] - round($product['concession_pri']*0.35, 2) . ' + ' . round($product['concession_pri']*0.35, 2);
1786
+                    $jf = $product['price'] - bcmul($product['concession_pri'],0.3, 2) . ' + ' . bcmul($product['concession_pri'],0.3, 2);
1787
+                    $jd = $product['price'] - bcmul($product['concession_pri'],0.35, 2) . ' + ' . bcmul($product['concession_pri'],0.35, 2);
1782 1788
                     if($product['concession_pri'] !=null || $product['concession_pri'] !=0){
1783
-                        $yanglao = round($product['concession_pri'] * 0.3, 2);
1784
-                        $pv = round($product['concession_pri'] * 0.35, 2);
1789
+                        $yanglao = bcmul($product['concession_pri'], 0.3, 2);
1790
+                        $pv = bcmul($product['concession_pri'], 0.35, 2);
1785 1791
                         $srtArry['jfduihuan'] =$jf;
1786 1792
                         $srtArry['jdduihuan'] = $jd;
1787
-                        $jifen = round($product['concession_pri'] * 0.35, 2);
1788
-                        $gongxian = round($product['concession_pri'] * 0.35, 2);
1789
-
1790
-                        $jcvr = $product['price'] - round($product['concession_pri']*0.3, 2);
1791
-                        $jcjf = round($product['concession_pri']*0.3, 2);
1792
-                        $jcprice = $product['price'] - round($product['concession_pri']*0.3, 2);
1793
-                        $jcjf1 = round($product['concession_pri']*0.3, 2);
1794
-                        $jcvr1 = $product['price'] - round($product['concession_pri']*0.35, 2);
1795
-                        $jcjd = round($product['concession_pri']*0.35, 2);
1796
-                        $jcprice1 = $product['price'] - round($product['concession_pri']*0.35, 2);
1797
-                        $jcjd1 = round($product['concession_pri']*0.35, 2);
1793
+                        $jifen = bcmul($product['concession_pri'], 0.35, 2);
1794
+                        $gongxian = bcmul($product['concession_pri'], 0.35, 2);
1795
+
1796
+                        $jcvr = $product['price'] - bcmul($product['concession_pri'], 0.3, 2);
1797
+                        $jcjf = bcmul($product['concession_pri'], 0.3, 2);
1798
+                        $jcprice = $product['price'] - bcmul($product['concession_pri'], 0.3, 2);
1799
+                        $jcjf1 = bcmul($product['concession_pri'], 0.3, 2);
1800
+                        $jcvr1 = $product['price'] - bcmul($product['concession_pri'], 0.35, 2);
1801
+                        $jcjd = bcmul($product['concession_pri'], 0.35, 2);
1802
+                        $jcprice1 = $product['price'] - bcmul($product['concession_pri'], 0.35, 2);
1803
+                        $jcjd1 = bcmul($product['concession_pri'], 0.35, 2);
1798 1804
 
1799 1805
                         $fzone_paytype= [
1800 1806
 //                ['type'=>'b1','price'=>$jcvr,'other'=>$jcjf],

+ 9 - 9
app/common/repositories/system/merchant/MerchantRepository.php

@@ -455,8 +455,8 @@ class MerchantRepository extends BaseRepository
455 455
 
456 456
             if($merId == 496){
457 457
 
458
-                $v['yanglao'] = round($num_yl * 0.035, 2);
459
-                $v['pv']=$num_yl *0.7;
458
+                $v['yanglao'] = bcmul($num_yl, 0.035, 2);
459
+                $v['pv'] = bcmul($num_yl, 0.7, 2);
460 460
                 //$v['vr']=$v['price'];
461 461
                 //1:为会员专区,
462 462
 
@@ -469,15 +469,15 @@ class MerchantRepository extends BaseRepository
469 469
 
470 470
             }else if($merId == 439 || $is_commercetrade){
471 471
                 //精彩生活和商贸区
472
-                $jf = $v['price'] - round($v['concession_pri']*0.3, 2) . ' + ' . round($v['concession_pri']*0.3, 2);
473
-                $jd = $v['price'] - round($v['concession_pri']*0.35, 2) . ' + ' . round($v['concession_pri']*0.35, 2);
472
+                $jf = $v['price'] - bcmul($v['concession_pri'],0.3, 2) . ' + ' . bcmul($v['concession_pri'],0.3, 2);
473
+                $jd = $v['price'] - bcmul($v['concession_pri'],0.35, 2) . ' + ' . bcmul($v['concession_pri'],0.35, 2);
474 474
                 if($v['concession_pri'] !=null || $v['concession_pri'] !=0){
475
-                    $v['yanglao'] = round($v['concession_pri'] * 0.3, 2);
476
-                    $v['pv'] = round($v['concession_pri'] * 0.35, 2);
475
+                    $v['yanglao'] = bcmul($v['concession_pri'],0.3, 2);
476
+                    $v['pv'] = bcmul($v['concession_pri'],0.35, 2);
477 477
                     $v['jfduihuan'] =$jf;
478 478
                     $v['jdduihuan'] = $jd;
479
-                    $v['jifen'] = round($v['concession_pri'] * 0.35, 2);
480
-                    $v['gongxian'] = round($v['concession_pri'] * 0.35, 2);
479
+                    $v['jifen'] = bcmul($v['concession_pri'], 0.35, 2);
480
+                    $v['gongxian'] = bcmul($v['concession_pri'], 0.35, 2);
481 481
                 }
482 482
             }else if($merId == 491){
483 483
                 // 获取商品sku
@@ -486,7 +486,7 @@ class MerchantRepository extends BaseRepository
486 486
 
487 487
 //                $num_yl = $v['price'];
488 488
 //                $pv= $num_yl * 0.3;
489
-                $yanglao = round($pv * 0.5, 2);
489
+                $yanglao = bcmul($pv, 0.5, 2);
490 490
                 $v['pv'] = $pv;
491 491
                 $v['yanglao'] = $yanglao;
492 492
 

+ 110 - 0
app/common/repositories/user/UserIdentityRepository.php

@@ -0,0 +1,110 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\repositories\user;
12
+
13
+
14
+use app\common\dao\user\UserIdentityDao;
15
+use app\common\repositories\BaseRepository;
16
+use FormBuilder\Exception\FormBuilderException;
17
+use FormBuilder\Factory\Elm;
18
+use FormBuilder\Form;
19
+use think\db\exception\DataNotFoundException;
20
+use think\db\exception\DbException;
21
+use think\db\exception\ModelNotFoundException;
22
+use think\facade\Route;
23
+
24
+/**
25
+ * Class UserIdentityRepository
26
+ * @package app\common\repositories\user
27
+ * @author xaboy
28
+ * @day 2020-05-07
29
+ * @mixin UserIdentityDao
30
+ */
31
+class UserIdentityRepository extends BaseRepository
32
+{
33
+    /**
34
+     * @var UserIdentityDao
35
+     */
36
+    protected $dao;
37
+
38
+    /**
39
+     * UserGroupRepository constructor.
40
+     * @param UserIdentityDao $dao
41
+     */
42
+    public function __construct(UserIdentityDao $dao)
43
+    {
44
+        $this->dao = $dao;
45
+    }
46
+
47
+    /**
48
+     * @param array $where
49
+     * @param $page
50
+     * @param $limit
51
+     * @return array
52
+     * @throws DataNotFoundException
53
+     * @throws DbException
54
+     * @throws ModelNotFoundException
55
+     * @author xaboy
56
+     * @day 2020-05-07
57
+     */
58
+    public function getList(array $where, $page, $limit)
59
+    {
60
+        $query = $this->dao->search($where);
61
+        $count = $query->count($this->dao->getPk());
62
+        $list = $query->page($page, $limit)->select();
63
+        return compact('count', 'list');
64
+    }
65
+
66
+    /**
67
+     * @param null $id
68
+     * @param array $formData
69
+     * @return Form
70
+     * @throws FormBuilderException
71
+     * @author xaboy
72
+     * @day 2020-05-07
73
+     */
74
+    public function form($id = null, array $formData = [])
75
+    {
76
+        $action = Route::buildUrl('configIdentityUpdate' , compact('id'))->build();
77
+        return Elm::createForm($action, [
78
+            Elm::number('arrive_num_own', '个人达标贡献值')->min(0)->size('large'),
79
+            Elm::number('arrive_num_team', '团队达标贡献值')->min(0)->size('large')
80
+        ])->setTitle('业务员升级设置')->formData($formData);
81
+    }
82
+
83
+    /**
84
+     * @param $id
85
+     * @return Form
86
+     * @throws FormBuilderException
87
+     * @throws DataNotFoundException
88
+     * @throws DbException
89
+     * @throws ModelNotFoundException
90
+     * @author xaboy
91
+     * @day 2020-05-07
92
+     */
93
+    public function updateForm($id)
94
+    {
95
+        return $this->form($id, $this->dao->get($id)->toArray());
96
+    }
97
+
98
+    /**
99
+     * @param array $where
100
+     * @return array
101
+     * @throws DataNotFoundException
102
+     * @throws DbException
103
+     * @throws ModelNotFoundException
104
+     */
105
+    public function getIdentityList(array $where = [])
106
+    {
107
+        $query = $this->dao->search($where);
108
+        return $query->select()->toArray();
109
+    }
110
+}

+ 8 - 2
app/common/repositories/user/UserOfflineRechargeRepository.php

@@ -171,8 +171,14 @@ class UserOfflineRechargeRepository extends BaseRepository
171 171
                     // //同步复购金
172 172
                     // Db::name("user_sign_fugou")->where('order_id', $order->id)->update(['uid' => $unionUser->uid]);
173 173
                     
174
-                    // //同步贡献值
175
-                    // Db::name("user_sign_gongxian")->where('order_id', $order->id)->update(['uid' => $unionUser->uid]);
174
+                    //同步贡献值
175
+                    $gongxian = Db::name('user_sign_gongxian')->where('order_id', $order->id)->find();
176
+                    if($gongxian){
177
+                        Db::name("user_sign_gongxian")->where('order_id', $order->id)->update(['uid' => $unionUser->uid]);
178
+                        $user_contribute = Db::name('user')->where('order_id', $order->id)->where('uid', $unionUser->uid)->value('contribute');
179
+                        $user_contribute = bcadd($user_contribute, $gongxian['number'], 2);
180
+                        Db::name('user')->where('uid', $unionUser->uid)->update(['contribute'=>$user_contribute]);
181
+                    }
176 182
 
177 183
 
178 184
 

+ 203 - 2
app/common/repositories/user/UserRepository.php

@@ -2881,7 +2881,6 @@ class UserRepository extends BaseRepository
2881 2881
         }
2882 2882
         $paramStr =  $paramStr.'sign='.urlencode($sign);
2883 2883
         return $paramStr;
2884
-
2885 2884
     }
2886 2885
 
2887 2886
     /*
@@ -3013,7 +3012,7 @@ class UserRepository extends BaseRepository
3013 3012
             $request->setGrantType("authorization_code");
3014 3013
             $request->setCode($authorization_code);
3015 3014
             $result = $aop->execute($request);
3016
-
3015
+            Db::name('log')->insert(['data'=>'支付宝相关信息']);
3017 3016
             if (isset($result->alipay_system_oauth_token_response->user_id)) {
3018 3017
                 $return['user_id'] = $result->alipay_system_oauth_token_response->user_id;
3019 3018
                 $return['msg'] = $result->alipay_system_oauth_token_response->access_token;
@@ -3226,4 +3225,206 @@ class UserRepository extends BaseRepository
3226 3225
         $resultArray = array_diff($originalArray, [$uid]);
3227 3226
         return $resultArray;
3228 3227
     }
3228
+
3229
+
3230
+    /**
3231
+     * 设置用户 身份
3232
+     * @param $uid
3233
+     * @param $identityId
3234
+     * @return int|mixed|null
3235
+     * @throws DbException
3236
+     */
3237
+    public function setUserIdentity($uid, $identityId = null)
3238
+    {
3239
+        $result = null;
3240
+        if (empty($identityId)) {
3241
+            $identityId = $this->getUserIdentity($uid);
3242
+        }
3243
+        $this->dao->update($uid, ['user_group' => $identityId]);
3244
+        return $identityId;
3245
+    }
3246
+
3247
+    /**
3248
+     * 获取用户 身份
3249
+     * @param $uid
3250
+     * @return int|mixed
3251
+     * @throws DataNotFoundException
3252
+     * @throws DbException
3253
+     * @throws ModelNotFoundException
3254
+     */
3255
+    public function getUserIdentity($uid)
3256
+    {
3257
+        // 1、获取所有等级信息
3258
+        /** @var UserIdentityRepository $identityRepository */
3259
+        $identityRepository = app()->make(UserIdentityRepository::class);
3260
+        $identityList = $identityRepository->getIdentityList();
3261
+
3262
+        // 2、获取身份需要的最深等级
3263
+        $lowerLevelNumList = array_column($identityList, 'lower_level_num');
3264
+        $lowerLevelNumMax = max($lowerLevelNumList);
3265
+        $lowerLevelNumMin = min($lowerLevelNumList);
3266
+        $needLower = $lowerLevelNumMax;
3267
+        if($lowerLevelNumMin == 0) {
3268
+            $needLower = $lowerLevelNumMin;
3269
+        }
3270
+
3271
+        // 3、获取下级用户 贡献值
3272
+        $userContributionSumMap = [];
3273
+        $uidContributeList = $this->getUidContributeListBySpreadUidList([$uid]);
3274
+        foreach ($uidContributeList as $uidContribute) {
3275
+            $userContributionSumMap[$uidContribute['uid']] = $this->getContributionSumByLevel([$uidContribute['uid']], $needLower);
3276
+            $userContributionSumMap[$uidContribute['uid']][0] = $uidContribute['contribute'];
3277
+        }
3278
+
3279
+        // 4、获取个人贡献值
3280
+        $userData = $this->dao->get($uid)->toArray();
3281
+
3282
+        // 5、当前用户等级
3283
+        $identityId = 0;
3284
+        usort($identityList, function ($a, $b) {
3285
+            return $b['user_group_id'] <=> $a['user_group_id'];  // 反转顺序,倒序排列
3286
+        });
3287
+        foreach ($identityList as $item) {
3288
+            $lowerLevelNum = $item['lower_level_num']??0;
3289
+
3290
+            $arriveNumOwn = $userData['contribute'];
3291
+            $arriveNumTeam = 0;
3292
+            $subordinateContribution = [];
3293
+
3294
+            foreach ($userContributionSumMap as $key => $value) {
3295
+                $subordinateContribution[$key] = 0;
3296
+                if ($lowerLevelNum != 0) {
3297
+                    foreach ($value as $k => $v) {
3298
+                        if ($k <= $lowerLevelNum) {
3299
+                            $subordinateContribution[$key] += $v;
3300
+                        } else {
3301
+                            break;
3302
+                        }
3303
+                    }
3304
+                } else {
3305
+                    $subordinateContribution[$key] = array_sum($value);
3306
+                }
3307
+            }
3308
+            if (!empty($subordinateContribution)) {
3309
+                // 大区业绩
3310
+                $dqYj = max($subordinateContribution);
3311
+                // 总业绩
3312
+                $zYj = array_sum($subordinateContribution);
3313
+                // 小区团体业绩
3314
+                $arriveNumTeam = bcsub($zYj, $dqYj, 2);
3315
+            }
3316
+            if ($item['arrive_num_own'] <= $arriveNumOwn && $item['arrive_num_team'] <= $arriveNumTeam) {
3317
+                $identityId = $item['user_group_id'];
3318
+                break;
3319
+            }
3320
+        }
3321
+        return $identityId;
3322
+    }
3323
+
3324
+    /**
3325
+     * 获取该会员的所有下级会员
3326
+     */
3327
+    public function getUidContributeListBySpreadUidList(array $uidList)
3328
+    {
3329
+        return Db::name("user")
3330
+            ->whereIn("spread_uid", $uidList)
3331
+            ->field("uid, contribute, spread_uid")
3332
+            ->select()
3333
+            ->toArray();
3334
+    }
3335
+
3336
+    /**
3337
+     * 计算指定用户下属每一层级的总贡献值。
3338
+     *
3339
+     * @param array $initialUserIds 初始用户ID列表 (视为第0层)。
3340
+     * @param int $maxDepth 需要查询的最大深度(相对于初始列表)。
3341
+     *                      0 表示查询所有层级直到末端。
3342
+     *                      1 表示只计算第1层(直接下级)的总贡献。
3343
+     *                      N 表示计算到第 N 层(包含第N层)的总贡献。
3344
+     * @return array 返回一个数组,键是层级号(从1开始),值是该层级所有用户的贡献值总和。
3345
+     *               例如:[ 1 => 600, 2 => 1300 ]
3346
+     */
3347
+    public function getContributionSumByLevel(array $initialUserIds, int $maxDepth = 0): array
3348
+    {
3349
+        $levelContributions = []; // 结果数组 [level => total_contribution]
3350
+        if (empty($initialUserIds)) {
3351
+            return $levelContributions;
3352
+        }
3353
+
3354
+        $currentLevelIds = $initialUserIds; // 当前层级的用户ID (初始为第0层)
3355
+        $currentLevel = 0; // 当前层级号
3356
+
3357
+        // 使用一个集合跟踪所有已处理过的下级用户ID,防止重复计算和循环
3358
+        $processedSubordinateIds = [];
3359
+
3360
+        while (!empty($currentLevelIds)) {
3361
+            // 计算下一层级的编号
3362
+            $nextLevel = $currentLevel + 1;
3363
+
3364
+            // 检查是否达到最大深度限制
3365
+            if ($maxDepth > 0 && $nextLevel > $maxDepth) {
3366
+                break; // 停止查询更深的层级
3367
+            }
3368
+
3369
+            // 批量查询当前层级用户的直接下级
3370
+            // 使用 array_chunk 防止 WHERE IN 子句过长 (根据数据库限制调整 chunkSize)
3371
+            $chunkSize = 500;
3372
+            $subordinatesOfCurrentLevel = [];
3373
+            foreach(array_chunk($currentLevelIds, $chunkSize) as $chunk) {
3374
+                $subordinatesChunk = Db::name('user')
3375
+                    ->field('uid, contribute') // 只需要下级的uid和贡献值
3376
+                    ->whereIn('spread_uid', $chunk) // spread_uid 在当前层级用户块中
3377
+                    ->select()
3378
+                    ->toArray();
3379
+                $subordinatesOfCurrentLevel = array_merge($subordinatesOfCurrentLevel, $subordinatesChunk);
3380
+            }
3381
+
3382
+            // 如果没有找到任何下级,结束循环
3383
+            if (empty($subordinatesOfCurrentLevel)) {
3384
+                break;
3385
+            }
3386
+
3387
+            $nextLevelTotalContribution = 0;
3388
+            $nextLevelIds = []; // 存储下一轮需要查询的用户ID
3389
+
3390
+            // 遍历找到的所有下级
3391
+            foreach ($subordinatesOfCurrentLevel as $subordinate) {
3392
+                $subordinateId = $subordinate['uid'];
3393
+                $subordinateContribution = $subordinate['contribute'] ?? 0; // 安全获取,默认为0
3394
+
3395
+                // 累加下一层级的总贡献值
3396
+                // 注意:这里简单累加,如果一个下级同时被当前层多个用户推荐,其贡献会被计算多次
3397
+                // 如果要求每个下级只贡献一次(即使有多个上级),需要调整逻辑,
3398
+                // 例如在累加前检查 $processedSubordinateIds
3399
+
3400
+                // --- 修改点:确保每个下级贡献只被计算一次 ---
3401
+                // if (!isset($processedSubordinateIds[$subordinateId])) { // 如果这个下级还没被处理过
3402
+                $nextLevelTotalContribution += (float)$subordinateContribution;
3403
+                // }
3404
+                // 注释掉上面的检查,因为用户描述似乎是按层级直接累加,不管这个下级是否被上层处理过。
3405
+                // 如果A1和A2都属于第1层,他们各自的下级B1和B2都属于第2层,B1和B2的贡献值直接加到第2层的总和里。
3406
+                // 如果需要严格按“人”计算,即使一个人出现在多层或被多人推荐也只算一次,则需要解开注释并调整
3407
+
3408
+                // 收集下一轮需要查询的用户ID,同样需要防止重复处理
3409
+                if (!isset($processedSubordinateIds[$subordinateId])) {
3410
+                    $nextLevelIds[] = $subordinateId;
3411
+                    // 标记这个下级ID已处理过,避免在更深层级中再次将其加入查询队列
3412
+                    $processedSubordinateIds[$subordinateId] = true;
3413
+                }
3414
+
3415
+            }
3416
+
3417
+            // 存储下一层级的总贡献值 (只有当贡献值大于0或你想记录空层级时)
3418
+            // 根据例子,我们只记录有贡献的层级,或者至少有用户的层级
3419
+            if (!empty($subordinatesOfCurrentLevel)) { // 只要找到了下级就记录该层
3420
+                $levelContributions[$nextLevel] = $nextLevelTotalContribution;
3421
+            }
3422
+
3423
+            // 准备下一轮迭代
3424
+            $currentLevelIds = array_unique($nextLevelIds); // 去重下一层的用户ID
3425
+            $currentLevel = $nextLevel; // 更新当前层级
3426
+        }
3427
+
3428
+        return $levelContributions;
3429
+    }
3229 3430
 }

+ 94 - 0
app/controller/admin/system/config/Identity.php

@@ -0,0 +1,94 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-03-24
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\controller\admin\system\config;
12
+
13
+
14
+use crmeb\basic\BaseController;
15
+use app\common\repositories\user\UserIdentityRepository;
16
+use FormBuilder\Exception\FormBuilderException;
17
+use think\App;
18
+use think\db\exception\DataNotFoundException;
19
+use think\db\exception\DbException;
20
+use think\db\exception\ModelNotFoundException;
21
+
22
+/**
23
+ * Class Config
24
+ * @package app\controller\admin\system\config
25
+ * @author xaboy
26
+ * @day 2020-03-27
27
+ */
28
+class Identity extends BaseController
29
+{
30
+    /**
31
+     * @var UserIdentityRepository
32
+     */
33
+    protected $repository;
34
+
35
+    /**
36
+     * Config constructor.
37
+     * @param App $app
38
+     * @param UserIdentityRepository $repository
39
+     */
40
+    public function __construct(App $app, UserIdentityRepository $repository)
41
+    {
42
+        parent::__construct($app);
43
+        $this->repository = $repository;
44
+    }
45
+
46
+    /**
47
+     * @return mixed
48
+     * @throws DataNotFoundException
49
+     * @throws DbException
50
+     * @throws ModelNotFoundException
51
+     * @author xaboy
52
+     * @day 2020-03-31
53
+     */
54
+    public function lst()
55
+    {
56
+        $where = $this->request->params(['keyword']);
57
+        [$page, $limit] = $this->getPage();
58
+        $lst = $this->repository->getList($where, $page, $limit);
59
+
60
+        return app('json')->success($lst);
61
+    }
62
+
63
+    /**
64
+     * @param int $id
65
+     * @return mixed
66
+     * @throws DataNotFoundException
67
+     * @throws DbException
68
+     * @throws ModelNotFoundException
69
+     * @throws FormBuilderException
70
+     * @author xaboy
71
+     * @day 2020-03-31
72
+     */
73
+    public function updateTable($id)
74
+    {
75
+        if (!$this->repository->exists($id)) app('json')->fail('数据不存在');
76
+        $form = $this->repository->updateForm($id);
77
+        return app('json')->success(formToData($form));
78
+    }
79
+
80
+    /**
81
+     * @param int $id
82
+     * @return mixed
83
+     * @throws DbException
84
+     * @author xaboy
85
+     * @day 2020-03-27
86
+     */
87
+    public function update($id)
88
+    {
89
+        $data = $this->request->params(['arrive_num_own', 'arrive_num_team']);
90
+        $this->repository->update($id, $data);
91
+        return app('json')->success('修改成功');
92
+    }
93
+
94
+}

+ 6 - 5
app/controller/api/Auth.php

@@ -1899,11 +1899,12 @@ class Auth extends BaseController
1899 1899
             if(empty($sessionKey['sessionKey'])||empty($encryptedData['encryptedData'])||empty($iv['iv'])){
1900 1900
                 return app('json')->fail('参数不正确');
1901 1901
             }
1902
-            $appid = 'wx82986c4471ce7efc';
1903
-            if($this->source=='yhc'){
1904
-                $appid = 'wx82986c4471ce7efc';
1905
-            }
1906
-            $appid = 'wx7b4d857deb0447f3';
1902
+//            $appid = 'wx82986c4471ce7efc';
1903
+//            if($this->source=='yhc'){
1904
+//                $appid = 'wx82986c4471ce7efc';
1905
+//            }
1906
+//            $appid = 'wx7b4d857deb0447f3';
1907
+            $appid = 'wx9082e5ac2fdb513f';
1907 1908
             $sessionKey =str_replace(' ','+', $sessionKey['sessionKey']);
1908 1909
 
1909 1910
             $encryptedData=str_replace(' ','+',$encryptedData['encryptedData']);

+ 37 - 21
app/controller/api/Notify.php

@@ -3,6 +3,7 @@ namespace app\controller\api;
3 3
 
4 4
 use AdaPaySdk\AdapayTools;
5 5
 use app\common\repositories\store\order\StoreRefundOrderRepository;
6
+use app\common\repositories\user\UserRepository;
6 7
 use app\controller\api\merchant\sxy\Access;
7 8
 use app\controller\api\store\service\Huafei;
8 9
 use think\facade\Db;
@@ -178,7 +179,7 @@ class Notify
178 179
 
179 180
                                     //Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,"contribute"=>$con,"score"=>$score]);
180 181
 
181
-                                    $this->bill_user_log($user_data['uid'],$ylj_pri,$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.$ylj_pri,$store_order_data['mer_id'],0);
182
+                                    $this->bill_user_log($user_data['uid'],$ylj_pri,$store_order_data['order_id'],5,$store_order_data['order_sn'],'消费获得养老金'.$ylj_pri,$store_order_data['mer_id'],0);
182 183
                                     $this->con_log($user_data['uid'],$pv,$store_order_data['order_id'],11,"购买精彩生活商品赠送贡献值");
183 184
                                     $this->score_log($user_data['uid'],$pv,$store_order_data['order_id'],11,"购买精彩生活商品赠送积分");
184 185
 
@@ -291,17 +292,19 @@ class Notify
291 292
                                             //积分
292 293
                                             $this->score_log($spread_data['uid'],$ssf,$store_order_data['order_id'],11,"精彩生活区商品赠送积分");
293 294
                                             // //推广佣金
294
-                                            $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id'],0);
295
+                                            $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id'],0);
295 296
                                             //养老金
296
-                                            $this->bill_user_log($spread_data['uid'],round($pv * 0.05,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.05,2),$store_order_data['mer_id'],0);
297
+                                            $this->bill_user_log($spread_data['uid'],round($pv * 0.05,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'推广获得养老金'.round($pv * 0.05,2),$store_order_data['mer_id'],0);
297 298
                                         }
298 299
 
299 300
                                         //普通用户推广人
300 301
                                         if($spread_data['user_group'] == 1){
301 302
                                             //给推广者分配佣金
302 303
                                             // $ylj_amount = $spread_data['annuity'] + round($pv * 0.3,2);
303
-                                            $yj_amount_90 = round($pv * 0.21,2) * 0.9;
304
-                                            $fgj_amount_10 = round($pv * 0.21,2) * 0.1;//推广者的佣金抽10%到个人复购金
304
+                                            // $yj_amount_90 = round($pv * 0.21,2) * 0.9;
305
+                                            $yj_amount_90 = round($pv * 0.3,2) * 0.9;
306
+                                            // $fgj_amount_10 = round($pv * 0.21,2) * 0.1;//推广者的佣金抽10%到个人复购金
307
+                                            $fgj_amount_10 = round($pv * 0.3,2) * 0.1;//推广者的佣金抽10%到个人复购金
305 308
 
306 309
                                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
307 310
                                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -309,8 +312,10 @@ class Notify
309 312
 
310 313
                                             //Db::name('user')->where('uid',$spread_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
311 314
 
312
-                                            $con = $spread_data['contribute'] + round($pv * 0.21,2);
313
-                                            $score = $spread_data['score'] + round($pv * 0.21,2);
315
+                                            // $con = $spread_data['contribute'] + round($pv * 0.21,2);
316
+                                            $con = $spread_data['contribute'] + round($pv * 0.3,2);
317
+                                            // $score = $spread_data['score'] + round($pv * 0.21,2);
318
+                                            $score = $spread_data['score'] + round($pv * 0.3,2);
314 319
 
315 320
                                             //贡献值和积分
316 321
                                             //Db::name('user')->where('uid',$spread_data['uid'])->update(["contribute"=>$con,"score"=>$score]);
@@ -318,9 +323,11 @@ class Notify
318 323
                                             //推广养老金
319 324
 
320 325
                                             //推广佣金
321
-                                            $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id'],0);
322
-                                            $this->con_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送贡献值");
323
-                                            $this->score_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送积分");
326
+                                            $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id'],0);
327
+                                            // $this->con_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送贡献值");
328
+                                            $this->con_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送贡献值");
329
+                                            // $this->score_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送积分");
330
+                                            $this->score_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送积分");
324 331
 
325 332
 
326 333
 
@@ -352,7 +359,7 @@ class Notify
352 359
 
353 360
                                             //Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
354 361
                                             //推广佣金
355
-                                            $this->bill_user_log($merchant_data['uid'],  $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.  $yj_amount_90,$store_order_data['mer_id'],0);
362
+                                            $this->bill_user_log($merchant_data['uid'],  $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'.  $yj_amount_90,$store_order_data['mer_id'],0);
356 363
 
357 364
                                         }
358 365
 
@@ -410,7 +417,7 @@ class Notify
410 417
 
411 418
                                 //Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,'contribute'=> $gxz_amount_mine,'score'=> $jf_amount_mine]);
412 419
  
413
-                                $this->bill_user_log($user_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
420
+                                $this->bill_user_log($user_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
414 421
  
415 422
                                 $this->con_log($user_data['uid'],$gx_jf,$store_order_data['order_id'],11,"购买会员专区商品赠送贡献值",1);
416 423
                                 $this->score_log($user_data['uid'],$gx_jf,$store_order_data['order_id'],11,"购买会员专区商品赠送积分",1);
@@ -531,9 +538,9 @@ class Notify
531 538
                                         $this->con_log($spread_data['uid'],round($gx_jf,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
532 539
 
533 540
                                         //养老金
534
-                                        $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
541
+                                        $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
535 542
                                         //佣金
536
-                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'. $yj_amount_90,$store_order_data['mer_id']);
543
+                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'. $yj_amount_90,$store_order_data['mer_id']);
537 544
                                         //复购金
538 545
                                         $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1,1);
539 546
 
@@ -549,7 +556,8 @@ class Notify
549 556
                                         // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.round($pv * 0.01,2),$store_order_data['mer_id']);
550 557
 
551 558
                                         //获取贡献值和积分和佣金
552
-                                        $gx_jf = $spread_data['contribute'] + round($pv * 0.21,2);
559
+                                        // $gx_jf = $spread_data['contribute'] + round($pv * 0.21,2);
560
+                                        $gx_jf = $spread_data['contribute'] + round($pv * 0.3,2);
553 561
 
554 562
                                         //$yj111 = $spread_data['brokerage_price'] + $yj1;
555 563
 
@@ -562,10 +570,12 @@ class Notify
562 570
 
563 571
 
564 572
                                         //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $gx_jf,'score'=> $gx_jf,'brokerage_price'=> $yj_amount,'fugou'=>$fgj_amount]);
565
-                                        $this->con_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
566
-                                        $this->score_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分",1);
573
+                                        // $this->con_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
574
+                                        $this->con_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
575
+                                        // $this->score_log($spread_data['uid'],round($pv * 0.21,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分",1);
576
+                                        $this->score_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分",1);
567 577
                                         //推广佣金
568
-                                        $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id']);
578
+                                        $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id']);
569 579
                                     }
570 580
 
571 581
 
@@ -591,9 +601,9 @@ class Notify
591 601
 
592 602
                                     $this->con_log($spread_data['uid'],round($gx_jf,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
593 603
                                     //养老金
594
-                                    $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
604
+                                    $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
595 605
                                     //佣金
596
-                                    $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'. $yj_amount_90,$store_order_data['mer_id']);
606
+                                    $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'. $yj_amount_90,$store_order_data['mer_id']);
597 607
                                     //复购金
598 608
                                     $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1,1);
599 609
 
@@ -636,7 +646,7 @@ class Notify
636 646
 
637 647
                                         //Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
638 648
                                         //推广佣金
639
-                                        $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.round($pv * 0.35,2),$store_order_data['mer_id']);
649
+                                        $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得拥金'.round($pv * 0.35,2),$store_order_data['mer_id']);
640 650
                                     }
641 651
 
642 652
                                 }
@@ -1410,6 +1420,9 @@ class Notify
1410 1420
 
1411 1421
                 if (strpos($mark, "购买") !== false) {
1412 1422
                     Db::name('user')->where("uid",$uid)->update(['contribute'=>$con_data['contribute'] + $num]);
1423
+                    /** @var UserRepository $userRepository */
1424
+                    $userRepository = app()->make(UserRepository::class);
1425
+                    $userRepository->setUserIdentity($uid);
1413 1426
                 }
1414 1427
 
1415 1428
                 if (strpos($mark, "推广") !== false) {
@@ -1466,6 +1479,9 @@ class Notify
1466 1479
                 // 检查是否包含“购买”
1467 1480
                 if (strpos($mark, "购买") !== false) {
1468 1481
                     Db::name('user')->where("uid",$uid)->update(['contribute'=>$con_data['contribute'] + $num]);
1482
+                    /** @var UserRepository $userRepository */
1483
+                    $userRepository = app()->make(UserRepository::class);
1484
+                    $userRepository->setUserIdentity($uid);
1469 1485
                 }
1470 1486
 
1471 1487
                  

+ 68 - 37
app/controller/api/movie/Movie.php

@@ -8,11 +8,13 @@
8 8
 namespace app\controller\api\movie;
9 9
 
10 10
 use app\common\repositories\movie\CinemaRepository;
11
+use app\common\repositories\movie\CinemaSchedRepository;
11 12
 use app\common\repositories\movie\FilmRepository;
12 13
 use app\common\repositories\movie\MovieRepository;
13 14
 use app\common\repositories\system\groupData\GroupDataRepository;
14 15
 use app\controller\merchant\user\User;
15 16
 use crmeb\basic\BaseController;
17
+use crmeb\services\ApiResponseService;
16 18
 use think\App;
17 19
 
18 20
 class Movie extends BaseController
@@ -95,19 +97,64 @@ class Movie extends BaseController
95 97
     }
96 98
 
97 99
     /**
98
-     * 获取影院场次列表
100
+     * 获取影片场次日期列表
99 101
      *
100 102
      * @return mixed
101 103
      */
102
-    public function getCinemaSched()
104
+    public function getFilmSchedDate()
103 105
     {
104
-        $cinema_sign = $this->request->param('cinema_sign', '');
105
-        if (empty($cinema_sign)) return app('json')->fail('请选择影院');
106
+        $film_sign = $this->request->param('film_sign', '');
107
+        if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
108
+
109
+        /** @var CinemaSchedRepository $cinemaSchedRepository */
110
+        $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
111
+        return app('json')->success($cinemaSchedRepository->getFilmSchedDate($film_sign));
112
+    }
106 113
 
114
+    /**
115
+     * 获取影片场次列表
116
+     *
117
+     * @return mixed
118
+     */
119
+    public function getFilmSched()
120
+    {
121
+        [$page, $limit] = $this->getPage();
107 122
         $film_sign = $this->request->param('film_sign', '');
108
-        if (empty($film_sign)) return app('json')->fail('请选择影片');
123
+        $longitude = $this->request->param('longitude', '');// 经度
124
+        $latitude = $this->request->param('latitude', '');// 纬度
125
+        $show_date = $this->request->param('show_date', '');
109 126
 
110
-        return app('json')->success($this->repository->getCinemaSched($film_sign, $cinema_sign));
127
+        if (empty($film_sign)) return app('json')->fail('请选择要观看的影片');
128
+        if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
129
+        if (empty($show_date)) return app('json')->fail('请选择观影日期');
130
+
131
+        /** @var CinemaSchedRepository $cinemaSchedRepository */
132
+        $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
133
+        return app('json')->success($cinemaSchedRepository->getFilmSched($page, $limit, $film_sign, $longitude, $latitude, $show_date));
134
+    }
135
+
136
+    /**
137
+     * 影院影片场次列表
138
+     *
139
+     * @return mixed
140
+     */
141
+    public function getCinemaFilmSched()
142
+    {
143
+        [$page, $limit] = $this->getPage();
144
+        $cinema_sign = $this->request->param('cinema_sign', '');
145
+        $film_sign = $this->request->param('film_sign', '');
146
+//        $longitude = $this->request->param('longitude', '');// 经度
147
+//        $latitude = $this->request->param('latitude', '');// 纬度
148
+        $show_date = $this->request->param('show_date', '');
149
+
150
+        if (empty($cinema_sign)) return app('json')->fail('请选择观影影院');
151
+        if (empty($film_sign)) return app('json')->fail('请选择观影影片');
152
+//        if (empty($longitude) || empty($latitude)) return app('json')->fail('请授权应用开启定位');
153
+        if (empty($show_date)) return app('json')->fail('请选择观影日期');
154
+
155
+        /** @var CinemaSchedRepository $cinemaSchedRepository */
156
+        $cinemaSchedRepository = app()->make(CinemaSchedRepository::class);
157
+        return app('json')->success($cinemaSchedRepository->getCinemaFilmSched($page, $limit, $cinema_sign, $film_sign, date('Y') . '-' . $show_date));
111 158
     }
112 159
 
113 160
     /**
@@ -118,10 +165,10 @@ class Movie extends BaseController
118 165
     public function getSchedSeat()
119 166
     {
120 167
         $relation_id = $this->request->param('relation_id', '');
121
-        if (empty($cinema_sign)) return app('json')->fail('请选择场次');
168
+        if (empty($relation_id)) return app('json')->fail('请选择观影场次');
122 169
 
123 170
         $sched_sign = $this->request->param('sched_sign', '');
124
-        if (empty($film_sign)) return app('json')->fail('请选择场次');
171
+        if (empty($sched_sign)) return app('json')->fail('请选择观影场次');
125 172
 
126 173
         return app('json')->success($this->repository->getSchedSeat($relation_id, $sched_sign));
127 174
     }
@@ -134,39 +181,21 @@ class Movie extends BaseController
134 181
     public function submitOrder()
135 182
     {
136 183
         $params = $this->request->params(
137
-            ['price', 0.00],
138
-            ['number', 0],
139
-            ['channel_type', ''],
140
-            ['pay_type', ''],
141
-            ['city_sign', ''],
142
-            ['city_name', ''],
143
-            ['area_code', ''],
144
-            ['area_name', ''],
145
-            ['cinema_sign', ''],
146
-            ['cinema_name', ''],
147
-            ['address', ''],
148
-            ['longitude', ''],
149
-            ['latitude', ''],
150
-            ['hall_sign', ''],
151
-            ['hall_name', ''],
152
-            ['relation_id', ''],
153
-            ['sched_sign', ''],
154
-            ['film_sign', ''],
155
-            ['film_name', ''],
156
-            ['show_date', ''],
157
-            ['show_time', ''],
158
-            ['sched_seat', '']
184
+            ['channel_type', 'P2'],
185
+            ['relation_id', ''], // 场次ID
186
+            ['sched_sign', ''], // 场次编码
187
+            ['seat_no', ''], // 座位
188
+            ['seat_sign', ''] // 座位编码
159 189
         );
160 190
 
161
-        if (empty($params['sched_sign'])) return app('json')->fail('请选择场次');
162
-        if (empty($params['seat_sign'])) return app('json')->fail('请选择座位');
163
-        if (empty($params['channel_type'])) return app('json')->fail('请选择购票类型');
191
+        if (empty($params['relation_id']) || empty($params['sched_sign'])) return app('json')->fail('请选择观影场次');
192
+        if (empty($params['seat_no']) || empty($params['seat_sign'])) return app('json')->fail('请选择观影座位');
164 193
 
165 194
         $result = $this->repository->submitOrder($this->request->userInfo(), $params);
166
-        if ($result['code'] == 200) {
167
-            return app('json')->success($result);
195
+        if (!empty($result)) {
196
+            return app('json')->success(['order_sn' => $result]);
168 197
         } else {
169
-            return app('json')->fail($result);
198
+            return app('json')->fail('锁座下单失败');
170 199
         }
171 200
     }
172 201
 
@@ -177,8 +206,10 @@ class Movie extends BaseController
177 206
      */
178 207
     public function confirmOrder()
179 208
     {
180
-        $order_sn = $this->request->param(['order_sn']);
209
+        $order_sn = $this->request->param('order_sn', '');
181 210
         if (empty($order_sn)) return app('json')->fail('订单不存在');
211
+        $pay_type = $this->request->param('pay_type', '');
212
+        if (empty($pay_type)) return app('json')->fail('请选择支付方式');
182 213
 
183 214
         return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn));
184 215
     }

+ 104 - 16
app/controller/api/user/User.php

@@ -231,6 +231,75 @@ class User extends BaseController
231 231
         log::info("=======date==={$data}");
232 232
         return app("json")->success($data);
233 233
     }
234
+
235
+
236
+    public function buildTreeContribute($users, $parentId = 0) {
237
+        $branch = array();
238
+        foreach ($users as $user) {
239
+            if ($user['spread_uid'] == $parentId) {
240
+                $children = $this->buildTreeContribute($users, $user['uid']); // 递归查找子节点
241
+                if ($children) {
242
+                    $user['children'] = $children; // 如果有子节点,添加到当前节点
243
+                }
244
+                $user['total_contribute'] = $user['contribute_sum']; // 初始化当前节点的总余额为自身余额
245
+                if ($children) { // 如果存在子节点,计算总余额
246
+                    foreach ($children as $child) {
247
+                        $user['total_contribute'] += $child['total_contribute']; // 累加子节点的总余额
248
+                    }
249
+                }
250
+                $branch[] = $user; // 将当前节点添加到树中
251
+            }
252
+        }
253
+        return $branch; // 返回当前分支的所有节点
254
+    }
255
+
256
+    // 根据父级uid,递归获取所有子级UID数组 默认深度10级
257
+    public function getRecursiveChildrenChengji($parentUid, $number = 10) {
258
+        $user = Db::name('user')->where('uid', $parentUid)->field('uid,spread_uid,contribute,per_contribute')->find();
259
+        $user['contribute_sum'] = bcadd($user['contribute'], $user['per_contribute'], 2);
260
+        $uids = [];// 用于存储符合条件的子级 uid
261
+        $result = [$user]; // 用于存储符合条件的子级数据
262
+
263
+        // 定义递归函数
264
+        $num = 0;//当前层级
265
+        $recursion = function ($parentUid, $number, $num) use (&$uids, &$result, &$recursion) {
266
+            if($num >= $number){ 
267
+                return;
268
+            }
269
+
270
+            // 查询当前父级的所有直接子级
271
+            $children = Db::name('user')->field('uid,spread_uid,contribute,per_contribute')->where("spread_uid", $parentUid)->select()->toArray();
272
+            // 如果没有子级,直接返回
273
+            if (!count($children) && count($children) < 1) {
274
+                return;
275
+            }else{
276
+                $num = $num + 1;
277
+            }
278
+
279
+            // 遍历每个子级
280
+            foreach ($children as $childUid) {
281
+                //如果有重复的就跳过 防止死循环
282
+                if(in_array($childUid['uid'], $uids)){
283
+                    continue;
284
+                }
285
+                // 将符合条件的子级 uid 添加到结果数组
286
+                $uids[] = $childUid['uid'];
287
+
288
+                // 将符合条件的子级 uid 添加到结果数组
289
+                $childUid['contribute_sum'] = bcadd($childUid['contribute'], $childUid['per_contribute'], 2);
290
+                $result[] = $childUid;
291
+
292
+                // 递归查询子级的子级
293
+                $recursion($childUid['uid'], $number, $num);
294
+            }
295
+        };
296
+
297
+        // 从初始父级开始递归查询
298
+        $recursion($parentUid, $number, $num);
299
+
300
+        return $result; // 返回结果数组,并去重
301
+    }
302
+
234 303
     //贡献值
235 304
 
236 305
     public function  gongxian_info(){
@@ -245,33 +314,52 @@ class User extends BaseController
245 314
             //     $totalcon += $v['number'];
246 315
             // }
247 316
             //已经入账贡献值
248
-            if( $con['user_group'] <= 2 ){
249
-                $data['total_source'] =  $con['contribute'] + $con['per_contribute'];
250
-            }else{
251
-                $data['total_source'] =  $con['contribute'];
252
-            }
317
+            // if( $con['user_group'] <= 2 ){
318
+            //     $data['total_source'] =  $con['contribute'] + $con['per_contribute'];
319
+            // }else{
320
+            $data['total_source'] =  $con['contribute'];
321
+            // }
253 322
            
254 323
             
255 324
            // $getteamscon = $this->getPerformance($user->uid);
256 325
 
257 326
             //$getcon = $this->getPerformance_getcon( $user->uid);
258 327
 
259
-            $team_userinfo_old_jbp22 = $this->getPerformance22($user->uid);
328
+            // $team_userinfo_old_jbp22 = $this->getPerformance22($user->uid);
260 329
 
261
-            //我的团队贡献值
262
-            if( $con['user_group'] <= 2 ){
263
-                $data['team_gongxian_num'] =  $team_userinfo_old_jbp22['person_nums_pv'] - $con['per_contribute'];
330
+            $user_id = $con['uid'];
331
+            $user_group = $con['user_group'];
332
+            $number = 10;
333
+            if($user_group <= 1){
334
+                $number = 1;
335
+            }
336
+            //如果下级团队只有一个人 那就不用再查了 为0
337
+            //如果用户等级为用户身份 只查一级直推
338
+            //去除掉贡献值最大的下级
339
+            $child_nums = $this->getRecursiveChildrenChengji($user_id, $number);
340
+            $child_nums_Tree = $this->buildTreeContribute($child_nums);
341
+            if (empty($child_nums_Tree)){
342
+                $child_nums_Tree = $child_nums;
343
+                $total_contribute = $child_nums_Tree[0]['per_contribute'];
264 344
             }else{
265
-                $data['team_gongxian_num'] = $team_userinfo_old_jbp22['person_nums_pv'];
345
+                // 找到贡献值最大的用户的索引
346
+                $maxBalanceIndex = array_search(max(array_column($child_nums_Tree[0]['children'], 'total_contribute')), array_column($child_nums_Tree, 'total_contribute'));
347
+                // 减去该用户的贡献值
348
+                $total_contribute = bcsub($child_nums_Tree[0]['total_contribute'], $child_nums_Tree[0]['children'][$maxBalanceIndex]['total_contribute'], 2);
266 349
             }
350
+            $data['team_gongxian_num'] = $total_contribute;
267 351
 
268
-           
352
+            //我的团队贡献值
353
+            // if( $con['user_group'] <= 2 ){
354
+            //     $data['team_gongxian_num'] = $team_userinfo_old_jbp22['person_nums_pv'] - $con['per_contribute'];
355
+            // }else{
356
+            //     $data['team_gongxian_num'] = $team_userinfo_old_jbp22['person_nums_pv'];
357
+            // }
269 358
 
270
-            //为生贡献值
359
+            //未生效贡献值
271 360
             $data['no_total_source']=Db::name('user_sign_gongxian')->where('status', -1)->where('uid', $user->uid)->sum('number');
272 361
             log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
273 362
             return app('json')->success($data);
274
-
275 363
         }
276 364
 
277 365
     }
@@ -311,14 +399,14 @@ class User extends BaseController
311 399
 
312 400
         if ($pm==0){
313 401
 
314
-            $data = DB::name('user_sign_gongxian')->where($where)->where('status', 1)->field('id,mark,number,addtime,order_id')->page($page, $limit)->order("id desc")->select();
402
+            $data = DB::name('user_sign_gongxian')->where($where)->where('status', 1)->where('number', '<>',0)->field('id,mark,number,addtime,order_id')->page($page, $limit)->order("id desc")->select();
315 403
         }
316 404
 //        if($pm==1){
317 405
 //            $data = DB::name('user_sign_gongxian')->where($where)->where('pm', 2)->field('id,mark,number,pm,addtime,order_id')->page($page, $limit)->order("id desc")->select();
318 406
 //
319 407
 //        }
320 408
         if($pm==2){
321
-            $data = DB::name('user_sign_gongxian')->where($where)->where('status', -1)->field('id,mark,number,addtime,order_id')->page($page, $limit)->order("id desc")->select();
409
+            $data = DB::name('user_sign_gongxian')->where($where)->where('number', '<>',0)->where('status', -1)->field('id,mark,number,addtime,order_id')->page($page, $limit)->order("id desc")->select();
322 410
 
323 411
         }
324 412
         log::info("=======date==={$data}");
@@ -2287,7 +2375,7 @@ return app("json")->success($data);
2287 2375
                 $paramStr = $userRepository->getTokenByCode($alinfo["authCode"], true);
2288 2376
 //                \think\facade\Db::name('log')->insert(['data'=>'支付宝授权信息'.json_encode($paramStr)]);
2289 2377
                 $nickname = empty($paramStr["nick_name"]) ? "al" . $alinfo["userId"] : $paramStr["nick_name"];
2290
-                $avater = empty($paramStr["avatar"]) ? "http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png" : $paramStr["avatar"];
2378
+                $avater = empty($paramStr["avatar"]) ? "https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png" : $paramStr["avatar"];
2291 2379
             }
2292 2380
             $data2 = [
2293 2381
                 "type"     => $type,

+ 11 - 6
app/controller/api/user/UserMp.php

@@ -36,8 +36,11 @@ class UserMp extends BaseController
36 36
         //点餐小程序
37 37
         // $this->appid = 'wx10669a2eca032216';
38 38
         // $this->secret = '0e71d5c636fdb9bf1c79c403db70f739';
39
-        $this->appid = 'wx7b4d857deb0447f3';
40
-        $this->secret = '643efbd7f3cd6398df1e7adb441afceb';
39
+//        $this->appid = 'wx7b4d857deb0447f3';
40
+//        $this->secret = '643efbd7f3cd6398df1e7adb441afceb';
41
+
42
+        $this->appid = 'wx9082e5ac2fdb513f';
43
+        $this->secret = 'e334c41e1c4aa962f65d1882092fbda6';
41 44
     }
42 45
 
43 46
     public function getUserUnionid(){
@@ -46,8 +49,10 @@ class UserMp extends BaseController
46 49
         if(!$data['code'] || $data['code'] == '' || $data['code'] =='undefined') {
47 50
             return app('json')->fail("异常操作");
48 51
         }
49
-        $appid = 'wx7b4d857deb0447f3';
50
-        $secret = '643efbd7f3cd6398df1e7adb441afceb';
52
+//        $appid = 'wx7b4d857deb0447f3';
53
+//        $secret = '643efbd7f3cd6398df1e7adb441afceb';
54
+        $appid = 'wx9082e5ac2fdb513f';
55
+        $secret = 'e334c41e1c4aa962f65d1882092fbda6';
51 56
         $url = "https://api.weixin.qq.com/sns/jscode2session?appid=".$appid."&secret=".$secret."&js_code=".$data['code']."&grant_type=authorization_code";
52 57
         $get = curlGet($url);
53 58
         if(!$get){
@@ -135,7 +140,7 @@ class UserMp extends BaseController
135 140
                     $unionData = [
136 141
                         'unionid' => $data['unionid'],
137 142
                         'nickname' => $data['nickname'] ? : time(),
138
-                        'avatar' => $data['avatar'] ? : 'http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png',
143
+                        'avatar' => $data['avatar'] ? : 'https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png',
139 144
                         'is_lock' => 1,
140 145
                         'lock_time' => date('Y-m-d H:i:s'),
141 146
                         'balance' => 0,
@@ -151,7 +156,7 @@ class UserMp extends BaseController
151 156
                     } else {
152 157
                         $updateData = [
153 158
                             'nickname' => $data['nickname'] ? : time(),
154
-                            'avatar' => $data['avatar'] ? : 'http://app.bjtdba.com/uploads/def/20201118/5984361a2e00f5407776bcd6eaaae1ce.png',
159
+                            'avatar' => $data['avatar'] ? : 'https://cdn.bjtdba.com/vod/image/2025-01-21/20250121180855764.png',
155 160
                             'update_time' => date('Y-m-d H:i:s')
156 161
                         ];
157 162
                         $unionUsersDao->update($unionUser->id, $updateData);

+ 9 - 3
app/controller/merchant/Common.php

@@ -57,9 +57,14 @@ class Common extends BaseController
57 57
     {
58 58
         $merId = $this->merId;
59 59
 
60
-        $list['gongxian'] = Db::name('user_sign_gongxian')->where('mer_id', $merId)->sum('number');
60
+        // $list['gongxian'] = Db::name('user_sign_gongxian')->where('mer_id', $merId)->sum('number');
61 61
         $list['jingdou'] = Db::name('user_sign_jingdou')->where('mer_id', $merId)->sum('number');
62
+        $list['fenrunzhi'] = Db::name('order_merchant')->where('mer_id', $merId)->where('paid', 1)->sum('available');
62 63
     
64
+        $list['xianxia'] = Db::name('order_merchant')->where('mer_id', $merId)->where('paid', 1)->count();
65
+        $list['xianshang'] = Db::name('store_order')->where('mer_id', $merId)->where('paid', 1)->count();
66
+
67
+
63 68
         return app('json')->success(compact('merId', 'list'));
64 69
     }
65 70
 
@@ -83,8 +88,9 @@ class Common extends BaseController
83 88
         $list = $query->page($pageNum, $pageSize)->order('id desc')->where('mer_id', $merId)->where('paid', 1)->select();
84 89
         $list = $list->toArray();
85 90
         foreach ($list as $k => $v) {
86
-            $list[$k]['pv'] = Db::name('user_sign_gongxian')->where('mer_id', $v['mer_id'])->where('order_id', $v['id'])->value('pv') ?? 0;
87
-            $list[$k]['gongxian'] = Db::name('user_sign_gongxian')->where('mer_id', $v['mer_id'])->where('order_id', $v['id'])->value('number') ?? 0;
91
+            $list[$k]['pv'] = Db::name('user_sign_gongxian')->where('order_id', $v['id'])->value('pv') ?? 0;
92
+            // $list[$k]['gongxian'] = Db::name('user_sign_gongxian')->where('mer_id', $v['mer_id'])->where('order_id', $v['id'])->value('number') ?? 0;
93
+            $list[$k]['fenrunzhi'] = $v['available'];
88 94
             $list[$k]['jingdou'] = Db::name('user_sign_jingdou')->where('mer_id', $v['mer_id'])->where('order_id', $v['id'])->value('number') ?? 0;
89 95
         }
90 96
      

+ 3 - 1
app/controller/merchant/store/shipping/ShippingTemplate.php

@@ -47,7 +47,9 @@ class ShippingTemplate extends BaseController
47 47
      */
48 48
     public function getList()
49 49
     {
50
-        return app('json')->success($this->repository->getList($this->request->merId()));
50
+//        return app('json')->success($this->repository->getList($this->request->merId()));
51
+        // 目前只包邮
52
+        return app('json')->success($this->repository->getList(0));
51 53
     }
52 54
 
53 55
     /**

+ 6 - 6
app/view/index/index.html

@@ -4,7 +4,7 @@
4 4
     <meta charset="UTF-8" />
5 5
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6 6
     <meta http-equiv="X-UA-Compatible" content="ie=edge" />
7
-    <title>储蓄保</title>
7
+    <title>幸福保</title>
8 8
     <link rel="stylesheet" href="index/css/all.min.css" />
9 9
     <link rel="stylesheet" href="index/css/slick.css">
10 10
     <link rel="stylesheet" href="index/css/slick-theme.css">
@@ -21,7 +21,7 @@
21 21
     <nav class="navbar navbar-expand-md tm-navbar" id="tmNav">
22 22
         <div class="container">
23 23
             <div class="tm-next">
24
-                <a href="#hero" class="navbar-brand">储蓄保</a>
24
+                <a href="#hero" class="navbar-brand">幸福保</a>
25 25
             </div>
26 26
 
27 27
             <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
@@ -46,7 +46,7 @@
46 46
 
47 47
     <div class="text-center tm-hero-text-container">
48 48
         <div class="tm-hero-text-container-inner">
49
-            <h2 class="tm-hero-title">储蓄保</h2>
49
+            <h2 class="tm-hero-title">幸福保</h2>
50 50
             <!-- <p class="tm-hero-subtitle">
51 51
                 Parallax Bootstrap Theme
52 52
                 <br />by TemplateMo
@@ -71,7 +71,7 @@
71 71
                 <div class="tm-intro-text-container">
72 72
                     <h2 class="tm-text-primary mb-4 tm-section-title">介绍</h2>
73 73
                     <p class="mb-4 tm-intro-text">
74
-						储蓄保让您轻松实现“互联网+养老”,专业可依赖的实力技术研发团队,成员分别来自移动互联网公司,通讯设计制造商、增值应用提供商、游戏设计公司,储蓄保APP致力于帮助百姓利用日常消费获取养老金,提升全国百姓养老、防老的生活品质;同时帮助商家引流,商家还可以用储蓄保移动互联网+广告,实现精准营销,高效获取目标客户,提高营业收入。
74
+						幸福保让您轻松实现“互联网+养老”,专业可依赖的实力技术研发团队,成员分别来自移动互联网公司,通讯设计制造商、增值应用提供商、游戏设计公司,幸福保APP致力于帮助百姓利用日常消费获取养老金,提升全国百姓养老、防老的生活品质;同时帮助商家引流,商家还可以用幸福保移动互联网+广告,实现精准营销,高效获取目标客户,提高营业收入。
75 75
                     </p>
76 76
                     <p class="mb-5 tm-intro-text">
77 77
 
@@ -204,13 +204,13 @@
204 204
                     <div class="tm-underline-inner"></div>
205 205
                 </div>
206 206
                 <p class="mb-5">
207
-					储蓄保让您轻松实现“互联网+养老”,专业可依赖的实力技术研发团队,成员分别来自移动互联网公司,通讯设计制造商、增值应用提供商、游戏设计公司,储蓄保APP致力于帮助百姓利用日常消费获取养老金,提升全国百姓养老、防老的生活品质;同时帮助商家引流,商家还可以用储蓄保移动互联网+广告,实现精准营销,高效获取目标客户,提高营业收入。
207
+					幸福保让您轻松实现“互联网+养老”,专业可依赖的实力技术研发团队,成员分别来自移动互联网公司,通讯设计制造商、增值应用提供商、游戏设计公司,幸福保APP致力于帮助百姓利用日常消费获取养老金,提升全国百姓养老、防老的生活品质;同时帮助商家引流,商家还可以用幸福保移动互联网+广告,实现精准营销,高效获取目标客户,提高营业收入。
208 208
 				</p>
209 209
         </div>
210 210
     </div>
211 211
     <a class="text-center small tm-footer gogoggg" href="http://www.beian.miit.gov.cn/" style="color: #fff;">
212 212
         <p class="mb-0">
213
-            京ICP备2020038339号-1
213
+            冀ICP备2025100336号-1
214 214
         </p>
215 215
     </a>
216 216
 </section>

+ 1 - 0
config/console.php

@@ -22,6 +22,7 @@ return [
22 22
         'ln:import_user_cxb' => 'app\command\test\ln\ImportUser2',
23 23
 //        'great_life_order_independent_account' => 'app\command\GreatLifeOrderIndependentAccount',
24 24
 //        'commercial-\_area_order_independent_account' => 'app\command\CommercialAreaOrderIndependentAccount',
25
+        // 'huafei_order_independent_account' => 'app\command\HuafeiOrderIndependentAccount',
25 26
         'movie_city_area' => 'app\command\MovieCityAreaCommand',
26 27
         'movie_cinema' => 'app\command\MovieCinemaCommand',
27 28
         'movie_film' => 'app\command\MovieFilmCommand',

+ 4 - 4
crmeb/listens/GongListen.php

@@ -21,10 +21,10 @@ class GongListen implements ListenerInterface
21 21
         $storeOrderRepository = app()->make(StoreOrderRepository::class);
22 22
         Timer::tick(60000, function () use ($storeOrderRepository) {
23 23
             //每天下午3点执行一次
24
-            if (date('i') == '00') {
24
+            // if (date('i') == '00') {
25 25
                 $storeOrderRepository->douhuomall_delivery();
26
-                $this->mer_365_up();
27
-            }
26
+                // $this->mer_365_up();
27
+            // }
28 28
             //每天晚上1点
29 29
             if (date('H:i') == '01:00') {
30 30
 //                $storeOrderRepository->yihuchashengji();
@@ -34,7 +34,7 @@ class GongListen implements ListenerInterface
34 34
 //                $storeOrderRepository->yihuchafenxiang();
35 35
             }
36 36
             if (date('H:i') == '23:00') {
37
-                $this->take();
37
+                // $this->take();
38 38
             }
39 39
         });
40 40
     }

+ 6 - 0
route/admin.php

@@ -86,6 +86,12 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
86 86
             Route::delete('delete/:id', '/delete')->name('configSettingDelete');
87 87
             Route::post('upload_file/:field', '/upload')->name('configUpload');
88 88
         })->prefix('admin.system.config.Config');
89
+        //用户身份升级配置
90
+        Route::group('config/identity', function () {
91
+            Route::post('update/:id', '/update')->name('configIdentityUpdate');
92
+            Route::get('update/table/:id', '/updateTable')->name('configIdentityUpdateForm');
93
+            Route::get('lst', '/lst')->name('configIdentityLst');
94
+        })->prefix('admin.system.config.Identity');
89 95
 
90 96
         Route::group('config/others', function () {
91 97
             Route::get('lst', 'ConfigOthers/lst')->name('configOthersSettingLst');

+ 8 - 6
route/api.php

@@ -1271,12 +1271,14 @@ Route::group('api/', function () {
1271 1271
 
1272 1272
     //电影
1273 1273
     Route::group('movie', function () {
1274
-        Route::get('city', '/getMovieCity');
1275
-        Route::get('area', '/getArea');
1276
-        Route::get('cinema', '/getCinema');
1277
-        Route::get('film', '/getFilm');
1278
-        Route::get('cinema_sched', '/getCinemaSched');
1279
-        Route::get('sched_seat', '/getSchedSeat');
1274
+        Route::get('city', '/getMovieCity'); // 城市列表
1275
+        Route::get('area', '/getArea'); // 城区列表
1276
+        Route::get('cinema', '/getCinema'); // 影院列表
1277
+        Route::get('film', '/getFilm'); // 影片列表
1278
+        Route::get('filmsched_date', '/getFilmSchedDate'); // 影片场次日期
1279
+        Route::get('film_sched', '/getFilmSched'); // 根据影片排片日期查询排片影院
1280
+        Route::get('cinemafilm_sched', '/getCinemaFilmSched'); // 根据影院影片场次日期查询场次列表
1281
+        Route::get('sched_seat', '/getSchedSeat'); // 获取场次座位
1280 1282
     })->prefix('api.movie.Movie');
1281 1283
 
1282 1284
     //电影 - 下单业务