diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 971cbc4f..639e4e1c 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -43,6 +43,7 @@ use think\facade\Db; use think\facade\Log; use think\facade\Queue; use crmeb\jobs\SendSmsJob; +use app\controller\api\Ceshi; /** * Class Auth @@ -54,6 +55,32 @@ class Auth extends BaseController { public function test() { + $type = $this->request->param('type'); + $res=[]; + switch ($type) { + case 1: + $res = (app()->make(Ceshi::class))->Merchant_reconciliation_download(); + break; + case 2: + $res = (app()->make(Ceshi::class))->Pay(); + break; + case 3: + $res = (app()->make(Ceshi::class))->SettlementQuery(); + break; + case 4: + $res = (app()->make(Ceshi::class))->OrderClosure(); + break; + case 5: + $res = (app()->make(Ceshi::class))->OrderQuery(); + break; + case 6: + $res = (app()->make(Ceshi::class))->refund(); + break; + case 7: + $res = (app()->make(Ceshi::class))->NoticeSettlement(); + break; + } + return app('json')->success(json_decode($res, true)); // $data = [ // 'tempId' => '', // 'id' => '', @@ -152,18 +179,18 @@ class Auth extends BaseController if (systemConfig('member_status')) $data['member_icon'] = $this->request->userInfo()->member->brokerage_icon ?? ''; if ($data['is_svip'] == 3) - $data['svip_endtime'] = date('Y-m-d H:i:s',strtotime("+100 year")); + $data['svip_endtime'] = date('Y-m-d H:i:s', strtotime("+100 year")); - $day = date('Y-m-d',time()); - $key = 'sign_'.$user['uid'].'_'.$day; + $day = date('Y-m-d', time()); + $key = 'sign_' . $user['uid'] . '_' . $day; $data['sign_status'] = false; if (Cache::get($key)) { - $data['sign_status'] = true; + $data['sign_status'] = true; } else { - $nu = app()->make(UserSignRepository::class)->getSign($user->uid,$day); + $nu = app()->make(UserSignRepository::class)->getSign($user->uid, $day); if ($nu) { $data['sign_status'] = true; - Cache::set($key,true, new \DateTime($day.' 23:59:59')); + Cache::set($key, true, new \DateTime($day . ' 23:59:59')); } } $data['is_wsxx'] = 0; @@ -171,7 +198,7 @@ class Auth extends BaseController $data['mer_info'] = []; // 判断是否是商户,并且有没有完善信息 //这里有点小问题以后要修改 - $store_service = Db::name('store_service')->where('uid', $data['uid'])->where('is_del', 0)->find(); + $store_service = Db::name('store_service')->where('uid', $data['uid'])->find(); if ($store_service) { $mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->where('status', 1)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name')->find(); if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') { @@ -387,7 +414,7 @@ class Auth extends BaseController public function verify(UserAuthValidate $validate) { - $data = $this->request->params(['phone', ['type', 'login'],['captchaType', ''], ['captchaVerification', ''],'token']); + $data = $this->request->params(['phone', ['type', 'login'], ['captchaType', ''], ['captchaVerification', ''], 'token']); //二次验证 try { aj_captcha_check_two($data['captchaType'], $data['captchaVerification']); @@ -423,14 +450,14 @@ class Auth extends BaseController public function smsLogin(UserAuthValidate $validate, UserRepository $repository) { - $data = $this->request->params(['phone', 'sms_code', 'spread', 'auth_token',['user_type','h5']]); + $data = $this->request->params(['phone', 'sms_code', 'spread', 'auth_token', ['user_type', 'h5']]); $validate->sceneSmslogin()->check($data); $sms_code = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['sms_code'], 'login'); if (!$sms_code) return app('json')->fail('验证码不正确'); $user = $repository->accountByUser($data['phone']); $auth = $this->parseAuthToken($data['auth_token']); if (!$user) $user = $repository->registr($data['phone'], null, $data['user_type']); - if ($auth && !$user['wechat_user_id']){ + if ($auth && !$user['wechat_user_id']) { $repository->syncBaseAuth($auth, $user); } $user = $repository->mainUser($user); @@ -479,7 +506,7 @@ class Auth extends BaseController */ public function register(UserAuthValidate $validate, UserRepository $repository) { - $data = $this->request->params(['phone', 'sms_code', 'spread', 'pwd', 'auth_token',['user_type','h5']]); + $data = $this->request->params(['phone', 'sms_code', 'spread', 'pwd', 'auth_token', ['user_type', 'h5']]); $validate->check($data); $sms_code = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['sms_code'], 'login'); if (!$sms_code) @@ -488,7 +515,7 @@ class Auth extends BaseController if ($user) return app('json')->fail('用户已存在'); $auth = $this->parseAuthToken($data['auth_token']); $user = $repository->registr($data['phone'], $data['pwd'], $data['user_type']); - if ($auth){ + if ($auth) { $repository->syncBaseAuth($auth, $user); } $user = $repository->mainUser($user); @@ -566,9 +593,9 @@ class Auth extends BaseController } else if ($auth['type'] === 'app_wechat') { $oauth = WechatService::create()->getApplication()->oauth; try { - $wechatInfo = $oauth->user(new AccessToken(['access_token'=>$data['code'],'openid'=>$data['openid']]))->getOriginal(); + $wechatInfo = $oauth->user(new AccessToken(['access_token' => $data['code'], 'openid' => $data['openid']]))->getOriginal(); } catch (Exception $e) { - throw new ValidateException('授权失败[001]'.$e->getMessage()); + throw new ValidateException('授权失败[001]' . $e->getMessage()); } $user = app()->make(WechatUserRepository::class)->syncAppUser($wechatInfo['unionid'], $wechatInfo, 'App', $createUser); if (!$user) @@ -584,7 +611,7 @@ class Auth extends BaseController if (null === ($payload = JWT::jsonDecode(JWT::urlsafeB64Decode($bodyb64)))) { throw new ValidateException('Invalid header encoding'); } - if($payload->sub != $data['openId']){ + if ($payload->sub != $data['openId']) { throw new ValidateException('授权失败'); } $user = app()->make(WechatUserRepository::class)->syncAppUser($data['openId'], [ @@ -766,8 +793,8 @@ class Auth extends BaseController */ public function ajcaptcha() { - $captchaType = $this->request->get('captchaType'); - if (!$captchaType) return app('json')->fail('请输入类型'); + $captchaType = $this->request->get('captchaType'); + if (!$captchaType) return app('json')->fail('请输入类型'); return app('json')->success(aj_captcha_create($captchaType)); } @@ -777,9 +804,9 @@ class Auth extends BaseController */ public function ajcheck() { - $token = $this->request->param('token',''); - $pointJson = $this->request->param('pointJson',''); - $captchaType = $this->request->param('captchaType',''); + $token = $this->request->param('token', ''); + $pointJson = $this->request->param('pointJson', ''); + $captchaType = $this->request->param('captchaType', ''); try { aj_captcha_check_one($captchaType, $token, $pointJson); diff --git a/app/controller/api/Ceshi.php b/app/controller/api/Ceshi.php new file mode 100644 index 00000000..221892d6 --- /dev/null +++ b/app/controller/api/Ceshi.php @@ -0,0 +1,325 @@ + 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560202000200000100", + "version": "1.0.0" + }, + "body": { + "mchtNo": "129765100270890", + "settleDate": "20200820", + "reqTime": "20200816153647", + "reqSsn": "c7c12347878pca8b5555d8d3630553as" + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } + public function Pay() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560202000200000500", + "version" :"1.0.0" + + }, + "body": { + "charset": "UTF-8", + "orderType": "01", + "orderNumber": "f7c646fd1d8pca8b5555d8d363075392", + "orderCurrency": "01", + "subject": "测试商品", + "channel": "02", + "orderSendTime": "20200713093647", + "orderAmt": "10", + "version": "1.0.0", + "payAmt": "10", + "backEndUrl": "http://www.testpay.com/backEndU", + "frontEndUrl": "http://www.testpay.com/frontEndUrl", + "merId": "129765100270890", + "orderDetailList": { + "payType": "", + "merLst": [ + { + "subOrderAmt": "10", + "orderNumber": "f7c646fd1d8pca8b5555d8d363075392", + "merId": "129765100270890", + "subPayAmt": "10", + "autoSettleFlag": "0", + "goodsInfo": [ + { + "goodsSubject": "测试商品", + "goodsPrice": "10", + "goodsUnit": "斤", + "goodsNum": "1", + "goodsTotalAmt": "10", + "goodsSpec": "10" + } + ] + } + ], + "orderAmt": "10", + "payAmt": "10" + } + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } + public function SettlementQuery() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560202000200000200", + "version" :"1.0.0" + + }, + "body": { + "charset": "UTF-8", + "orderNumber": "f7jugi1dlhna8b5555d8d363075392", + "subOrderNumber":"f7jugi1dlhna8b5555d8d363075392", + "settleMerNo":"129765100270890", + "merId":"129765100270890", + "version":"V5.0.0" + + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } + + public function OrderClosure() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560102000200000100", + "version" :"1.0.0" + + }, + "body": { + "orderNumber":"b16808d20c4e4e9eb7224e49756d456f", + "merId":"129765100278888" + + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } + + public function OrderQuery() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560202000200000000", + "version" :"1.0.0" + + }, + "body": { + "charset":"UTF-8", + "orderNumber":"f7c646fd1d8pca8b5555d8d363075393", + "merId":"129765100270890", + "version":"v5.0.0", + "tranType":"04" + + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } + + public function refund() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560202000200000400", + "version" :"1.0.0" + + }, + "body": { + "charset":"UTF-8", + "orderNumber":"f7c646mlkd8pca8b5555d8d363075abc", + "merNo":"129765100270890", + "channel":"02", + "oriSubOrderNumber":"f7jugi1d8pca8b5555d8d363075392", + "merId":"129765100270890", + "orderSendTime":"20200713093647", + "orderAmt":"10", + "oriOrderNumber":"f7jugi1d8pca8b5555d8d363075392", + "version":"V5.0.0", + "backEndUrl":"https://www.testpay.com/refund" + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } + public function NoticeSettlement() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => '*/*', + 'Host' => '127.0.0.1:23552', + 'Connection' => 'keep-alive' + ]; + $body = '{ + "header": { + "appId": "000000000010012", + "appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec", + "openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541", + "appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9", + "openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1", + "appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7", + "httpDomainName": "https://open-test.scrcu.com:9051/open-gate", + "apiUrl": "/onlinepay/OPC321560202000200000400", + "version" :"1.0.0" + + }, + "body": { + "charset":"UTF-8", + "orderNumber":"f7c646mlkd8pca8b5555d8d363075abc", + "merNo":"129765100270890", + "channel":"02", + "oriSubOrderNumber":"f7jugi1d8pca8b5555d8d363075392", + "merId":"129765100270890", + "orderSendTime":"20200713093647", + "orderAmt":"10", + "oriOrderNumber":"f7jugi1d8pca8b5555d8d363075392", + "version":"V5.0.0", + "backEndUrl":"https://www.testpay.com/refund" + } +}'; + $client = new Client(['base_uri' => 'http://127.0.0.1:23552']); + $request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body); + try { + $res = $client->send($request); + } catch (GuzzleException $e) { + halt($e); + } + return $res->getBody()->getContents(); + } +} \ No newline at end of file