diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index e40fd86..67cefae 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -60,13 +60,24 @@ class StoreOrderDao extends BaseDao * @day 2020/6/16 */ public function search(array $where, $sysDel = 0){ - $query = StoreOrder::hasWhere('merchant', function ($query) use ($where) { - if (isset($where['is_trader']) && $where['is_trader'] !== '') { + $query = StoreOrder::alias('StoreOrder') + ->leftJoin('Merchant','Merchant.mer_id = StoreOrder.mer_id') + ->where(function($query){ + $query->where('Merchant.is_del',0)->whereOr('StoreOrder.mer_id', 0); + }) + ->when(isset($where['is_trader']) && $where['is_trader'] !== '', function ($query) use ($where) { $query->where('is_trader', $where['is_trader']); - } - $query->where('is_del',0); - }); - // 存在商户id是否 判断商户id类型,显示对应的订单 + }); + + // $query = StoreOrder::hasWhere('merchant', function ($query) use ($where) { + // if (isset($where['is_trader']) && $where['is_trader'] !== '') { + // $query->where('is_trader', $where['is_trader'])->whereOr('StoreOrder.mer_id', 0); + // } + // $query->where(function($hasQuery){ + // $hasQuery->where('is_del',0)->whereOr('StoreOrder.mer_id', 0); + // }); + // }); + // 存在商户id是否 判断商户id类型,显示对应的订单 30,31,32,33,34 if(isset($where['mer_id']) && $where['mer_id'] !== ''){ $merchantType = app()->make(MerchantRepository::class) ->getSearch([]) @@ -75,13 +86,12 @@ class StoreOrderDao extends BaseDao // 供应商 仅显示酒道馆进货订单 if($merchantType == 2) $where['activity_type'] = 35; } - $isWithGoods = $where['is_with_goods'] ?? 0; $activityType = $where['activity_type'] ?? 0; if($isWithGoods == 1 || $activityType == 35){ - $query->whereNotIn('StoreOrder.activity_type',[20,30]); - }else{ - $query->whereNotIn('StoreOrder.activity_type',[20,30,35]); + $query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34]); + }else if($activityType == 0){ + $query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,35]); } $query->when(($sysDel !== null), function ($query) use ($sysDel) { diff --git a/app/common/model/store/order/StoreOrder.php b/app/common/model/store/order/StoreOrder.php index 6f08e63..346e6fd 100644 --- a/app/common/model/store/order/StoreOrder.php +++ b/app/common/model/store/order/StoreOrder.php @@ -156,7 +156,7 @@ class StoreOrder extends BaseModel public function getOpenReceiptAttr() { - return merchantConfig($this->mer_id,'mer_open_receipt') ?: 0; + return merchantConfig((int)$this->mer_id,'mer_open_receipt') ?: 0; } public function getOrderExtendAttr($val) diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 80d2a95..b2fce2d 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -1828,6 +1828,8 @@ class StoreOrderRepository extends BaseRepository public function getList(array $where, $page, $limit) { $query = $this->dao->search($where)->where('StoreOrder.is_del', 0); + + // debug( $this->dao->search($where)->where('StoreOrder.is_del', 0)->fetchSql()->select()); $count = $query->count(); $list = $query->with([ 'orderProduct', diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 8fe5209..6f2d176 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -180,8 +180,10 @@ class StoreOrder extends BaseController $where['with_goods_mer_id'] = is_array($agentInfo['mer_id_list']) ? $agentInfo['mer_id_list'] : []; $where['activity_type'] = 35; } + // 获取订单 + $result = $this->repository->getList($where, $page, $limit); - return app('json')->success($this->repository->getList($where, $page, $limit)); + return app('json')->success($result); } /**