更新保证金

This commit is contained in:
yaooo 2023-09-25 17:48:49 +08:00
parent 26d680995e
commit 55d8a5b1d0
5 changed files with 12 additions and 14 deletions

View File

@ -116,7 +116,7 @@ class MerchantIntentionRepository extends BaseRepository
$margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']);
$data['is_margin'] = $margin['is_margin'] ?? -1;
$data['margin'] = 0;
$data['margin'] = $margin['margin'] ?? 0;
$merData = [];
if ($create) {
$password = substr($intention['phone'], -6);
@ -138,9 +138,7 @@ class MerchantIntentionRepository extends BaseRepository
'mer_password' => $password,
'is_margin' => $margin['is_margin'] ?? -1,
// 用户需缴纳保证金
'recharge_margin' => $margin['margin'] ?? 0,
// 用户已缴纳保证金
'margin' => 0,
'margin' => $margin['margin'] ?? 0,
'uid' => $intention['uid'],
'reg_admin_id' => $autoCreate ? 0: request()->adminId(),
'mer_intention_id' => $id

View File

@ -98,7 +98,7 @@ class ServeOrderRepository extends BaseRepository
$arr = [
'type_id' => $ret['type_id'],
'is_margin' => $ret['is_margin'],
'margin' => $ret['recharge_margin'],
'margin' => $ret['margin'],
];
$param = [
'status' => 0,
@ -109,7 +109,7 @@ class ServeOrderRepository extends BaseRepository
'pay_type' => $data['pay_type'],
'attach' => 'meal',
'order_info' => json_encode($arr,JSON_UNESCAPED_UNICODE),
'pay_price' => $ret['recharge_margin'],
'pay_price' => $ret['margin'],
];
return compact('key', 'param');

View File

@ -286,7 +286,7 @@ class Auth extends BaseController
'uid' => $user['uid'],
'mer_id' => $merchant['mer_id'],
'order_sn' => $orderSn,
'total_price' => $merchant['recharge_margin'],
'total_price' => $merchant['margin'],
'pay_type' => 1,
'create_time' => date('Y-m-d H:i:s')
]);
@ -296,10 +296,10 @@ class Auth extends BaseController
"mer_id" => $merchant['mer_id'],
"pay_type" => 1,
"attach" => "margin",
"order_info" => '{"is_margin":1,"margin":"' . $merchant['recharge_margin'] . '"}',
"pay_price" => $merchant['recharge_margin'],
"order_info" => '{"is_margin":1,"margin":"' . $merchant['margin'] . '"}',
"pay_price" => $merchant['margin'],
"order_sn" => $orderSn,
"body" => $merchant['mer_name'] . ' - ' . $merchant['recharge_margin'],
"body" => $merchant['mer_name'] . ' - ' . $merchant['margin'],
];
$payType = 'weixinApp';
$service = new PayService($payType, $param);

View File

@ -264,7 +264,7 @@ class Merchant extends BaseController
if(empty($id)){
return app('json')->fail('参数错误');
}
$data = Db::name('merchant')->where('mer_id',$id)->field('uid,mer_id,mer_name,margin,recharge_margin,is_margin')->find();
$data = Db::name('merchant')->where('mer_id',$id)->field('uid,mer_id,mer_name,margin,paid_margin,is_margin')->find();
return app('json')->success($data);
}

View File

@ -26,11 +26,11 @@ class paySuccessMargin
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([
'margin' => $marginAmount
]);
$rechargeAmount = (float)$merchantInfo['recharge_margin'] - (float)$marginInfo['total_price'];
$paidAmount = (float)$merchantInfo['paid_margin'] - (float)$marginInfo['total_price'];
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([
'recharge_margin' => $rechargeAmount
'paid_margin' => $paidAmount
]);
if ($rechargeAmount <= 0) {
if ($paidAmount <= 0) {
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([
'is_margin' => 10
]);