作者 lihan

我的资料、我的优惠券、我要充值

@@ -17,6 +17,9 @@ class ActivityController extends HomeBaseController @@ -17,6 +17,9 @@ class ActivityController extends HomeBaseController
17 * @url /activity/Activity/_list 17 * @url /activity/Activity/_list
18 * @method POST 18 * @method POST
19 * 19 *
  20 + * @param name:t_id type:int require:1 default:2 desc:活动分类id
  21 + * @param name:keyword type:char require:1 default:2 desc:关键词
  22 + *
20 * @return version:版本号 23 * @return version:版本号
21 * @return code:错误码 24 * @return code:错误码
22 */ 25 */
@@ -28,13 +31,14 @@ class ActivityController extends HomeBaseController @@ -28,13 +31,14 @@ class ActivityController extends HomeBaseController
28 $type = Db::name('type')->field('type_name,type_url,type_icon')->order('listorder')->select(); 31 $type = Db::name('type')->field('type_name,type_url,type_icon')->order('listorder')->select();
29 //活动 32 //活动
30 $model = new ActivityModel; 33 $model = new ActivityModel;
31 - $activity = $model->activityList('', time(), session('user.id')); 34 + $t_id = request()->param('t_id');
  35 + $keyword = request()->param('keyword');
  36 + $activity = $model->activityList($t_id, time(), session('user.id'), $keyword);
32 $result = [ 37 $result = [
33 'banner' => $banner, 38 'banner' => $banner,
34 'type' => $type, 39 'type' => $type,
35 'activity' => $activity 40 'activity' => $activity
36 ]; 41 ];
37 - //  
38 echo json_encode(['data' => $result, 'code' => 20000]); 42 echo json_encode(['data' => $result, 'code' => 20000]);
39 exit(); 43 exit();
40 } 44 }
@@ -17,17 +17,21 @@ class ActivityModel extends Model @@ -17,17 +17,21 @@ class ActivityModel extends Model
17 * @param null $tId 17 * @param null $tId
18 * @param $nowTime 18 * @param $nowTime
19 * @param $userId 19 * @param $userId
20 - * @return false|\PDOStatement|string|\think\Collection 20 + * @param null $keyword
  21 + * @return array
21 * @throws \think\db\exception\DataNotFoundException 22 * @throws \think\db\exception\DataNotFoundException
22 * @throws \think\db\exception\ModelNotFoundException 23 * @throws \think\db\exception\ModelNotFoundException
23 * @throws \think\exception\DbException 24 * @throws \think\exception\DbException
24 */ 25 */
25 - public function activityList($tId = null, $nowTime, $userId) 26 + public function activityList($tId = null, $nowTime, $userId, $keyword=null)
26 { 27 {
27 $where = []; 28 $where = [];
28 if ($tId != null) { 29 if ($tId != null) {
29 $where['t_id'] = ['eq', $tId]; 30 $where['t_id'] = ['eq', $tId];
30 } 31 }
  32 + if ($keyword != null) {
  33 + $where['name'] = ['like', "%$keyword%"];
  34 + }
31 $res = Db::name('activity')->field('id,name,thumb')->where($where)->select()->toArray(); 35 $res = Db::name('activity')->field('id,name,thumb')->where($where)->select()->toArray();
32 //只显示还未到报名日期活动最近的一条行程 36 //只显示还未到报名日期活动最近的一条行程
33 foreach ($res as $key => $item) { 37 foreach ($res as $key => $item) {
@@ -61,10 +65,18 @@ class ActivityModel extends Model @@ -61,10 +65,18 @@ class ActivityModel extends Model
61 65
62 private function allSchedule($activityId) 66 private function allSchedule($activityId)
63 { 67 {
64 - $res = Db::name('activity_schedule')->field('start_time,end_time,price')->where(['activity_id' => $activityId])->select(); 68 + $res = Db::name('activity_schedule')
  69 + ->field('id as schedule_id,start_time,end_time,price,maximum,real_join_num,addition_join_num')
  70 + ->where(['activity_id' => $activityId])
  71 + ->select();
65 foreach ($res as $k => $v) { 72 foreach ($res as $k => $v) {
66 $v['start_time'] = date('Y-m-d', $v['start_time']); 73 $v['start_time'] = date('Y-m-d', $v['start_time']);
67 $v['end_time'] = date('Y-m-d', $v['end_time']); 74 $v['end_time'] = date('Y-m-d', $v['end_time']);
  75 + $v['sales_num'] = $v['real_join_num'] + $v['addition_join_num'];
  76 + $v['residue_num'] = $v['maximum'] - $v['sales_num'];
  77 + unset($v['real_join_num']);
  78 + unset($v['addition_join_num']);
  79 + unset($v['maximum']);
68 $res[$k] = $v; 80 $res[$k] = $v;
69 } 81 }
70 return $res; 82 return $res;
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/8/30
  6 + * Time: 14:29
  7 + */
  8 +namespace app\admin\controller;
  9 +use cmf\controller\AdminBaseController;
  10 +use think\Db;
  11 +
  12 +class DiscountCouponController extends AdminBaseController
  13 +{
  14 +
  15 + public function add()
  16 + {
  17 + $request = request();
  18 + if ($request->isPost()) {
  19 + $post = $request->param();
  20 + if (empty($post['discount_coupon_name'])) {
  21 + $this->error('请输入优惠券名称');
  22 + }
  23 + if (empty($post['overflow']) || $post['overflow'] < 0) {
  24 + $this->error('请输入正确满减金额');
  25 + }
  26 + if (empty($post['reduce']) || $post['reduce'] < 0) {
  27 + $this->error('请输入正确满减金额');
  28 + }
  29 + if (empty($post['deadline'])) {
  30 + $this->error('请选择截止日期');
  31 + }
  32 + if (empty($post['user_id'])) {
  33 + $this->error('请匹配用户');
  34 + }
  35 + $n = count($post['user_id']);
  36 + $data = [];
  37 + for ($i = 0; $i < $n; $i++) {
  38 + $data[$i] = array(
  39 + 'user_id' => $post['user_id'][$i],
  40 + 'discount_coupon_name' => $post['discount_coupon_name'],
  41 + 'overflow' => $post['overflow'],
  42 + 'reduce' => $post['reduce'],
  43 + 'deadline' => strtotime($post['deadline']),
  44 + 'status' => 1
  45 + );
  46 + }
  47 + if (Db::name('discount_coupon')->insertAll($data)) {
  48 + $this->success('创建优惠券成功');
  49 + } else {
  50 + $this->error('创建优惠券失败');
  51 + }
  52 + } else {
  53 + return $this->fetch('', [
  54 + 'user' => $this->getUserList()
  55 + ]);
  56 + }
  57 + }
  58 +
  59 + public function index()
  60 + {
  61 + $posts = Db::name('discount_coupon')->alias('d')->field('sami_discount_coupon.id,discount_coupon_name,deadline,user_nickname,status')
  62 + ->join('sami_user u', 'u.id=d.user_id')
  63 + ->order("id DESC")
  64 + ->paginate(20);
  65 + return $this->fetch('', [
  66 + 'posts' => $posts,
  67 + 'page' => $posts->render()
  68 + ]);
  69 + }
  70 +
  71 + public function getUserList()
  72 + {
  73 + $keywords = request()->param('keywords');
  74 + $map = array();
  75 + $map['user_type'] = ['eq', 2];
  76 + if (!empty($keywords)) {
  77 + $map['user_nickname'] = array('like', "%$keywords%");
  78 + }
  79 + $user = Db::name('user')->field('id,user_nickname')->where($map)->select();
  80 + $html = '<tr>
  81 + <th><input type="checkbox" id="All" onclick="checkAll()"></th>
  82 + <th width="300"><input style="width: 200px; display: unset" class="form-control" type="text" placeholder="搜索" id="Search" value="' . $keywords . '" onchange="ajax()">&nbsp;&nbsp;&nbsp;搜索</th>
  83 + </tr>';
  84 + foreach ($user as $item) {
  85 + $html .= '<tr>
  86 + <td><input type="checkbox" name="user_id[]" value="' . $item['id'] . '"></td>
  87 + <td>' . $item['user_nickname'] . '</td>
  88 + </tr>';
  89 + }
  90 + if (request()->isAjax()) {
  91 + echo json_encode(['data' => $html]);
  92 + exit();
  93 + } else {
  94 + return $user;
  95 + }
  96 + }
  97 +
  98 + public function edit()
  99 + {
  100 + $request = request();
  101 + $id = $request->param('id');
  102 + if ($request->isPost()) {
  103 + $post = $request->param();
  104 + if (empty($post['discount_coupon_name'])) {
  105 + $this->error('请输入优惠券名称');
  106 + }
  107 + if (empty($post['overflow']) || $post['overflow'] < 0) {
  108 + $this->error('请输入正确满减金额');
  109 + }
  110 + if (empty($post['reduce']) || $post['reduce'] < 0) {
  111 + $this->error('请输入正确满减金额');
  112 + }
  113 + if (empty($post['deadline'])) {
  114 + $this->error('请选择截止日期');
  115 + }
  116 + $post['id'] = $id;
  117 + $post['deadline'] = strtotime($post['deadline']);
  118 + if (Db::name('discount_coupon')->update($post)) {
  119 + $this->success('编辑优惠券成功');
  120 + } else {
  121 + $this->error('您未作出任何修改');
  122 + }
  123 + } else {
  124 + return $this->fetch('', [
  125 + 'id' => $id,
  126 + 'info' => Db::name('discount_coupon')->where(array('id' => $id))->find()
  127 + ]);
  128 + }
  129 + }
  130 +
  131 + public function del()
  132 + {
  133 + $id = request()->param('id');
  134 + if (Db::name('discount_coupon')->delete($id)) {
  135 + $this->success('销毁成功');
  136 + } else {
  137 + $this->error('销毁失败');
  138 + }
  139 + }
  140 +
  141 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/9/5
  6 + * Time: 15:03
  7 + */
  8 +namespace app\coupons\model;
  9 +use think\Model;
  10 +use think\Db;
  11 +
  12 +class CouponModel extends Model
  13 +{
  14 + public function getAllDiscountCouponByUniqueIdAndByStatus($status = null, $user_id)
  15 + {
  16 + if ($status == null) {
  17 + $status = 1;
  18 + }
  19 + $map['status'] = array('eq', $status);
  20 + $map['user_id'] = array('eq', $user_id);
  21 + $res = Db::name('discount_coupon')->field('id,reduce,discount_coupon_name,deadline')->where($map)->select()->toArray();
  22 + foreach ($res as $key => $item) {
  23 + $item['deadline'] = date('Y-m-d', $item['deadline']);
  24 + $res[$key] = $item;
  25 + }
  26 + return $res;
  27 + }
  28 +
  29 +}
@@ -11,8 +11,6 @@ class EscortController extends HomeBaseController @@ -11,8 +11,6 @@ class EscortController extends HomeBaseController
11 11
12 function _initialize() 12 function _initialize()
13 { 13 {
14 - header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求  
15 - header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');  
16 if (empty(session('user.id'))) { 14 if (empty(session('user.id'))) {
17 echo json_encode(['msg' => '登陆失败', 'code' => 40001]); 15 echo json_encode(['msg' => '登陆失败', 'code' => 40001]);
18 exit(); 16 exit();
@@ -23,6 +23,7 @@ class IndexController extends HomeBaseController @@ -23,6 +23,7 @@ class IndexController extends HomeBaseController
23 function __construct() 23 function __construct()
24 { 24 {
25 session('user.id', 2); 25 session('user.id', 2);
  26 + echo session('user.id');
26 } 27 }
27 28
28 /** 29 /**
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/9/5
  6 + * Time: 10:48
  7 + */
  8 +
  9 +namespace app\user\controller;
  10 +use app\coupons\model\CouponModel;
  11 +use cmf\controller\HomeBaseController;
  12 +use Think\Db;
  13 +use app\coupons\model\DiscountCouponModel;
  14 +
  15 +/**
  16 + * @title 个人中心模块
  17 + */
  18 +class CenterController extends HomeBaseController
  19 +{
  20 +
  21 + function __construct()
  22 + {
  23 + session('user.id', 2);
  24 + if (empty(session('user.id'))) {
  25 + echo json_encode(['msg' => '登陆失败', 'code' => 40001]);
  26 + exit();
  27 + }
  28 + }
  29 +
  30 + /**
  31 + * @title 我的资料
  32 + * @description 默认访问接口(post方式更改用户信息需要填写参数,post以外是模板渲染用户信息)
  33 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  34 + * @url /user/Center/myInfo
  35 + * @method GET
  36 + *
  37 + * @param name:realname type:char require:1 default:李涵 desc:真实姓名
  38 + * @param name:tel type:char require:1 default:15122554644 desc:手机号
  39 + * @param name:wechat type:char require:1 default:xxxxxx desc:微信号
  40 + * @param name:identity type:char require:1 default:12010319960501291X desc:身份证号
  41 + *
  42 + * @return version:版本号
  43 + * @return code:错误码
  44 + */
  45 + public function myInfo()
  46 + {
  47 + $request = request();
  48 + if ($request->isPost()) {
  49 + $post = $request->param();
  50 + if ($post['realname'] == null) {
  51 + echo json_encode(['msg' => '请填写真实姓名', 'code' => 40000]);
  52 + exit();
  53 + }
  54 + if ($post['tel'] == null) {
  55 + echo json_encode(['msg' => '请填写手机号', 'code' => 40000]);
  56 + exit();
  57 + }
  58 + if ($post['wechat'] == null) {
  59 + echo json_encode(['msg' => '请填写微信号', 'code' => 40000]);
  60 + exit();
  61 + }
  62 + if ($post['identity'] == null) {
  63 + echo json_encode(['msg' => '请填写身份证信息', 'code' => 40000]);
  64 + exit();
  65 + }
  66 + $post['id'] = session('user.id');
  67 + if (Db::name('user')->update($post)) {
  68 + echo json_encode(['data' => '更改成功', 'code' => 20000]);
  69 + exit();
  70 + } else {
  71 + echo json_encode(['data' => '您为做出任何修改', 'code' => 40000]);
  72 + exit();
  73 + }
  74 +
  75 + } else {
  76 + $userInfo = Db::name('user')->field('avatar,user_nickname,realname,tel,wechat,identity')
  77 + ->where(['id' => session('user.id')])
  78 + ->find();
  79 + echo json_encode(['data' => $userInfo, 'code' => 20000]);
  80 + exit();
  81 + }
  82 + }
  83 +
  84 + /**
  85 + * @title 我的优惠券
  86 + * @description 默认访问接口
  87 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  88 + * @url /user/Center/discountCoupon
  89 + * @method POST
  90 + *
  91 + * @param name:status type:char require:1 default:1 desc:1未使用2已使用3已过期
  92 + *
  93 + * @return version:版本号
  94 + * @return code:错误码
  95 + * @return id:优惠券id
  96 + * @return reduce:减
  97 + * @return discount_coupon_name:优惠券名称
  98 + * @return deadline:截止日期
  99 + */
  100 + public function discountCoupon()
  101 + {
  102 + $request = request();
  103 + if ($request->isPost()) {
  104 + $post = $request->param();
  105 + $user_id = session('user.id');
  106 + $model = new CouponModel;
  107 + $data = $model->getAllDiscountCouponByUniqueIdAndByStatus($post['status'], $user_id);
  108 + if (empty($data)) {
  109 + echo json_encode(['msg' => '暂无数据', 'code' => 40000]);
  110 + exit();
  111 + } else {
  112 + echo json_encode(['data' => $data, 'code' => 20000]);
  113 + exit();
  114 + }
  115 + }
  116 + }
  117 +
  118 + /**
  119 + * @title 我要充值
  120 + * @description 默认访问接口
  121 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  122 + * @url /user/Center/charge
  123 + * @method POST
  124 + *
  125 + * @param name:is_bonus type:int require:1 default:0 desc:0普通充值1活动专享
  126 + *
  127 + * @return version:版本号
  128 + * @return code:错误码
  129 + * @return id:充值卡id
  130 + * @return denomination:面值
  131 + * @return bonus:赠送金额
  132 + */
  133 + public function charge()
  134 + {
  135 + $is_bonus = request()->param('is_bonus');
  136 + $where['is_on_sale'] = ['eq', 1];
  137 + $is_bonus = (empty($is_bonus)) ? 0 : 1;
  138 + $where['is_bonus'] = ['eq', $is_bonus];
  139 + $field = 'id,denomination';
  140 + if ($is_bonus == 1) {
  141 + $field .= ',bonus';
  142 + }
  143 + $res = Db::name('charge')->field($field)->where($where)->select()->toArray();
  144 + echo json_encode(['data' => $res, 'code' => 20000]);
  145 + exit();
  146 + }
  147 +
  148 +}
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="#A" data-toggle="tab">生成</a></li>
  7 + </ul>
  8 + <form class="form-horizontal margin-top-20" action="{:url('DiscountCoupon/add')}" method="post">
  9 + <div class="tabbable" style="float: left;">
  10 + <div class="tab-content">
  11 + <div class="tab-pane active" id="A">
  12 + <fieldset>
  13 + <div class="control-group">
  14 + <label class="control-label">优惠券名称</label>
  15 + <div class="controls">
  16 + <input class="form-control" type="text" name="discount_coupon_name" value="">
  17 + </div>
  18 + </div>
  19 + <div class="control-group">
  20 + <label class="control-label"></label>
  21 + <div class="controls">
  22 + <input class="form-control" type="number" name="overflow" value="">
  23 + </div>
  24 + </div>
  25 + <div class="control-group">
  26 + <label class="control-label"></label>
  27 + <div class="controls">
  28 + <input class="form-control" type="number" name="reduce" value="">
  29 + </div>
  30 + </div>
  31 + <div class="control-group">
  32 + <label class="control-label">截止日期</label>
  33 + <div class="controls">
  34 + <input type="text" name="deadline" class="form-control js-bootstrap-datetime" autocomplete="off">
  35 + </div>
  36 + </div>
  37 + </fieldset>
  38 + </div>
  39 + </div>
  40 + </div>
  41 + <div class="user_list" style="float: left; margin-left: 100px; width: 350px; height:500px; overflow: scroll; overflow-x:hidden">
  42 + <table class="table table-hover table-bordered table-list" id="TABLE">
  43 + <tr>
  44 + <th><input type="checkbox" id="All" onclick="checkAll()"></th>
  45 + <th><input class="form-control" style="width: 200px; display: unset" type="text" placeholder="关键词" id="Search" onchange="ajax()">&nbsp;&nbsp;搜索</th>
  46 + </tr>
  47 + <volist name="user" id="vo">
  48 + <tr>
  49 + <td><input type="checkbox" name="user_id[]" value="{$vo.id}"></td>
  50 + <td>{$vo.user_nickname}</td>
  51 + </tr>
  52 + </volist>
  53 + </table>
  54 + </div>
  55 + <div style="clear: both">&nbsp;</div>
  56 + <div class="form-actions" style="clear: both">
  57 + <button class="btn btn-primary js-ajax-submit"type="submit">生成</button>
  58 + <a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
  59 + </div>
  60 + </form>
  61 +</div>
  62 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  63 +<script>
  64 + function ajax() {
  65 + $.ajax({
  66 + url:"{:url('DiscountCoupon/getUserList')}",
  67 + data:{
  68 + keywords:$("#Search").val()
  69 + },
  70 + type:"POST",
  71 + dataType:"JSON",
  72 +
  73 + success:function (data) {
  74 + //alert(data.data);
  75 + $("#TABLE").html(data.data);
  76 + }
  77 + })
  78 + }
  79 +
  80 + function checkAll() {
  81 + var input = $("#TABLE input[type='checkbox']");
  82 + var go = true;
  83 + if(input[0].checked === false) {
  84 + go = false;
  85 + }
  86 + for (var i = 1; i <= input.length; i++) {
  87 + input[i].checked = go;
  88 + }
  89 + }
  90 +
  91 +</script>
  92 +</body>
  93 +</html>
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="#A" data-toggle="tab">编辑</a></li>
  7 + </ul>
  8 + <form class="form-horizontal margin-top-20" action="{:url('DiscountCoupon/edit')}" method="post">
  9 + <div class="tabbable" style="float: left">
  10 + <div class="tab-content">
  11 + <div class="tab-pane active" id="A">
  12 + <fieldset>
  13 + <div class="control-group">
  14 + <label class="control-label">优惠券名称</label>
  15 + <div class="controls">
  16 + <input class="form-control" type="text" name="discount_coupon_name" value="{$info.discount_coupon_name}">
  17 + </div>
  18 + </div>
  19 + <div class="control-group">
  20 + <label class="control-label"></label>
  21 + <div class="controls">
  22 + <input class="form-control" type="number" name="overflow" value="{$info.overflow}">
  23 + </div>
  24 + </div>
  25 + <div class="control-group">
  26 + <label class="control-label"></label>
  27 + <div class="controls">
  28 + <input class="form-control" type="number" name="reduce" value="{$info.reduce}">
  29 + </div>
  30 + </div>
  31 + <div class="control-group">
  32 + <label class="control-label">截止日期</label>
  33 + <div class="controls">
  34 + <input class="form-control js-bootstrap-datetime" type="text" name="deadline" value="{$info.deadline|date='Y-m-d H:i',###}" autocomplete="off">
  35 + </div>
  36 + </div>
  37 + </fieldset>
  38 + </div>
  39 + </div>
  40 + </div>
  41 + <div style="clear: both">&nbsp;</div>
  42 + <div class="form-actions" style="clear: both">
  43 + <input type="hidden" name="id" value="{$id}">
  44 + <button class="btn btn-primary js-ajax-submit"type="submit">编辑</button>
  45 + <a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
  46 + </div>
  47 + </form>
  48 +</div>
  49 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  50 +</body>
  51 +</html>
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="javascript:;">优惠券列表</a></li>
  7 + <li><a href="{:url('DiscountCoupon/add')}">生成优惠券</a></li>
  8 + </ul>
  9 + <form class="js-ajax-form" action="" method="post">
  10 + <table class="table table-hover table-bordered table-list">
  11 + <thead>
  12 + <tr>
  13 + <th>序号</th>
  14 + <th>所属人员</th>
  15 + <th>优惠券名称</th>
  16 + <th>截止日期</th>
  17 + <th>状态</th>
  18 + <th>操作</th>
  19 + </tr>
  20 + </thead>
  21 + <volist name="posts" id="vo" key="k">
  22 + <tr>
  23 + <td>{$k}</td>
  24 + <td>{$vo.user_nickname}</td>
  25 + <td>{$vo.discount_coupon_name}</td>
  26 + <td><if condition="$vo.deadline eq '2147483647'">永久<else/>{$vo.deadline|date='Y-m-d',###}</if></td>
  27 + <td>
  28 + <if condition="$vo.status eq '1'">
  29 + <font color="red">未使用</font>
  30 + </if>
  31 + <if condition="$vo.status eq '2'">
  32 + <font color="green">已使用</font>
  33 + </if>
  34 + <if condition="$vo.status eq '3'">
  35 + <font color="#808080">已过期</font>
  36 + </if>
  37 + </td>
  38 + <td>
  39 + <a href="{:url('DiscountCoupon/edit',array('id'=>$vo['id']))}"><font color="#1e90ff">编辑</font></a> |
  40 + <a href="{:url('DiscountCoupon/del',array('id'=>$vo['id']))}" onclick="return isDel()"><font color="red">销毁</font></a>
  41 + </td>
  42 + </tr>
  43 + </volist>
  44 + </table>
  45 + <ul class="pagination">{$page|default=''}</ul>
  46 + </form>
  47 +</div>
  48 +<script src="__PUBLIC__/js/common.js"></script>
  49 +<script>
  50 + function isDel() {
  51 + if(!window.confirm('是否确认销毁优惠券')) {
  52 + return false;
  53 + }else{
  54 + return true;
  55 + }
  56 + }
  57 +</script>
  58 +</body>
  59 +</html>
@@ -4,23 +4,24 @@ namespace Api\Doc; @@ -4,23 +4,24 @@ namespace Api\Doc;
4 class Doc 4 class Doc
5 { 5 {
6 protected $config = [ 6 protected $config = [
7 - 'title'=>'APi接口文档',  
8 - 'version'=>'1.0.0',  
9 - 'copyright'=>'银河百荣科技', 7 + 'title' => 'APi接口文档',
  8 + 'version' => '1.0.0',
  9 + 'copyright' => '银河百荣科技',
10 'controller' => [ 10 'controller' => [
11 'app\portal\controller\IndexController', 11 'app\portal\controller\IndexController',
12 'app\escort\controller\EscortController', 12 'app\escort\controller\EscortController',
13 - 'app\activity\controller\ActivityController' 13 + 'app\activity\controller\ActivityController',
  14 + 'app\user\controller\CenterController'
14 ], 15 ],
15 - 'password'=>'bronet',  
16 - 'static_path'=>'',  
17 - 'filter_method'=>['_empty'], 16 + 'password' => 'bronet',
  17 + 'static_path' => '',
  18 + 'filter_method' => ['_empty'],
18 'return_format' => [ 19 'return_format' => [
19 'code' => "状态码20000/40000+", 20 'code' => "状态码20000/40000+",
20 'msg' => "提示信息", 21 'msg' => "提示信息",
21 ], 22 ],
22 - 'public_header'=>[],  
23 - 'public_param'=>[] 23 + 'public_header' => [],
  24 + 'public_param' => []
24 ]; 25 ];
25 26
26 /** 27 /**
@@ -77,10 +78,8 @@ class Doc @@ -77,10 +78,8 @@ class Doc
77 { 78 {
78 $controller = $this->config['controller']; 79 $controller = $this->config['controller'];
79 $list = []; 80 $list = [];
80 - foreach ($controller as $class)  
81 - {  
82 - if(class_exists($class))  
83 - { 81 + foreach ($controller as $class) {
  82 + if (class_exists($class)) {
84 $module = []; 83 $module = [];
85 $reflection = new \ReflectionClass($class); 84 $reflection = new \ReflectionClass($class);
86 $doc_str = $reflection->getDocComment(); 85 $doc_str = $reflection->getDocComment();
@@ -91,38 +90,36 @@ class Doc @@ -91,38 +90,36 @@ class Doc
91 $method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC); 90 $method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
92 $filter_method = array_merge(['__construct'], $this->config['filter_method']); 91 $filter_method = array_merge(['__construct'], $this->config['filter_method']);
93 $module['actions'] = []; 92 $module['actions'] = [];
94 - foreach ($method as $action){  
95 - if(!in_array($action->name, $filter_method))  
96 - { 93 + foreach ($method as $action) {
  94 + if (!in_array($action->name, $filter_method)) {
97 $doc = new DocParser(); 95 $doc = new DocParser();
98 $doc_str = $action->getDocComment(); 96 $doc_str = $action->getDocComment();
99 - if($doc_str)  
100 - { 97 + if ($doc_str) {
101 $action_doc = $doc->parse($doc_str); 98 $action_doc = $doc->parse($doc_str);
102 - $action_doc['name'] = $class."::".$action->name;  
103 - if(array_key_exists('title', $action_doc)){  
104 - if(array_key_exists('module', $action_doc)){ 99 + $action_doc['name'] = $class . "::" . $action->name;
  100 + if (array_key_exists('title', $action_doc)) {
  101 + if (array_key_exists('module', $action_doc)) {
105 $key = array_search($action_doc['module'], array_column($module['actions'], 'title')); 102 $key = array_search($action_doc['module'], array_column($module['actions'], 'title'));
106 - if($key === false){ 103 + if ($key === false) {
107 $action = $module; 104 $action = $module;
108 $action['title'] = $action_doc['module']; 105 $action['title'] = $action_doc['module'];
109 $action['module'] = $action_doc['module']; 106 $action['module'] = $action_doc['module'];
110 $action['actions'] = []; 107 $action['actions'] = [];
111 array_push($action['actions'], $action_doc); 108 array_push($action['actions'], $action_doc);
112 array_push($module['actions'], $action); 109 array_push($module['actions'], $action);
113 - }else{ 110 + } else {
114 array_push($module['actions'][$key]['actions'], $action_doc); 111 array_push($module['actions'][$key]['actions'], $action_doc);
115 } 112 }
116 - }else{ 113 + } else {
117 array_push($module['actions'], $action_doc); 114 array_push($module['actions'], $action_doc);
118 } 115 }
119 } 116 }
120 } 117 }
121 } 118 }
122 } 119 }
123 - if(array_key_exists('group', $module)){ 120 + if (array_key_exists('group', $module)) {
124 $key = array_search($module['group'], array_column($list, 'title')); 121 $key = array_search($module['group'], array_column($list, 'title'));
125 - if($key === false){ //创建分组 122 + if ($key === false) { //创建分组
126 $floder = [ 123 $floder = [
127 'title' => $module['group'], 124 'title' => $module['group'],
128 'description' => '', 125 'description' => '',
@@ -132,10 +129,10 @@ class Doc @@ -132,10 +129,10 @@ class Doc
132 ]; 129 ];
133 array_push($floder['actions'], $module); 130 array_push($floder['actions'], $module);
134 array_push($list, $floder); 131 array_push($list, $floder);
135 - }else{ 132 + } else {
136 array_push($list[$key]['actions'], $module); 133 array_push($list[$key]['actions'], $module);
137 } 134 }
138 - }else{ 135 + } else {
139 array_push($list, $module); 136 array_push($list, $module);
140 } 137 }
141 } 138 }
@@ -157,21 +154,19 @@ class Doc @@ -157,21 +154,19 @@ class Doc
157 $doc_str = $reflection->getDocComment(); 154 $doc_str = $reflection->getDocComment();
158 $doc = new DocParser(); 155 $doc = new DocParser();
159 $class_doc = $doc->parse($doc_str); 156 $class_doc = $doc->parse($doc_str);
160 - if(array_key_exists('group', $class_doc)){ 157 + if (array_key_exists('group', $class_doc)) {
161 $key = array_search($class_doc['group'], array_column($list, 'title')); 158 $key = array_search($class_doc['group'], array_column($list, 'title'));
162 - if($key === false){ //创建分组 159 + if ($key === false) { //创建分组
163 $floder = [ 160 $floder = [
164 'title' => $class_doc['group'], 161 'title' => $class_doc['group'],
165 'children' => [] 162 'children' => []
166 ]; 163 ];
167 array_push($floder['children'], $class_doc); 164 array_push($floder['children'], $class_doc);
168 array_push($list, $floder); 165 array_push($list, $floder);
169 - }  
170 - else  
171 - { 166 + } else {
172 array_push($list[$key]['children'], $class_doc); 167 array_push($list[$key]['children'], $class_doc);
173 } 168 }
174 - }else{ 169 + } else {
175 array_push($list, $class_doc); 170 array_push($list, $class_doc);
176 } 171 }
177 } 172 }
@@ -188,18 +183,18 @@ class Doc @@ -188,18 +183,18 @@ class Doc
188 public function getInfo($class, $action) 183 public function getInfo($class, $action)
189 { 184 {
190 $action_doc = []; 185 $action_doc = [];
191 - if($class && class_exists($class)){ 186 + if ($class && class_exists($class)) {
192 $reflection = new \ReflectionClass($class); 187 $reflection = new \ReflectionClass($class);
193 $doc_str = $reflection->getDocComment(); 188 $doc_str = $reflection->getDocComment();
194 $doc = new DocParser(); 189 $doc = new DocParser();
195 $class_doc = $doc->parse($doc_str); 190 $class_doc = $doc->parse($doc_str);
196 - $class_doc['header'] = isset($class_doc['header'])? $class_doc['header'] : []; 191 + $class_doc['header'] = isset($class_doc['header']) ? $class_doc['header'] : [];
197 $class_doc['param'] = isset($class_doc['param']) ? $class_doc['param'] : []; 192 $class_doc['param'] = isset($class_doc['param']) ? $class_doc['param'] : [];
198 - if($reflection->hasMethod($action)) { 193 + if ($reflection->hasMethod($action)) {
199 $method = $reflection->getMethod($action); 194 $method = $reflection->getMethod($action);
200 $doc = new DocParser(); 195 $doc = new DocParser();
201 $action_doc = $doc->parse($method->getDocComment()); 196 $action_doc = $doc->parse($method->getDocComment());
202 - $action_doc['name'] = $class."::".$method->name; 197 + $action_doc['name'] = $class . "::" . $method->name;
203 $action_doc['header'] = isset($action_doc['header']) ? array_merge($class_doc['header'], $action_doc['header']) : $class_doc['header']; 198 $action_doc['header'] = isset($action_doc['header']) ? array_merge($class_doc['header'], $action_doc['header']) : $class_doc['header'];
204 $action_doc['param'] = isset($action_doc['param']) ? array_merge($class_doc['param'], $action_doc['param']) : $class_doc['param']; 199 $action_doc['param'] = isset($action_doc['param']) ? array_merge($class_doc['param'], $action_doc['param']) : $class_doc['param'];
205 } 200 }
@@ -216,27 +211,22 @@ class Doc @@ -216,27 +211,22 @@ class Doc
216 { 211 {
217 $controller = $this->config['controller']; 212 $controller = $this->config['controller'];
218 $list = []; 213 $list = [];
219 - foreach ($controller as $class)  
220 - {  
221 - if(class_exists($class))  
222 - { 214 + foreach ($controller as $class) {
  215 + if (class_exists($class)) {
223 $reflection = new \ReflectionClass($class); 216 $reflection = new \ReflectionClass($class);
224 $method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC); 217 $method = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
225 $filter_method = array_merge(['__construct'], $this->config['filter_method']); 218 $filter_method = array_merge(['__construct'], $this->config['filter_method']);
226 - foreach ($method as $action){  
227 - if(!in_array($action->name, $filter_method))  
228 - { 219 + foreach ($method as $action) {
  220 + if (!in_array($action->name, $filter_method)) {
229 $doc = new DocParser(); 221 $doc = new DocParser();
230 $doc_str = $action->getDocComment(); 222 $doc_str = $action->getDocComment();
231 - if($doc_str)  
232 - { 223 + if ($doc_str) {
233 $action_doc = $doc->parse($doc_str); 224 $action_doc = $doc->parse($doc_str);
234 - $action_doc['name'] = $class."::".$action->name;  
235 - if((isset($action_doc['title']) && strpos($action_doc['title'], $keyword) !== false) 225 + $action_doc['name'] = $class . "::" . $action->name;
  226 + if ((isset($action_doc['title']) && strpos($action_doc['title'], $keyword) !== false)
236 || (isset($action_doc['description']) && strpos($action_doc['description'], $keyword) !== false) 227 || (isset($action_doc['description']) && strpos($action_doc['description'], $keyword) !== false)
237 || (isset($action_doc['author']) && strpos($action_doc['author'], $keyword) !== false) 228 || (isset($action_doc['author']) && strpos($action_doc['author'], $keyword) !== false)
238 - || (isset($action_doc['url']) && strpos($action_doc['url'], $keyword) !== false))  
239 - { 229 + || (isset($action_doc['url']) && strpos($action_doc['url'], $keyword) !== false)) {
240 array_push($list, $action_doc); 230 array_push($list, $action_doc);
241 } 231 }
242 } 232 }
@@ -256,17 +246,16 @@ class Doc @@ -256,17 +246,16 @@ class Doc
256 { 246 {
257 $json = '{<br>'; 247 $json = '{<br>';
258 $data = $this->config['return_format']; 248 $data = $this->config['return_format'];
259 - foreach ($data as $name=>$value) {  
260 - $json .= '&nbsp;&nbsp;"'.$name.'":'.$value.',<br>'; 249 + foreach ($data as $name => $value) {
  250 + $json .= '&nbsp;&nbsp;"' . $name . '":' . $value . ',<br>';
261 } 251 }
262 $json .= '&nbsp;&nbsp;"data":{<br/>'; 252 $json .= '&nbsp;&nbsp;"data":{<br/>';
263 $returns = isset($doc['return']) ? $doc['return'] : []; 253 $returns = isset($doc['return']) ? $doc['return'] : [];
264 - foreach ($returns as $val)  
265 - { 254 + foreach ($returns as $val) {
266 list($name, $value) = explode(":", trim($val)); 255 list($name, $value) = explode(":", trim($val));
267 - if(strpos($value, '@') != false){ 256 + if (strpos($value, '@') != false) {
268 $json .= $this->string2jsonArray($doc, $val, '&nbsp;&nbsp;&nbsp;&nbsp;'); 257 $json .= $this->string2jsonArray($doc, $val, '&nbsp;&nbsp;&nbsp;&nbsp;');
269 - }else{ 258 + } else {
270 $json .= '&nbsp;&nbsp;&nbsp;&nbsp;' . $this->string2json(trim($name), $value); 259 $json .= '&nbsp;&nbsp;&nbsp;&nbsp;' . $this->string2json(trim($name), $value);
271 } 260 }
272 } 261 }
@@ -281,11 +270,12 @@ class Doc @@ -281,11 +270,12 @@ class Doc
281 * @param $val 270 * @param $val
282 * @return string 271 * @return string
283 */ 272 */
284 - private function string2json($name, $val){  
285 - if(strpos($val,'#') != false){  
286 - return '"'.$name.'": ["'.str_replace('#','',$val).'"],<br/>';  
287 - }else {  
288 - return '"'.$name.'":"'.$val.'",<br/>'; 273 + private function string2json($name, $val)
  274 + {
  275 + if (strpos($val, '#') != false) {
  276 + return '"' . $name . '": ["' . str_replace('#', '', $val) . '"],<br/>';
  277 + } else {
  278 + return '"' . $name . '":"' . $val . '",<br/>';
289 } 279 }
290 } 280 }
291 281
@@ -296,28 +286,29 @@ class Doc @@ -296,28 +286,29 @@ class Doc
296 * @param $space 286 * @param $space
297 * @return string 287 * @return string
298 */ 288 */
299 - private function string2jsonArray($doc, $val, $space){ 289 + private function string2jsonArray($doc, $val, $space)
  290 + {
300 list($name, $value) = explode(":", trim($val)); 291 list($name, $value) = explode(":", trim($val));
301 $json = ""; 292 $json = "";
302 - if(strpos($value, "@!") != false){  
303 - $json .= $space.'"'.$name.'":{//'.str_replace('@!','',$value).'<br/>';  
304 - }else{  
305 - $json .= $space.'"'.$name.'":[{//'.str_replace('@','',$value).'<br/>'; 293 + if (strpos($value, "@!") != false) {
  294 + $json .= $space . '"' . $name . '":{//' . str_replace('@!', '', $value) . '<br/>';
  295 + } else {
  296 + $json .= $space . '"' . $name . '":[{//' . str_replace('@', '', $value) . '<br/>';
306 } 297 }
307 $return = isset($doc[$name]) ? $doc[$name] : []; 298 $return = isset($doc[$name]) ? $doc[$name] : [];
308 - if(preg_match_all('/(\w+):(.*?)[\s\n]/s', $return." ", $meatchs)){  
309 - foreach ($meatchs[0] as $key=>$v){  
310 - if(strpos($meatchs[2][$key],'@') != false){  
311 - $json .= $this->string2jsonArray($doc,$v,$space.'&nbsp;&nbsp;');  
312 - } else{  
313 - $json .= $space.'&nbsp;&nbsp;'. $this->string2json(trim($meatchs[1][$key]), $meatchs[2][$key]); 299 + if (preg_match_all('/(\w+):(.*?)[\s\n]/s', $return . " ", $meatchs)) {
  300 + foreach ($meatchs[0] as $key => $v) {
  301 + if (strpos($meatchs[2][$key], '@') != false) {
  302 + $json .= $this->string2jsonArray($doc, $v, $space . '&nbsp;&nbsp;');
  303 + } else {
  304 + $json .= $space . '&nbsp;&nbsp;' . $this->string2json(trim($meatchs[1][$key]), $meatchs[2][$key]);
314 } 305 }
315 } 306 }
316 } 307 }
317 - if(strpos($value, "@!") != false){  
318 - $json .= $space."}<br/>";  
319 - }else{  
320 - $json .= $space."}]<br/>"; 308 + if (strpos($value, "@!") != false) {
  309 + $json .= $space . "}<br/>";
  310 + } else {
  311 + $json .= $space . "}]<br/>";
321 } 312 }
322 return $json; 313 return $json;
323 } 314 }