feat: 新增小程序商户查看订单列表功能

This commit is contained in:
mkm 2024-08-13 14:19:53 +08:00
parent f5cd985157
commit e1bece7622
3 changed files with 109 additions and 2 deletions

View File

@ -6,6 +6,7 @@ use app\admin\logic\store_order\StoreOrderLogic;
use app\api\logic\order\OrderLogic; use app\api\logic\order\OrderLogic;
use app\api\controller\BaseApiController; use app\api\controller\BaseApiController;
use app\api\lists\order\OrderList; use app\api\lists\order\OrderList;
use app\api\lists\order\StoreOrderList;
use app\api\validate\OrderValidate; use app\api\validate\OrderValidate;
use app\common\enum\PayEnum; use app\common\enum\PayEnum;
use app\common\enum\YesNoEnum; use app\common\enum\YesNoEnum;
@ -34,7 +35,15 @@ class OrderController extends BaseApiController
return $this->dataLists(new OrderList()); return $this->dataLists(new OrderList());
} }
/**
* 小程序商户查看订单列表
*/
public function store_order_list()
{
$store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id');
$this->request->__set('store_id',$store_id);
return $this->dataLists(new StoreOrderList());
}
/** /**
* 核销码查数据 * 核销码查数据
*/ */

View File

@ -0,0 +1,98 @@
<?php
namespace app\api\lists\order;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use Picqer\Barcode\BarcodeGeneratorPNG;
/**
* 零售订单列表
* Class RetailOrderList
* @package app\api\order
*/
class StoreOrderList extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
*/
public function setSearch(): array
{
return [
'=' => ['paid', 'status', 'is_writeoff','reservation'],
'between_time' => 'create_time',
'%like%' => ['order_id'],
];
}
/**
* @notes 零售订单列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @date 2024/04/27 11:26
*/
public function lists(): array
{
$store_id = $this->request->__get('store_id');
if (!$store_id) return [];
$this->searchWhere[]=['paid','=',1];
$this->searchWhere[]=['store_id','=',$store_id];
$data = StoreOrder::where($this->searchWhere)
->whereIn('shipping_type',[1,2])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->each(function ($item) {
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info')->limit(3)->select()
->each(function ($v) use ($item) {
$v['store_name'] = '';
$v['image'] = '';
$v['price'] = '';
$v['unit_name']='';
if(isset($v['cart_info'])){
// foreach( $v['cart_info'] as $k=>$vv){
$v['store_name'] =$v['cart_info']['name'];
$v['image'] =$v['cart_info'] ['image'];
$v['price'] = $v['cart_info']['price'];
$v['unit_name']=$v['cart_info']['unit_name']??'';
// }
}
});
$item['goods_count'] = count(explode(',', $item['cart_id']));
if ($item['refund_reason_time']) {
$item['refund_reason_time'] = date('Y-m-d H:i:s', $item['refund_reason_time']);
}
if ($item['pay_time']) {
$item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
}
})
->toArray();
return $data;
}
/**
* @notes 零售订单数量
* @return int
* @date 2024/04/27 11:26
*/
public function count(): int
{
$store_id = $this->request->__get('store_id');
if (!$store_id) return 0;
return StoreOrder::where($this->searchWhere)->whereIn('shipping_type',[1,2])->count();
}
}

View File

@ -82,7 +82,7 @@ class StoreProductLists extends BaseApiDataLists implements ListsSearchInterface
if($type==1){ if($type==1){
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
}elseif($type==2){ }elseif($type==2){
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,vip_price price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,purchase price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
} }
$this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['status', '=', 1];