添加个人中心功能
This commit is contained in:
@@ -8,12 +8,28 @@ class Calendar extends ApiBase
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$date = $this->request->post("date");
|
||||
if (!$date) {
|
||||
return $this->_error("日期不能为空");
|
||||
$month = $this->request->post("month");
|
||||
if (!$month) {
|
||||
return $this->_error("月份不能为空");
|
||||
}
|
||||
//查询这个时间的服务
|
||||
$service = Db::name('order_exe')->where('date', $date)->where('abnormal', 0)->select();
|
||||
|
||||
// 验证月份格式:2026-01
|
||||
if (!preg_match('/^\d{4}-\d{2}$/', $month)) {
|
||||
return $this->_error("月份格式错误,请使用格式:2026-01");
|
||||
}
|
||||
|
||||
// 计算该月的开始和结束日期
|
||||
$startDate = $month . '-01';
|
||||
$endDate = date('Y-m-t', strtotime($startDate)); // 获取该月最后一天
|
||||
|
||||
// 查询该月份的所有服务数据
|
||||
$service = Db::name('order_exe')
|
||||
->where('date', '>=', $startDate)
|
||||
->where('date', '<=', $endDate)
|
||||
->where('abnormal', 0)
|
||||
->order('date asc, addtime asc')
|
||||
->select();
|
||||
|
||||
$serviceDate = [];
|
||||
if ($service) {
|
||||
//查询到有数据,就去找服务人员
|
||||
@@ -24,15 +40,27 @@ class Calendar extends ApiBase
|
||||
->where('leave', 1)
|
||||
->find();
|
||||
if ($staffName){
|
||||
$startTime = date('H:i', strtotime($v['start_time']));
|
||||
$timeoutTime = date('H:i', strtotime($v['timeout']));
|
||||
$timeRange = $startTime . '-' . $timeoutTime;
|
||||
// 处理服务时间
|
||||
$timeRange = '';
|
||||
if (!empty($v['start_time']) && !empty($v['timeout'])) {
|
||||
// 判断是否为时间戳(数字)
|
||||
$startTimestamp = is_numeric($v['start_time']) ? $v['start_time'] : strtotime($v['start_time']);
|
||||
$timeoutTimestamp = is_numeric($v['timeout']) ? $v['timeout'] : strtotime($v['timeout']);
|
||||
$startTime = date('H:i', $startTimestamp);
|
||||
$timeoutTime = date('H:i', $timeoutTimestamp);
|
||||
$timeRange = $startTime . '-' . $timeoutTime;
|
||||
} elseif (!empty($v['start_time'])) {
|
||||
$startTimestamp = is_numeric($v['start_time']) ? $v['start_time'] : strtotime($v['start_time']);
|
||||
$startTime = date('H:i', $startTimestamp);
|
||||
$timeRange = $startTime;
|
||||
}
|
||||
|
||||
$serviceDate[] = [
|
||||
'date' => $v['date'],
|
||||
'staff_name' => $staffName['name'],
|
||||
'addtime' => $v['addtime'] == 1 ? '上午' : ($v['addtime'] == 2 ? '下午' : ''), //1表示上午,2表示下午
|
||||
'serviceTime' => $timeRange,
|
||||
'xq' => $v['xq'],
|
||||
'xq' => $v['xq'] ?? $this->getChineseWeekDay($v['date']), // 如果没有xq字段,则根据日期计算
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -40,4 +68,16 @@ class Calendar extends ApiBase
|
||||
}
|
||||
return $this->_success("成功", $serviceDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中文星期
|
||||
* @param string $date 日期格式:Y-m-d
|
||||
* @return string
|
||||
*/
|
||||
private function getChineseWeekDay($date)
|
||||
{
|
||||
$weekDay = date('w', strtotime($date));
|
||||
$weekList = ['日', '一', '二', '三', '四', '五', '六'];
|
||||
return '星期' . $weekList[$weekDay];
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class Cart extends ApiBase
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$res = CartLogic::add($post['item_id'], $post['goods_num'], $this->user_id);
|
||||
$res = CartLogic::add($post['item_id'], $post['goods_num'], $this->user_id, $post['type']);
|
||||
if ($res === true) {
|
||||
$this->_success('加入成功');
|
||||
}
|
||||
|
||||
@@ -66,21 +66,6 @@ class Order extends ApiBase
|
||||
$post['user_id'] = $this->user_id;
|
||||
$post['client'] = $this->client;
|
||||
|
||||
// $openid = 'oehgp4zzyK34d3TgnXD1ytpeNRjI';
|
||||
|
||||
// //发送下单成功通知
|
||||
// $template = [
|
||||
// 'touser'=>$openid,
|
||||
// 'template_id'=>'qTmpP2ZnGMpgAFgNsmcVMfTjCeSE7GXEQQaFTUERAuU',
|
||||
// 'page'=>'',//点击模板消息 打开小程序页面
|
||||
// 'data'=>[
|
||||
// 'thing2'=>['value'=>'擦玻璃服务'],
|
||||
// 'amount8'=>['value'=>'金额:2元'],
|
||||
// 'time10'=>['value'=>date('Y-m-d H:i',time())]
|
||||
// ]
|
||||
// ];
|
||||
// $r = send_mini_template($template);
|
||||
|
||||
$check = $this->validate($post, 'app\api\validate\Order.buy');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
|
||||
@@ -406,8 +406,14 @@ class Staffgoods extends ApiBase
|
||||
public function order_sever_list()
|
||||
{
|
||||
$userid = $this->user_id;
|
||||
$zorderId = $this->request->get('zorderId');
|
||||
|
||||
$where = ['user_id' => $userid];
|
||||
if (!empty($zorderId)) {
|
||||
$where['order_id'] = $zorderId;
|
||||
}
|
||||
$lists = Db::name('orderexe_evaluate')
|
||||
->where('user_id',$userid)
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->paginate(10);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user