作者 lihan

.

  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/9/12
  6 + * Time: 15:17
  7 + */
  8 +namespace app\collect\controller;
  9 +use cmf\controller\HomeBaseController;
  10 +use Think\Db;
  11 +
  12 +/**
  13 + * @title 收藏模块
  14 + */
  15 +class CollectController extends HomeBaseController
  16 +{
  17 + /**
  18 + * @title 我的收藏列表
  19 + * @description 接口说明
  20 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  21 + * @url /collect/Collect/index
  22 + * @method POST
  23 + */
  24 + public function index()
  25 + {
  26 + //收藏的活动
  27 + $activity = Db::name('collect')->alias('c')
  28 + ->field('a.name,a.thumb')
  29 + ->join('activity a', 'a.id=c.activity_id')
  30 + ->where(['c.user_id' => session('user.id')])
  31 + ->select();
  32 + $news = Db::name('collect_news')->alias('c')
  33 + ->field('p.post_title,p.more')
  34 + ->join('portal_post p', 'p.id=c.post_id')
  35 + ->where(['c.user_id' => session('user.id')])
  36 + ->select();
  37 + foreach ($news as $k => $v) {
  38 + $temp = json_decode($v['more'], true);
  39 + $v['thumb'] = cmf_get_image_url($temp['thumbnail']);
  40 + unset($v['more']);
  41 + $news[$k] = $v;
  42 + }
  43 + $data = [
  44 + 'activity' => $activity,
  45 + 'news' => $news
  46 + ];
  47 + echo json_encode(['data' => $data]);
  48 + exit();
  49 + }
  50 +
  51 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/9/12
  6 + * Time: 15:25
  7 + */
  8 +namespace app\news\controller;
  9 +use cmf\controller\HomeBaseController;
  10 +use Think\Db;
  11 +
  12 +/**
  13 + * @title 新闻模块
  14 + */
  15 +class NewsController extends HomeBaseController
  16 +{
  17 + /**
  18 + * @title 新闻列表
  19 + * @description 接口说明
  20 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  21 + * @url /news/News/newsList
  22 + * @method POST
  23 + */
  24 + public function newsList()
  25 + {
  26 +
  27 + }
  28 +
  29 + /**
  30 + * @title 新闻详情
  31 + * @description 接口说明
  32 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  33 + * @url /news/News/detail
  34 + * @method GET
  35 + *
  36 + * @param name:id type:int require:1 default:1 other: desc:文章id
  37 + */
  38 + public function detail()
  39 + {
  40 + $id = request()->param('id');
  41 + $news = Db::name('portal_post')->field('post_title,post_content,published_time')->where(['id' => $id])->find();
  42 + $news['published_time'] = date('Y/m/d', $news['published_time']);
  43 + $news['post_content'] = html_entity_decode($news['post_content']);
  44 + echo json_encode(['news' => $news]);
  45 + exit();
  46 + }
  47 +
  48 + /**
  49 + * @title 收藏文章
  50 + * @description 接口说明
  51 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  52 + * @url /news/News/collect
  53 + * @method POST
  54 + *
  55 + * @param name:id type:int require:1 default:1 other: desc:文章id
  56 + */
  57 + public function collect()
  58 + {
  59 + $request = request();
  60 + if ($request->isPost()) {
  61 + if (!empty(session('user.id'))) {
  62 + $id = $request->param('id');
  63 + if (Db::name('collect_news')->where(['post_id' => $id])->count()) {
  64 + echo json_encode(['msg' => '您已收藏过啦', 'code' => 40000]);
  65 + exit();
  66 + } else {
  67 + $data = [
  68 + 'user_id' => session('user.id'),
  69 + 'post_id' => $id,
  70 + ];
  71 + if (Db::name('collect_news')->insert($data)) {
  72 + echo json_encode(['msg' => '收藏成功', 'code' => 20000]);
  73 + exit();
  74 + } else {
  75 + echo json_encode(['msg' => '收藏失败', 'code' => 40000]);
  76 + exit();
  77 + }
  78 + }
  79 + } else {
  80 + echo json_encode(['msg' => '请先登录', 'code' => 40001]);
  81 + exit();
  82 + }
  83 + }
  84 + }
  85 +
  86 +}
@@ -201,16 +201,62 @@ class CenterController extends HomeBaseController @@ -201,16 +201,62 @@ class CenterController extends HomeBaseController
201 public function orderDetail() 201 public function orderDetail()
202 { 202 {
203 $request = request(); 203 $request = request();
  204 + //订单基本信息
204 $oid = $request->param('oid'); 205 $oid = $request->param('oid');
205 $info = Db::name('order_info')->alias('o') 206 $info = Db::name('order_info')->alias('o')
206 - ->field('o.id as oid,o.order_sn,a.name,a.thumb,o.status') 207 + ->field('o.id as oid,o.order_sn,a.name,a.thumb,o.status,a.down_price,s.price')
207 ->join('activity a', 'a.id=o.activity_id') 208 ->join('activity a', 'a.id=o.activity_id')
  209 + ->join('activity_schedule s', 's.id=o.schedule_id')
208 ->where(['o.id' => $oid]) 210 ->where(['o.id' => $oid])
209 ->order('add_time DESC') 211 ->order('add_time DESC')
210 ->find(); 212 ->find();
211 $info['status_text'] = getOrderStatusText($info['status']); 213 $info['status_text'] = getOrderStatusText($info['status']);
212 $info['count'] = Db::name('order_detail')->where(['oid' => $oid])->count(); 214 $info['count'] = Db::name('order_detail')->where(['oid' => $oid])->count();
213 - echo json_encode(['data' => $info, 'code' => 20000]); 215 + $escort = Db::name('order_detail')->alias('d')
  216 + ->field('d.id,d.status,e.name,e.tel')
  217 + ->join('escort e', 'e.id=d.escort_id')
  218 + ->where(['oid' => $oid])
  219 + ->select();
  220 + foreach ($escort as $k => $v) {
  221 + $v['count'] = 1;
  222 + $v['down_price'] = $info['down_price'];
  223 + $escort[$k] = $v;
  224 + }
  225 + $return = [
  226 + 'baseInfo' => $info,
  227 + 'escort' => $escort
  228 + ];
  229 + echo json_encode(['data' => $return, 'code' => 20000]);
  230 + exit();
  231 + }
  232 +
  233 + /**
  234 + * @title 钱包记录
  235 + * @description 默认访问接口
  236 + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
  237 + * @url /user/Center/walletLog
  238 + * @method POST
  239 + */
  240 + public function walletLog()
  241 + {
  242 + $balance = Db::name('user')->where(['id' => session('user.id')])->value('balance');
  243 + $log = Db::name('my_wallet')->field('type,cost,create_time')->where(['user_id' => session('user.id')])->order('create_time DESC')->select()->toArray();
  244 + foreach ($log as $k => $v) {
  245 + $v['create_time'] = date('Y.m.d H:i:s', $v['create_time']);
  246 + if ($v['type'] == 0) {
  247 + $v['type_text'] = '账户消费';
  248 + } elseif ($v['type'] == 1) {
  249 + $v['type_text'] = '账户充值';
  250 + } else {
  251 + $v['type_text'] = '退款订单';
  252 + }
  253 + $log[$k] = $v;
  254 + }
  255 + $return = [
  256 + 'balance' => $balance,
  257 + 'log' => $log
  258 + ];
  259 + echo json_encode(['data' => $return, 'code' => 20000]);
214 exit(); 260 exit();
215 } 261 }
216 262
1 <?php return array ( 1 <?php return array (
  2 + '户外频道/:id' =>
  3 + array (
  4 + 0 => 'portal/Article/index?cid=8',
  5 + 1 =>
  6 + array (
  7 + ),
  8 + 2 =>
  9 + array (
  10 + 'id' => '\d+',
  11 + 'cid' => '\d+',
  12 + ),
  13 + ),
  14 + '户外频道' =>
  15 + array (
  16 + 0 => 'portal/List/index?id=8',
  17 + 1 =>
  18 + array (
  19 + ),
  20 + 2 =>
  21 + array (
  22 + 'id' => '\d+',
  23 + ),
  24 + ),
2 ); 25 );
@@ -13,7 +13,9 @@ class Doc @@ -13,7 +13,9 @@ class Doc
13 'app\activity\controller\ActivityController', 13 'app\activity\controller\ActivityController',
14 'app\user\controller\CenterController', 14 'app\user\controller\CenterController',
15 'app\team\controller\TeamController', 15 'app\team\controller\TeamController',
16 - 'app\order\controller\OrderController' 16 + 'app\order\controller\OrderController',
  17 + 'app\collect\controller\CollectController',
  18 + 'app\news\controller\NewsController'
17 ], 19 ],
18 'password' => 'bronet', 20 'password' => 'bronet',
19 'static_path' => '', 21 'static_path' => '',