commit
7438141702
@ -10,13 +10,15 @@ use app\common\model\store_product_unit\StoreProductUnit;
|
|||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
|
use app\common\lists\ListsExcelInterface;
|
||||||
|
use app\common\lists\ListsSortInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门店商品辅助表
|
* 门店商品辅助表
|
||||||
* Class StoreBranchProductLists
|
* Class StoreBranchProductLists
|
||||||
* @package app\admin\listssystem_store
|
* @package app\admin\listssystem_store
|
||||||
*/
|
*/
|
||||||
class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface, ListsSortInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -29,14 +31,28 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['product_id', 'cate_id','store_id','status'],
|
'=' => ['product_id', 'cate_id', 'store_id', 'status'],
|
||||||
'%pipe_like%' => ['store_name_code'=>'store_name|bar_code'],
|
'%pipe_like%' => ['store_name_code' => 'store_name|bar_code'],
|
||||||
'%like%' => ['store_name'],
|
'%like%' => ['store_name'],
|
||||||
'<='=> ['stock'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置支持排序字段
|
||||||
|
* @return string[]
|
||||||
|
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||||
|
*/
|
||||||
|
public function setSortFields(): array
|
||||||
|
{
|
||||||
|
return ['stock' => 'stock'];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置默认排序
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function setDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return [ 'id' => 'desc','stock' => 'desc',];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @notes 获取门店列表列表
|
* @notes 获取门店列表列表
|
||||||
* @return array
|
* @return array
|
||||||
@ -48,32 +64,32 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$class_all=$this->request->get('class_all');
|
$class_all = $this->request->get('class_all');
|
||||||
$where=[];
|
$where = [];
|
||||||
if($class_all){
|
if ($class_all) {
|
||||||
$arr=Cate::where('pid',$class_all)->column('id');
|
$arr = Cate::where('pid', $class_all)->column('id');
|
||||||
if($arr){
|
if ($arr) {
|
||||||
$arr2=Cate::where('pid','in',$arr)->column('id');
|
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
|
||||||
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
$where[] = ['cate_id', 'in', array_merge($arr, $arr2)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(empty($where) && $class_all){
|
if (empty($where) && $class_all) {
|
||||||
//2或者1
|
//2或者1
|
||||||
$where[]=['cate_id','=',$class_all];
|
$where[] = ['cate_id', '=', $class_all];
|
||||||
}
|
}
|
||||||
if($where){
|
if ($where) {
|
||||||
$this->searchWhere[]=$where;
|
$this->searchWhere[] = $where;
|
||||||
}
|
}
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
return StoreBranchProduct::where($this->searchWhere)
|
||||||
->field(['id','store_id','product_id', 'image', 'store_name','store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information'])
|
->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price', 'manufacturer_information'])
|
||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['sort' => 'desc','stock'=>'desc','id' => 'desc'])
|
->order($this->sortOrder)
|
||||||
->select()
|
->select()
|
||||||
->each(function ($item) {
|
->each(function ($item) {
|
||||||
$item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name');
|
$item['system_store_name'] = SystemStore::where('id', $item['store_id'])->value('name');
|
||||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||||
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
||||||
return $item;
|
return $item;
|
||||||
@ -97,4 +113,42 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 导出文件名
|
||||||
|
* @return string
|
||||||
|
* @author 乔峰
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setFileName(): string
|
||||||
|
{
|
||||||
|
if ($this->request->get('store_id')) {
|
||||||
|
$name = SystemStore::where('id', $this->request->get('store_id'))->value('name');
|
||||||
|
return $name . '商品列表';
|
||||||
|
}
|
||||||
|
return '门店商品列表';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 导出字段
|
||||||
|
* @return string[]
|
||||||
|
* @author 乔峰
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setExcelFields(): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'store_name' => '商品名称',
|
||||||
|
'store_info' => '规格',
|
||||||
|
'unit_name' => '单位',
|
||||||
|
'cate_name' => '分类',
|
||||||
|
'stock' => '库存',
|
||||||
|
'sales' => '销量',
|
||||||
|
'purchase' => '供货价',
|
||||||
|
'cost' => '商户价',
|
||||||
|
'vip_price' => '会员价',
|
||||||
|
'price' => '零售价',
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists;
|
|||||||
use app\common\model\cate\Cate;
|
use app\common\model\cate\Cate;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
@ -65,7 +66,9 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||||
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
$nums=WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
||||||
|
$stock=StoreBranchProduct::where('store_id','<>','4')->where('product_id',$item['id'])->sum('stock');
|
||||||
|
$item['stock'] = bcadd($nums,$stock);
|
||||||
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
||||||
return $item;
|
return $item;
|
||||||
})?->toArray();
|
})?->toArray();
|
||||||
|
@ -10,13 +10,14 @@ use app\common\model\auth\Admin;
|
|||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
use app\common\model\warehouse\Warehouse;
|
use app\common\model\warehouse\Warehouse;
|
||||||
|
use app\common\lists\ListsExcelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品仓储信息列表
|
* 商品仓储信息列表
|
||||||
* Class WarehouseProductLists
|
* Class WarehouseProductLists
|
||||||
* @package app\admin\listswarehouse_product
|
* @package app\admin\listswarehouse_product
|
||||||
*/
|
*/
|
||||||
class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public $ids;
|
public $ids;
|
||||||
@ -87,7 +88,9 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
$item->admin_name='';
|
$item->admin_name='';
|
||||||
}
|
}
|
||||||
if($item->product_id){
|
if($item->product_id){
|
||||||
$item->store_name=StoreProduct::where('id',$item->product_id)->value('store_name');
|
$find=StoreProduct::where('id',$item->product_id)->field('image,store_name')->find();
|
||||||
|
$item->store_name=$find->store_name;
|
||||||
|
$item->image=$find->image;
|
||||||
}else{
|
}else{
|
||||||
$item->store_name='';
|
$item->store_name='';
|
||||||
}
|
}
|
||||||
@ -121,5 +124,58 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
return WarehouseProduct::where($this->searchWhere)->count();
|
return WarehouseProduct::where($this->searchWhere)->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @notes 导出文件名
|
||||||
|
* @return string
|
||||||
|
* @author 乔峰
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setFileName(): string
|
||||||
|
{
|
||||||
|
$financial_pm=$this->request->get('financial_pm');
|
||||||
|
if($financial_pm==1){
|
||||||
|
return '入库列表';
|
||||||
|
}
|
||||||
|
return '出库列表';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 导出字段
|
||||||
|
* @return string[]
|
||||||
|
* @author 乔峰
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setExcelFields(): array
|
||||||
|
{
|
||||||
|
$financial_pm=$this->request->get('financial_pm');
|
||||||
|
if($financial_pm==1){
|
||||||
|
$data=[
|
||||||
|
'admin_name' => '操作人员',
|
||||||
|
'warehouse_name' => '仓库',
|
||||||
|
'store_name' => '商品名称',
|
||||||
|
'financial_pm_name' => '出入库',
|
||||||
|
'batch' => '批次',
|
||||||
|
'nums' => '数量',
|
||||||
|
'manufacture' => '生产日期',
|
||||||
|
'expiration_date' => '保质期',
|
||||||
|
'purchase' => '采购价',
|
||||||
|
'price' => '零售',
|
||||||
|
'total_price' => '总价',
|
||||||
|
'create_time' => '操作时间',
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$data=[
|
||||||
|
'admin_name' => '操作人员',
|
||||||
|
'warehouse_name' => '仓库',
|
||||||
|
'store_name' => '商品名称',
|
||||||
|
'financial_pm_name' => '出入库',
|
||||||
|
'system_store_name'=>'门店',
|
||||||
|
'nums' => '数量',
|
||||||
|
'create_time' => '操作时间',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,13 +10,14 @@ use app\common\model\store_category\StoreCategory;
|
|||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\common\model\warehouse\Warehouse;
|
use app\common\model\warehouse\Warehouse;
|
||||||
|
use app\common\lists\ListsSortInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库商品存储列表
|
* 仓库商品存储列表
|
||||||
* Class WarehouseProductStoregeLists
|
* Class WarehouseProductStoregeLists
|
||||||
* @package app\admin\listswarehouse_product_storege
|
* @package app\admin\listswarehouse_product_storege
|
||||||
*/
|
*/
|
||||||
class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface
|
class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface,ListsSortInterface
|
||||||
{
|
{
|
||||||
public $ids;
|
public $ids;
|
||||||
public $store_name;
|
public $store_name;
|
||||||
@ -30,10 +31,26 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['warehouse_id'],
|
'=' => ['warehouse_id','product_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置支持排序字段
|
||||||
|
* @return string[]
|
||||||
|
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||||
|
*/
|
||||||
|
public function setSortFields(): array
|
||||||
|
{
|
||||||
|
return ['nums' => 'nums'];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置默认排序
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function setDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return [ 'id' => 'desc','nums' => 'desc',];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取仓库商品存储列表
|
* @notes 获取仓库商品存储列表
|
||||||
@ -58,7 +75,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
|
|||||||
return WarehouseProductStorege::where($this->searchWhere)
|
return WarehouseProductStorege::where($this->searchWhere)
|
||||||
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order($this->sortOrder)
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
||||||
$find = StoreProduct::where('id', $item->product_id)->find();
|
$find = StoreProduct::where('id', $item->product_id)->find();
|
||||||
|
@ -51,6 +51,11 @@ class StoreBranchProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function edit(array $params): bool
|
public static function edit(array $params): bool
|
||||||
{
|
{
|
||||||
|
$StoreProduct=StoreBranchProduct::where('id', $params['id'])->find();
|
||||||
|
if($params['status']==1 &&$StoreProduct['price']==0){
|
||||||
|
self::setError('商品价格不能为0,无法上架');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$data=[
|
$data=[
|
||||||
@ -60,7 +65,6 @@ class StoreBranchProductLogic extends BaseLogic
|
|||||||
'unit'=>$params['unit'],
|
'unit'=>$params['unit'],
|
||||||
'status'=>$params['status'],
|
'status'=>$params['status'],
|
||||||
];
|
];
|
||||||
$StoreProduct=StoreBranchProduct::where('id', $params['id'])->find();
|
|
||||||
if(isset($params['cate_id'])){
|
if(isset($params['cate_id'])){
|
||||||
if ($StoreProduct['cate_id'] != $params['cate_id']) {
|
if ($StoreProduct['cate_id'] != $params['cate_id']) {
|
||||||
self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id']);
|
self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id']);
|
||||||
|
@ -29,10 +29,10 @@ trait ListsSortTrait
|
|||||||
return $defaultOrder;
|
return $defaultOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->orderBy = 'desc') {
|
if ($this->orderBy == 'desc') {
|
||||||
return [$field => 'desc'];
|
return [$field => 'desc'];
|
||||||
}
|
}
|
||||||
if ($this->orderBy = 'asc') {
|
if ($this->orderBy == 'asc') {
|
||||||
return [$field => 'asc'];
|
return [$field => 'asc'];
|
||||||
}
|
}
|
||||||
return $defaultOrder;
|
return $defaultOrder;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user