作者 lihan

行程日历大功能、团队定制表单、后台团队定制列表详情、订单初步逻辑

... ... @@ -126,4 +126,58 @@ class ActivityController extends HomeBaseController
}
}
/**
* @title 行程日历
* @description 默认访问接口(默认不填是当前月份,如果填写传值是上方日历选项卡的栏目时间戳)
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /activity/Activity/journeyCalendar
* @method POST
*
* @param name:timestamp type:int require:1 default:1538323200 other: desc:选项卡时间戳
*/
public function journeyCalendar()
{
$calendar = [];
for ($m = 1; $m < 13; $m++) {
$label = getMonthEnglishWords($m - 1);
$date = date("Y-$m");
$calendar[$m - 1]['label'] = $label;
$calendar[$m - 1]['date'] = $date;
$calendar[$m - 1]['timestamp'] = strtotime(date("Y-$m-01"));
}
$monthStart = (empty(request()->param('timestamp'))) ? strtotime(date("Y-m-01")) : request()->param('timestamp');
$monthEnd = strtotime('+1months', $monthStart);
echo json_encode([
'nav' => $calendar,
'activity_list' => $this->journeyActivity($monthStart, $monthEnd)
]);
exit();
}
private function journeyActivity($monthStart, $monthEnd)
{
$map = [
'start_time' => ['between', [$monthStart, $monthEnd]],
'is_on_sale' => ['eq', 1]
];
$res = Db::name('activity_schedule')->alias('s')
->field('a.id,a.name,a.thumb,s.price,s.maximum,real_join_num,addition_join_num,s.start_time')
->join('activity a', 'a.id=s.activity_id')
->where($map)
->order('start_time DESC')
->select()->toArray();
$model = new ActivityModel;
foreach ($res as $k => $v) {
$v['start_time'] = date('Y.m.d', $v['start_time']);
$v['sales_num'] = $v['real_join_num'] + $v['addition_join_num'];
$v['residue_num'] = $v['maximum'] - $v['sales_num'];
unset($v['real_join_num']);
unset($v['addition_join_num']);
unset($v['maximum']);
$v['is_collect'] = $model->isCollect($v['id'], session('user.id'));
$res[$k] = $v;
}
return $res;
}
}
... ...
... ... @@ -23,7 +23,7 @@ class ActivityModel extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function activityList($tId = null, $nowTime, $userId, $keyword=null)
public function activityList($tId = null, $nowTime, $userId, $keyword = null)
{
$where = [];
if ($tId != null) {
... ... @@ -148,7 +148,7 @@ class ActivityModel extends Model
* @param $userId
* @return int|string
*/
private function isCollect($activityId, $userId)
public function isCollect($activityId, $userId)
{
$isCollected = Db::name('collect')->where(['activity_id' => $activityId, 'user_id' => $userId])->count();
return $isCollected;
... ...
<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/9/6
* Time: 14:20
*/
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
class TeamController extends AdminBaseController
{
public function index()
{
$res = Db::name('team_customization')
->field('id,team_name,team_num,start_time')
->order('start_time DESC')
->paginate(20);
return $this->fetch('', [
'posts' => $res,
'page' => $res->render()
]);
}
public function detail()
{
$info = Db::name('team_customization')->where(['id' => request()->param('id')])->find();
return $this->fetch('', [
'info' => $info
]);
}
}
\ No newline at end of file
... ...
<?php
namespace app\order\controller;
use cmf\controller\HomeBaseController;
use think\Db;
/**
* @title 订单模块
*/
class OrderController extends HomeBaseController
{
/**
* @title 活动列表
* @description 默认访问接口
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /order/Order/confirm
* @method POST
*/
public function confirm()
{
$request = request();
$activity_id = $request->param('activity_id');
if ($request->isPost()) {
$activity = Db::name('activity')->field('name')->find();
} else {
return $this->fetch();
}
}
}
\ No newline at end of file
... ...
<?php
namespace app\team\controller;
use cmf\controller\HomeBaseController;
use Think\Db;
/**
* @title 团队定制模块
*/
class TeamController extends HomeBaseController
{
/**
* @title 提交表单
* @description 默认访问接口
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /team/Team/teamCustomization
* @method POST
*
* @param name:team_name type:char require:1 default:法兰不死队 other: desc:团队名称
* @param name:team_num type:int require:1 default:999 other: desc:团队人员数量
* @param name:start_time type:date require:1 default:2018-09-01 other: desc:出发日期
* @param name:end_time type:date require:1 default:2018-10-01 other: desc:结束日期
* @param name:city type:char require:1 default:天津市 other: desc:市
* @param name:county type:char require:1 default:南开区 other: desc:区
* @param name:street type:char require:1 default:华苑 other: desc:街道
* @param name:contact type:char require:1 default:李大师 other: desc:联系人
* @param name:tel type:char require:1 default:15122554643 other: desc:电话
* @param name:wechat type:char require:1 default:xxx other: desc:微信号
* @param name:desc type:text require:1 default:欢迎来到德莱联盟 other: desc:需求描述
*/
public function teamCustomization()
{
$request = request();
if ($request->isPost()) {
$post = $request->param();
$result = $this->validate(
[
'team_name' => $post['team_name'],
'team_num' => $post['team_num'],
'start_time' => $post['start_time'],
'end_time' => $post['end_time'],
'contact' => $post['contact'],
'tel' => $post['tel'],
'wechat' => $post['wechat'],
'desc' => $post['desc']
],
[
'team_name' => 'require',
'team_num' => 'require',
'start_time' => 'require',
'end_time' => 'require',
'contact' => 'require',
'tel' => 'require',
'wechat' => 'require',
'desc' => 'require'
]);
if (true !== $result) {
echo json_encode(['msg' => $result, 'code' => 40000]);
exit();
} else {
$post['address'] = $post['city'] . $post['county'] . $post['street'];
unset($post['city']);
unset($post['county']);
unset($post['street']);
if (Db::name('team_customization')->insert($post)) {
echo json_encode(['msg' => '提交成功', 'code' => 20000]);
exit();
} else {
echo json_encode(['msg' => '提交失败', 'code' => 40000]);
exit();
}
}
} else {
return $this->fetch();
}
}
}
\ No newline at end of file
... ...
... ... @@ -88,7 +88,7 @@ class CenterController extends HomeBaseController
* @url /user/Center/discountCoupon
* @method POST
*
* @param name:status type:char require:1 default:1 desc:1未使用2已使用3已过期
* @param name:status type:int require:1 default:1 desc:1未使用2已使用3已过期
*
* @return version:版本号
* @return code:错误码
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">团队定制</a></li>
</ul>
<div class="body">
<li><h2>团队定制</h2></li>
<li><div class="left">团队名称</div><div class="text">{$info.team_name}</div></li>
<li><div class="left">团队人数</div><div class="text">{$info.team_num}</div></li>
<li><div class="left">出行日期</div><div class="text">{$info.start_time}至{$info.end_time}</div></li>
<li><div class="left">出发地点</div><div class="text">{$info.address}</div></li>
<li><div class="left">联系人</div><div class="text">{$info.contact}</div></li>
<li><div class="left">手机号码</div><div class="text">{$info.tel}</div></li>
<li><div class="left">微信号码</div><div class="text">{$info.wechat}</div></li>
<li><div class="left">需求描述</div></li>
<div style="padding-left: 25%">{$info.desc}</div>
</div>
</div>
<style>
.body{width:50%; margin:0 auto; margin-top: 20px;}
.body li{width: 100%; height: 45px; line-height: 45px; list-style: none; font-size: large}
.body li h2{text-align: center}
.left{float: left; width: 50%; text-align: center}
.text{float: left; width: 50%; text-align: center}
</style>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">团队定制</a></li>
</ul>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered table-list">
<tr>
<th>序号</th>
<th>团队姓名</th>
<th>团队人数</th>
<th>出发日期</th>
<th>查看</th>
</tr>
<volist name="posts" id="vo" key="k">
<tr>
<td>{$k}</td>
<td>{$vo.team_name}</td>
<td>{$vo.team_num}</td>
<td>{$vo.start_time}</td>
<td><a href="{:url('Team/detail',['id'=>$vo['id']])}">查看详情</a></td>
</tr>
</volist>
</table>
<ul class="pagination">{$page|default=''}</ul>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
$(".form-control").change(function () {
$.ajax({
url:"{:url('Type/listOrder')}",
data:{
id:$(this).attr('data-id'),
listorder:$(this).val()
},
type:"POST",
dataType:"JSON"
})
})
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -1869,3 +1869,22 @@ function createQRcode($savePath, $qrData = 'PHP QR Code :)', $qrLevel = 'L', $qr
return FALSE;
}
function getMonthEnglishWords($index)
{
$arr = [
0 => 'Jan.',
1 => 'Feb.',
2 => 'Mar.',
3 => 'Apr.',
4 => 'May.',
5 => 'Jun.',
6 => 'Jul.',
7 => 'Aug.',
8 => 'Sep.',
9 => 'Oct.',
10 => 'Nov.',
11 => 'Dec.'
];
return $arr[$index];
}
... ...
... ... @@ -11,7 +11,9 @@ class Doc
'app\portal\controller\IndexController',
'app\escort\controller\EscortController',
'app\activity\controller\ActivityController',
'app\user\controller\CenterController'
'app\user\controller\CenterController',
'app\team\controller\TeamController',
'app\order\controller\OrderController'
],
'password' => 'bronet',
'static_path' => '',
... ...