Merge branch 'dev' of https://gitea.lihaink.cn/mkm/shop-php into dev
This commit is contained in:
commit
1efbe4f84b
@ -317,6 +317,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
|
||||
$_order_rate = 0;
|
||||
|
||||
//平台手续费
|
||||
if ($order['commission_rate'] > 0) {
|
||||
|
||||
$commission_rate = ($order['commission_rate'] / 100);
|
||||
@ -324,7 +325,8 @@ class StoreOrderRepository extends BaseRepository
|
||||
$_order_rate = bcmul($_payPrice, $commission_rate, 2);
|
||||
|
||||
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
|
||||
event('order.paySuccessOrder', compact('order','_order_rate'));
|
||||
// 结算各镇 小组佣金
|
||||
// event('order.paySuccessOrder', compact('order','_order_rate'));
|
||||
|
||||
}
|
||||
|
||||
@ -373,6 +375,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
'financial_record_sn' => $financeSn . ($i++)
|
||||
];
|
||||
}
|
||||
//保证金计算
|
||||
if ($_payPrice > 0) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
@ -435,10 +438,11 @@ class StoreOrderRepository extends BaseRepository
|
||||
//自动打印订单
|
||||
$this->autoPrinter($order->order_id, $order->mer_id);
|
||||
}
|
||||
if ($groupOrder->user->spread_uid) {
|
||||
Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_pay_num', 'inc' => 1]);
|
||||
Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_money', 'inc' => $groupOrder->pay_price]);
|
||||
}
|
||||
//分销判断
|
||||
// if ($groupOrder->user->spread_uid) {
|
||||
// Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_pay_num', 'inc' => 1]);
|
||||
// Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_money', 'inc' => $groupOrder->pay_price]);
|
||||
// }
|
||||
app()->make(UserRepository::class)->update($groupOrder->uid, [
|
||||
'pay_count' => Db::raw('pay_count+' . count($groupOrder->orderList)),
|
||||
'pay_price' => Db::raw('pay_price+' . $groupOrder->pay_price),
|
||||
@ -467,7 +471,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]);
|
||||
Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_num', 'inc' => 1]);
|
||||
app()->make(UserBrokerageRepository::class)->incMemberValue($groupOrder->uid, 'member_pay_num', $groupOrder->group_order_id);
|
||||
event('order.paySuccess', compact('groupOrder'));
|
||||
// event('order.paySuccess', compact('groupOrder'));
|
||||
//店内扫码支付
|
||||
if (isset($groupOrder['micro_pay']) && $groupOrder['micro_pay'] == 1) {
|
||||
$order = $this->dao->search(['uid' => $groupOrder->uid])->where('group_order_id', $groupOrder->group_order_id)->find();
|
||||
|
@ -51,6 +51,7 @@ use think\db\exception\ModelNotFoundException;
|
||||
use think\Exception;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
use think\facade\Queue;
|
||||
use think\facade\Route;
|
||||
use think\Model;
|
||||
@ -688,18 +689,19 @@ class MerchantRepository extends BaseRepository
|
||||
public function autoMargin($income, $order, $finance, $financeSn, $index = 0)
|
||||
{
|
||||
$merchant = Merchant::find($this->merId);
|
||||
//商户保证金未完全缴纳且设置了自动扣除比例
|
||||
if ($merchant['margin'] <= $merchant['paid_margin'] || ($this->forceMargin === false && $merchant['auto_margin_rate'] <= 0 && $merchant['auto_margin_rate'] > 100)) {
|
||||
$margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');
|
||||
//商户保证金大于支付保证金 或者forceMargin==false 直接返回 不计算保证金
|
||||
if ($merchant['paid_margin']>= $margin|| ($this->forceMargin === false && $merchant['auto_margin_rate'] == 0)) {
|
||||
return [$income, $finance, false];
|
||||
}
|
||||
$rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate'];
|
||||
//商户保证金未完全缴纳且设置了自动扣除比例
|
||||
$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];
|
||||
}
|
||||
// //商户保证金未完全缴纳且设置了自动扣除比例
|
||||
$margin = bcmul($income, bcdiv($rate, 100,2), 2);
|
||||
// $margin = min(bcsub($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,
|
||||
@ -741,7 +743,7 @@ class MerchantRepository extends BaseRepository
|
||||
throw new \Exception('merchant 保存出错', 500);
|
||||
}
|
||||
|
||||
return [$income, $finance, true];
|
||||
return [bcsub($income,$margin), $finance, true];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -279,14 +279,20 @@ class Auth extends BaseController
|
||||
return app('json')->fail('用户店铺异常');
|
||||
}
|
||||
if($merchant['margin'] == 0){
|
||||
return app('json')->fail('当前金额为0,不能进行充值');
|
||||
$margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');
|
||||
$margin = bcsub($margin,$merchant['paid_margin'],2);
|
||||
if($margin==0){
|
||||
return app('json')->fail('当前金额为0,不能进行充值');
|
||||
}
|
||||
}else{
|
||||
$margin=0;
|
||||
}
|
||||
$orderSn = "bzj" . date('YmdHis') . uniqid();
|
||||
Db::name('margin_order')->insert([
|
||||
'uid' => $user['uid'],
|
||||
'mer_id' => $merchant['mer_id'],
|
||||
'order_sn' => $orderSn,
|
||||
'total_price' => $merchant['margin'],
|
||||
'total_price' => $margin,
|
||||
'pay_type' => 1,
|
||||
'create_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
@ -296,10 +302,10 @@ class Auth extends BaseController
|
||||
"mer_id" => $merchant['mer_id'],
|
||||
"pay_type" => 1,
|
||||
"attach" => "margin",
|
||||
"order_info" => '{"is_margin":1,"margin":"' . $merchant['margin'] . '"}',
|
||||
"pay_price" => $merchant['margin'],
|
||||
"order_info" => '{"is_margin":1,"margin":"' . $margin . '"}',
|
||||
"pay_price" => $margin,
|
||||
"order_sn" => $orderSn,
|
||||
"body" => $merchant['mer_name'] . ' - ' . $merchant['margin'],
|
||||
"body" => $merchant['mer_name'] . ' - ' . $margin,
|
||||
];
|
||||
$payType = 'weixinApp';
|
||||
$service = new PayService($payType, $param);
|
||||
|
@ -268,7 +268,11 @@ class Merchant extends BaseController
|
||||
if(empty($merchantInfo)){
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$merchantInfo['unpaid_margin'] = $merchantInfo['margin'];
|
||||
$margin = Db::name('MerchantType')->where('mer_type_id', $merchantInfo['type_id'])->value('margin');
|
||||
$merchantInfo['unpaid_margin'] = bcsub($margin,$merchantInfo['paid_margin'],2);
|
||||
if($merchantInfo['margin']==0){
|
||||
$merchantInfo['margin']=$merchantInfo['unpaid_margin'];
|
||||
}
|
||||
return app('json')->success($merchantInfo);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class paySuccessMargin
|
||||
//已支付的保证金
|
||||
$paidMarginAmount = bcadd($merchantInfo['paid_margin'], $marginInfo['total_price'], 2);
|
||||
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'])->where('uid', $marginInfo['uid'])->update([
|
||||
'paid_margin' => $paidMarginAmount
|
||||
'paid_margin' => $paidMarginAmount,'ot_margin'=>$paidMarginAmount
|
||||
]);
|
||||
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'])->where('uid', $marginInfo['uid'])->update([
|
||||
'margin' => 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user