parent
c8a49e73f6
commit
8eb7a7d256
|
|
@ -47,29 +47,34 @@ class StoreGroupOrderDao extends BaseDao
|
|||
*/
|
||||
public function search(array $where,$is_points = null)
|
||||
{
|
||||
$query = StoreGroupOrder::getDB()->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
|
||||
$query->where('paid', $where['paid']);
|
||||
})
|
||||
->whereNotIn('activity_type', [30,31,32,33])
|
||||
->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
|
||||
$query->where('paid', $where['paid']);
|
||||
})
|
||||
->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
|
||||
$query->where('uid', $where['uid']);
|
||||
})
|
||||
|
||||
->when(!is_null($is_points), function ($query) use ($is_points) {
|
||||
if ($is_points) {
|
||||
$query->where('activity_type', 20);
|
||||
} else {
|
||||
$query->where('activity_type', '<>',20);
|
||||
}
|
||||
})
|
||||
->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
|
||||
$query->where('is_del', $where['is_del']);
|
||||
}, function ($query) {
|
||||
$query->where('is_del', 0);
|
||||
});
|
||||
$query = StoreGroupOrder::getDB()
|
||||
->when(isset($where['paid']) && $where['paid'] !== '',function($query) use ($where){
|
||||
$query->where('paid',$where['paid']);
|
||||
})
|
||||
->whereNotIn('activity_type',[30,31,32,33])
|
||||
->when(isset($where['paid']) && $where['paid'] !== '',function($query) use ($where){
|
||||
$query->where('paid',$where['paid']);
|
||||
})
|
||||
->when(isset($where['uid']) && $where['uid'] !== '',function($query) use ($where){
|
||||
$query->where('uid',$where['uid']);
|
||||
})
|
||||
->when(isset($where['with_goods_mer_id']) && $where['with_goods_mer_id'] !== '',function($query) use ($where){
|
||||
if(is_array($where['with_goods_mer_id'] )) $query->whereIn('with_goods_mer_id',$where['with_goods_mer_id']);
|
||||
else $query->where('with_goods_mer_id',$where['with_goods_mer_id']);
|
||||
})
|
||||
->when(!is_null($is_points),function($query) use ($is_points){
|
||||
if($is_points){
|
||||
$query->where('activity_type',20);
|
||||
}
|
||||
else{
|
||||
$query->where('activity_type','<>',20);
|
||||
}
|
||||
})
|
||||
->when(isset($where['is_del']) && $where['is_del'] !== '',function($query) use ($where){
|
||||
$query->where('is_del',$where['is_del']);
|
||||
},function($query){
|
||||
$query->where('is_del',0);
|
||||
});
|
||||
return $query->order('create_time DESC');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace app\common\dao\store\order;
|
|||
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\marketing\Agent;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\order\StoreOrderProduct;
|
||||
use app\common\model\store\order\StoreOrderStatus;
|
||||
|
|
@ -75,10 +76,6 @@ 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){
|
||||
|
|
@ -123,7 +120,8 @@ class StoreOrderDao extends BaseDao
|
|||
})
|
||||
->when(isset($where['with_goods_mer_id']) && $where['with_goods_mer_id'] !== '' && $where['with_goods_mer_id'] > 0, function ($query) use ($where) {
|
||||
// 酒道馆查看自己进货订单
|
||||
$query->where('with_goods_mer_id', $where['with_goods_mer_id']);
|
||||
if(is_array($where['with_goods_mer_id'] )) $query->whereIn('with_goods_mer_id',$where['with_goods_mer_id']);
|
||||
else $query->where('with_goods_mer_id',$where['with_goods_mer_id']);
|
||||
})
|
||||
->when(isset($where['is_spread']) && $where['is_spread'] !== '', function ($query) use ($where) {
|
||||
if ($where['is_spread']) {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class AgentRepository extends BaseRepository{
|
|||
// 获取对应的角色身份列表
|
||||
return $this->dao->searchList(['uid'=>$uid])
|
||||
->whereIn('agent_type', $agentType)
|
||||
->whereNotIn('agent_type', [7,8])// 忽略无管理菜单的角色
|
||||
->whereNotIn('agent_type', [7])// 忽略无管理菜单的角色
|
||||
->field(['id','uid','agent_type','province_id','city_id','area_id','street_id','address','mer_id','contact_name','pid','corporate_name'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
|
@ -297,7 +297,7 @@ class AgentRepository extends BaseRepository{
|
|||
->toArray();
|
||||
}
|
||||
// 获取已被酒道馆绑定的商户
|
||||
$shop_mer = $this->getMerchant(0);
|
||||
$shop_mer = $this->getMerchant(1);
|
||||
// 获取已被烟酒店绑定的商户
|
||||
$wine = $this->getMerchant(3);
|
||||
// 获取已被餐厅绑定的商户
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ class StoreOrderRepository extends BaseRepository
|
|||
$orderCount = $this->dao->search(['uid' => $uid, 'paid' => 1,'is_user' => 1])->count();
|
||||
return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all');
|
||||
}
|
||||
|
||||
// 酒道馆进货订单
|
||||
public function merOrderNumber(int $merId)
|
||||
{
|
||||
$noPay =app()->make(StoreGroupOrderRepository::class)->search(['with_goods_mer_id' => $merId,'activity_type' => 35,'is_del' => 0,'paid' => 0],0)->count();
|
||||
|
|
@ -629,6 +629,23 @@ class StoreOrderRepository extends BaseRepository
|
|||
$orderCount = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'paid' => 1,'is_user' => 1])->count();
|
||||
return compact('orderPrice','noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all');
|
||||
}
|
||||
// 代理相关订单
|
||||
public function agentOrderNumber(array $merIdList){
|
||||
$noPay =app()->make(StoreGroupOrderRepository::class)->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35,'is_del' => 0,'paid' => 0],0)->count();
|
||||
$noPostage = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$all = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noDeliver = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noComment = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$done = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$refund = 0;//app()->make(StoreRefundOrderRepository::class)->getWhereCount(['with_goods_mer_id' => $merId, 'status' => [0, 1, 2]]);
|
||||
$orderPrice = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'paid' => 1])->sum('pay_price');
|
||||
$orderCount = $this->dao->search(['with_goods_mer_id' => $merIdList,'activity_type' => 35, 'paid' => 1,'is_user' => 1])->count();
|
||||
|
||||
return compact('orderPrice','noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
namespace app\controller\api\store\order;
|
||||
|
||||
|
||||
use app\common\model\marketing\Agent;
|
||||
use app\common\repositories\delivery\DeliveryOrderRepository;
|
||||
use app\common\repositories\store\order\StoreOrderCreateRepository;
|
||||
use app\common\repositories\store\order\StoreOrderReceiptRepository;
|
||||
|
|
@ -166,6 +167,19 @@ class StoreOrder extends BaseController
|
|||
$where['uid'] = $this->request->uid();
|
||||
$where['paid'] = 1;
|
||||
$where['is_user'] = 1;
|
||||
|
||||
$agentId = $this->request->param('agent_id', 0);
|
||||
if($agentId > 0){
|
||||
// todo 目前只有配送商需要查询订单信息 如果以后其他身份需要关联订单信息 需要根据身份进行判断处理
|
||||
$agentInfo = Agent::where('id',$agentId)
|
||||
->field(['id','uid','agent_type'])
|
||||
->append(['mer_id_list'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$where['with_goods_mer_id'] = is_array($agentInfo['mer_id_list']) ? $agentInfo['mer_id_list'] : [];
|
||||
$where['activity_type'] = 35;
|
||||
}
|
||||
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||
}
|
||||
|
||||
|
|
@ -194,14 +208,33 @@ class StoreOrder extends BaseController
|
|||
public function number(){
|
||||
$is_with_goods = $this->request->param('is_with_goods', 0);
|
||||
$with_goods_mer_id = $this->request->param('with_goods_mer_id', 0);
|
||||
$agentId = $this->request->param('agent_id', 0);
|
||||
|
||||
if($is_with_goods == 1){
|
||||
$data = $this->repository->merOrderNumber($with_goods_mer_id);
|
||||
}else{
|
||||
$data = ['orderPrice' => $this->request->userInfo()->pay_price];
|
||||
$data2 = $this->repository->userOrderNumber($this->request->uid());
|
||||
$data = $data + $data2;
|
||||
// 存在代理ID 根据代理类型进行处理
|
||||
if($agentId > 0){
|
||||
// todo 目前只有配送商需要查询订单信息 如果以后其他身份需要关联订单信息 需要根据身份进行判断处理
|
||||
$agentInfo = Agent::where('id',$agentId)
|
||||
->field(['id','uid','agent_type'])
|
||||
->append(['mer_id_list'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$merIdList = is_array($agentInfo['mer_id_list']) ? $agentInfo['mer_id_list'] : [];
|
||||
|
||||
$data = $this->repository->agentOrderNumber((array)$merIdList);
|
||||
}
|
||||
else{
|
||||
// 非代理内容
|
||||
if($is_with_goods == 1){
|
||||
// 酒道馆进货订单查看
|
||||
$data = $this->repository->merOrderNumber($with_goods_mer_id);
|
||||
}else{
|
||||
// 用户普通订单查看
|
||||
$data = ['orderPrice' => $this->request->userInfo()->pay_price];
|
||||
$data2 = $this->repository->userOrderNumber($this->request->uid());
|
||||
$data = $data + $data2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return app('json')->success($data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue