Update
parent
7185c79419
commit
d706b14456
|
|
@ -55,20 +55,22 @@ class PreIncomeJobCommand extends Command
|
||||||
//发送商家端预收益进帐消息
|
//发送商家端预收益进帐消息
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
switch (get_class($job->jobable)) {
|
switch (get_class($job->jobable)) {
|
||||||
case Order::class://如果是订单类型,则发送预收益消息
|
case Order::class://如果是订单类型,则发送预收益消息
|
||||||
$order = $job->jobable;
|
$order = $job->jobable;
|
||||||
$incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get();
|
$incomesLogs = DistributionPreIncome::where('order_id', $order->id)->get();
|
||||||
foreach ($incomesLogs as $log) {
|
foreach ($incomesLogs as $log) {
|
||||||
MerchantMessage::createDistributionMessage($log->user_id, [
|
MerchantMessage::createDistributionMessage($log->user_id, [
|
||||||
'title'=>'恭喜收入'.$log->total_revenue.'元',
|
'title'=>'恭喜收入'.$log->total_revenue.'元',
|
||||||
'content'=>'您有新的预收益产生,共'.$log->total_revenue.'元。',
|
'content'=>'您有新的预收益产生,共'.$log->total_revenue.'元。',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -44,33 +44,33 @@ class PreIncomeSettleCommand extends Command
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
$walletService->changeBalance(
|
$walletService->changeBalance(
|
||||||
$preIncome->user,
|
$preIncome->user,
|
||||||
bcmul($preIncome->total_revenue, 100),
|
bcmul($preIncome->total_revenue, 100),
|
||||||
WalletLog::ACTION_DISTRIBUTION_PRE_INCOME,
|
WalletLog::ACTION_DISTRIBUTION_PRE_INCOME,
|
||||||
$preIncome->remarks,
|
$preIncome->remarks,
|
||||||
$preIncome
|
$preIncome
|
||||||
);
|
);
|
||||||
|
|
||||||
// 计算配额
|
// 计算配额
|
||||||
$changeQuota = bcmul($preIncome->total_revenue, app_settings('distribution.quota_v2_rate', 0), 4);
|
$changeQuota = bcmul($preIncome->total_revenue, app_settings('distribution.quota_v2_rate', 0), 4);
|
||||||
$changeQuota = round($changeQuota, 3);
|
$changeQuota = round($changeQuota, 3);
|
||||||
|
|
||||||
$preIncome->user->userInfo()->update([
|
$preIncome->user->userInfo()->update([
|
||||||
'quota_v2' => DB::raw("quota_v2+{$changeQuota}"),
|
'quota_v2' => DB::raw("quota_v2+{$changeQuota}"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$preIncome->user->quotaLogs()->create([
|
$preIncome->user->quotaLogs()->create([
|
||||||
'loggable_id' => $preIncome->id,
|
'loggable_id' => $preIncome->id,
|
||||||
'loggable_type' => $preIncome->getMorphClass(),
|
'loggable_type' => $preIncome->getMorphClass(),
|
||||||
'change_quota' => $changeQuota,
|
'change_quota' => $changeQuota,
|
||||||
'remarks' => $preIncome->type_text.'得配额',
|
'remarks' => $preIncome->type_text.'得配额',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 将预收益标记为已结算
|
// 将预收益标记为已结算
|
||||||
$preIncome->update([
|
$preIncome->update([
|
||||||
'completed_at' => now(),
|
'completed_at' => now(),
|
||||||
'status' => DistributionPreIncome::STATUS_PROCESSED,
|
'status' => DistributionPreIncome::STATUS_PROCESSED,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue