|
|
@@ -13,6 +13,7 @@ namespace App\Services;
|
|
|
|
|
|
use App\Models\MemberModel;
|
|
|
use App\Models\RechargeModel;
|
|
|
+use App\Models\WithdrawModel;
|
|
|
|
|
|
/**
|
|
|
* 提现记录管理-服务类
|
|
|
@@ -31,7 +32,7 @@ class WithdrawService extends BaseService
|
|
|
*/
|
|
|
public function __construct()
|
|
|
{
|
|
|
- $this->model = new RechargeModel();
|
|
|
+ $this->model = new WithdrawModel();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -127,8 +128,63 @@ class WithdrawService extends BaseService
|
|
|
return parent::edit($data); // TODO: Change the autogenerated stub
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户工资提现
|
|
|
+ * @param $userId
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
public function withdraw($userId){
|
|
|
$params = request()->all();
|
|
|
+ $money = isset($params['money'])? $params['money'] : 0;
|
|
|
+ if($money<=0){
|
|
|
+ return message('提现金额错误', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证提现限制
|
|
|
+ $limitMin = ConfigService::make()->getConfigByCode('withdraw_min');
|
|
|
+ if($money > $limitMin){
|
|
|
+ return message('最低提现金额为:'.$limitMin.'元', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证账户
|
|
|
+ $memberInfo = MemberModel::where(['id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->select(['id','openid','nickname','salary'])
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if(!$memberInfo){
|
|
|
+ return message('账户不可操作或已冻结,请联系客服', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($memberInfo->salary < $money){
|
|
|
+ return message('可提现金额不足', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理
|
|
|
+ $data = [
|
|
|
+ 'order_sn'=> get_order_num('T'),
|
|
|
+ 'user_id'=> $userId,
|
|
|
+ 'pay_type'=> isset($params['pay_type'])? $params['pay_type'] : 1,
|
|
|
+ 'money'=> $money,
|
|
|
+ 'balance'=> $memberInfo->salary,
|
|
|
+ 'realname'=> isset($params['realname'])? $params['realname'] : '',
|
|
|
+ 'account'=> isset($params['account'])? $params['account'] : '',
|
|
|
+ 'qrcode'=> isset($params['qrcode'])? $params['qrcode'] : '',
|
|
|
+ 'remark'=> isset($params['remark'])? $params['remark'] : '',
|
|
|
+ 'status'=> 2,
|
|
|
+ ];
|
|
|
+
|
|
|
+ \DB::beginTransaction();
|
|
|
+ if(!MemberModel::where(['id'=> $userId,'mark'=> 1])->descrement('salary', $money)){
|
|
|
+ \DB::rollBack();
|
|
|
+ return message('更新账户失败,请刷新后重试',false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!$this->model::insertGetId($data)){
|
|
|
+ \DB::rollBack();
|
|
|
+ return message('提现处理失败,请刷新后重试',false);
|
|
|
+ }
|
|
|
|
|
|
+ \DB::commit();
|
|
|
+ return message('提现申请成功,请耐心等候审核打款',true);
|
|
|
}
|
|
|
}
|