作者 lihan

.

<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/9/12
* Time: 15:17
*/
namespace app\collect\controller;
use cmf\controller\HomeBaseController;
use Think\Db;
/**
* @title 收藏模块
*/
class CollectController extends HomeBaseController
{
/**
* @title 我的收藏列表
* @description 接口说明
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /collect/Collect/index
* @method POST
*/
public function index()
{
//收藏的活动
$activity = Db::name('collect')->alias('c')
->field('a.name,a.thumb')
->join('activity a', 'a.id=c.activity_id')
->where(['c.user_id' => session('user.id')])
->select();
$news = Db::name('collect_news')->alias('c')
->field('p.post_title,p.more')
->join('portal_post p', 'p.id=c.post_id')
->where(['c.user_id' => session('user.id')])
->select();
foreach ($news as $k => $v) {
$temp = json_decode($v['more'], true);
$v['thumb'] = cmf_get_image_url($temp['thumbnail']);
unset($v['more']);
$news[$k] = $v;
}
$data = [
'activity' => $activity,
'news' => $news
];
echo json_encode(['data' => $data]);
exit();
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/9/12
* Time: 15:25
*/
namespace app\news\controller;
use cmf\controller\HomeBaseController;
use Think\Db;
/**
* @title 新闻模块
*/
class NewsController extends HomeBaseController
{
/**
* @title 新闻列表
* @description 接口说明
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /news/News/newsList
* @method POST
*/
public function newsList()
{
}
/**
* @title 新闻详情
* @description 接口说明
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /news/News/detail
* @method GET
*
* @param name:id type:int require:1 default:1 other: desc:文章id
*/
public function detail()
{
$id = request()->param('id');
$news = Db::name('portal_post')->field('post_title,post_content,published_time')->where(['id' => $id])->find();
$news['published_time'] = date('Y/m/d', $news['published_time']);
$news['post_content'] = html_entity_decode($news['post_content']);
echo json_encode(['news' => $news]);
exit();
}
/**
* @title 收藏文章
* @description 接口说明
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /news/News/collect
* @method POST
*
* @param name:id type:int require:1 default:1 other: desc:文章id
*/
public function collect()
{
$request = request();
if ($request->isPost()) {
if (!empty(session('user.id'))) {
$id = $request->param('id');
if (Db::name('collect_news')->where(['post_id' => $id])->count()) {
echo json_encode(['msg' => '您已收藏过啦', 'code' => 40000]);
exit();
} else {
$data = [
'user_id' => session('user.id'),
'post_id' => $id,
];
if (Db::name('collect_news')->insert($data)) {
echo json_encode(['msg' => '收藏成功', 'code' => 20000]);
exit();
} else {
echo json_encode(['msg' => '收藏失败', 'code' => 40000]);
exit();
}
}
} else {
echo json_encode(['msg' => '请先登录', 'code' => 40001]);
exit();
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -201,16 +201,62 @@ class CenterController extends HomeBaseController
public function orderDetail()
{
$request = request();
//订单基本信息
$oid = $request->param('oid');
$info = Db::name('order_info')->alias('o')
->field('o.id as oid,o.order_sn,a.name,a.thumb,o.status')
->field('o.id as oid,o.order_sn,a.name,a.thumb,o.status,a.down_price,s.price')
->join('activity a', 'a.id=o.activity_id')
->join('activity_schedule s', 's.id=o.schedule_id')
->where(['o.id' => $oid])
->order('add_time DESC')
->find();
$info['status_text'] = getOrderStatusText($info['status']);
$info['count'] = Db::name('order_detail')->where(['oid' => $oid])->count();
echo json_encode(['data' => $info, 'code' => 20000]);
$escort = Db::name('order_detail')->alias('d')
->field('d.id,d.status,e.name,e.tel')
->join('escort e', 'e.id=d.escort_id')
->where(['oid' => $oid])
->select();
foreach ($escort as $k => $v) {
$v['count'] = 1;
$v['down_price'] = $info['down_price'];
$escort[$k] = $v;
}
$return = [
'baseInfo' => $info,
'escort' => $escort
];
echo json_encode(['data' => $return, 'code' => 20000]);
exit();
}
/**
* @title 钱包记录
* @description 默认访问接口
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /user/Center/walletLog
* @method POST
*/
public function walletLog()
{
$balance = Db::name('user')->where(['id' => session('user.id')])->value('balance');
$log = Db::name('my_wallet')->field('type,cost,create_time')->where(['user_id' => session('user.id')])->order('create_time DESC')->select()->toArray();
foreach ($log as $k => $v) {
$v['create_time'] = date('Y.m.d H:i:s', $v['create_time']);
if ($v['type'] == 0) {
$v['type_text'] = '账户消费';
} elseif ($v['type'] == 1) {
$v['type_text'] = '账户充值';
} else {
$v['type_text'] = '退款订单';
}
$log[$k] = $v;
}
$return = [
'balance' => $balance,
'log' => $log
];
echo json_encode(['data' => $return, 'code' => 20000]);
exit();
}
... ...
<?php return array (
'户外频道/:id' =>
array (
0 => 'portal/Article/index?cid=8',
1 =>
array (
),
2 =>
array (
'id' => '\d+',
'cid' => '\d+',
),
),
'户外频道' =>
array (
0 => 'portal/List/index?id=8',
1 =>
array (
),
2 =>
array (
'id' => '\d+',
),
),
);
\ No newline at end of file
... ...
... ... @@ -13,7 +13,9 @@ class Doc
'app\activity\controller\ActivityController',
'app\user\controller\CenterController',
'app\team\controller\TeamController',
'app\order\controller\OrderController'
'app\order\controller\OrderController',
'app\collect\controller\CollectController',
'app\news\controller\NewsController'
],
'password' => 'bronet',
'static_path' => '',
... ...