佣金或保证金为0时不写入记录
This commit is contained in:
parent
8e5b2fa121
commit
cc2d406b31
@ -694,6 +694,9 @@ class MerchantRepository extends BaseRepository
|
||||
$margin = bcmul($income, $rate / 100, 2);
|
||||
$margin = min(bcsub($merchant['margin'], $merchant['paid_margin'], 2), $margin);
|
||||
$income = max(bcsub($income, $margin, 2), 0);
|
||||
if ($margin <= 0) {
|
||||
return [$income, $finance, false];
|
||||
}
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
|
@ -107,19 +107,21 @@ class paySuccessOrder
|
||||
$this->calculate(Merchant::TypeCloudWarehouse, 'commission_to_cloud_rate');
|
||||
}
|
||||
|
||||
//平台佣金
|
||||
$this->finance[] = [
|
||||
'order_id' => $this->event['order']['order_id'],
|
||||
'order_sn' => $this->event['order']['order_sn'],
|
||||
'user_info' => $this->event['order']->user->nickname,
|
||||
'user_id' => $this->event['order']['uid'],
|
||||
'financial_type' => 'commission_to_platform',
|
||||
'financial_pm' => 1,
|
||||
'type' => 1,
|
||||
'number' => $this->remain,
|
||||
'mer_id' => 0,
|
||||
'financial_record_sn' => $this->financeSn . $this->index
|
||||
];
|
||||
if ($this->remain > 0) {
|
||||
//平台佣金
|
||||
$this->finance[] = [
|
||||
'order_id' => $this->event['order']['order_id'],
|
||||
'order_sn' => $this->event['order']['order_sn'],
|
||||
'user_info' => $this->event['order']->user->nickname,
|
||||
'user_id' => $this->event['order']['uid'],
|
||||
'financial_type' => 'commission_to_platform',
|
||||
'financial_pm' => 1,
|
||||
'type' => 1,
|
||||
'number' => $this->remain,
|
||||
'mer_id' => 0,
|
||||
'financial_record_sn' => $this->financeSn . $this->index
|
||||
];
|
||||
}
|
||||
|
||||
if (!$financialRecordRepository->insertAll($this->finance)) {
|
||||
throw new \Exception('财务流水保存出错');
|
||||
@ -156,6 +158,10 @@ class paySuccessOrder
|
||||
'commission_to_cloud_rate' => 'cloud_warehouse',
|
||||
];
|
||||
$amount = bcmul($this->totalAmount, (string)($rate / 100), 2);
|
||||
if ($amount <= 0) {
|
||||
Log::info("订单分佣:$typeName 佣金为0");
|
||||
return false;
|
||||
}
|
||||
$this->remain = bcsub($this->remain, $amount, 2);
|
||||
$this->finance[] = [
|
||||
'order_id' => $this->event['order']['order_id'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user