修复:订单支付成功后 门店结算金额错误,未成功增加和减少省公司门店佣金及供应商门店佣金
This commit is contained in:
parent
daf6af005b
commit
0db7c644ef
|
|
@ -311,48 +311,6 @@ class StoreOrderRepository extends BaseRepository
|
|||
'user_type' => $storeOrderStatusRepository::U_TYPE_USER,
|
||||
];
|
||||
|
||||
// 循环商品处理
|
||||
foreach ($order->orderProduct as $product) {
|
||||
$product->append(['product']);
|
||||
//TODO 成为推广员
|
||||
if ($flag && $product['cart_info']['product']['is_gift_bag']) {
|
||||
app()->make(UserRepository::class)->promoter($order->uid);
|
||||
$flag = false;
|
||||
}
|
||||
|
||||
// 判断:是否存在 province_here_id(当前所在地址绑定商户id)
|
||||
if((int)$product['province_here_id'] > 0 && (float)$product['product']['agent_two_money'] > 0){
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'province_mer',// 省公司门店提成
|
||||
'financial_pm' => 1,
|
||||
'type' => 1,
|
||||
'number' => (float)sprintf("%.2f",(float)$product['product']['agent_two_money'] * (int)$product['product_num']),
|
||||
'mer_id' => (int)$product['province_here_id'],
|
||||
'financial_record_sn' => $financeSn. ($i++),
|
||||
'status' => 0,
|
||||
];
|
||||
}
|
||||
// 判断:是否存在 供应商提成
|
||||
if((float)$product['product']['supplier_money'] > 0 && (int)$product['product']['supplier_mer_id'] > 0){
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'supplier_mer',// 供应商提成
|
||||
'financial_pm' => 1,
|
||||
'type' => 1,
|
||||
'number' => (float)sprintf("%.2f",(float)$product['product']['supplier_money'] * (int)$product['product_num']),
|
||||
'mer_id' => (int)(int)$product['product']['supplier_mer_id'],
|
||||
'financial_record_sn' => $financeSn. ($i++),
|
||||
'status' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
|
|
@ -367,17 +325,104 @@ class StoreOrderRepository extends BaseRepository
|
|||
'financial_record_sn' => $financeSn . ($i++),
|
||||
'status' => 1,
|
||||
];
|
||||
|
||||
$_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
if ($presell) {
|
||||
if (isset($order->orderProduct[0]['cart_info']['presell_extension_one']) && $order->orderProduct[0]['cart_info']['presell_extension_one'] > 0) {
|
||||
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_one'], 2);
|
||||
// 循环商品处理
|
||||
foreach ($order->orderProduct as $product) {
|
||||
$product->append(['product']);
|
||||
//TODO 成为推广员
|
||||
if ($flag && $product['cart_info']['product']['is_gift_bag']) {
|
||||
app()->make(UserRepository::class)->promoter($order->uid);
|
||||
$flag = false;
|
||||
}
|
||||
if (isset($order->orderProduct[0]['cart_info']['presell_extension_two']) && $order->orderProduct[0]['cart_info']['presell_extension_two'] > 0) {
|
||||
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_two'], 2);
|
||||
|
||||
$_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
if ($presell) {
|
||||
if (isset($order->orderProduct[0]['cart_info']['presell_extension_one']) && $order->orderProduct[0]['cart_info']['presell_extension_one'] > 0) {
|
||||
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_one'], 2);
|
||||
}
|
||||
if (isset($order->orderProduct[0]['cart_info']['presell_extension_two']) && $order->orderProduct[0]['cart_info']['presell_extension_two'] > 0) {
|
||||
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_two'], 2);
|
||||
}
|
||||
}
|
||||
|
||||
// 判断:是否存在 province_here_id(当前所在地址绑定商户id)
|
||||
if((int)$product['province_here_id'] > 0 && (float)$product['product']['agent_two_money'] > 0){
|
||||
$agentTwoMoney = (float)sprintf("%.2f",(float)$product['product']['agent_two_money'] * (int)$product['product_num']);
|
||||
// 减少当前门店结算金额
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'province_mer_dec',// 省公司门店提成 - 减少省公司门店结算金额
|
||||
'financial_pm' => 0,
|
||||
'type' => 1,
|
||||
'number' => $agentTwoMoney,
|
||||
'mer_id' => $order->mer_id,
|
||||
'financial_record_sn' => $financeSn. ($i++),
|
||||
'status' => 0,
|
||||
];
|
||||
$_payPrice = bcsub($_payPrice, $agentTwoMoney, 2);
|
||||
// 增加 当前所在地址绑定商户增加门店佣金
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'province_mer',// 省公司门店提成 - 增加省公司门店结算金额
|
||||
'financial_pm' => 1,
|
||||
'type' => 1,
|
||||
'number' => $agentTwoMoney,
|
||||
'mer_id' => (int)$product['province_here_id'],
|
||||
'financial_record_sn' => $financeSn. ($i++),
|
||||
'status' => 0,
|
||||
];
|
||||
Db::name('merchant')
|
||||
->where('mer_id', (int)$product['province_here_id'])
|
||||
->inc('mer_money', $agentTwoMoney)
|
||||
->update();
|
||||
}
|
||||
// 判断:是否存在 供应商提成
|
||||
if((float)$product['product']['supplier_money'] > 0 && (int)$product['product']['supplier_mer_id'] > 0){
|
||||
$supplierMoney = (float)sprintf("%.2f",(float)$product['product']['supplier_money'] * (int)$product['product_num']);
|
||||
// 减少当前门店结算金额
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'supplier_mer_dec',// 供应商提成 - 减少省公司门店结算金额
|
||||
'financial_pm' => 0,
|
||||
'type' => 1,
|
||||
'number' => $supplierMoney,
|
||||
'mer_id' => $order->mer_id,
|
||||
'financial_record_sn' => $financeSn. ($i++),
|
||||
'status' => 0,
|
||||
];
|
||||
$_payPrice = bcsub($_payPrice, $supplierMoney, 2);
|
||||
// 增加供应商 门店佣金
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'supplier_mer',// 供应商提成 - 增加供应商结算金额
|
||||
'financial_pm' => 1,
|
||||
'type' => 1,
|
||||
'number' => $supplierMoney,
|
||||
'mer_id' => (int)$product['product']['supplier_mer_id'],
|
||||
'financial_record_sn' => $financeSn. ($i++),
|
||||
'status' => 0,
|
||||
];
|
||||
Db::name('merchant')
|
||||
->where('mer_id', (int)$product['product']['supplier_mer_id'])
|
||||
->inc('mer_money', $supplierMoney)
|
||||
->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$_order_rate = 0;
|
||||
|
||||
if ($order['commission_rate'] > 0) {
|
||||
|
|
@ -510,7 +555,7 @@ class StoreOrderRepository extends BaseRepository
|
|||
$storeOrderProfitsharingRepository->insertAll($profitsharing);
|
||||
}
|
||||
|
||||
$financialRecordRepository->insertAll($finance);
|
||||
$financialRecordRepository->insertAll(array_reverse($finance));
|
||||
$storeOrderStatusRepository->batchCreateLog($orderStatus);
|
||||
if (count($groupOrder['give_coupon_ids']) > 0) $groupOrder['give_coupon_ids'] = app()->make(StoreCouponRepository::class)->getGiveCoupon($groupOrder['give_coupon_ids'])->column('coupon_id');
|
||||
$groupOrder->save();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ class FinancialRecord extends BaseController
|
|||
'order_platform_coupon',
|
||||
'order_svip_coupon',
|
||||
'province_mer',
|
||||
'supplier_mer'
|
||||
'province_mer_dec',
|
||||
'supplier_mer',
|
||||
'supplier_mer_dec'
|
||||
];
|
||||
}
|
||||
else{
|
||||
|
|
@ -55,7 +57,9 @@ class FinancialRecord extends BaseController
|
|||
'order_platform_coupon',
|
||||
'order_svip_coupon',
|
||||
'province_mer',
|
||||
'supplier_mer'
|
||||
'province_mer_dec',
|
||||
'supplier_mer',
|
||||
'supplier_mer_dec'
|
||||
];
|
||||
}
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||
|
|
|
|||
Loading…
Reference in New Issue