From ca9f2baf1d3927efd8337ae5b4526afb07c12a45 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 26 Sep 2019 15:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A8=E5=B9=BF=E5=91=98?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E8=AE=A2=E5=8D=95=E7=94=9F=E6=88=90=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Service/PromoteService.class.php | 73 +++++-------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index c107142f7..7d6535534 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -422,9 +422,9 @@ class PromoteService { 'status' => false, ]; } - $sn = date('YmdHis').strtoupper(md5(json_encode($params) . 'PromoteCoinRecord' . 'FROM' . rand(0, 99999))); + + $promoteCoinRecordService = new PromoteCoinRecordService(); $fromRecord = [ - 'sn' => $sn, 'type' => 2, 'sub_type' => 4, 'ref_id' => $formRefId, @@ -432,21 +432,12 @@ class PromoteService { 'target_type' => 1, 'coin' => $num, 'balance_coin' => $fromBalanceCoin - $num, - 'create_time' => time(), 'description' => $isUseBind ? '绑定币转账' : '通用币转账', 'remark' => $remark, ]; - $status = M('PromoteCoinRecord', 'tab_')->add($fromRecord); - if (!$status) { - $model->rollback(); - return [ - 'msg' => '系统异常', - 'status' => false, - ]; - } - $sn = date('YmdHis').strtoupper(md5(json_encode($params) . 'PromoteCoinRecord' . 'TO' . rand(0, 99999))); + $promoteCoinRecordService->addRecord($fromRecord); + $toRecord = [ - 'sn' => $sn, 'type' => 1, 'sub_type' => 3, 'ref_id' => $agentRefId, @@ -454,18 +445,11 @@ class PromoteService { 'target_type' => 2, 'coin' => $num, 'balance_coin' => $userPlay['bind_balance'] + $num, - 'create_time' => time(), 'description' => $isUseBind ? '绑定币转账' : '通用币转账', 'remark' => $remark, ]; - $status = M('PromoteCoinRecord', 'tab_')->add($toRecord); - if (!$status) { - $model->rollback(); - return [ - 'msg' => '系统异常', - 'status' => false, - ]; - } + $promoteCoinRecordService->addRecord($toRecord); + $incStatus = M('UserPlay', 'tab_')->where(['game_id' => $gameId, 'user_id' => $userId])->setInc('bind_balance', $num); $decStatus = $this->decCoin($promoteId, $num, $isUseBind ? $gameId : 0); if (!$incStatus || !$decStatus) { @@ -542,9 +526,8 @@ class PromoteService { ]; } - $sn = date('YmdHis').strtoupper(md5(json_encode($params) . 'PromoteCoinRecord' . 'FROM' . rand(0, 99999))); + $promoteCoinRecordService = new PromoteCoinRecordService(); $fromRecord = [ - 'sn' => $sn, 'type' => 2, 'sub_type' => 4, 'ref_id' => $formRefId, @@ -552,22 +535,12 @@ class PromoteService { 'target_type' => 1, 'coin' => $num, 'balance_coin' => $fromBalanceCoin - $num, - 'create_time' => time(), 'description' => '平台币转账', 'remark' => $remark, ]; - $status = M('PromoteCoinRecord', 'tab_')->add($fromRecord); - if (!$status) { - $model->rollback(); - return [ - 'msg' => '系统异常', - 'status' => false, - ]; - } + $promoteCoinRecordService->addRecord($fromRecord); - $sn = date('YmdHis').strtoupper(md5(json_encode($params) . 'PromoteCoinRecord' . 'TO' . rand(0, 99999))); $toRecord = [ - 'sn' => $sn, 'type' => 1, 'sub_type' => 3, 'ref_id' => $toRefId, @@ -575,18 +548,10 @@ class PromoteService { 'target_type' => 1, 'coin' => $num, 'balance_coin' => $toBalanceCoin + $num, - 'create_time' => time(), 'description' => '平台币转账', 'remark' => $remark, ]; - $status = M('PromoteCoinRecord', 'tab_')->add($toRecord); - if (!$status) { - $model->rollback(); - return [ - 'msg' => '系统异常', - 'status' => false, - ]; - } + $promoteCoinRecordService->addRecord($toRecord); $incStatus = $this->incCoin($toPromoteId, $num, $gameId); $decStatus = $this->decCoin($fromPromoteId, $num, $isUseBind ? $gameId : 0); @@ -687,9 +652,8 @@ class PromoteService { $promoteCoinService = new PromoteCoinService(); $refId = $promoteCoinService->addRecord($log); - $sn = date('YmdHis').strtoupper(md5($promoteId . $num . $adminId . 'PromoteCoinRecord' . rand(0, 99999))); + $promoteCoinRecordService = new PromoteCoinRecordService(); $record = [ - 'sn' => $sn, 'type' => 2, 'sub_type' => 5, 'ref_id' => $refId, @@ -697,14 +661,13 @@ class PromoteService { 'target_type' => 1, 'coin' => $num, 'balance_coin' => $balanceCoin - $num, - 'create_time' => time(), 'description' => '后台回收', 'remark' => '', ]; - $status2 = M('PromoteCoinRecord', 'tab_')->add($record); + $promoteCoinRecordService->addRecord($record); - $status1 = $this->decCoin($promoteId, $num, $gameId); - if ($refId && $status1 && $status2) { + $status = $this->decCoin($promoteId, $num, $gameId); + if ($refId && $status) { $model->commit(); return true; } @@ -733,11 +696,10 @@ class PromoteService { $promoteCoinService = new PromoteCoinService(); $refId = $promoteCoinService->addRecord($log); - $status1 = $this->incCoin($promoteId, $num, $gameId); + $status = $this->incCoin($promoteId, $num, $gameId); - $sn = date('YmdHis').strtoupper(md5($promoteId . $num . $adminId . 'PromoteCoinRecord' . rand(0, 99999))); + $promoteCoinRecordService = new PromoteCoinRecordService(); $record = [ - 'sn' => $sn, 'type' => 1, 'sub_type' => 2, 'ref_id' => $refId, @@ -745,13 +707,12 @@ class PromoteService { 'target_type' => 1, 'coin' => $num, 'balance_coin' => $balanceCoin + $num, - 'create_time' => time(), 'description' => '后台发放', 'remark' => '', ]; - $status2 = M('PromoteCoinRecord', 'tab_')->add($record); + $promoteCoinRecordService->addRecord($record); - if ($refId && $status2 && $status1) { + if ($refId && $status) { $model->commit(); return true; }