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

Merge branch 'master' into sxb-dev-01

sunxbiao 1 год назад
Родитель
Сommit
3f25a8783f

+ 2 - 0
app/command/CinemaSchedCommand.php

@@ -37,6 +37,8 @@ class CinemaSchedCommand extends Command
37
             foreach ($result['cinema_list'] as $key => $value) {
37
             foreach ($result['cinema_list'] as $key => $value) {
38
                 foreach ($filmResult['film_list'] as $subKey => $subValue) {
38
                 foreach ($filmResult['film_list'] as $subKey => $subValue) {
39
                     $this->doCinemaSched($subValue, $value);
39
                     $this->doCinemaSched($subValue, $value);
40
+//                    if ($subValue['film_sign'] == 'F6556061D4' && $value['cinema_sign'] == 'CCB622D8D8') {
41
+//                    }
40
                 }
42
                 }
41
             }
43
             }
42
         } catch (\Exception $exception) {
44
         } catch (\Exception $exception) {

+ 8 - 12
app/common/repositories/movie/MovieRepository.php

@@ -123,22 +123,18 @@ class MovieRepository extends BaseRepository
123
     {
123
     {
124
         $result = DouHuoMallFilmApiRequest::getSchedSeat($relation_id, $sched_sign);
124
         $result = DouHuoMallFilmApiRequest::getSchedSeat($relation_id, $sched_sign);
125
 
125
 
126
-        $schedSeatList = (isset($result['code']) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE))
127
-            ? $result['data']['list'] : [];
126
+        $schedSeatList = (isset($result['code']) && ($result['code'] == ApiResponseService::DEFAULT_SUCCESS_CODE)) ? $result['data'] : [];
128
         foreach ($schedSeatList as $key => $value) {
127
         foreach ($schedSeatList as $key => $value) {
129
-            $tmpprice = json_decode($value['price'], true);
130
-            if (isset($tmpprice['P2'])) {
131
-                $price = $tmpprice['P2'];
132
-            } elseif (isset($tmpprice['P1'])) {
133
-                $price = $tmpprice['P1'];
134
-            } elseif (isset($tmpprice['P0'])) {
135
-                $price = $tmpprice['P0'];
136
-            } else {
137
-                $price = 0.00;
128
+            $tmpprice = [];
129
+            foreach ($value['price'] as $pKey => $pValue) {
130
+                $tmpprice[$pValue] = ['channel_type' => $pKey, 'price' => $pValue];
138
             }
131
             }
132
+            ksort($tmpprice);
133
+            $tmpprice = array_shift($tmpprice);
139
             unset($schedSeatList[$key]['price']);
134
             unset($schedSeatList[$key]['price']);
140
 
135
 
141
-            $pcYanglaojinGongxian = self::getPvYanglaojinScore($price);
136
+            $pcYanglaojinGongxian = self::getPvYanglaojinScore($tmpprice['price']);
137
+            $schedSeatList[$key]['channel_type'] = $tmpprice['channel_type'];
142
             $schedSeatList[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
138
             $schedSeatList[$key]['price'] = $pcYanglaojinGongxian['cost_price'];
143
             $schedSeatList[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
139
             $schedSeatList[$key]['yanglaojin'] = $pcYanglaojinGongxian['yanglaojin'];
144
             $schedSeatList[$key]['pv'] = $pcYanglaojinGongxian['pv'];
140
             $schedSeatList[$key]['pv'] = $pcYanglaojinGongxian['pv'];

+ 1 - 1
app/controller/api/movie/Movie.php

@@ -189,7 +189,7 @@ class Movie extends BaseController
189
         );
189
         );
190
 
190
 
191
         if (empty($params['relation_id']) || empty($params['sched_sign'])) 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('请选择座位');
192
+        if (empty($params['seat_no']) || empty($params['seat_sign'])) return app('json')->fail('请选择观影座位');
193
 
193
 
194
         $result = $this->repository->submitOrder($this->request->userInfo(), $params);
194
         $result = $this->repository->submitOrder($this->request->userInfo(), $params);
195
         if (!empty($result)) {
195
         if (!empty($result)) {

+ 101 - 13
app/controller/api/user/User.php

@@ -231,6 +231,75 @@ class User extends BaseController
231
         log::info("=======date==={$data}");
231
         log::info("=======date==={$data}");
232
         return app("json")->success($data);
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
     public function  gongxian_info(){
305
     public function  gongxian_info(){
@@ -245,33 +314,52 @@ class User extends BaseController
245
             //     $totalcon += $v['number'];
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
            // $getteamscon = $this->getPerformance($user->uid);
324
            // $getteamscon = $this->getPerformance($user->uid);
256
 
325
 
257
             //$getcon = $this->getPerformance_getcon( $user->uid);
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
             }else{
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
             $data['no_total_source']=Db::name('user_sign_gongxian')->where('status', -1)->where('uid', $user->uid)->sum('number');
360
             $data['no_total_source']=Db::name('user_sign_gongxian')->where('status', -1)->where('uid', $user->uid)->sum('number');
272
             log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
361
             log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
273
             return app('json')->success($data);
362
             return app('json')->success($data);
274
-
275
         }
363
         }
276
 
364
 
277
     }
365
     }