repository = $repository; $this->source = $this->request->header('source'); $this->merId = $this->request->header('merId'); } public function lst() { [$page,$limit] = $this->getPage(); $where = $this->request->params(['status', 'type']); $where['uid'] = $this->request->uid(); return app('json')->success($this->repository->serach($where,$page,$limit)); } /** * @param $phone * @param $code * @return bool * @author Qinii * @day 2020-06-12 */ public function checkSmsCode($phone, $code) { $sms_key = 'api.auth.sms.' . $phone; if (!$cache_code = Cache::get($sms_key)) return false; if ($code != $cache_code) return false; Cache::delete($sms_key); return true; } /** * 申请提现 * extract_type 1微信 2支付宝 * @param validate $validate * @return mixed */ public function create(validate $validate) { $data = $this->checkParams($validate); $user = $this->request->userInfo(); $uid = $this->request->uid(); $type = $this->request->param('type', 1);//1-佣金 2-会员商品直推佣金 3红包 $sms_code = $this->request->param('sms_code'); // if (!$this->checkSmsCode($user['account'], $sms_code) && $sms_code != '6865'){ // return app('json')->fail('验证码不正确'); // } if(!in_array($data["extract_type"],[1,2,3])){ return app('json')->fail('不支持的类型,请选择微信或支付宝'); } if (!$data['extract_price']) return app('json')->fail('请输入提现金额'); if ($type == 1) { if ($data['extract_price'] < (systemConfig('withdrawal_money'))) return app('json')->fail('未到达提现最低额度'); if ($user['brokerage_price'] < $data['extract_price']) return app('json')->fail('提现金额不足'); if ($data['extract_type'] == 3){ if (!$data['bank_id']) return app('json')->fail('请选择银行卡信息'); } if($data["extract_type"] == 1){ $user_extract_openid=Db::name('user_extract_openid')->where('uid',$uid)->find(); if(!$user_extract_openid || $user_extract_openid['openid']==''){ return app('json')->fail('请先绑定提现微信'); } } }elseif ($type == 3) { if ($data['extract_price'] < (systemConfig('withdrawal_money'))) return app('json')->fail('未到达提现最低额度'); if ($user['hongbao'] < $data['extract_price']) return app('json')->fail('提现金额不足'); if ($data['extract_type'] == 3){ if (!$data['bank_id']) return app('json')->fail('请选择银行卡信息'); } if($data["extract_type"] == 1){ $user_extract_openid=Db::name('user_extract_openid')->where('uid',$uid)->find(); if(!$user_extract_openid || $user_extract_openid['openid']==''){ return app('json')->fail('请先绑定提现微信'); } } }else{ if ($user['member_brokerage_price'] < (systemConfig('withdrawal_money'))) return app('json')->fail('未到达提现最低额度'); if ($user['member_brokerage_price'] < $data['extract_price']) return app('json')->fail('提现金额不足'); } $res = $this->repository->create($user,$data,$uid,$type); if ($res == true){ return app('json')->success('申请已提交'); }else{ return app('json')->fail('申请提现失败:'.$data["extract_type"]); // return app('json')->success(["code"=>2,"msg"=>"请绑定账号"]); } } public function checkParams(validate $validate) { $data = $this->request->params(['extract_type','bank_id','bank_code','bank_address','alipay_code','wechat','extract_pic','extract_price','real_name']); // $validate->check($data); return $data; } public function bankLst() { [$page,$limit] = $this->getPage(); $data = app()->make(GroupDataRepository::class)->groupData('bank_list',0,$page,$limit); return app('json')->success($data); } /** * type 1微信 2支付宝 * account 账号 * info 1 收款码 / 2 姓名 * @return mixed */ public function band_account(){ $type=input("type/d","1"); $account=input("account/s",""); $info=input("info/s",""); $uid = $this->request->uid(); $res=$this->repository->band_account($type,$account,$info,$uid); return app('json')->success($res); } public function band_openid(){ $type=input("type/d","1"); $openid=input("openid",""); $nickname = input("nickname", ""); $avatar = input("avatar", ""); if(empty($openid)){ return app('json')->fail("绑定微信失败"); } $uid = $this->request->uid(); $res=$this->repository->band_openid($openid,$uid, $nickname, $avatar); if($res){ return app('json')->success('绑定成功'); } return app('json')->fail("此微信已绑定其他账户"); } /** * type 1微信 2支付宝 * @return mixed */ public function get_band_account_info(){ $type=input("type/d","1"); $uid = $this->request->uid(); $res= $this->repository->band_account_info($type,$uid); if ($res){ return app('json')->success("绑定成功"); }else{ return app('json')->fail("请绑定"); } } public function withdrawal_notify($type) { // Db::name('log')->insert(['data'=>'支付宝提现回调1111']); $data=$this->request->param(); // Db::name('log')->insert(['data'=>'支付宝提现回调'.json_encode($data)]); Log::info($data); switch ($type){ case 'zfb': $aop =new AopCertClient(); $aop->alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArHwMZtNYBkK5q2jQ0Ml18H8MhQX9Bpuz/ignvuJC47K7LHY+F6/U/+o/nYeDhqHzUajMAAyM06N3r2qBnWQRjC4JKFMO4i5xIDVycuumzcsWz3LwAkHOFG/S1pGXFWh74zdQDNednhvnNOiTDwjefZRnf5HUqEZK/7tRSaZvzSUIAwHG2zj0C6AYkhg5wr6ZJxgRDjPjqbs6ZMqLT+pITsnCcc6IgIisZbPTdtw1U2FKmQm5n228drI3XKYbE3UVT2y6R0mZNmqmiHDszmYSKOjDrpgtMExWpee8kUFn7J800HIyYtq0nRv1ypdWngUZtkm+szVWOTDGgN4eHQW3FwIDAQAB"; $flag = $aop->rsaCheckV1($data, dirname(__FILE__). '/../../../../extend/alipay/aop/cert/alipayCertPublicKey.crt', "RSA2"); if($flag){ $biz_content=json_decode($data['biz_content'],true); // Db::name('log')->insert(['data'=>'支付宝提现回调验签成功']); Db::name('entropy_barter_bill')->where('order_no',$biz_content['out_biz_no'])->where('pm',2)->update(['status'=>2,'remarks'=>'已到账']); Db::name('user_extract')->where('order_sn',$biz_content['out_biz_no'])->update(['status'=>1]); // $bill=Db::name('entropy_barter_bill')->where('order_no',$biz_content['out_biz_no'])->where('pm',2)->find(); // $mer_id=Db::name('user_extract')->where('order_sn',$biz_content['out_biz_no'])->value('mer_id'); // Db::name('entropy_barter_user_'.$mer_id)->where('eb_id',$bill['to_id'])->dec('wallet',$bill['number'])->update(); echo "success"; }else{ // Db::name('log')->insert(['data'=>'支付宝提现回调验签失败']); echo "error"; } case 'wx': } } }