1. 更新 UserWithdrawController.php 文件,优化用户提现逻辑。
2. 更新 MerchantLogic.php 文件,优化商户逻辑
This commit is contained in:
parent
99c2020aa2
commit
358dfe078b
@ -56,10 +56,9 @@ class UserWithdrawController extends BaseApiController
|
|||||||
public function withdraw()
|
public function withdraw()
|
||||||
{
|
{
|
||||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('withdraw');
|
$params = (new MerchantWithdrawValidate())->post()->goCheck('withdraw');
|
||||||
// $uid = $this->request->userInfo['user_id'];
|
$uid = $this->request->userId;
|
||||||
// $merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
// $merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||||
// $supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||||
$supplier = $this->request->userInfo['supplier'];
|
|
||||||
if (!$supplier) {
|
if (!$supplier) {
|
||||||
return $this->fail('当前用户非供应商');
|
return $this->fail('当前用户非供应商');
|
||||||
}
|
}
|
||||||
@ -94,6 +93,8 @@ class UserWithdrawController extends BaseApiController
|
|||||||
'admin_id' => 0,
|
'admin_id' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
|
$supplier->mer_money =bcsub($supplier->mer_money, $params['amount'], 2);
|
||||||
|
$supplier->save();
|
||||||
(new MerchantWithdraw)->save($save_data);
|
(new MerchantWithdraw)->save($save_data);
|
||||||
return $this->success('提现成功,等待管理员审核');
|
return $this->success('提现成功,等待管理员审核');
|
||||||
// }else{
|
// }else{
|
||||||
|
@ -19,14 +19,17 @@ class MerchantLogic extends BaseLogic
|
|||||||
public static function amount_account($merchant)
|
public static function amount_account($merchant)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$mer_money = Merchant::where('mer_id', $merchant['mer_id'])->value('mer_money');
|
||||||
$bank_list = MerchantBank::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->select()->each(function ($data) {
|
$bank_list = MerchantBank::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->select()->each(function ($data) {
|
||||||
$bank_info = Bank::where('id', $data['bank_id'])->findOrEmpty();
|
$bank_info = Bank::where('id', $data['bank_id'])->findOrEmpty();
|
||||||
$data['bank_name'] = !$bank_info->isEmpty() ? $bank_info['name'] : '';
|
$data['bank_name'] = !$bank_info->isEmpty() ? $bank_info['name'] : '';
|
||||||
$data['bank_image'] = !$bank_info->isEmpty() ? $bank_info['image'] : '';
|
$data['bank_image'] = !$bank_info->isEmpty() ? $bank_info['image'] : '';
|
||||||
return $data;
|
return $data;
|
||||||
})->toArray();
|
})->toArray();
|
||||||
return $bank_list;
|
return [
|
||||||
|
'balance' => $mer_money,
|
||||||
|
'bank_list' => $bank_list
|
||||||
|
];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
@ -53,6 +56,8 @@ class MerchantLogic extends BaseLogic
|
|||||||
'admin_id' => 0,
|
'admin_id' => 0,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
|
$merchant->mer_money =bcsub($merchant->mer_money, $params['amount'], 2);
|
||||||
|
$merchant->save();
|
||||||
(new MerchantWithdraw)->save($save_data);
|
(new MerchantWithdraw)->save($save_data);
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -64,7 +69,8 @@ class MerchantLogic extends BaseLogic
|
|||||||
/**
|
/**
|
||||||
* 提现信息
|
* 提现信息
|
||||||
*/
|
*/
|
||||||
public static function taking_info($merchant){
|
public static function taking_info($merchant)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$total_amount = MerchantWithdraw::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->where('is_arrival', 1)->sum('amount');
|
$total_amount = MerchantWithdraw::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->where('is_arrival', 1)->sum('amount');
|
||||||
$count = MerchantWithdraw::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->where('is_arrival', 1)->count();
|
$count = MerchantWithdraw::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->where('is_arrival', 1)->count();
|
||||||
@ -73,6 +79,5 @@ class MerchantLogic extends BaseLogic
|
|||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user