Browse Source

线下付款不扣除余额

master
李可松 4 years ago
parent
commit
b33b92cdc7
  1. 117
      app/Http/Controllers/Api/VerificationController.php

117
app/Http/Controllers/Api/VerificationController.php

@ -132,37 +132,17 @@ class VerificationController extends Controller
$order->id,
StatementTraits::$type[0]
);
//抽成
//if ($order->guide->rate > 0) {
// //计算抽成金额
// $guideCut = bcmul($order->guide_price, $order->guide->rate, 6);
// $cutPrice = $guideCut > 0 ? bcdiv($guideCut, 100, 6) : 0;
// //总后台抽成流水
// if ($cutPrice > 0) {
// $adminCreate[] = $service->createByOrderFormAdmin(
// $cutPrice,
// StatementType::CUT,
// $order->guide->id,
// DemandTraits::$col[2],
// $order->id,
// );
// //地接被抽成流水
// $statementCreate[] = $service->createByOrder(
// bcmul($cutPrice, -1, 2),
// StatementType::CUT,
// $order->guide->id,
// DemandTraits::$col[2],
// $order->id,
// StatementTraits::$type[0]
// );
//$guidePrice = bcsub($order->guide_price, $cutPrice, 6);
$guide = Guide::query()->where('id', $order->guide->id)->lockForUpdate()->first();
$guide->balance = bcadd($guide->balance, $guidePrice, 6);
$guide->save();
// }
//}
}
/**
* 线下付款已经在app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php扣过了
* 这里不能再重复扣除。如果需要解除,同时还要注意下退款的情况
*/
if ($order->pay_type != PayType::OFFLINE) {
//分账给供应商
$orderItem = OrderProductItem::query()
->where([
@ -175,7 +155,6 @@ class VerificationController extends Controller
->groupBy('supplier_id')
->get();
foreach ($orderItem as $v) {
$cost = bcadd($cost, $v->sum_price, 6);
$supplierPrice = $v->sum_price;
$statementCreate[] = $service->createByOrder(
@ -187,49 +166,14 @@ class VerificationController extends Controller
StatementTraits::$type[0]
);
//if ($v->supplier->rate > 0) {
// //计算抽成金额
// $supplierCut = bcmul($v->sum_price, $v->supplier->rate, 6);
// $cutPrice = $supplierCut > 0 ? bcdiv($supplierCut, 100, 6) : 0;
// if ($cutPrice > 0) {
// //总后台抽成流水
// $adminCreate[] = $service->createByOrderFormAdmin(
// $cutPrice,
// StatementType::CUT,
// $v->supplier_id,
// DemandTraits::$col[1],
// $order->id,
// );
// //供应商被抽成流水
// $statementCreate[] = $service->createByOrder(
// bcmul($cutPrice, -1, 6),
// StatementType::CUT,
// $v->supplier_id,
// DemandTraits::$col[1],
// $order->id,
// StatementTraits::$type[0]
// );
// $supplierPrice = bcsub($supplierPrice, $cutPrice, 6);
//
// }
//}
$supplier = Supplier::query()->where('id', $v->supplier_id)->lockForUpdate()->first();
//处理交易金
if ($v->sum_persons > 0) {
//计算交易金
$deposit = $v->sum_persons;
//流水
// $statementCreate[] = $service->createByOrder(
// bcmul($deposit, -1, 6),
// StatementType::DEPOSIT,
// $v->supplier_id,
// DemandTraits::$col[1],
// $order->id,
// StatementTraits::$type[0]
// );
//扣
$supplier->trade_balance = bcsub($supplier->trade_balance,$deposit,6);
$supplier->trade_balance = bcsub($supplier->trade_balance, $deposit, 6);
//$supplier->balance = bcadd($supplier->deposit_used, $supplierPrice, 6);
//$supplier->balance = bcsub($supplier->deposit_frozen, $supplierPrice, 6);
}
@ -242,7 +186,6 @@ class VerificationController extends Controller
//成本价 加上地接价格
$agentPrice = bcsub($order->price, $cost, 2);
$statementCreate[] = $service->createByOrder(
$agentPrice,
StatementType::ORDER,
@ -251,53 +194,11 @@ class VerificationController extends Controller
$order->id,
StatementTraits::$type[0]
);
//
////抽成
//if ($order->agent->rate > 0) {
// //计算抽成金额
// $agentCut = bcmul($agentPrice, $order->agent->rate, 6);
// $cutPrice = $agentCut > 0 ? bcdiv($agentCut, 100, 6) : 0;
//
// //总后台抽成流水
// if ($cutPrice > 0) {
// $adminCreate[] = $service->createByOrderFormAdmin(
// $cutPrice,
// StatementType::CUT,
// $order->agent->id,
// DemandTraits::$col[0],
// $order->id,
// );
// //代理商被抽成流水
// $statementCreate[] = $service->createByOrder(
// bcmul($cutPrice, -1, 6),
// StatementType::CUT,
// $order->agent->id,
// DemandTraits::$col[0],
// $order->id,
// StatementTraits::$type[0]
// );
// $agentPrice = bcsub($agentPrice, $cutPrice, 6);
// }
//扣除微信支付手续费
//$chargePrice = bcmul($order->price, 0.006, 6);
//$statementCreate[] = $service->createByOrder(
// bcmul($chargePrice, -1, 6),
// StatementType::CHARGE,
// $order->agent_id,
// DemandTraits::$col[0],
// $order->id,
// StatementTraits::$type[0]
//);
//$agentPrice = bcsub($agentPrice, $chargePrice, 6);
$agent = Agent::query()->where('id', $order->agent->id)->lockForUpdate()->first();
$agent->balance = bcadd($agent->balance, $agentPrice, 6);
$agent->save();
//}
//if (!empty($adminCreate)) {
// $order->statementAdmin()->createMany($adminCreate);
//}
}
if (!empty($statementCreate)) {
$order->statement()->createMany($statementCreate);

Loading…
Cancel
Save