佣金或保证金为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 = bcmul($income, $rate / 100, 2);
|
||||||
$margin = min(bcsub($merchant['margin'], $merchant['paid_margin'], 2), $margin);
|
$margin = min(bcsub($merchant['margin'], $merchant['paid_margin'], 2), $margin);
|
||||||
$income = max(bcsub($income, $margin, 2), 0);
|
$income = max(bcsub($income, $margin, 2), 0);
|
||||||
|
if ($margin <= 0) {
|
||||||
|
return [$income, $finance, false];
|
||||||
|
}
|
||||||
$finance[] = [
|
$finance[] = [
|
||||||
'order_id' => $order->order_id,
|
'order_id' => $order->order_id,
|
||||||
'order_sn' => $order->order_sn,
|
'order_sn' => $order->order_sn,
|
||||||
|
@ -107,6 +107,7 @@ class paySuccessOrder
|
|||||||
$this->calculate(Merchant::TypeCloudWarehouse, 'commission_to_cloud_rate');
|
$this->calculate(Merchant::TypeCloudWarehouse, 'commission_to_cloud_rate');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->remain > 0) {
|
||||||
//平台佣金
|
//平台佣金
|
||||||
$this->finance[] = [
|
$this->finance[] = [
|
||||||
'order_id' => $this->event['order']['order_id'],
|
'order_id' => $this->event['order']['order_id'],
|
||||||
@ -120,6 +121,7 @@ class paySuccessOrder
|
|||||||
'mer_id' => 0,
|
'mer_id' => 0,
|
||||||
'financial_record_sn' => $this->financeSn . $this->index
|
'financial_record_sn' => $this->financeSn . $this->index
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if (!$financialRecordRepository->insertAll($this->finance)) {
|
if (!$financialRecordRepository->insertAll($this->finance)) {
|
||||||
throw new \Exception('财务流水保存出错');
|
throw new \Exception('财务流水保存出错');
|
||||||
@ -156,6 +158,10 @@ class paySuccessOrder
|
|||||||
'commission_to_cloud_rate' => 'cloud_warehouse',
|
'commission_to_cloud_rate' => 'cloud_warehouse',
|
||||||
];
|
];
|
||||||
$amount = bcmul($this->totalAmount, (string)($rate / 100), 2);
|
$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->remain = bcsub($this->remain, $amount, 2);
|
||||||
$this->finance[] = [
|
$this->finance[] = [
|
||||||
'order_id' => $this->event['order']['order_id'],
|
'order_id' => $this->event['order']['order_id'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user