From ac9cdea7c918e50f543173aba2594d36848bff4b Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 25 Sep 2020 16:18:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=AE=B6=E4=B8=AD=E5=BF=83=20?= =?UTF-8?q?=E4=BD=99=E9=A2=9D=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/BalanceStatementController.php | 3 ++- app/Model/v3/FinancialRecord.php | 5 +++++ .../v3/Implementations/RevenueListService.php | 22 ++++++++++++++----- .../RevenueListServiceInterface.php | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/Controller/v3/BalanceStatementController.php b/app/Controller/v3/BalanceStatementController.php index cd5d0b5..a6e7263 100644 --- a/app/Controller/v3/BalanceStatementController.php +++ b/app/Controller/v3/BalanceStatementController.php @@ -24,6 +24,7 @@ class BalanceStatementController extends BaseController public function getRevenueListByUser(UserRequest $request) { $userId = $this->request->input('user_id',0); + $tab = $this->request->input('tab',''); $page = $this->request->input('page',0); $pagesize = $this->request->input('pagesize',0); $startTime = $this->request->input('start_time',''); @@ -36,7 +37,7 @@ class BalanceStatementController extends BaseController $endTime = strtotime($endTime.' 23:59:59'); } - return $this->success($this->revenueListService->getListByUser($userId, $page, $pagesize ,$startTime,$endTime)); + return $this->success($this->revenueListService->getListByUser($userId, $tab,$page, $pagesize ,$startTime,$endTime)); } public function getWithdrawalListByStore() diff --git a/app/Model/v3/FinancialRecord.php b/app/Model/v3/FinancialRecord.php index 965d763..cb56b89 100644 --- a/app/Model/v3/FinancialRecord.php +++ b/app/Model/v3/FinancialRecord.php @@ -76,6 +76,11 @@ class FinancialRecord extends Model const MONEY_TYPE_CS_WITHDRAW = 104; // 社区提现类型 const MONEY_TYPE_STORE_WITHDRAW = 105; // 商户提现类型 const MONEY_TYPE_STORE_OL_ORDER_DIRECT_REFUND = 106; // 商户订单退款(直接退) + //线上订单 包含收入和退款 + const MONEY_TYPE_STORE_ORDER_ONLINE = [self::MONEY_TYPE_STORE_OL_ORDER_COMP, self::MONEY_TYPE_STORE_OL_ORDER_DIRECT_REFUND]; + + //商户奖励 + const MONEY_TYPE_STORE_REWARD = [self::MONEY_TYPE_STORE_PLAT_NEW_USER, self::MONEY_TYPE_STORE_FIRST_ORDER]; /** * 状态 diff --git a/app/Service/v3/Implementations/RevenueListService.php b/app/Service/v3/Implementations/RevenueListService.php index 4a5dd06..d922be5 100644 --- a/app/Service/v3/Implementations/RevenueListService.php +++ b/app/Service/v3/Implementations/RevenueListService.php @@ -24,17 +24,29 @@ class RevenueListService implements RevenueListServiceInterface // TODO: Implement undo() method. } - public function getListByUser($userId, $page=1, $pagesize=10 ,$startTime = '',$endTime = '') + public function getListByUser($userId,$tab ,$page=1, $pagesize=10 ,$startTime = '',$endTime = '') { $financialRecord = new FinancialRecord(); $mod = bcmod((string)$userId, '5', 0); $financialRecord->suffix($mod); $builder = $financialRecord->where('user_id',$userId) - //->where('money_type','<',100) ->where('user_type','=',UserType::STORE); - // if(!empty($startTime) && !empty($endTime)){ - // $builder->whereBetween('created_at',[strtotime($startTime.' 00:00:00'),strtotime($endTime.' 23:59:59')]); - // } + switch ($tab) { + case 'all': + break; + case 'online': + $builder->whereIn('money_type', $financialRecord::MONEY_TYPE_STORE_ORDER_ONLINE); + break; + case 'offline': + $builder->where('money_type', $financialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP); + break; + case 'withdraw': + $builder->where('money_type', $financialRecord::MONEY_TYPE_STORE_WITHDRAW); + break; + case 'reward': + $builder->whereIn('money_type', $financialRecord::MONEY_TYPE_STORE_REWARD); + break; + } if (!empty($startTime)) { $builder->where('created_at', '>=', $startTime); diff --git a/app/Service/v3/Interfaces/RevenueListServiceInterface.php b/app/Service/v3/Interfaces/RevenueListServiceInterface.php index f94e48a..bf6eec3 100644 --- a/app/Service/v3/Interfaces/RevenueListServiceInterface.php +++ b/app/Service/v3/Interfaces/RevenueListServiceInterface.php @@ -12,7 +12,7 @@ interface RevenueListServiceInterface public function undo(); - public function getListByUser($userId, $page=1, $pagesize=10 ,$startTime = '',$endTime = ''); + public function getListByUser($userId, $tab,$page=1, $pagesize=10 ,$startTime = '',$endTime = ''); public function getRevenueByUser($userId,$type = [],$startTime = '',$endTime = ''); } \ No newline at end of file