commit
75b8d794e5
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\inventory_store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\inventory_store\InventoryStoreLists;
|
||||||
|
use app\admin\logic\inventory_store\InventoryStoreLogic;
|
||||||
|
use app\admin\validate\inventory_store\InventoryStoreValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店盘存控制器
|
||||||
|
* Class InventoryStoreController
|
||||||
|
* @package app\admin\controller\inventory_store
|
||||||
|
*/
|
||||||
|
class InventoryStoreController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取门店盘存列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new InventoryStoreLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加门店盘存
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new InventoryStoreValidate())->post()->goCheck('add');
|
||||||
|
$result = InventoryStoreLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(InventoryStoreLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑门店盘存
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new InventoryStoreValidate())->post()->goCheck('edit');
|
||||||
|
$params['admin_id']=$this->adminId;
|
||||||
|
$result = InventoryStoreLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(InventoryStoreLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 门店盘存核准
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function enter_nums()
|
||||||
|
{
|
||||||
|
$params = $this->request->post();
|
||||||
|
$result = InventoryStoreLogic::enterNums($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('核准成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\inventory_warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\inventory_warehouse\InventoryWarehouseLists;
|
||||||
|
use app\admin\logic\inventory_warehouse\InventoryWarehouseLogic;
|
||||||
|
use app\admin\validate\inventory_warehouse\InventoryWarehouseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库盘存控制器
|
||||||
|
* Class InventoryWarehouseController
|
||||||
|
* @package app\admin\controller\inventory_warehouse
|
||||||
|
*/
|
||||||
|
class InventoryWarehouseController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库盘存列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new InventoryWarehouseLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加仓库盘存
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new InventoryWarehouseValidate())->post()->goCheck('add');
|
||||||
|
$result = InventoryWarehouseLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(InventoryWarehouseLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑仓库盘存
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new InventoryWarehouseValidate())->post()->goCheck('edit');
|
||||||
|
$params['admin_id']=$this->adminId;
|
||||||
|
$result = InventoryWarehouseLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(InventoryWarehouseLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除仓库盘存
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new InventoryWarehouseValidate())->post()->goCheck('delete');
|
||||||
|
InventoryWarehouseLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 门店盘存核准
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function enter_nums()
|
||||||
|
{
|
||||||
|
$params = $this->request->post();
|
||||||
|
$params['warehouse_id']=1;
|
||||||
|
$result = InventoryWarehouseLogic::enterNums($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('核准成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
86
app/admin/lists/inventory_store/InventoryStoreLists.php
Normal file
86
app/admin/lists/inventory_store/InventoryStoreLists.php
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\inventory_store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\inventory_store\InventoryStore;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\auth\Admin;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店盘存列表
|
||||||
|
* Class InventoryStoreLists
|
||||||
|
* @package app\admin\listsinventory_store
|
||||||
|
*/
|
||||||
|
class InventoryStoreLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['store_id', 'nums', 'enter_nums', 'status'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取门店盘存列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return InventoryStore::where($this->searchWhere)
|
||||||
|
->field(['id', 'product_id', 'admin_id', 'staff_id', 'store_id', 'nums', 'enter_nums', 'status', 'create_time'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['create_time' => 'desc'])
|
||||||
|
->select()->each(function ($item) {
|
||||||
|
$item->status_name = match ($item->status) {
|
||||||
|
0 => '待盘点',
|
||||||
|
1 => '盘点中',
|
||||||
|
2 => '盘点完成',
|
||||||
|
default => '未知',
|
||||||
|
};
|
||||||
|
if($item->admin_id){
|
||||||
|
$item->admin_name = Admin::where('id',$item->admin_id)->value('name');
|
||||||
|
}
|
||||||
|
if($item->staff_id){
|
||||||
|
$item->staff_name = SystemStoreStaff::where('id',$item->staff_id)->value('staff_name');
|
||||||
|
}
|
||||||
|
if($item->store_id){
|
||||||
|
$item->store_name = SystemStore::where('id',$item->store_id)->value('name');
|
||||||
|
}
|
||||||
|
if($item->product_id){
|
||||||
|
$item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取门店盘存数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return InventoryStore::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\inventory_warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\inventory_warehouse\InventoryWarehouse;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\auth\Admin;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库盘存列表
|
||||||
|
* Class InventoryWarehouseLists
|
||||||
|
* @package app\admin\listsinventory_warehouse
|
||||||
|
*/
|
||||||
|
class InventoryWarehouseLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['product_id', 'warehouse_id'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库盘存列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return InventoryWarehouse::where($this->searchWhere)
|
||||||
|
->field(['id', 'product_id', 'admin_id', 'warehouse_id', 'nums', 'enter_nums', 'status','create_time'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function ($item) {
|
||||||
|
$item->status_name = match ($item->status) {
|
||||||
|
0 => '待盘点',
|
||||||
|
1 => '盘点中',
|
||||||
|
2 => '盘点完成',
|
||||||
|
default => '未知',
|
||||||
|
};
|
||||||
|
if($item->admin_id){
|
||||||
|
$item->admin_name = Admin::where('id',$item->admin_id)->value('name');
|
||||||
|
}
|
||||||
|
if($item->product_id){
|
||||||
|
$item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库盘存数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return InventoryWarehouse::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ namespace app\admin\lists\warehouse_product;
|
|||||||
|
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\beforehand_order\BeforehandOrder;
|
||||||
use app\common\model\warehouse_product\WarehouseProduct;
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
@ -65,7 +66,7 @@ class StoreWarehouseProductLists extends BaseAdminDataLists implements ListsSear
|
|||||||
$this->searchWhere[] = ['financial_pm', '=',0];
|
$this->searchWhere[] = ['financial_pm', '=',0];
|
||||||
$this->searchWhere[] = ['order_type', 'in',[1, 2, 3, 4, 8]];
|
$this->searchWhere[] = ['order_type', 'in',[1, 2, 3, 4, 8]];
|
||||||
return WarehouseProduct::where($this->searchWhere)
|
return WarehouseProduct::where($this->searchWhere)
|
||||||
->field(['id', 'admin_id', 'store_id','product_id', 'nums', 'refund_nums', 'status', 'mark', 'create_time',])
|
->field(['id', 'admin_id', 'store_id','product_id', 'nums', 'refund_nums', 'status', 'mark', 'create_time', 'order_type'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
// ->withTrashed()
|
// ->withTrashed()
|
||||||
@ -96,6 +97,7 @@ class StoreWarehouseProductLists extends BaseAdminDataLists implements ListsSear
|
|||||||
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type);
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WarehouseProduct::where($this->searchWhere)
|
return WarehouseProduct::where($this->searchWhere)
|
||||||
->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay'])
|
->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay', 'order_type'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
// ->withTrashed()
|
// ->withTrashed()
|
||||||
|
107
app/admin/logic/inventory_store/InventoryStoreLogic.php
Normal file
107
app/admin/logic/inventory_store/InventoryStoreLogic.php
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\inventory_store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\inventory_store\InventoryStore;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
use think\db\Raw;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店盘存逻辑
|
||||||
|
* Class InventoryStoreLogic
|
||||||
|
* @package app\admin\logic\inventory_store
|
||||||
|
*/
|
||||||
|
class InventoryStoreLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加门店盘存
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$find=InventoryStore::where('store_id', $params['store_id'])->whereDay('create_time')->find();
|
||||||
|
if($find){
|
||||||
|
throw new BusinessException('今日数据已生成');
|
||||||
|
}
|
||||||
|
$arr=StoreBranchProduct::where('store_id',$params['store_id'])->field('product_id,store_id,stock as nums')->select()->toArray();
|
||||||
|
(new InventoryStore())->saveAll($arr);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑门店盘存
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
InventoryStore::where('id', $params['id'])->update([
|
||||||
|
'admin_id'=>$params['admin_id']??0,
|
||||||
|
'enter_nums'=>$params['nums']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static function enterNums(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
InventoryStore::where('store_id', $params['store_id'])->whereDay('create_time',$params['create_time'])->update([
|
||||||
|
'status'=>2
|
||||||
|
]);
|
||||||
|
|
||||||
|
$arr=InventoryStore::where('store_id', $params['store_id'])->where('nums','<>',new Raw('enter_nums'))->whereDay('create_time',$params['create_time'])->select();
|
||||||
|
foreach ($arr as $k=>$v){
|
||||||
|
StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$v['store_id'])->update([
|
||||||
|
'stock'=>$v['enter_nums']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除门店盘存
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return InventoryStore::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
108
app/admin/logic/inventory_warehouse/InventoryWarehouseLogic.php
Normal file
108
app/admin/logic/inventory_warehouse/InventoryWarehouseLogic.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\inventory_warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\inventory_warehouse\InventoryWarehouse;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
use think\db\Raw;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库盘存逻辑
|
||||||
|
* Class InventoryWarehouseLogic
|
||||||
|
* @package app\admin\logic\inventory_warehouse
|
||||||
|
*/
|
||||||
|
class InventoryWarehouseLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加仓库盘存
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$find=InventoryWarehouse::where('warehouse_id', 1)->whereDay('create_time')->find();
|
||||||
|
if($find){
|
||||||
|
throw new BusinessException('今日数据已生成');
|
||||||
|
}
|
||||||
|
$arr=WarehouseProductStorege::where('warehouse_id',1)->field('product_id,nums,warehouse_id')->select()->toArray();
|
||||||
|
(new InventoryWarehouse())->saveAll($arr);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑仓库盘存
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
InventoryWarehouse::where('id', $params['id'])->update([
|
||||||
|
'admin_id'=>$params['admin_id']??0,
|
||||||
|
'enter_nums'=>$params['nums']
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除仓库盘存
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return InventoryWarehouse::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function enterNums(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
InventoryWarehouse::where('warehouse_id', $params['warehouse_id'])->whereDay('create_time',$params['create_time'])->update([
|
||||||
|
'status'=>2
|
||||||
|
]);
|
||||||
|
|
||||||
|
$arr=InventoryWarehouse::where('warehouse_id', $params['warehouse_id'])->where('nums','<>',new Raw('enter_nums'))->whereDay('create_time',$params['create_time'])->select();
|
||||||
|
foreach ($arr as $k=>$v){
|
||||||
|
WarehouseProductStorege::where('product_id',$v['product_id'])->where('warehouse_id',$v['warehouse_id'])->update([
|
||||||
|
'nums'=>$v['enter_nums']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\inventory_store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店盘存验证器
|
||||||
|
* Class InventoryStoreValidate
|
||||||
|
* @package app\admin\validate\inventory_store
|
||||||
|
*/
|
||||||
|
class InventoryStoreValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return InventoryStoreValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->remove('id', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return InventoryStoreValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return InventoryStoreValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return InventoryStoreValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 11:46
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\inventory_warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库盘存验证器
|
||||||
|
* Class InventoryWarehouseValidate
|
||||||
|
* @package app\admin\validate\inventory_warehouse
|
||||||
|
*/
|
||||||
|
class InventoryWarehouseValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return InventoryWarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->remove('id', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return InventoryWarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return InventoryWarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return InventoryWarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2025/02/14 17:24
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,8 +29,10 @@ class BeforehandOrder extends BaseModel
|
|||||||
3 => '一条龙订单',
|
3 => '一条龙订单',
|
||||||
4 => '线上订单',
|
4 => '线上订单',
|
||||||
5 => '仓库补货',
|
5 => '仓库补货',
|
||||||
6 => '采购订单',
|
6 => '往期补单',
|
||||||
7 => '其他订单',
|
7 => '采购订单',
|
||||||
|
8 => '其他订单',
|
||||||
|
9 => '往期补单',
|
||||||
];
|
];
|
||||||
return $typeMap[$type] ?? '';
|
return $typeMap[$type] ?? '';
|
||||||
}
|
}
|
||||||
|
22
app/common/model/inventory_store/InventoryStore.php
Normal file
22
app/common/model/inventory_store/InventoryStore.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\inventory_store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店盘存模型
|
||||||
|
* Class InventoryStore
|
||||||
|
* @package app\common\model\inventory_store
|
||||||
|
*/
|
||||||
|
class InventoryStore extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'inventory_store';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
22
app/common/model/inventory_warehouse/InventoryWarehouse.php
Normal file
22
app/common/model/inventory_warehouse/InventoryWarehouse.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\inventory_warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库盘存模型
|
||||||
|
* Class InventoryWarehouse
|
||||||
|
* @package app\common\model\inventory_warehouse
|
||||||
|
*/
|
||||||
|
class InventoryWarehouse extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'inventory_warehouse';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user