From 689cc08b69ccffec389c16dc6e9c167d38e9ce3f Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Fri, 1 Nov 2019 15:50:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/access_data_foldline.txt | 2 +- .../Base/Service/PromoteService.class.php | 14 +++---- .../Controller/FinanceController.class.php | 17 +++++++++ .../Controller/PromoteController.class.php | 37 ++++++++++++++----- .../Home/View/default/Promote/children.html | 36 ++++++++++++++---- 5 files changed, 81 insertions(+), 25 deletions(-) create mode 100644 Application/Home/Controller/FinanceController.class.php diff --git a/Application/Admin/Controller/access_data_foldline.txt b/Application/Admin/Controller/access_data_foldline.txt index f2bc7fb38..2d8d3add6 100644 --- a/Application/Admin/Controller/access_data_foldline.txt +++ b/Application/Admin/Controller/access_data_foldline.txt @@ -1 +1 @@ -{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":0,"active":0,"player":0,"money":0},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]} \ No newline at end of file +{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":21},{"time":"17:00","count":10},{"time":"18:00","count":7},{"time":"19:00","count":11},{"time":"20:00","count":11},{"time":"21:00","count":8},{"time":"22:00","count":11},{"time":"23:00","count":10}],"sum":{"news":89,"active":2506,"player":378,"money":33093},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":851},{"time":"17:00","count":280},{"time":"18:00","count":142},{"time":"19:00","count":105},{"time":"20:00","count":81},{"time":"21:00","count":143},{"time":"22:00","count":420},{"time":"23:00","count":484}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":179},{"time":"17:00","count":54},{"time":"18:00","count":28},{"time":"19:00","count":24},{"time":"20:00","count":14},{"time":"21:00","count":12},{"time":"22:00","count":27},{"time":"23:00","count":40}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":"15639.00"},{"time":"17:00","count":"5328.00"},{"time":"18:00","count":"5490.00"},{"time":"19:00","count":"1178.00"},{"time":"20:00","count":"1274.00"},{"time":"21:00","count":"484.00"},{"time":"22:00","count":"2327.00"},{"time":"23:00","count":"1373.00"}]} \ No newline at end of file diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index 4442beb3d..c8b3e8381 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -155,6 +155,11 @@ class PromoteService { } public function shiftPromote($task) + { + + } + + public function shiftChildPromote($task) { $model = new Model(); $model->startTrans(); @@ -162,19 +167,14 @@ class PromoteService { $coinRecordService = new PromoteCoinRecordService(); $promoteCoinService = new PromoteCoinService(); - $toPromoteId = $task['to_promote_id']; - $fromPromoteId = $task['from_promote_id']; $balanceCoinMode = $task['balance_coin_mode']; - $toPromote = D('promote')->where(['id' => $toPromoteId])->find(); - $fromPromote = D('promote')->where(['id' => $fromPromoteId])->find(); + $toPromote = M('promote', 'tab_')->where(['id' => $task['to_promote_id']])->find(); + $fromPromote = M('promote', 'tab_')->where(['id' => $task['from_promote_id']])->find(); $topPromote = $this->getTopPromote($fromPromote); $status = $this->shiftRemoveCoin($fromPromote, $topPromote, $task); - // 测试 - // $model->rollback(); - if (!$status) { $model->rollback(); return ['status' => false, 'msg' => '系统异常2']; diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php new file mode 100644 index 000000000..8296697fe --- /dev/null +++ b/Application/Home/Controller/FinanceController.class.php @@ -0,0 +1,17 @@ +paginate($query); $ids = array_column($records, 'id'); - $parentIds = array_column($records, 'parent_id'); $countList = []; $playerList = []; @@ -920,10 +919,10 @@ class PromoteController extends BaseController $playerList = M('user_play', 'tab_')->field(['count(*)' => 'count', 'promote_id' => 'promote_id'])->where(['promote_id' => ['in', $ids]])->group('promote_id')->select(); $shiftList = M('shift_task', 'sys_')->field(['count(*)' => 'count', 'from_promote_id' => 'from_promote_id'])->where(['status' => 0, 'type' => 1, 'promote_id' => ['in', $ids]])->group('from_promote_id')->select(); $shiftPlayerList = M('shift_task', 'sys_')->field(['count(*)' => 'count', 'from_promote_id' => 'from_promote_id'])->where(['status' => 0, 'type' => 2, 'promote_id' => ['in', $ids]])->group('from_promote_id')->select(); - $countList = array_column($countList, 'parent_id'); - $playerList = array_column($playerList, 'promote_id'); - $shiftList = array_column($shiftList, 'from_promote_id'); - $shiftPlayerList = array_column($shiftPlayerList, 'from_promote_id'); + $hasChildList = array_column($countList, 'parent_id'); + $hasPlayerList = array_column($playerList, 'promote_id'); + $hasShiftList = array_column($shiftList, 'from_promote_id'); + $hasShiftPlayerList = array_column($shiftPlayerList, 'from_promote_id'); } if ($promoteType == 0) { @@ -935,10 +934,10 @@ class PromoteController extends BaseController } $this->assign('promoteTypeName', $promoteTypeName); - $this->assign('countList', $countList); - $this->assign('playerList', $playerList); - $this->assign('shiftList', $shiftList); - $this->assign('shiftPlayerList', $shiftPlayerList); + $this->assign('hasChildList', $hasChildList); + $this->assign('hasPlayerList', $hasPlayerList); + $this->assign('hasShiftList', $hasShiftList); + $this->assign('hasShiftPlayerList', $hasShiftPlayerList); $this->assign('count', $count); $this->assign('pagination', $pagination); $this->assign('records', $records); @@ -2262,6 +2261,26 @@ class PromoteController extends BaseController $this->display(); } } + + public function getSubPromotes() + { + $level = I('level', 0); + $promoteId = I('promote_id', 0); + $promote = $this->getLoginPromote(); + if ($promoteId > 0) { + $promote = M('promote', 'tab_')->where(['id' => $promoteId])->find(); + } + $map = ['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']]; + if ($level > 0) { + $map['level'] = $level; + } + $promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where($map)->select(); + $this->ajaxReturn([ + 'status' => 1, + 'msg' => '成功', + 'data' => ['promotes' => $promotes] + ]); + } } diff --git a/Application/Home/View/default/Promote/children.html b/Application/Home/View/default/Promote/children.html index 6cd7cc6ee..cf08b8e65 100644 --- a/Application/Home/View/default/Promote/children.html +++ b/Application/Home/View/default/Promote/children.html @@ -13,7 +13,8 @@
@@ -175,10 +173,7 @@
@@ -205,6 +200,30 @@ $(function(){ $(".select_gallery").select2(); + var promoteType = $('input[name=promote_type]').val() + var level = 0 + if (promoteType == 0) { + level = 2 + } else if (promoteType == 1) { + level = 3 + } else if (promoteType == 2) { + level = 4 + } + $.ajax({ + url: "{:U('Promote/getSubPromotes')}", + data: {level: level}, + type: 'post', + dataType: 'json', + success: function(response) { + var options = '' + for (var i in response.data.promotes) { + var promote = response.data.promotes[i] + options += '' + } + $('select[name=to_promote_id]').html(options) + } + }) + $('#shift-player-order-time').datetimepicker({ format: 'yyyy-mm-dd', language:"zh-CN", @@ -378,6 +397,7 @@ $(function(){ }) } }) + $('.shift-player-btn').on({ click: function() { From edc40b8a1b2bc25db440a984ed90382e91f68b33 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Fri, 1 Nov 2019 18:43:26 +0800 Subject: [PATCH 2/2] ss --- .../Base/Service/PromoteService.class.php | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index c8b3e8381..e07dba79c 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -155,11 +155,6 @@ class PromoteService { } public function shiftPromote($task) - { - - } - - public function shiftChildPromote($task) { $model = new Model(); $model->startTrans(); @@ -172,53 +167,64 @@ class PromoteService { $toPromote = M('promote', 'tab_')->where(['id' => $task['to_promote_id']])->find(); $fromPromote = M('promote', 'tab_')->where(['id' => $task['from_promote_id']])->find(); $topPromote = $this->getTopPromote($fromPromote); - - $status = $this->shiftRemoveCoin($fromPromote, $topPromote, $task); + $status = $this->shiftRemoveCoin($fromPromote, $task); if (!$status) { $model->rollback(); - return ['status' => false, 'msg' => '系统异常2']; + return ['status' => false, 'msg' => '系统异常, 处理推广员平台币失败']; } - $promote = new PromoteModel(); - $updateData = [ - 'parent_id' => $toPromote['id'] - ]; - $updateData = [ - 'chain' => ['exp', 'replace(chain,\''.$fromPromote['chain'].'\',\''. $toPromote['chain'].'\')'] - ]; - if ($fromPromote['grand_id'] == 0) { - $status = $promote->where('parent_id=' . $fromPromoteId)->save($updateData); - } else { - $status = $promote->where('id=' . $fromPromoteId)->save($updateData); + $firstMap = ['parent_id' => $fromPromote['id']]; + $secondMap = ['chain' => ['like', $fromPromote['chain'] . $fromPromote['id'] . '/%']]; + if ($task['shift_ids'] != '') { + $shiftIds = json_decode($task['shift_ids'], true) ?? []; + $firstMap['id'] = ['in', $shiftIds]; + $secondMap['id'] = ['in', $shiftIds]; } + $status = M('promote', 'tab_')->where($firstMap)->save(['parent_id' => $toPromote['id']]); if (!$status) { $model->rollback(); - return ['status' => false, 'msg' => '系统异常1']; + return ['status' => false, 'msg' => '系统异常,修改推广员上级失败']; + } + + $status = M('promote', 'tab_')->where($secondMap)->save(['chain' => $toPromote['chain'] . $toPromote['id'] . '/']); + if (!$status) { + $model->rollback(); + return ['status' => false, 'msg' => '系统异常,修改推广员CHAIN失败']; } $status1 = M('ShiftTask')->where('id=' . $task['id'])->save(['status' => 1]); if (!$status1) { $model->rollback(); - return ['status' => false, 'msg' => '系统异常3']; + return ['status' => false, 'msg' => '系统异常,修改迁移任务状态失败']; } $model->commit(); return ['status' => true, 'msg' => '推广帐号迁移成功']; } - public function shiftRemoveCoin($promote, $topPromote, $task) + public function shiftRemoveCoin($promote, $task) { + $shiftIds = null; + if ($task['shift_ids'] != '') { + $shiftIds = json_decode($task['shift_ids'], true) ?? []; + } + + $topPromote = $this->getTopPromote($promote); $coinRecordService = new PromoteCoinRecordService(); $promoteCoinService = new PromoteCoinService(); $topBalanceCoin = $this->getBalanceCoin($topPromote['id'], 0); $topBalancePlus = 0; - $promotes = D('promote')->field(['id', 'balance_coin'])->where(['parent_id' => $promote['id']])->select(); - $ids = array_column($promotes, 'id'); - + $map = ['chain' => $promote['chain'] . $chain['id'] . '/%']; + if ($shiftIds != null) { + $map['id'] = ['in', $shiftIds]; + } + $subPromotes = M('promote', 'tab_')->field(['id', 'balance_coin'])->where($map)->select(); + $ids = array_column($subPromotes, 'id'); $ids[] = $promote['id']; + $promoteCoins = []; $balances = M('PromoteBalanceCoin', 'tab_')->where(['promote_id' => ['in', $ids]])->select(); @@ -306,9 +312,7 @@ class PromoteService { $toPromote = D('promote')->where(['id' => $toPromoteId])->find(); $fromPromote = D('promote')->where(['id' => $fromPromoteId])->find(); - // $promote = new PromoteModel(); - // $promote->where('parent_id=' . $fromPromoteId)->save(['parent_id' => $toPromoteId]); - + $user1 = new UserModel(); $users = $user1->field(['id', 'account', 'nickname'])->where('promote_id=' . $fromPromoteId)->select();