6
0
Fork 0
release
李静 2022-02-25 16:28:32 +08:00
parent 7185c79419
commit d706b14456
2 changed files with 31 additions and 29 deletions

View File

@ -55,20 +55,22 @@ class PreIncomeJobCommand extends Command
//发送商家端预收益进帐消息
try {
DB::beginTransaction();
switch (get_class($job->jobable)) {
case Order::class://如果是订单类型,则发送预收益消息
$order = $job->jobable;
$incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get();
foreach ($incomesLogs as $log) {
MerchantMessage::createDistributionMessage($log->user_id, [
'title'=>'恭喜收入'.$log->total_revenue.'元',
'content'=>'您有新的预收益产生,共'.$log->total_revenue.'元。',
]);
}
break;
default:
break;
}
case Order::class://如果是订单类型,则发送预收益消息
$order = $job->jobable;
$incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get();
foreach ($incomesLogs as $log) {
MerchantMessage::createDistributionMessage($log->user_id, [
'title'=>'恭喜收入'.$log->total_revenue.'元',
'content'=>'您有新的预收益产生,共'.$log->total_revenue.'元。',
]);
}
break;
default:
break;
}
DB::commit();
} catch (Throwable $e) {
DB::rollBack();

View File

@ -44,33 +44,33 @@ class PreIncomeSettleCommand extends Command
DB::beginTransaction();
$walletService->changeBalance(
$preIncome->user,
bcmul($preIncome->total_revenue, 100),
WalletLog::ACTION_DISTRIBUTION_PRE_INCOME,
$preIncome->remarks,
$preIncome
);
$preIncome->user,
bcmul($preIncome->total_revenue, 100),
WalletLog::ACTION_DISTRIBUTION_PRE_INCOME,
$preIncome->remarks,
$preIncome
);
// 计算配额
$changeQuota = bcmul($preIncome->total_revenue, app_settings('distribution.quota_v2_rate', 0), 4);
$changeQuota = round($changeQuota, 3);
$preIncome->user->userInfo()->update([
'quota_v2' => DB::raw("quota_v2+{$changeQuota}"),
]);
'quota_v2' => DB::raw("quota_v2+{$changeQuota}"),
]);
$preIncome->user->quotaLogs()->create([
'loggable_id' => $preIncome->id,
'loggable_type' => $preIncome->getMorphClass(),
'change_quota' => $changeQuota,
'remarks' => $preIncome->type_text.'得配额',
]);
'loggable_id' => $preIncome->id,
'loggable_type' => $preIncome->getMorphClass(),
'change_quota' => $changeQuota,
'remarks' => $preIncome->type_text.'得配额',
]);
// 将预收益标记为已结算
$preIncome->update([
'completed_at' => now(),
'status' => DistributionPreIncome::STATUS_PROCESSED,
]);
'completed_at' => now(),
'status' => DistributionPreIncome::STATUS_PROCESSED,
]);
DB::commit();
} catch (Throwable $e) {