From 4c8b8df8249d44d4718aa56124a35c55ed8001ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=96=E5=8F=AB?= <392494244@qq.com> Date: Fri, 8 Dec 2023 17:01:53 +0800 Subject: [PATCH] 1 --- app/api/controller/food/User.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/api/controller/food/User.php b/app/api/controller/food/User.php index 49b6c8f..1f908ca 100644 --- a/app/api/controller/food/User.php +++ b/app/api/controller/food/User.php @@ -135,12 +135,15 @@ class User extends Controller public function getWxUserCoupon() { $post = $this->request->get(); - $where = [ - 'openid' => $post['openid'], - ]; - if (isset($post['id'])) { - $where['coupon_user_id'] = $post['id']; + + if (isset($post['coupon_id'])) { + $where['coupon_user_id'] = $post['coupon_id']; } + + if (isset($post['openid'])) { + $where['openid'] = $post['openid']; + } + $data = Db::name('food_coupon_user_wx')->where($where)->select(); return $this->renderSuccess($data, '成功'); } @@ -200,9 +203,6 @@ class User extends Controller return $this->renderError('授权失败'); } $coupon_id = $_GET['coupon_id'] ?? ''; - - write_log($coupon_id, __DIR__); - $appid = 'wx89c12dd426a55a2e'; $app_secret = '33e66bcf944f9810abbb5ddd7825403d'; $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$app_secret&code={$get['code']}&grant_type=authorization_code"; @@ -229,9 +229,6 @@ class User extends Controller $url = 'https://app.cxhxy.h5.dev.1nww.com/#/?openid=' . $openid; } - write_log($url, __DIR__); - - return redirect($url); } }