shop模块商品添加供货商搜索

This commit is contained in:
wangxiaowei 2024-09-09 12:04:54 +08:00
parent 46ac56f3fc
commit 51be69f326
3 changed files with 53 additions and 34 deletions

@ -68,7 +68,8 @@ class Goods extends ShopBase
'statistics' => $statistics,
'cate_list' => $cate_list, //平台分类
'shop_cate_list' => $shop_cate_list, //商家分类
'goods_type' => GoodsEnum::getTypeDesc()
'goods_type' => GoodsEnum::getTypeDesc(),
'shop_type' => session('shop_info')['type'] ?? 2
]);
}

@ -55,11 +55,11 @@ class GoodsLogic extends Logic
*/
public static function statistics($shop_id){
$where = [
['del', '<>', GoodsEnum::DEL_TRUE],
['shop_id', '=', $shop_id]
['g.del', '<>', GoodsEnum::DEL_TRUE],
['g.shop_id', '=', $shop_id]
];
$goods_list = Goods::where($where)
->field('id,status,stock,stock_warn,audit_status,del')
$goods_list = Goods::alias('g') ->join('supplier s', 'g.supplier_id = s.id')->where($where)
->field('g.id,g.status,g.stock,g.stock_warn,g.audit_status,g.del')
->select();
$goods = [
@ -124,70 +124,78 @@ class GoodsLogic extends Logic
public static function lists($get)
{
$where = [
['shop_id', '=', $get['shop_id']]
['g.shop_id', '=', $get['shop_id']]
];
if(isset($get['goods_name']) && $get['goods_name']) {
$where[] = ['name','like','%'.$get['goods_name'].'%'];
if(isset($get['supplier_name']) && $get['supplier_name']) {
$where[] = ['s.name','like','%'. $get['supplier_name'] . '%'];
}
if(isset($get['goods_name']) && $get['goods_name']) {
$where[] = ['g.name','like','%'.$get['goods_name'].'%'];
}
if(!empty($get['platform_cate_id'])) {
$where[] = ['first_cate_id|second_cate_id|third_cate_id','=', $get['platform_cate_id']];
$where[] = ['g.first_cate_id|g.second_cate_id|g.third_cate_id','=', $get['platform_cate_id']];
}
if(!empty($get['shop_cate_id'])) {
$where[] = ['shop_cate_id','=', $get['shop_cate_id']];
$where[] = ['g.shop_cate_id','=', $get['shop_cate_id']];
}
if(isset($get['goods_type']) && $get['goods_type'] != '') {
$where[] = ['type','=', $get['goods_type']];
$where[] = ['g.type','=', $get['goods_type']];
}
$type = $get['type'] ?? 0;
switch ($type) {
case 1: //销售中
$where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
$where[] = ['stock','exp', Db::raw('>=stock_warn')];
$where[] = ['g.status', '=', GoodsEnum::STATUS_SHELVES];//上架
$where[] = ['g.del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
$where[] = ['g.stock','exp', Db::raw('>=stock_warn')];
break;
case 2: //库存预警
$where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
$where[] = ['stock','exp', Db::raw('<stock_warn')];
$where[] = ['g.status', '=', GoodsEnum::STATUS_SHELVES];//上架
$where[] = ['g.del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
$where[] = ['g.stock','exp', Db::raw('<stock_warn')];
break;
case 3: //仓库中
$where[] = ['status', '=', GoodsEnum::STATUS_SOLD_OUT];//下架
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
$where[] = ['g.status', '=', GoodsEnum::STATUS_SOLD_OUT];//下架
$where[] = ['g.del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
break;
case 4: //回收站
$where[] = ['del', '=', GoodsEnum::DEL_RECYCLE];
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
$where[] = ['g.del', '=', GoodsEnum::DEL_RECYCLE];
$where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
break;
case 5: //待审核
$where[] = ['del', '<>', GoodsEnum::DEL_TRUE];
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_STAY];
$where[] = ['g.del', '<>', GoodsEnum::DEL_TRUE];
$where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_STAY];
break;
case 6: //审核未通过
$where[] = ['del', '<>', GoodsEnum::DEL_TRUE];
$where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_REFUSE];
$where[] = ['g.del', '<>', GoodsEnum::DEL_TRUE];
$where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_REFUSE];
break;
default:
$where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
$where[] = ['g.del', '=', GoodsEnum::DEL_NORMAL];
}
$order = [
'sort' => 'asc',
'id' => 'desc'
'g.sort' => 'asc',
'g.id' => 'desc'
];
$lists = Goods::where($where)
$lists = Goods::alias('g')
->join('supplier s', 'g.supplier_id = s.id')
->where($where)
->append(['is_distribution_desc'])
->page($get['page'], $get['limit'])
->order($order)
->select();
$count = Goods::where($where)->count();
$count = Goods::alias('g')->join('supplier s', 'g.supplier_id = s.id')->where($where)->count();
if($count) {
$lists = $lists->toArray();
}else{

@ -23,7 +23,15 @@
<!--搜索条件-->
<div class="layui-card-body layui-form">
<div class="layui-form-item">
{if condition="$shop_type eq 1"}
<div class="layui-inline">
<label class="layui-form-label">供货商:</label>
<div class="layui-input-inline">
<input type="text" name="supplier_name" id="supplier_name" autocomplete="off" class="layui-input">
</div>
</div>
{/if}
<div class="layui-inline">
<label class="layui-form-label">商品名称:</label>
<div class="layui-input-inline">
@ -152,6 +160,7 @@
//清空查询
form.on('submit(clear-search)', function(){
$('#supplier_name').val('');
$('#goods_name').val('');
$('#platform_cate_id').val('');
$('#shop_cate_id').val('');
@ -254,6 +263,7 @@
element.on('tab(like-tabs)', function (data) {
var type = $(this).attr('data-type');
// 重置搜索模块
$('#supplier_name').val('');
$('#goods_name').val('');
$('#platform_cate_id').val('');
$('#shop_cate_id').val('');