feat(menu): 更新店铺菜单链接

This commit is contained in:
mkm 2024-09-23 18:45:57 +08:00
parent a8f1887b45
commit 1d8e9a9a36
5 changed files with 254 additions and 6 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace app\api\controller\branch_product;
use app\api\controller\BaseApiController;
use app\api\lists\branch_product\BranchProductLists;
class BranchProductController extends BaseApiController
{
/**
* 商品列表
*/
public function lists()
{
return $this->dataLists(new BranchProductLists());
}
}

View File

@ -200,12 +200,13 @@ class StoreController extends BaseApiController
*/
public function menu_list(){
$menu=[
['name'=>'每日配送统计'],
['name'=>'累计配送统计'],
['name'=>'每日销量统计'],
['name'=>'累计销量统计'],
['name'=>'商品库存'],
['name'=>'店铺收支']
['name'=>'每日配送统计','url'=>'/pagesOrder/deliveryOrder/index'],
['name'=>'累计配送统计','url'=>'/pagesOrder/deliveryOrder/count'],
['name'=>'每日销量统计','url'=>'/pagesOrder/productSales/index'],
['name'=>'累计销量统计','url'=>'/pagesOrder/productSales/count'],
['name'=>'商品库存','url'=>'/pagesOrder/store_product/index'],
['name'=>'订单列表','url'=>'/pagesOrder/delivery/index'],
['name'=>'店铺收支'],
];
return $this->success('ok',['menu'=>$menu]);
}

View File

@ -0,0 +1,29 @@
<?php
namespace app\api\controller\store_order_cart_info;
use app\api\controller\BaseApiController;
use app\api\lists\store_order_cart_info\CateLists;
/**
* 商品销量控制器
* Class StoreOrderCartInfoController
* @package app\admin\controller\goods
*/
class StoreOrderCartInfoController extends BaseApiController
{
/**
* @notes 获取商品分类列表
* @return
* @author likeadmin
* @date 2024/04/23 10:27
*/
public function lists()
{
return $this->dataLists(new CateLists());
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace app\api\lists\branch_product;
use app\api\lists\BaseApiDataLists;
use app\common\model\store_product\StoreProduct;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_branch_product\StoreBranchProduct;
/**
* 商品列表列表
* Class goods
* @package app\api\goods
*/
class BranchProductLists extends BaseApiDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function setSearch(): array
{
return [
'=' => [ 'cate_id', 'top_cate_id', 'two_cate_id'],
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
];
}
/**
* @notes 设置支持排序字段
* @return string[]
* @date 2021/12/29 10:07
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
*/
public function setSortFields(): array
{
return ['sell' => 'price', 'sales' => 'sales',];
}
/**
* @notes 设置默认排序
* @return string[]
* @date 2021/12/29 10:06
*/
public function setDefaultOrder(): array
{
return ['sort'=>'desc','price' => 'asc', 'id' => 'desc'];
}
/**
* @notes 获取商品列表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function lists(): array
{
// $order = $this->request->get('order', '');
// $field = $this->request->get('field', '');
// if (empty($order) || empty($field)) {
// $order = $this->sortOrder;
// } else {
// $order = [$field => $order];
// }
$fields = 'id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,unit,batch,two_cate_id,stock,is_lack';
$tag = '';
$this->searchWhere[] = ['is_show', '=', 1];
$this->searchWhere[] = ['product_type', 'in', [0,4]];
return StoreBranchProduct::where($this->searchWhere)
->field($fields)
->with(['className', 'unitName'])
->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder)
->select()->each(function ($item) use ($tag) {
if($item['is_lack']==1){
$tag='缺货';
}
$item['tag'] = $tag;
return $item;
})
->toArray();
}
/**
* @notes 获取商品列表数量
* @return int
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function count(): int
{
return StoreBranchProduct::where($this->searchWhere)
->count();
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace app\api\lists\store_order_cart_info;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_category\StoreCategory;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_unit\StoreProductUnit;
/**
* 订单购物详情列表
* Class StoreOrderCartInfoLists
* @package app\api\operation
*/
class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
*/
public function setSearch(): array
{
return [
'between_time' => 'create_time'
];
}
/**
* @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 [];
// if ($this->request->get('start_time') == '') {
// $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
// }
$is_group=$this->request->get('is_group');
$this->searchWhere[] = ['is_pay', '=', 1];
$this->searchWhere[] = ['status', '>=', 0];
$this->searchWhere[] = ['store_id', '=', 1];
$query = StoreOrderCartInfo::where($this->searchWhere);
if ($is_group == 1) {
$query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']);
} else {
$query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid');
}
return $query->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item){
$find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find();
if ($find) {
$item['image'] = $find['image']; //商品图片
$item['store_name'] = $find['store_name']; //商品名称
$item['store_info'] = $find['store_info']; //商品规格
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name') ?? '';
} else {
$item['image'] = ''; //商品图片
$item['store_name'] = ''; //商品名称
$item['store_info'] = ''; //商品规格-(数据库叫商品简介)
$item['unit_name'] = ''; //
$item['cate_name'] = ''; //
$item['system_store'] = ''; //
}
return $item; //返回处理后的数据。
})
->toArray();
}
/**
* @notes 获取地址数量
* @return int
* @date 2024/04/27 11:26
*/
public function count(): int
{
return StoreOrderCartInfo::where($this->searchWhere)->count();
}
}