调整订单财务流水写入

This commit is contained in:
luofei 2024-02-01 16:08:15 +08:00
parent 1e6b21378d
commit 9f9c0c5329
3 changed files with 7 additions and 84 deletions

View File

@ -146,7 +146,7 @@ class FinancialDao extends BaseDao
'financial_pm' => $pm,
'type' => $type,
'number' => $number,
'mer_id' => !empty($merId) ? $merId : $this->order->mer_id,
'mer_id' => $merId !== '' ? $merId : $this->order->mer_id,
'financial_record_sn' => $this->financeSn . ($this->index++)
];
}

View File

@ -221,7 +221,6 @@ class StoreOrderRepository extends BaseRepository
$userMerchantRepository = app()->make(UserMerchantRepository::class);
$storeOrderProfitsharingRepository = app()->make(StoreOrderProfitsharingRepository::class);
$uid = $groupOrder->uid;
$i = 0;
// $isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder);
//订单记录
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
@ -305,16 +304,17 @@ class StoreOrderRepository extends BaseRepository
$financeDao->order = $order;
$financeDao->user = $groupOrder->user;
$financialType = $presell ? 'order_presell' : 'order';
// 商户流水账单数据
$financeDao->setData($order->pay_price, $financialType, 1, $presell ? 2 : 1);
// 平台订单收入流水账单数据
$financeDao->platformIn($order->total_price, $financialType, 0);
$financeDao->platformOut($order->consumption_money, 'platform_consumption', 0);
if ($order->source == 103) {
$_payPrice = $order->procure_price;
$financeDao->publicOut($_payPrice, 'supply_chain');
//市级供应链
$product_mer_id = Db::name('store_order_product')->where('order_id', $order->order_id)->value('product_mer_id');
// 平台支付市供应链流水账单数据
$financeDao->platformOut($_payPrice, 'supply_chain', $product_mer_id);
if ($product_mer_id) {
$financeDao->publicOut($_payPrice, 'order', $product_mer_id);
//市级供应链押金计算
if ($_payPrice > 0) {
/** @var MerchantRepository $merchantRepo */
@ -324,92 +324,15 @@ class StoreOrderRepository extends BaseRepository
[$_payCityPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao);
}
if (isset($_payCityPrice)) {
$financeDao->platformOut($_payCityPrice, 'order_true', $product_mer_id);
if (!$is_combine) {
app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice);
}
}
}
//计算手续费
$_order_rate = bcsub($order->pay_price, $_payPrice, 2);
//计算镇级供应链云仓实际获得金额
// 服务团队佣金统一由新供销平台结算
// if ($_order_rate > 0) {
// $commission_rate = bcdiv(12, 100, 2);
// $_payPrice = bcmul($_order_rate, $commission_rate, 2);
// } else {
// $_payPrice = 0;
// }
} else {
$_payPrice = $order->pay_price;
$_order_rate = 0;
//平台手续费
if ($order['commission_rate'] > 0) {
$commission_rate = ($order['commission_rate'] / 100);
$_order_rate = bcmul($_payPrice, $commission_rate, 2);
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
// 结算各镇 小组佣金
// event('order.paySuccessOrder', compact('order', '_order_rate'));
}
}
// 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);
// }
// }
if (!$presell) {
if ($order['commission_rate'] > 0 || $order->source == 103) {
//支出手续费
$financeDao->publicOut($_order_rate, 'order_charge');
}
//押金计算
if ($_payPrice > 0) {
/** @var MerchantRepository $merchantRepo */
$merchantRepo = app()->make(MerchantRepository::class);
$merchantRepo->merId = $order->mer_id;
$merchantRepo->forceMargin = false;
[$_payCityPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao);
}
if ($order->source == 103) {
$financeDao->publicOut($_payPrice, 'commission_to_cloud_warehouse');
} else {
$financeDao->platformOut($_payPrice, 'order_true');
}
// if ($order->platform_coupon_price > 0) {
// $finance[] = [
// 'order_id' => $order->order_id,
// 'order_sn' => $order->order_sn,
// 'user_info' => $groupOrder->user->nickname,
// 'user_id' => $uid,
// 'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon',
// 'financial_pm' => 0,
// 'type' => 1,
// 'number' => $order->platform_coupon_price,
// 'mer_id' => $order->mer_id,
// 'financial_record_sn' => $financeSn . ($i++)
// ];
// $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2);
// }
if (!$is_combine) {
app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice);
}
}
if ($is_combine) {
$profitsharing[] = [
'profitsharing_sn' => $storeOrderProfitsharingRepository->getOrderSn(),

View File

@ -776,7 +776,7 @@ class MerchantRepository extends BaseRepository
// if ($margin <= 0) {
// return [$income, $financeDao];
// }
$financeDao->publicOut($margin, 'auto_margin', $this->merId);
$financeDao->platformIn($margin, 'auto_margin', $this->merId);
if(bcadd($merchant['paid_margin'],$margin)>=$merchant['margin']){
$is_margin=10;
}else{