diff --git a/app/Model/UserBalance.php b/app/Model/UserBalance.php index 91b02d5..a72620e 100644 --- a/app/Model/UserBalance.php +++ b/app/Model/UserBalance.php @@ -7,10 +7,28 @@ namespace App\Model; */ class UserBalance extends Model { - const USER_TYPE_MP = 1; - const USER_TYPE_MM = 2; - const USER_TYPE_CS = 3; - const USER_TYPE_USER = 4; + /** + * 账户类型 + * + * 总账 + * 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; /** diff --git a/app/Service/FinancialRecordService.php b/app/Service/FinancialRecordService.php index bd48cae..d9a6ca4 100644 --- a/app/Service/FinancialRecordService.php +++ b/app/Service/FinancialRecordService.php @@ -77,7 +77,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_CS, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -105,7 +105,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_CS, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -132,7 +132,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_CS, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money,2); @@ -165,7 +165,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_STORE, + 'user_type' => $user_type, 'source_id' => $store->id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -194,7 +194,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_STORE, + 'user_type' => $user_type, 'source_id' => $store->id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -276,7 +276,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_STORE, + 'user_type' => $user_type, 'source_id' => $store->id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -306,7 +306,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_STORE, + 'user_type' => $user_type, 'source_id' => $store->id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -349,7 +349,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_MM, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -374,7 +374,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_MM, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -399,7 +399,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_MP, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -424,7 +424,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_MP, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2); @@ -449,7 +449,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface // 维护余额 $balance = UserBalance::firstOrNew([ - 'user_type' => UserBalance::USER_TYPE_MP, + 'user_type' => $user_type, 'source_id' => $user_id ]); $balance->balance = bcadd($balance->balance, $money, 2);