作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

提现恢复

@@ -840,36 +840,36 @@ class User extends Api @@ -840,36 +840,36 @@ class User extends Api
840 !empty(cache('withdraw_token'.$this->auth->id)) && $this->error('提现频繁,请稍后再试'); 840 !empty(cache('withdraw_token'.$this->auth->id)) && $this->error('提现频繁,请稍后再试');
841 cache('withdraw_token'.$this->auth->id,'123',5); 841 cache('withdraw_token'.$this->auth->id,'123',5);
842 842
843 -// Db::startTrans();  
844 -// try{  
845 -// $withdraw = Withdraw::create([  
846 -// 'user_id' => $this->auth->id,  
847 -// 'order_sn' => get_order_sn(),  
848 -// 'money' => $money,  
849 -// ]);  
850 -// // 变更会员余额  
851 -// UserModel::money(-$money,$this->auth->id,'提现',['withdraw_id' => $withdraw['id']]);  
852 -//  
853 -// // 发起企业付款  
854 -// $Wechat = new Wechat;  
855 -// $openid = Db::name('third')->where('user_id',$this->auth->id)->value('openid');  
856 -// if(!$balance = $Wechat->toBalance($withdraw['order_sn'], $openid, $withdraw['money'] * 100)){  
857 -// $this->error($Wechat->getError());  
858 -// }  
859 -// // 记录企业付款单号  
860 -// $withdraw->payment_no = $balance['payment_no'];  
861 -// $withdraw->payment_time = $balance['payment_time'];  
862 -// $withdraw->status = '1';  
863 -// $withdraw->save();  
864 -//  
865 -// Db::commit();  
866 -// } catch (PDOException $e) {  
867 -// Db::rollback();  
868 -// $this->error($e->getMessage());  
869 -// } catch (Exception $e) {  
870 -// Db::rollback();  
871 -// $this->error($e->getMessage());  
872 -// } 843 + Db::startTrans();
  844 + try{
  845 + $withdraw = Withdraw::create([
  846 + 'user_id' => $this->auth->id,
  847 + 'order_sn' => get_order_sn(),
  848 + 'money' => $money,
  849 + ]);
  850 + // 变更会员余额
  851 + UserModel::money(-$money,$this->auth->id,'提现',['withdraw_id' => $withdraw['id']]);
  852 +
  853 + // 发起企业付款
  854 + $Wechat = new Wechat;
  855 + $openid = Db::name('third')->where('user_id',$this->auth->id)->value('openid');
  856 + if(!$balance = $Wechat->toBalance($withdraw['order_sn'], $openid, $withdraw['money'] * 100)){
  857 + $this->error($Wechat->getError());
  858 + }
  859 + // 记录企业付款单号
  860 + $withdraw->payment_no = $balance['payment_no'];
  861 + $withdraw->payment_time = $balance['payment_time'];
  862 + $withdraw->status = '1';
  863 + $withdraw->save();
  864 +
  865 + Db::commit();
  866 + } catch (PDOException $e) {
  867 + Db::rollback();
  868 + $this->error($e->getMessage());
  869 + } catch (Exception $e) {
  870 + Db::rollback();
  871 + $this->error($e->getMessage());
  872 + }
873 $this->success('成功'); 873 $this->success('成功');
874 } 874 }
875 875