|
@@ -10,7 +10,8 @@ use app\model\OrderSheet;
|
|
|
use support\Request;
|
|
|
use support\Response;
|
|
|
|
|
|
-class DishesController extends Curd{
|
|
|
+class DishesController extends Curd
|
|
|
+{
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->model = new Order();
|
|
@@ -41,7 +42,7 @@ class DishesController extends Curd{
|
|
|
// $where['order_category'] = 'DISHES';
|
|
|
if (!empty($where['order_status_system']) && in_array($where['order_status_system'], ['PENDING', 'WAITING', 'SENDING', 'RECVING', 'SIGNED', 'CONFIRM'])) {
|
|
|
$where['order_is_complete'] = 'N';
|
|
|
- $where['order_category'] = ['<>','RETURN'];
|
|
|
+ $where['order_category'] = ['<>', 'RETURN'];
|
|
|
}
|
|
|
|
|
|
// if (!empty($where['order_status_system']) && $where['order_status_system'] == 'RETURN') {
|
|
@@ -54,29 +55,32 @@ class DishesController extends Curd{
|
|
|
// }
|
|
|
// if ($request->get('goods_classify') || $request->get('goods_name')){
|
|
|
// $where['order_id'] = '';
|
|
|
- $goodsClassify = $request->get('goods_classify', '');
|
|
|
- $goodsName = $request->get('goods_name','');
|
|
|
- if (!empty($goodsName) && empty($goodsClassify)){
|
|
|
- $goodsIds = Goods::where('goods_name','like','%'.$request->get('goods_name').'%')->pluck('goods_id')->toArray();
|
|
|
- }else if(!empty($goodsClassify)){
|
|
|
- if($goodsClassify == 'SERVICE'){
|
|
|
- $goodsModel = Goods::whereIn('goods_classify',['SERVICE','CHNMED','CHNNCD']);
|
|
|
- }else{
|
|
|
- $goodsModel = Goods::where('goods_classify',$goodsClassify);
|
|
|
- }
|
|
|
-
|
|
|
- if(!empty($goodsName)){
|
|
|
- $goodsModel->where('goods_name','like','%'.$goodsName.'%');
|
|
|
- }
|
|
|
+ if (empty($where['order_id'])){
|
|
|
+ $goodsClassify = 'MEALS';
|
|
|
+ }
|
|
|
+ $goodsClassify = $request->get('goods_classify', '');
|
|
|
+ $goodsName = $request->get('goods_name', '');
|
|
|
+ if (!empty($goodsName) && empty($goodsClassify)) {
|
|
|
+ $goodsIds = Goods::where('goods_name', 'like', '%' . $request->get('goods_name') . '%')->pluck('goods_id')->toArray();
|
|
|
+ } else if (!empty($goodsClassify)) {
|
|
|
+ if ($goodsClassify == 'SERVICE') {
|
|
|
+ $goodsModel = Goods::whereIn('goods_classify', ['SERVICE', 'CHNMED', 'CHNNCD']);
|
|
|
+ } else {
|
|
|
+ $goodsModel = Goods::where('goods_classify', $goodsClassify);
|
|
|
+ }
|
|
|
|
|
|
- $goodsIds = $goodsModel->pluck('goods_id')->toArray();
|
|
|
+ if (!empty($goodsName)) {
|
|
|
+ $goodsModel->where('goods_name', 'like', '%' . $goodsName . '%');
|
|
|
}
|
|
|
- if(!empty($goodsIds)){
|
|
|
- $orderIds = OrderSheet::whereIn('join_sheet_goods_id',$goodsIds)->pluck('join_sheet_order_id')->toArray();
|
|
|
- if($orderIds){
|
|
|
- $where['order_id'] = ['in',implode(',',$orderIds)];
|
|
|
- }
|
|
|
+
|
|
|
+ $goodsIds = $goodsModel->pluck('goods_id')->toArray();
|
|
|
+ }
|
|
|
+ if (!empty($goodsIds)) {
|
|
|
+ $orderIds = OrderSheet::whereIn('join_sheet_goods_id', $goodsIds)->pluck('join_sheet_order_id')->toArray();
|
|
|
+ if ($orderIds) {
|
|
|
+ $where['order_id'] = ['in', implode(',', $orderIds)];
|
|
|
}
|
|
|
+ }
|
|
|
// }
|
|
|
$query = $this->doSelect($where, $field, $order);
|
|
|
return $this->doFormat($query, $format, $limit);
|
|
@@ -86,7 +90,7 @@ class DishesController extends Curd{
|
|
|
{
|
|
|
$model = $this->model->with([
|
|
|
'sheets' => function ($query) {
|
|
|
- $query->select('join_sheet_order_id', 'order_sheet_id', 'join_sheet_goods_id', 'order_sheet_num','order_sheet_price');
|
|
|
+ $query->select('join_sheet_order_id', 'order_sheet_id', 'join_sheet_goods_id', 'order_sheet_num', 'order_sheet_price');
|
|
|
},
|
|
|
'member' => function ($query) {
|
|
|
$query->select('member_id', 'member_mobile');
|
|
@@ -104,7 +108,7 @@ class DishesController extends Curd{
|
|
|
'express' => function ($query) {
|
|
|
$query->select('join_express_order_id', 'order_express_type');
|
|
|
}
|
|
|
- ])->leftJoin('order_return','order_return.join_return_order_id','=','order.order_id');
|
|
|
+ ])->leftJoin('order_return', 'order_return.join_return_order_id', '=', 'order.order_id');
|
|
|
// ->leftJoin('order_sheet','join_sheet_order_id','=','order.order_id');
|
|
|
foreach ($where as $column => $value) {
|
|
|
if (is_array($value)) {
|
|
@@ -138,7 +142,7 @@ class DishesController extends Curd{
|
|
|
if ($field) {
|
|
|
$model = $model->orderBy($field, $order);
|
|
|
}
|
|
|
- $model = $model->select('order.*','order_return.orders_return_id', 'order_return.join_return_order_id', 'order_return.order_return_status','order_return.order_return_apply_json','order_return.order_return_remark');
|
|
|
+ $model = $model->select('order.*', 'order_return.orders_return_id', 'order_return.join_return_order_id', 'order_return.order_return_status', 'order_return.order_return_apply_json', 'order_return.order_return_remark');
|
|
|
return $model;
|
|
|
}
|
|
|
|
|
@@ -149,21 +153,21 @@ class DishesController extends Curd{
|
|
|
$item['sheet'] = $item['sheets'][0] ?? [];
|
|
|
if (!empty($item['sheet'])) {
|
|
|
$goods = Goods::where('goods_id', $item['sheet']['join_sheet_goods_id'])->first();
|
|
|
- if(count($item['sheets']) > 1 && $goods && $goods->goods_classify == 'MEALS'){
|
|
|
+ if (count($item['sheets']) > 1 && $goods && $goods->goods_classify == 'MEALS') {
|
|
|
$sheetDeng = ' 等餐品';
|
|
|
}
|
|
|
- $item['sheet']['goods_name'] = ($goods && $goods->goods_name) ? $goods->goods_name.$sheetDeng : '';
|
|
|
+ $item['sheet']['goods_name'] = ($goods && $goods->goods_name) ? $goods->goods_name . $sheetDeng : '';
|
|
|
$item['sheet']['goods_classify'] = $goods->goods_classify ?? '';
|
|
|
$item['sheet']['order_sheet_num'] = intval($item['sheet']['order_sheet_num']);
|
|
|
}
|
|
|
unset($item['sheets']);
|
|
|
- if (isset($item['orders_return_id'])){
|
|
|
+ if (isset($item['orders_return_id'])) {
|
|
|
$item['return'] = [
|
|
|
- 'orders_return_id'=>$item['orders_return_id'],
|
|
|
+ 'orders_return_id' => $item['orders_return_id'],
|
|
|
'join_return_order_id' => $item['join_return_order_id'],
|
|
|
'order_return_status' => $item['order_return_status'],
|
|
|
'order_return_apply_json' => $item['order_return_apply_json'],
|
|
|
- 'order_return_remark'=>$item['order_return_remark']
|
|
|
+ 'order_return_remark' => $item['order_return_remark']
|
|
|
];
|
|
|
}
|
|
|
}
|