修复内容
This commit is contained in:
@@ -22,24 +22,24 @@ class Calendar extends ApiBase
|
|||||||
$startDate = $month . '-01';
|
$startDate = $month . '-01';
|
||||||
$endDate = date('Y-m-t', strtotime($startDate)); // 获取该月最后一天
|
$endDate = date('Y-m-t', strtotime($startDate)); // 获取该月最后一天
|
||||||
|
|
||||||
// 查询该月份的所有服务数据
|
// 查询该月份的所有服务数据,关联商品表和员工表
|
||||||
$service = Db::name('order_exe')
|
$service = Db::name('order_exe')
|
||||||
->where('date', '>=', $startDate)
|
->alias('oe')
|
||||||
->where('date', '<=', $endDate)
|
->join('goods g', 'oe.goods_id = g.id', 'LEFT')
|
||||||
->where('abnormal', 0)
|
->join('staff s', 'oe.staff_id = s.id', 'LEFT')
|
||||||
->order('date asc, addtime asc')
|
->where('oe.date', '>=', $startDate)
|
||||||
|
->where('oe.date', '<=', $endDate)
|
||||||
|
->where('oe.abnormal', 0)
|
||||||
|
->where('s.onwork', 1)
|
||||||
|
->where('s.leave', 1)
|
||||||
|
->where('oe.staff_id', '<>', null)
|
||||||
|
->field('oe.date,oe.addtime,oe.start_time,oe.timeout,oe.xq,oe.staff_id,s.name as staff_name,g.name as goods_name')
|
||||||
|
->order('oe.date asc, oe.addtime asc')
|
||||||
->select();
|
->select();
|
||||||
|
|
||||||
$serviceDate = [];
|
$serviceDate = [];
|
||||||
if ($service) {
|
if ($service) {
|
||||||
//查询到有数据,就去找服务人员
|
|
||||||
foreach ($service as $v) {
|
foreach ($service as $v) {
|
||||||
if ($v['staff_id'] != null) {
|
|
||||||
$staffName = Db::name('staff')->where('id', $v['staff_id'])
|
|
||||||
->where('onwork', 1)
|
|
||||||
->where('leave', 1)
|
|
||||||
->find();
|
|
||||||
if ($staffName){
|
|
||||||
// 处理服务时间
|
// 处理服务时间
|
||||||
$timeRange = '';
|
$timeRange = '';
|
||||||
if (!empty($v['start_time']) && !empty($v['timeout'])) {
|
if (!empty($v['start_time']) && !empty($v['timeout'])) {
|
||||||
@@ -57,15 +57,14 @@ class Calendar extends ApiBase
|
|||||||
|
|
||||||
$serviceDate[] = [
|
$serviceDate[] = [
|
||||||
'date' => $v['date'],
|
'date' => $v['date'],
|
||||||
'staff_name' => $staffName['name'],
|
'staff_name' => $v['staff_name'] ?? '',
|
||||||
|
'goods_name' => $v['goods_name'] ?? '',
|
||||||
'addtime' => $v['addtime'] == 1 ? '上午' : ($v['addtime'] == 2 ? '下午' : ''), //1表示上午,2表示下午
|
'addtime' => $v['addtime'] == 1 ? '上午' : ($v['addtime'] == 2 ? '下午' : ''), //1表示上午,2表示下午
|
||||||
'serviceTime' => $timeRange,
|
'serviceTime' => $timeRange,
|
||||||
'xq' => $v['xq'] ?? $this->getChineseWeekDay($v['date']), // 如果没有xq字段,则根据日期计算
|
'xq' => $v['xq'] ?? $this->getChineseWeekDay($v['date']), // 如果没有xq字段,则根据日期计算
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->_success("成功", $serviceDate);
|
return $this->_success("成功", $serviceDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
use app\api\logic\StaffgoodsLogic;
|
use app\api\logic\StaffgoodsLogic;
|
||||||
use app\common\server\UrlServer;
|
use app\common\server\UrlServer;
|
||||||
use app\api\model\{Orderexe};
|
use app\api\model\OrderEvaluate;
|
||||||
|
use app\api\model\Orderexe;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
|
||||||
class Staffgoods extends ApiBase
|
class Staffgoods extends ApiBase
|
||||||
@@ -412,17 +413,33 @@ class Staffgoods extends ApiBase
|
|||||||
if (!empty($zorderId)) {
|
if (!empty($zorderId)) {
|
||||||
$where['order_id'] = $zorderId;
|
$where['order_id'] = $zorderId;
|
||||||
}
|
}
|
||||||
$lists = Db::name('orderexe_evaluate')
|
$lists = OrderEvaluate::with(['orderexe' => function ($query) {
|
||||||
|
$query->field('id,goods_id');
|
||||||
|
}, 'orderexe.goods'])
|
||||||
->where($where)
|
->where($where)
|
||||||
->order('id desc')
|
->order('id desc')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
|
|
||||||
|
// 获取 items 并修改
|
||||||
$items = $lists->items();
|
$items = $lists->items();
|
||||||
foreach ($items as $k => $v) {
|
$dataArray = [];
|
||||||
$items[$k]['create_time'] = date('Y-m', $v['create_time']);
|
if (is_array($items) && count($items) > 0) {
|
||||||
|
foreach ($items as $v) {
|
||||||
|
$dataArray[] = [
|
||||||
|
'id' => $v['id'],
|
||||||
|
'content' => $v['content'],
|
||||||
|
'create_time' => date('Y-m-d', $v['create_time']),
|
||||||
|
'eceives' => $v['eceives'],
|
||||||
|
'eceivesd' => $v['eceivesd'],
|
||||||
|
'score' => $v['score'],
|
||||||
|
'goods_name' => $v['orderexe']['goods']['name'],
|
||||||
|
'goods_image' => $v['orderexe']['goods']['image'],
|
||||||
|
'min_price' => $v['orderexe']['goods']['min_price'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
$lists->items($items);
|
}
|
||||||
$this->_success('获取数据成功', $lists);
|
|
||||||
|
$this->_success('获取数据成功', $dataArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
//员工的工资单
|
//员工的工资单
|
||||||
|
|||||||
17
application/api/model/OrderEvaluate.php
Normal file
17
application/api/model/OrderEvaluate.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
use think\model\relation\HasOne;
|
||||||
|
|
||||||
|
class OrderEvaluate extends Model
|
||||||
|
{
|
||||||
|
protected $name = 'orderexe_evaluate';
|
||||||
|
|
||||||
|
//关联子订单
|
||||||
|
public function orderexe():HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne('Orderexe','id','order_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -97,6 +97,13 @@ class Orderexe extends Model
|
|||||||
return $this->hasMany('order_goods', 'order_id', 'id');
|
return $this->hasMany('order_goods', 'order_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//关联商品
|
||||||
|
public function goods()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('goods', 'goods_id', 'id')
|
||||||
|
->field('id,name,image,min_price');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getGoodsCountAttr($value, $data)
|
public function getGoodsCountAttr($value, $data)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user