From 54a5e11b86109d81b6918bd210af5aacf05c4d80 Mon Sep 17 00:00:00 2001 From: weigang Date: Tue, 25 Aug 2020 16:17:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=B1=BB=E5=9E=8B=E5=92=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9=E3=80=81?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/FinancialRecord.php | 16 ++- app/Service/FinancialRecordService.php | 99 +++++++++++++++-- .../FinancialRecordServiceInterface.php | 101 ++++++++++++++++-- 3 files changed, 194 insertions(+), 22 deletions(-) diff --git a/app/Model/FinancialRecord.php b/app/Model/FinancialRecord.php index b56adbe..9da433e 100644 --- a/app/Model/FinancialRecord.php +++ b/app/Model/FinancialRecord.php @@ -23,15 +23,23 @@ class FinancialRecord extends Model * 总账 * USER_TYPE_LEDGER / -1 * - * 用户/商户账户 + * 用户 * USER_TYPE_USER / 1 * * MP用户账户,服务商、市场经理、服务站点等 * USER_TYPE_MP / 2 + * USER_TYPE_MM / 3 + * USER_TYPE_CS / 4 + * + * 商户账户 + * USER_TYPE_STORE / 5 */ const USER_TYPE_LEDGER = -1; const USER_TYPE_USER = 1; const USER_TYPE_MP = 2; + const USER_TYPE_MM = 3; + const USER_TYPE_CS = 4; + const USER_TYPE_STORE = 5; /** * 关联类型 @@ -44,9 +52,9 @@ class FinancialRecord extends Model /** * 流水类型,大的分类,<100是奖励分账等收入项 >=100是提现消费等支出项 */ - const MONEY_TYPE_PLAT_NEW_USER = 1; // 社区服务点新用户奖励(线上订单完成) - const MONEY_TYPE_FIRST_ORDER = 2; // 社区服务点新用户线上首单奖励(线上订单完成) - const MONEY_TYPE_OL_ORDER = 3; // 社区服务点用户线上订单分账(线上订单完成) + const MONEY_TYPE_CS_PLAT_NEW_USER = 1; // 社区服务点新用户奖励(线上订单完成) + const MONEY_TYPE_CS_FIRST_ORDER = 2; // 社区服务点新用户线上首单奖励(线上订单完成) + const MONEY_TYPE_CS_OL_ORDER = 3; // 社区服务点用户线上订单分账(线上订单完成) const MONEY_TYPE_STORE_PLAT_NEW_USER = 4; // 商户平台新用户奖励 const MONEY_TYPE_STORE_FIRST_ORDER = 5; // 商户当日首单奖励 const MONEY_TYPE_STORE_OL_ORDER_COMP = 6; // 商户线上订单完成收入 diff --git a/app/Service/FinancialRecordService.php b/app/Service/FinancialRecordService.php index 574de5c..992f949 100644 --- a/app/Service/FinancialRecordService.php +++ b/app/Service/FinancialRecordService.php @@ -58,7 +58,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function communityAwardByPlatNewUser($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=1, $desc='新用户奖励', $comment='社区服务点') + public function communityAwardByPlatNewUser( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_CS, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_CS_PLAT_NEW_USER, + $desc='新用户奖励', + $comment='社区服务点' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 @@ -73,7 +82,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function communityAwardByPlatNewUserFirstOLOrder($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=2, $desc='新用户首单奖励', $comment='社区服务点') + public function communityAwardByPlatNewUserFirstOLOrder( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_CS, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_CS_FIRST_ORDER, + $desc='新用户首单奖励', + $comment='社区服务点' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 @@ -88,7 +106,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function communitySeparateAccountsByOrderComp($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=3, $desc='用户订单分成', $comment='社区服务点') + public function communitySeparateAccountsByOrderComp( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_CS, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_CS_OL_ORDER, + $desc='用户订单分成', + $comment='社区服务点' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 @@ -104,7 +131,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function storeAwardByPlatNewUserOFLOrder($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=4, $desc='新用户下单奖励', $comment='用户当面付商户奖励') + public function storeAwardByPlatNewUserOFLOrder( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_STORE, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_STORE_PLAT_NEW_USER, + $desc='新用户下单奖励', + $comment='用户当面付商户奖励' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 同时维护钱包 @@ -116,7 +152,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function storeAwardByTodayFirstOFLOrder($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=5, $desc='用户店铺首单奖励', $comment='用户当面付商户奖励') + public function storeAwardByTodayFirstOFLOrder( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_STORE, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_STORE_FIRST_ORDER, + $desc='用户店铺首单奖励', + $comment='用户当面付商户奖励' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 同时维护钱包 @@ -147,7 +192,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function userByOFLOrderPaid($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=100, $desc='用户下单(线下)', $comment='用户下单') + public function userByOFLOrderPaid( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_USER, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_USER_OFL_ORDER, + $desc='用户下单(线下)', + $comment='用户下单' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); } @@ -155,7 +209,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function userByOLOrderPaid($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=101, $desc='用户下单(线上)', $comment='用户下单') + public function userByOLOrderPaid( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_USER, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_USER_OL_ORDER, + $desc='用户下单(线上)', + $comment='用户下单' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); } @@ -163,7 +226,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function storeByOLOrderComp($user_id, $source_id, $money, $user_type = 1, $source_type = 1, $money_type = 6, $desc = '线上外卖订单收入', $comment = '用户订单完成') + public function storeByOLOrderComp( + $user_id, + $source_id, + $money, + $user_type = FinancialRecord::USER_TYPE_STORE, + $source_type = FinancialRecord::SOURCE_TYPE_ORDER, + $money_type = FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP, + $desc = '线上外卖订单收入', + $comment = '用户订单完成' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 同时维护钱包 @@ -175,7 +247,16 @@ class FinancialRecordService implements FinancialRecordServiceInterface /** * @inheritDoc */ - public function storeByOFLOrderComp($user_id, $source_id, $money, $user_type = 1, $source_type = 1, $money_type = 7, $desc = '线下当面付订单收入', $comment = '用户订单完成') + public function storeByOFLOrderComp( + $user_id, + $source_id, + $money, + $user_type = FinancialRecord::USER_TYPE_STORE, + $source_type = FinancialRecord::SOURCE_TYPE_ORDER, + $money_type = FinancialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP, + $desc = '线下当面付订单收入', + $comment = '用户订单完成' + ) { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); } diff --git a/app/Service/FinancialRecordServiceInterface.php b/app/Service/FinancialRecordServiceInterface.php index 8a53628..a8f13be 100644 --- a/app/Service/FinancialRecordServiceInterface.php +++ b/app/Service/FinancialRecordServiceInterface.php @@ -2,6 +2,8 @@ namespace App\Service; +use App\Model\FinancialRecord; + interface FinancialRecordServiceInterface { @@ -17,7 +19,16 @@ interface FinancialRecordServiceInterface * @param string $desc * @return mixed */ - public function communityAwardByPlatNewUser($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=1, $desc='新用户奖励', $comment=''); + public function communityAwardByPlatNewUser( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_CS, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_CS_PLAT_NEW_USER, + $desc='新用户奖励', + $comment='' + ); /** * 社区服务点新用户线上首单奖励 @@ -31,7 +42,16 @@ interface FinancialRecordServiceInterface * @param string $desc * @return mixed */ - public function communityAwardByPlatNewUserFirstOLOrder($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=2, $desc='新用户首单奖励', $comment=''); + public function communityAwardByPlatNewUserFirstOLOrder( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_CS, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_CS_FIRST_ORDER, + $desc='新用户首单奖励', + $comment='' + ); /** * 社区服务点用户订单完成分账 @@ -45,7 +65,16 @@ interface FinancialRecordServiceInterface * @param string $desc * @return mixed */ - public function communitySeparateAccountsByOrderComp($user_id, $source_id, $money, $user_type=2, $source_type=1, $money_type=3, $desc='用户订单分成', $comment=''); + public function communitySeparateAccountsByOrderComp( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_CS, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_CS_OL_ORDER, + $desc='用户订单分成', + $comment='' + ); /** * 收支总账 @@ -71,7 +100,16 @@ interface FinancialRecordServiceInterface * @param string $comment * @return mixed */ - public function storeAwardByPlatNewUserOFLOrder($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=4, $desc='新用户下单奖励', $comment=''); + public function storeAwardByPlatNewUserOFLOrder( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_STORE, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_STORE_PLAT_NEW_USER, + $desc='新用户下单奖励', + $comment='' + ); /** * 商户线下用户支付用户当日首单奖励 @@ -85,7 +123,16 @@ interface FinancialRecordServiceInterface * @param string $comment * @return mixed */ - public function storeAwardByTodayFirstOFLOrder($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=5, $desc='用户店铺首单奖励', $comment=''); + public function storeAwardByTodayFirstOFLOrder( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_STORE, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_STORE_FIRST_ORDER, + $desc='用户店铺首单奖励', + $comment='' + ); /** * 用户线下订单支付流水 @@ -99,7 +146,16 @@ interface FinancialRecordServiceInterface * @param string $comment * @return mixed */ - public function userByOFLOrderPaid($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=100, $desc='用户下单(线下)', $comment=''); + public function userByOFLOrderPaid( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_USER, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_USER_OFL_ORDER, + $desc='用户下单(线下)', + $comment='' + ); /** * 用户线上订单支付流水 @@ -113,7 +169,16 @@ interface FinancialRecordServiceInterface * @param string $comment * @return mixed */ - public function userByOLOrderPaid($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=101, $desc='用户下单(线上)', $comment=''); + public function userByOLOrderPaid( + $user_id, + $source_id, + $money, + $user_type=FinancialRecord::USER_TYPE_USER, + $source_type=FinancialRecord::SOURCE_TYPE_ORDER, + $money_type=FinancialRecord::MONEY_TYPE_USER_OL_ORDER, + $desc='用户下单(线上)', + $comment='' + ); /** * 商户线上订单完成收入流水 @@ -127,7 +192,16 @@ interface FinancialRecordServiceInterface * @param string $comment * @return mixed */ - public function storeByOLOrderComp($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=6, $desc='线上外卖订单收入', $comment=''); + public function storeByOLOrderComp( + $user_id, + $source_id, + $money, + $user_type = FinancialRecord::USER_TYPE_STORE, + $source_type = FinancialRecord::SOURCE_TYPE_ORDER, + $money_type = FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP, + $desc='线上外卖订单收入', + $comment='' + ); /** * 商户线下订单完成收入流水 @@ -141,6 +215,15 @@ interface FinancialRecordServiceInterface * @param string $comment * @return mixed */ - public function storeByOFLOrderComp($user_id, $source_id, $money, $user_type=1, $source_type=1, $money_type=7, $desc='线下当面付订单收入', $comment=''); + public function storeByOFLOrderComp( + $user_id, + $source_id, + $money, + $user_type = FinancialRecord::USER_TYPE_STORE, + $source_type = FinancialRecord::SOURCE_TYPE_ORDER, + $money_type = FinancialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP, + $desc='线下当面付订单收入', + $comment='' + ); } \ No newline at end of file