核销列表
This commit is contained in:
parent
a0918ed516
commit
2a489b6270
@ -28,6 +28,29 @@ class OrderController extends BaseApiController
|
||||
return $this->dataLists(new OrderList());
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('核销订单列表'),
|
||||
ApiDoc\url('/api/order/order/write_list'),
|
||||
ApiDoc\Method('POST'),
|
||||
ApiDoc\Param(name: "type", type: "int", require: true, desc: "1:待核销;2:已核销"),
|
||||
ApiDoc\Param(name: "name", type: "string", require: false, desc: "商品名/订单id"),
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
]
|
||||
public function write_list()
|
||||
{
|
||||
$status = (int)$this->request->post('status',1);
|
||||
$params = $this->request->post();
|
||||
$params['page_no'] = isset($params['page_no'])?: 1;
|
||||
$params['page_size'] = isset($params['page_size'])?: 15;
|
||||
$info = $this->userInfo;
|
||||
$res = OrderLogic::write_list($info,$status,$params);
|
||||
$res['page_no'] =$params['page_no'];
|
||||
$res['page_size'] =$params['page_size'];
|
||||
return $this->success('ok',$res);
|
||||
|
||||
}
|
||||
#[
|
||||
ApiDoc\Title('订单校验'),
|
||||
ApiDoc\url('/api/order/order/checkOrder'),
|
||||
|
@ -16,6 +16,7 @@ use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use support\Log;
|
||||
@ -438,4 +439,54 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
|
||||
|
||||
public static function write_list($info,$status,$params)
|
||||
{
|
||||
|
||||
$store_id = SystemStoreStaff::where('phone',$info['mobile'])->value('store_id');
|
||||
if(empty($store_id)){
|
||||
throw new \Exception('该用户未绑定店铺请查看');
|
||||
}
|
||||
|
||||
//先查商品相似
|
||||
$query = StoreOrderCartInfo::alias('o')
|
||||
->leftJoin('store_branch_product p','p.id = o.product_id')
|
||||
->leftJoin('store_order s','s.id = o.oid')
|
||||
->field('o.oid,p.store_name,s.order_id')
|
||||
->where('o.store_id',$store_id);
|
||||
|
||||
if(isset($params['name']) && $params['name']){
|
||||
if($params['name'] && preg_match('/[\x{4e00}-\x{9fff}]+/u', $params['name'])==1){
|
||||
$query->where('p.store_name','like','%'.$params['name'].'%');
|
||||
}else{
|
||||
$query->where('s.order_id',$params['name']);
|
||||
}
|
||||
|
||||
}
|
||||
$product = $query->select();
|
||||
if(empty($product)){
|
||||
return [
|
||||
'list'=>[],
|
||||
'count'=>0
|
||||
];
|
||||
}
|
||||
$oids = array_column($product->toArray(), 'oid');
|
||||
$uniqueOids = array_unique($oids);
|
||||
$query = StoreOrder::with(['store'])
|
||||
->whereIn('id',$uniqueOids)
|
||||
->where('status',$status);
|
||||
$count = $query->count();
|
||||
$list = $query
|
||||
->page($params['page_no'], $params['page_size'])
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function($item){
|
||||
$item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with('goodsName')->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time')->limit(3)->select();
|
||||
$item['goods_count']=count(explode(',',$item['cart_id']));
|
||||
})
|
||||
->toArray();
|
||||
return [
|
||||
'list'=>$list,
|
||||
'count'=>$count
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ class StoreOrder extends BaseModel
|
||||
|
||||
public function store()
|
||||
{
|
||||
return $this->hasOne(SystemStore::class, 'id','store_id');
|
||||
return $this->hasOne(SystemStore::class, 'id','store_id')
|
||||
->bind(['store_name'=>'name', 'store_phone'=>'phone']);
|
||||
}
|
||||
|
||||
public function getPayTypeAttr($value, $data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user