From 4c70a3a85168fe11e96f7cc90d682780aa3f3bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=96=E5=8F=AB?= <392494244@qq.com> Date: Sat, 9 Dec 2023 15:37:08 +0800 Subject: [PATCH] 1 --- app/api/controller/food/User.php | 18 ++++++++++++++---- app/store/config/food.php | 4 ++++ app/store/controller/food/User.php | 2 +- app/store/view/food/user/tpl/tp_recharge1.html | 1 + app/store/view/food/user/wx_index.html | 1 + .../eb/300fe116b3568a7e80a6c2812b1a38.php | 2 +- 6 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 app/store/view/food/user/tpl/tp_recharge1.html create mode 100644 app/store/view/food/user/wx_index.html diff --git a/app/api/controller/food/User.php b/app/api/controller/food/User.php index 6cad09e..e42ed85 100644 --- a/app/api/controller/food/User.php +++ b/app/api/controller/food/User.php @@ -154,10 +154,10 @@ class User extends Controller } $data = Db::name('food_coupon_user_wx')->where($where)->select(); - $data['list'] = $data; - $data['wx_openid'] = $openid ?? ''; + $arr['list'] = json_decode($data,true); + $arr['wx_openid'] = $openid ?? ''; - return $this->renderSuccess($data, '成功'); + return $this->renderSuccess($arr, '成功'); } @@ -172,6 +172,11 @@ class User extends Controller { $post = $this->request->post(); + + if (!isset($post['openid']) && !isset($post['coupon_id'])) { + return $this->renderError('你没核销权限'); + } + $user = Db::name('user_wx')->where(['wx_openid' => $post['openid']])->value('is_role'); if (empty($user) || $user == 0) { return $this->renderError('你没核销权限'); @@ -182,6 +187,11 @@ class User extends Controller 'coupon_user_id' => $post['coupon_id'], ]; + $status = Db::name('food_coupon_user_wx')->where($where)->value('status'); + if ($status == 2) { + return $this->renderError('该优惠券已核销'); + } + $data = Db::name('food_coupon_user_wx')->where($where)->update(['status' => 2]); return $this->renderSuccess($data, '成功'); } @@ -235,7 +245,7 @@ class User extends Controller if (!empty($coupon_id)) { //优惠券详情 - $url = 'https://app.cxhxy.h5.dev.1nww.com/#/pages/details/details?coupon_id=' . $coupon_id; + $url = 'https://app.cxhxy.h5.dev.1nww.com/#/pages/details/details?coupon_id=' . $coupon_id . '&openid=' . $openid; } else { //优惠券列表 $url = 'https://app.cxhxy.h5.dev.1nww.com/#/?openid=' . $openid; diff --git a/app/store/config/food.php b/app/store/config/food.php index 9e00f13..cccf687 100644 --- a/app/store/config/food.php +++ b/app/store/config/food.php @@ -240,6 +240,10 @@ return [ [ 'name' => '用户列表', 'index' => 'food.user/index', + ], + [ + 'name' => '公众号用户', + 'index' => 'food.user/wx_index', ], [ 'name' => '交易记录', diff --git a/app/store/controller/food/User.php b/app/store/controller/food/User.php index ab74686..2184438 100644 --- a/app/store/controller/food/User.php +++ b/app/store/controller/food/User.php @@ -1 +1 @@ -getList(false); $model = new UserModel; $list = $model->getList($gender, $search); return View::fetch('index', compact('list','shop','gender','search')); } /** * 用户充值 *$recharge 接收表单数据(数组) *$source 0为充值余额,1为充值积分 */ public function recharge() { if ($this->request->isPost()) { $model = new RecordModel; $data = $this->postData('data'); if($this->shop_mode == 10){ $data['shop_id'] = $this->shop_id; } if ($model->add($data)) { return $this->renderSuccess('添加成功', url('food.user/index')); } $error = $model->getError() ?: '添加失败'; return $this->renderError($error); } return redirect(url('food.user/index')); } } \ No newline at end of file +getList(false); $model = new UserModel; $list = $model->getList($gender, $search); return View::fetch('index', compact('list', 'shop', 'gender', 'search')); } /** * 用户列表 * @param string $gender * @param string $search * @return string * @throws \think\db\exception\DbException */ public function wx_index($gender = 'all', $search = '') { $list = \think\facade\Db::name('user_wx')->where([])->field('id,nickname,headimgurl,is_role,create_time')->select()->toArray(); foreach ($list as $key => $value) { $list[$key]['create_time'] = date('Y-m-d H:i:s'); $list[$key]['is_role'] = $value['is_role'] == 1 ? '核销员' : '用户'; } View::assign('list', $list); return View::fetch('wx_index'); } /** * 用户充值 *$recharge 接收表单数据(数组) *$source 0为充值余额,1为充值积分 */ public function recharge() { if ($this->request->isPost()) { $model = new RecordModel; $data = $this->postData('data'); if ($this->shop_mode == 10) { $data['shop_id'] = $this->shop_id; } if ($model->add($data)) { return $this->renderSuccess('添加成功', url('food.user/index')); } $error = $model->getError() ?: '添加失败'; return $this->renderError($error); } return redirect(url('food.user/index')); } /** * 用户充值 *$recharge 接收表单数据(数组) *$source 0为充值余额,1为充值积分 */ public function recharge1() { if ($this->request->isPost()) { $data = $this->request->post(); $info = \think\facade\Db::name('user_wx')->where(['id' => $data['id']])->update(['is_role' => $data['is_role']]); if ($info) { return $this->renderSuccess('成功', url('food.user/wx_index')); } return $this->renderError('失败'); } return redirect(url('food.user/wx_index')); } } \ No newline at end of file diff --git a/app/store/view/food/user/tpl/tp_recharge1.html b/app/store/view/food/user/tpl/tp_recharge1.html new file mode 100644 index 0000000..34b5c34 --- /dev/null +++ b/app/store/view/food/user/tpl/tp_recharge1.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/store/view/food/user/wx_index.html b/app/store/view/food/user/wx_index.html new file mode 100644 index 0000000..60ad9a4 --- /dev/null +++ b/app/store/view/food/user/wx_index.html @@ -0,0 +1 @@ +{layout name="layout/food" /}
用户列表
{if !empty($list)} {foreach $list as $item} {/foreach} {else /} {/if}
ID 头像 昵称 关注时间 是否是审核员 操作
{$item['id']} {$item['nickname']|default='--'} {$item['create_time']|default='--'} {$item['is_role']|default='--'}
暂无记录
{include file="food/user/tpl/tp_recharge1" /} \ No newline at end of file diff --git a/runtime/cache/eb/300fe116b3568a7e80a6c2812b1a38.php b/runtime/cache/eb/300fe116b3568a7e80a6c2812b1a38.php index 32eaf40..7ece428 100644 --- a/runtime/cache/eb/300fe116b3568a7e80a6c2812b1a38.php +++ b/runtime/cache/eb/300fe116b3568a7e80a6c2812b1a38.php @@ -1,4 +1,4 @@ -1701879149 \ No newline at end of file +1702106311 \ No newline at end of file