From e373631ff390990ed9825f4e41ebeac8d1a14dc0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 5 Jun 2024 12:36:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=99=A8=E5=92=8CAPI=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=92=8C=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ExceptionHandler.php | 2 +- app/api/controller/IndexController.php | 88 ++++++++++++++------ app/common/service/wechat/WechatTemplate.php | 2 +- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/app/ExceptionHandler.php b/app/ExceptionHandler.php index 283ba1719..8cfa3719a 100644 --- a/app/ExceptionHandler.php +++ b/app/ExceptionHandler.php @@ -37,6 +37,6 @@ class ExceptionHandler extends Handler return response(json_encode($error, JSON_UNESCAPED_UNICODE)); } // 非json请求则返回一个页面 - return new Response(200, [], $exception->getMessage()); + return new Response(200, [], 'msg:'.$exception->getMessage().'。line:'.$exception->getLine().'。file:'.$exception->getFile()); } } diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 6ffbd56a1..2cb6a7358 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -5,24 +5,60 @@ namespace app\api\controller; use app\admin\validate\tools\GenerateTableValidate; use app\admin\logic\tools\GeneratorLogic; use app\common\logic\store_order\StoreOrderLogic; +use app\common\service\pay\PayService; +use app\common\service\wechat\WechatTemplate; +use Exception; use think\facade\Db; use Webman\Config; use hg\apidoc\annotation as ApiDoc; +use Yansongda\Pay\Exception\InvalidSignException; + #[ApiDoc\NotParse()] class IndexController extends BaseApiController { - public $notNeedLogin = ['index','app_update','express_list','province','city','area','street']; + public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street']; public function index() { + try{ + $a=new WechatTemplate(); + $a->NewQuotationNotification(['openid'=>'ocqhF6UfFQXE-SbzbP5YVQJlQAh0','data1'=>'阿萨','data2'=>date('Y-m-d H:i:s'),'data3'=>'占山','data3'=>18982406440]); + }catch (Exception $e){ + d($e); + } - d(2); - $params=['store_id'=>2,'pay_type'=>17]; - $a=StoreOrderLogic::createOrder([1],0,null,$params); +d(22); + $auth_code = $this->request->get('code'); + $pay = (new PayService()); + $order = [ + 'description' => '条码商品', + 'out_trade_no' => (string)time(), + 'payer' => [ + 'auth_code' => (string)$auth_code + ], + 'amount' => [ + 'total' =>1, + ], + 'scene_info' => [ + "store_info" => [ + 'id' => '1' + ] + ], + ]; + + try{ + $a= $pay->wechat->pos($order); + + }catch (\Exception $th) { + d($th); + } +d($a); + $params = ['store_id' => 2, 'pay_type' => 17]; + $a = StoreOrderLogic::createOrder([1], 0, null, $params); d($a); - return json(['msg' =>create_password(123456, '11d3')]); + return json(['msg' => create_password(123456, '11d3')]); } /** @@ -41,42 +77,46 @@ class IndexController extends BaseApiController /** * @notes 获取app更新信息 */ - public function app_update(){ - $find= Db::name('app_update')->where('type',2)->order('id','desc')->findOrEmpty(); - return $this->success('ok',$find); + public function app_update() + { + $find = Db::name('app_update')->where('type', 2)->order('id', 'desc')->findOrEmpty(); + return $this->success('ok', $find); } /** * @notes 获取省列表 */ - public function province(){ - $list= Db::name('geo_province')->select()->toArray(); - return $this->success('ok',$list); + public function province() + { + $list = Db::name('geo_province')->select()->toArray(); + return $this->success('ok', $list); } /** * @notes 获取市列表 */ - public function city(){ - $province_code=$this->request->get('code'); - $list= Db::name('geo_city')->where('province_code',$province_code)->select()?->toArray(); - return $this->success('ok',$list); + public function city() + { + $province_code = $this->request->get('code'); + $list = Db::name('geo_city')->where('province_code', $province_code)->select()?->toArray(); + return $this->success('ok', $list); } /** * @notes 获取区列表 */ - public function area(){ - $city_code=$this->request->get('code'); - $list= Db::name('geo_area')->where('city_code',$city_code)->select()?->toArray(); - return $this->success('ok',$list); + public function area() + { + $city_code = $this->request->get('code'); + $list = Db::name('geo_area')->where('city_code', $city_code)->select()?->toArray(); + return $this->success('ok', $list); } /** * @notes 获取街道列表 */ - public function street(){ - $area_code=$this->request->get('area_code'); - $list= Db::name('geo_street')->where('area_code',$area_code)->select()?->toArray(); - return $this->success('ok',$list); + public function street() + { + $area_code = $this->request->get('area_code'); + $list = Db::name('geo_street')->where('area_code', $area_code)->select()?->toArray(); + return $this->success('ok', $list); } - } diff --git a/app/common/service/wechat/WechatTemplate.php b/app/common/service/wechat/WechatTemplate.php index 52d6c660c..bff36b478 100644 --- a/app/common/service/wechat/WechatTemplate.php +++ b/app/common/service/wechat/WechatTemplate.php @@ -49,7 +49,7 @@ class WechatTemplate 'data' => [ 'thing2' => ['value' => $data['data1']], 'thing3' => ['value' => $data['data2']], - 'const4' => ['value' => $data['data3']??08302669767], + 'const4' => ['value' => $data['data3']??'08302669767'], ] ]; return $this->post($template);