|
@@ -6,6 +6,7 @@ use Illuminate\Console\Command;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
use Modules\Jiesuan\Services\CompanyUserMoneyService;
|
|
|
+use Modules\Jiesuan\Services\ConstService;
|
|
|
|
|
|
class CompanyChargeDayJiesuan extends Command
|
|
|
{
|
|
@@ -77,61 +78,35 @@ class CompanyChargeDayJiesuan extends Command
|
|
|
'updated_at' => $now,
|
|
|
];
|
|
|
}
|
|
|
- DB::transaction(function () use ($insertData, $now){
|
|
|
+
|
|
|
+ DB::transaction(function () use ($insertData, $now){
|
|
|
DB::table('jiesuan_records')->insert($insertData);
|
|
|
foreach ($insertData as $item) {
|
|
|
$beforeUserMoneyInfo = CompanyUserMoneyService::userMoneyInfo($item['company_uid']);
|
|
|
$companyUserMoney = DB::table('company_user_money')
|
|
|
->where('company_uid', $item['company_uid'])->first();
|
|
|
if($companyUserMoney) {
|
|
|
- $beforeTotalIncome = $companyUserMoney->total_income;
|
|
|
$afterTotalIncome = bcadd($companyUserMoney->total_income, $item['charge_money'], 2);
|
|
|
DB::table('company_user_money')
|
|
|
->where(['company_uid' => $item['company_uid']])
|
|
|
->update([
|
|
|
'total_income' => $afterTotalIncome,
|
|
|
+ 'total_tuikuan' => bcadd($companyUserMoney->total_tuikuan, $item['tuikuan_money'], 2),
|
|
|
'updated_at' => $now
|
|
|
]);
|
|
|
} else {
|
|
|
- $beforeTotalIncome = 0;
|
|
|
$afterTotalIncome = $item['charge_money'];
|
|
|
DB::table('company_user_money')
|
|
|
->insert([
|
|
|
'company_uid' => $item['company_uid'],
|
|
|
'total_income' => $afterTotalIncome,
|
|
|
+ 'total_tuikuan' => $item['tuikuan_money'],
|
|
|
'created_at' => $now, 'updated_at' => $now,
|
|
|
]);
|
|
|
}
|
|
|
$currentUserMoneyInfo = CompanyUserMoneyService::userMoneyInfo($item['company_uid']);
|
|
|
- DB::table('company_user_money_change_logs')
|
|
|
- ->insert([
|
|
|
- 'type' => 1,
|
|
|
- 'company_uid' => $item['company_uid'],
|
|
|
- 'created_at' => $now,
|
|
|
- 'log' => \json_encode([
|
|
|
- 'desc' => sprintf('总充值变动:[%s元-->%s元],当前总打款:[%s元],总退款变动:[%s元-->%s元],当前审核中:[%s元],余额变动:[%s元-->%s元]',
|
|
|
- $beforeTotalIncome, $currentUserMoneyInfo->total_income,$currentUserMoneyInfo->total_dakuan,
|
|
|
- $beforeUserMoneyInfo->total_tuikuan,
|
|
|
- $currentUserMoneyInfo->total_tuikuan, $currentUserMoneyInfo->tixian_money,
|
|
|
- $beforeUserMoneyInfo->yue_money,
|
|
|
- $currentUserMoneyInfo->yue_money),
|
|
|
- 'before' => [
|
|
|
- 'total_income' => $beforeUserMoneyInfo->total_income,
|
|
|
- 'total_dakuan' => $beforeUserMoneyInfo->total_dakuan,
|
|
|
- 'total_tuikuan' => $beforeUserMoneyInfo->total_tuikuan,
|
|
|
- 'tixian_money' => $beforeUserMoneyInfo->tixian_money,
|
|
|
- 'yue_money' => $beforeUserMoneyInfo->yue_money,
|
|
|
- ],
|
|
|
- 'after' => [
|
|
|
- 'total_income' => $currentUserMoneyInfo->total_income,
|
|
|
- 'total_dakuan' => $currentUserMoneyInfo->total_dakuan,
|
|
|
- 'total_tuikuan' => $currentUserMoneyInfo->total_tuikuan,
|
|
|
- 'tixian_money' => $currentUserMoneyInfo->tixian_money,
|
|
|
- 'yue_money' => $currentUserMoneyInfo->yue_money,
|
|
|
- ],
|
|
|
- 'created_at' => $now,
|
|
|
- ], JSON_UNESCAPED_UNICODE)
|
|
|
- ]);
|
|
|
+ CompanyUserMoneyService::log($item['company_uid'], ConstService::MONEY_CHANGE_TYPE_DAY_JIESUAN,
|
|
|
+ $beforeUserMoneyInfo, $currentUserMoneyInfo);
|
|
|
}
|
|
|
});
|
|
|
});
|