This commit is contained in:
尖叫 2023-12-09 15:37:08 +08:00
parent c7e68c97ac
commit 4c70a3a851
6 changed files with 22 additions and 6 deletions

View File

@ -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;

View File

@ -240,6 +240,10 @@ return [
[
'name' => '用户列表',
'index' => 'food.user/index',
],
[
'name' => '公众号用户',
'index' => 'food.user/wx_index',
],
[
'name' => '交易记录',

View File

@ -1 +1 @@
<?php namespace app\store\controller\food; use app\store\controller\food\Controller; use app\store\model\food\Shop as ShopModel; use app\store\model\food\User as UserModel; use app\store\model\food\Record as RecordModel; use think\facade\View; /** * 用户管理 */ class User extends Controller { /** * 用户列表 */ public function index($gender = 'all', $search = '') { $model = new ShopModel; $shop = $model->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')); } }
<?php namespace app\store\controller\food; use app\store\controller\food\Controller; use app\store\model\food\Shop as ShopModel; use app\store\model\food\User as UserModel; use app\store\model\food\Record as RecordModel; use think\Db; use think\facade\View; /** * 用户管理 */ class User extends Controller { /** * 用户列表 */ public function index($gender = 'all', $search = '') { $model = new ShopModel; $shop = $model->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')); } }

View File

@ -0,0 +1 @@
<!-- 模板:用户充值 --> <script id="tpl-recharge1" type="text/template"> <div class="am-padding-xs am-padding-top-sm"> <div class="am-form-group"> <label class="am-u-sm-3 am-form-label">操作方式</label> <input type="hidden" name="id" value="{{ user_id }}"> <div class="am-u-sm-8 am-u-end"> <label class="am-radio-inline"> <input type="radio" name="is_role" value="0" data-am-ucheck checked> 用户 </label> <label class="am-radio-inline"> <input type="radio" name="is_role" value="1" data-am-ucheck> 核销员 </label> </div> </div> </div> </script>

View File

@ -0,0 +1 @@
{layout name="layout/food" /} <div class="row-content am-cf"> <div class="row"> <div class="am-u-sm-12 am-u-md-12 am-u-lg-12"> <div class="widget am-cf"> <div class="widget-head am-cf"> <div class="widget-title am-cf">用户列表</div> </div> <div class="widget-body am-fr"> <!-- 工具栏 --> <div class="page_toolbar am-margin-bottom am-cf"> <form class="toolbar-form" action="{:url('food.user/wx_index')}"> <div class="am-u-sm-12"> <div class="am fr"> </div> </div> </form> </div> <div class="am-scrollable-horizontal am-u-sm-12"> <table width="100%" class="am-table am-table-hover tpl-table-black"> <thead> <tr> <th>ID</th> <th>头像</th> <th>昵称</th> <th>关注时间</th> <th>是否是审核员</th> <th>操作</th> </tr> </thead> <tbody> {if !empty($list)} {foreach $list as $item} <tr> <td class="am-text-middle">{$item['id']}</td> <td class="am-text-middle"> <img src="{$item['headimgurl']}" width="72" height="72" alt=""> </td> <td class="am-text-middle">{$item['nickname']|default='--'}</td> <td class="am-text-middle">{$item['create_time']|default='--'}</td> <td class="am-text-middle">{$item['is_role']|default='--'}</td> <td class="am-text-middle"> <div class="tpl-table-black-operation"> <a class="j-recharge tpl-table-black-operation-default" href="javascript:void(0);" title="核销员" data-user_id="{$item['id']}" <i class="iconfont icon-qiandai"></i>变更核销员 </a> </div> </td> </tr> {/foreach} {else /} <tr> <td colspan="12" class="am-text-center">暂无记录</td> </tr> {/if} </tbody> </table> </div> <div class="am-u-lg-12 am-cf"> <div class="am-fr"></div> <div class="am-fr pagination-total am-margin-right"> <!-- <div class="am-vertical-align-middle">总记录:</div>--> </div> </div> </div> </div> </div> </div> </div> {include file="food/user/tpl/tp_recharge1" /} <script> $(function () { /** * 账户充值 */ $('.j-recharge').on('click', function () { var data = $(this).data(); $.showAction({ title: '核销员变更', area: '460px', content: template('tpl-recharge1', data), uCheck: true, success: function ($content) { $('#my-form').formPost({ url: "{:url('food.user/recharge1')}" }); }, btn2: function ($content) { return true; } }); }); }); </script>

View File

@ -1,4 +1,4 @@
<?php
//000000000600
exit();?>
1701879149
1702106311