commit
a54adbd928
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\admin\controller\purchase_order;
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\purchase_order\PurchaseOrderLists;
|
||||||
|
|
||||||
|
class PurchaseOrderController extends BaseAdminController{
|
||||||
|
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new PurchaseOrderLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -99,15 +99,16 @@ class StoreProductController extends BaseAdminController
|
|||||||
$product_arr = $this->request->post('product_arr');
|
$product_arr = $this->request->post('product_arr');
|
||||||
$store_arr = $this->request->post('store_arr');
|
$store_arr = $this->request->post('store_arr');
|
||||||
$stock_type = $this->request->post('stock_type',1);
|
$stock_type = $this->request->post('stock_type',1);
|
||||||
|
$warehouse_id = $this->request->post('warehouse_id');
|
||||||
if (count($store_arr) == 1) {
|
if (count($store_arr) == 1) {
|
||||||
$store_id = $store_arr[0];
|
$store_id = $store_arr[0];
|
||||||
foreach ($product_arr as $key => $arr) {
|
foreach ($product_arr as $key => $arr) {
|
||||||
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId]);
|
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId,'warehouse_id'=>$warehouse_id]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($product_arr as $key => $arr) {
|
foreach ($product_arr as $key => $arr) {
|
||||||
foreach ($store_arr as $k => $store_id) {
|
foreach ($store_arr as $k => $store_id) {
|
||||||
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId]);
|
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId,'warehouse_id'=>$warehouse_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
95
app/admin/controller/warehouse/WarehouseController.php
Normal file
95
app/admin/controller/warehouse/WarehouseController.php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\warehouse\WarehouseLists;
|
||||||
|
use app\admin\logic\warehouse\WarehouseLogic;
|
||||||
|
use app\admin\validate\warehouse\WarehouseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库信息控制器
|
||||||
|
* Class WarehouseController
|
||||||
|
* @package app\admin\controller\warehouse
|
||||||
|
*/
|
||||||
|
class WarehouseController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库信息列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new WarehouseLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加仓库信息
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseValidate())->post()->goCheck('add');
|
||||||
|
$result = WarehouseLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(WarehouseLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑仓库信息
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseValidate())->post()->goCheck('edit');
|
||||||
|
$result = WarehouseLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(WarehouseLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除仓库信息
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseValidate())->post()->goCheck('delete');
|
||||||
|
WarehouseLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库信息详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseValidate())->goCheck('detail');
|
||||||
|
$result = WarehouseLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\warehouse_product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\warehouse_product\WarehouseProductLists;
|
||||||
|
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||||
|
use app\admin\validate\warehouse_product\WarehouseProductValidate;
|
||||||
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品仓储信息控制器
|
||||||
|
* Class WarehouseProductController
|
||||||
|
* @package app\admin\controller\warehouse_product
|
||||||
|
*/
|
||||||
|
class WarehouseProductController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品仓储信息列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new WarehouseProductLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加商品仓储信息
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseProductValidate())->post()->goCheck('add');
|
||||||
|
$params['admin_id']=$this->adminId;
|
||||||
|
$result = WarehouseProductLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(WarehouseProductLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑商品仓储信息
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseProductValidate())->post()->goCheck('edit');
|
||||||
|
$params['admin_id']=$this->adminId;
|
||||||
|
$result = WarehouseProductLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(WarehouseProductLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除商品仓储信息
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseProductValidate())->post()->goCheck('delete');
|
||||||
|
WarehouseProductLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品仓储信息详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new WarehouseProductValidate())->goCheck('detail');
|
||||||
|
$result = WarehouseProductLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认操作
|
||||||
|
*/
|
||||||
|
public function enter(){
|
||||||
|
$id=$this->request->post('id');
|
||||||
|
$result = WarehouseProductLogic::enter($id);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(WarehouseProductLogic::getError());
|
||||||
|
return $this->success($result);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\warehouse_product_storege;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeLists;
|
||||||
|
use app\admin\logic\warehouse_product_storege\WarehouseProductStoregeLogic;
|
||||||
|
use app\admin\validate\warehouse_product_storege\WarehouseProductStoregeValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库商品存储控制器
|
||||||
|
* Class WarehouseProductStoregeController
|
||||||
|
* @package app\admin\controller\warehouse_product_storege
|
||||||
|
*/
|
||||||
|
class WarehouseProductStoregeController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库商品存储列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new WarehouseProductStoregeLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @notes 添加仓库商品存储
|
||||||
|
// * @return \think\response\Json
|
||||||
|
// * @author admin
|
||||||
|
// * @date 2024/08/01 10:22
|
||||||
|
// */
|
||||||
|
// public function add()
|
||||||
|
// {
|
||||||
|
// $params = (new WarehouseProductStoregeValidate())->post()->goCheck('add');
|
||||||
|
// $result = WarehouseProductStoregeLogic::add($params);
|
||||||
|
// if (true === $result) {
|
||||||
|
// return $this->success('添加成功', [], 1, 1);
|
||||||
|
// }
|
||||||
|
// return $this->fail(WarehouseProductStoregeLogic::getError());
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @notes 编辑仓库商品存储
|
||||||
|
// * @return \think\response\Json
|
||||||
|
// * @author admin
|
||||||
|
// * @date 2024/08/01 10:22
|
||||||
|
// */
|
||||||
|
// public function edit()
|
||||||
|
// {
|
||||||
|
// $params = (new WarehouseProductStoregeValidate())->post()->goCheck('edit');
|
||||||
|
// $result = WarehouseProductStoregeLogic::edit($params);
|
||||||
|
// if (true === $result) {
|
||||||
|
// return $this->success('编辑成功', [], 1, 1);
|
||||||
|
// }
|
||||||
|
// return $this->fail(WarehouseProductStoregeLogic::getError());
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @notes 删除仓库商品存储
|
||||||
|
// * @return \think\response\Json
|
||||||
|
// * @author admin
|
||||||
|
// * @date 2024/08/01 10:22
|
||||||
|
// */
|
||||||
|
// public function delete()
|
||||||
|
// {
|
||||||
|
// $params = (new WarehouseProductStoregeValidate())->post()->goCheck('delete');
|
||||||
|
// WarehouseProductStoregeLogic::delete($params);
|
||||||
|
// return $this->success('删除成功', [], 1, 1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @notes 获取仓库商品存储详情
|
||||||
|
// * @return \think\response\Json
|
||||||
|
// * @author admin
|
||||||
|
// * @date 2024/08/01 10:22
|
||||||
|
// */
|
||||||
|
// public function detail()
|
||||||
|
// {
|
||||||
|
// $params = (new WarehouseProductStoregeValidate())->goCheck('detail');
|
||||||
|
// $result = WarehouseProductStoregeLogic::detail($params);
|
||||||
|
// return $this->data($result);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
62
app/admin/lists/purchase_order/PurchaseOrderLists.php
Normal file
62
app/admin/lists/purchase_order/PurchaseOrderLists.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\purchase_order;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\purchase_order\PurchaseOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购订单列表
|
||||||
|
* Class PurchaseOrderLists
|
||||||
|
* @package app\admin\lists\purchase_order
|
||||||
|
*/
|
||||||
|
class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 17:09
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['store_id', 'order_id'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购订单列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 17:09
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return PurchaseOrder::where($this->searchWhere)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购订单数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 17:09
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return PurchaseOrder::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
65
app/admin/lists/warehouse/WarehouseLists.php
Normal file
65
app/admin/lists/warehouse/WarehouseLists.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\warehouse\Warehouse;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库信息列表
|
||||||
|
* Class WarehouseLists
|
||||||
|
* @package app\admin\listswarehouse
|
||||||
|
*/
|
||||||
|
class WarehouseLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['name', 'contacts', 'tel'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库信息列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return Warehouse::where($this->searchWhere)
|
||||||
|
->field(['id', 'name', 'code', 'contacts', 'tel', 'address', 'notes', 'sort'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库信息数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return Warehouse::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
89
app/admin/lists/warehouse_product/WarehouseProductLists.php
Normal file
89
app/admin/lists/warehouse_product/WarehouseProductLists.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\warehouse_product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\auth\Admin;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品仓储信息列表
|
||||||
|
* Class WarehouseProductLists
|
||||||
|
* @package app\admin\listswarehouse_product
|
||||||
|
*/
|
||||||
|
class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['warehouse_id', 'product_id', 'financial_pm'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品仓储信息列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return WarehouseProduct::where($this->searchWhere)
|
||||||
|
->field(['id', 'admin_id','warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'total_price', 'manufacture','expiration_date','status'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function ($item){
|
||||||
|
if($item->financial_pm==0){
|
||||||
|
$item->financial_pm_name='出库';
|
||||||
|
}else{
|
||||||
|
$item->financial_pm_name='入库';
|
||||||
|
}
|
||||||
|
if($item->status==0){
|
||||||
|
$item->status_name='未确认';
|
||||||
|
}else{
|
||||||
|
$item->status_name='已确认';
|
||||||
|
}
|
||||||
|
if($item->admin_id){
|
||||||
|
$item->admin_name=Admin::where('id',$item->admin_id)->value('name');
|
||||||
|
}else{
|
||||||
|
$item->admin_name='';
|
||||||
|
}
|
||||||
|
if($item->product_id){
|
||||||
|
$item->store_name=StoreProduct::where('id',$item->product_id)->value('store_name');
|
||||||
|
}else{
|
||||||
|
$item->store_name='';
|
||||||
|
}
|
||||||
|
$item->expiration_date=$item->expiration_date?date('Y-m-d',$item->expiration_date):'';
|
||||||
|
$item->manufacture=$item->manufacture?date('Y-m-d',$item->manufacture):'';
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品仓储信息数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return WarehouseProduct::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\warehouse_product_storege;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
use app\common\model\warehouse\Warehouse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库商品存储列表
|
||||||
|
* Class WarehouseProductStoregeLists
|
||||||
|
* @package app\admin\listswarehouse_product_storege
|
||||||
|
*/
|
||||||
|
class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// '=' => ['warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库商品存储列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return WarehouseProductStorege::where($this->searchWhere)
|
||||||
|
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function ($item){
|
||||||
|
$item->warehouse_name = Warehouse::where('id',$item->warehouse_id)->value('name');
|
||||||
|
$find= StoreProduct::where('id',$item->product_id)->find();
|
||||||
|
if($find){
|
||||||
|
$item->store_name = $find->store_name;
|
||||||
|
$item->image = $find->image;
|
||||||
|
$item->bar_code = $find->bar_code;
|
||||||
|
$item->price = $find->price;
|
||||||
|
$item->cost = $find->cost;
|
||||||
|
$item->purchase = $find->purchase;
|
||||||
|
$item->store_info = $find->store_info;
|
||||||
|
$item->rose = $find->rose;
|
||||||
|
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||||
|
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name');
|
||||||
|
}
|
||||||
|
$item['stock']=$item['nums'];
|
||||||
|
return $item;
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库商品存储数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return WarehouseProductStorege::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
106
app/admin/logic/warehouse/WarehouseLogic.php
Normal file
106
app/admin/logic/warehouse/WarehouseLogic.php
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\warehouse\Warehouse;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库信息逻辑
|
||||||
|
* Class WarehouseLogic
|
||||||
|
* @package app\admin\logic\warehouse
|
||||||
|
*/
|
||||||
|
class WarehouseLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加仓库信息
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
Warehouse::create([
|
||||||
|
'name' => $params['name'],
|
||||||
|
'code' => $params['code'],
|
||||||
|
'contacts' => $params['contacts'],
|
||||||
|
'tel' => $params['tel'],
|
||||||
|
'address' => $params['address'],
|
||||||
|
'notes' => $params['notes'],
|
||||||
|
'sort' => $params['sort']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑仓库信息
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
Warehouse::where('id', $params['id'])->update([
|
||||||
|
'name' => $params['name'],
|
||||||
|
'code' => $params['code'],
|
||||||
|
'contacts' => $params['contacts'],
|
||||||
|
'tel' => $params['tel'],
|
||||||
|
'address' => $params['address'],
|
||||||
|
'notes' => $params['notes'],
|
||||||
|
'sort' => $params['sort']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除仓库信息
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return Warehouse::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库信息详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return Warehouse::findOrEmpty($params['id'])->toArray();
|
||||||
|
}
|
||||||
|
}
|
158
app/admin/logic/warehouse_product/WarehouseProductLogic.php
Normal file
158
app/admin/logic/warehouse_product/WarehouseProductLogic.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\warehouse_product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品仓储信息逻辑
|
||||||
|
* Class WarehouseProductLogic
|
||||||
|
* @package app\admin\logic\warehouse_product
|
||||||
|
*/
|
||||||
|
class WarehouseProductLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加商品仓储信息
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$res=WarehouseProduct::create([
|
||||||
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'financial_pm' => $params['financial_pm'],
|
||||||
|
'batch' => $params['batch'],
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'price' => $params['price']??'',
|
||||||
|
'total_price' => $params['total_price']??'',
|
||||||
|
'admin_id' => $params['admin_id'],
|
||||||
|
'code' => $params['code']??'',
|
||||||
|
'manufacture' => $params['manufacture']?strtotime($params['manufacture']):'',
|
||||||
|
'expiration_date' =>$params['expiration_date']?strtotime($params['expiration_date']):'',
|
||||||
|
'status' => $params['status']??0,
|
||||||
|
'mark' => $params['mark']??'',
|
||||||
|
]);
|
||||||
|
self::enter($res['id']);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑商品仓储信息
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
WarehouseProduct::where('id', $params['id'])->update([
|
||||||
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'financial_pm' => $params['financial_pm'],
|
||||||
|
'batch' => $params['batch'],
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'price' => $params['price'],
|
||||||
|
'admin_id' => $params['admin_id'],
|
||||||
|
'total_price' => $params['total_price'],
|
||||||
|
'code' => $params['code'],
|
||||||
|
'manufacture' => strtotime($params['manufacture']),
|
||||||
|
'expiration_date' => strtotime($params['expiration_date']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 确认商品仓储信息
|
||||||
|
* @param array $params
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public static function enter($id)
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$find=WarehouseProduct::where('id',$id)->find();
|
||||||
|
$find->status=1;
|
||||||
|
$find->save();
|
||||||
|
StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update();
|
||||||
|
$storege=WarehouseProductStorege::where('warehouse_id',$find['warehouse_id'])->where('product_id',$find['product_id'])->find();
|
||||||
|
if($storege){
|
||||||
|
$storege->nums=$storege->nums+$find['nums'];
|
||||||
|
$storege->save();
|
||||||
|
}else{
|
||||||
|
WarehouseProductStorege::create([
|
||||||
|
'warehouse_id' => $find['warehouse_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'nums' => $find['nums'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除商品仓储信息
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return WarehouseProduct::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品仓储信息详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
$data= WarehouseProduct::findOrEmpty($params['id'])->toArray();
|
||||||
|
if($data){
|
||||||
|
$data['manufacture']=date('Y-m-d',$data['manufacture']);
|
||||||
|
$data['expiration_date']=date('Y-m-d',$data['expiration_date']);
|
||||||
|
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\warehouse_product_storege;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库商品存储逻辑
|
||||||
|
* Class WarehouseProductStoregeLogic
|
||||||
|
* @package app\admin\logic\warehouse_product_storege
|
||||||
|
*/
|
||||||
|
class WarehouseProductStoregeLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加仓库商品存储
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
WarehouseProductStorege::create([
|
||||||
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'price' => $params['price'],
|
||||||
|
'total_price' => $params['total_price'],
|
||||||
|
'status' => $params['status']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑仓库商品存储
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
WarehouseProductStorege::where('id', $params['id'])->update([
|
||||||
|
'warehouse_id' => $params['warehouse_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'price' => $params['price'],
|
||||||
|
'total_price' => $params['total_price'],
|
||||||
|
'status' => $params['status']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除仓库商品存储
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return WarehouseProductStorege::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取仓库商品存储详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return WarehouseProductStorege::findOrEmpty($params['id'])->toArray();
|
||||||
|
}
|
||||||
|
}
|
84
app/admin/validate/warehouse/WarehouseValidate.php
Normal file
84
app/admin/validate/warehouse/WarehouseValidate.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库信息验证器
|
||||||
|
* Class WarehouseValidate
|
||||||
|
* @package app\admin\validate\warehouse
|
||||||
|
*/
|
||||||
|
class WarehouseValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'name' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'name' => '仓库名称',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return WarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return WarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return WarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return WarehouseValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:10
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\warehouse_product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品仓储信息验证器
|
||||||
|
* Class WarehouseProductValidate
|
||||||
|
* @package app\admin\validate\warehouse_product
|
||||||
|
*/
|
||||||
|
class WarehouseProductValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'warehouse_id' => 'require',
|
||||||
|
'product_id' => 'require',
|
||||||
|
'financial_pm' => 'require',
|
||||||
|
'batch' => 'require',
|
||||||
|
'nums' => 'require',
|
||||||
|
'price' => 'require',
|
||||||
|
'total_price' => 'require',
|
||||||
|
'status' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'warehouse_id' => '仓库ID',
|
||||||
|
'product_id' => '商品ID',
|
||||||
|
'financial_pm' => '0 = 出库 1 = 获得',
|
||||||
|
'batch' => '批次',
|
||||||
|
'nums' => '数量',
|
||||||
|
'price' => '价格',
|
||||||
|
'total_price' => '总价',
|
||||||
|
'status' => '状态',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return WarehouseProductValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['warehouse_id','product_id','financial_pm','batch','nums','price','total_price']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return WarehouseProductValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','warehouse_id','product_id','financial_pm','batch','nums','price','total_price']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return WarehouseProductValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return WarehouseProductValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/07/31 16:55
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\warehouse_product_storege;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库商品存储验证器
|
||||||
|
* Class WarehouseProductStoregeValidate
|
||||||
|
* @package app\admin\validate\warehouse_product_storege
|
||||||
|
*/
|
||||||
|
class WarehouseProductStoregeValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'warehouse_id' => 'require',
|
||||||
|
'product_id' => 'require',
|
||||||
|
'nums' => 'require',
|
||||||
|
'price' => 'require',
|
||||||
|
'total_price' => 'require',
|
||||||
|
'status' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'warehouse_id' => '仓库ID',
|
||||||
|
'product_id' => '商品ID',
|
||||||
|
'nums' => '数量',
|
||||||
|
'price' => '价格',
|
||||||
|
'total_price' => '价格',
|
||||||
|
'status' => '状态',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return WarehouseProductStoregeValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['warehouse_id','product_id','nums','price','total_price','status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return WarehouseProductStoregeValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','warehouse_id','product_id','nums','price','total_price','status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return WarehouseProductStoregeValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return WarehouseProductStoregeValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/01 10:22
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
app/common/model/purchase_order/PurchaseOrder.php
Normal file
22
app/common/model/purchase_order/PurchaseOrder.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\purchase_order;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购订单
|
||||||
|
* Class PurchaseOrder
|
||||||
|
* @package app\common\model\purchase_order
|
||||||
|
*/
|
||||||
|
class PurchaseOrder extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'purchase_order';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
22
app/common/model/purchase_order_info/PurchaseOrderInfo.php
Normal file
22
app/common/model/purchase_order_info/PurchaseOrderInfo.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\purchase_order_info;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购订单详情
|
||||||
|
* Class PurchaseOrderInfo
|
||||||
|
* @package app\common\model\purchase_order_info
|
||||||
|
*/
|
||||||
|
class PurchaseOrderInfo extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'purchase_order_info';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
22
app/common/model/warehouse/Warehouse.php
Normal file
22
app/common/model/warehouse/Warehouse.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\warehouse;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库信息模型
|
||||||
|
* Class Warehouse
|
||||||
|
* @package app\common\model\warehouse
|
||||||
|
*/
|
||||||
|
class Warehouse extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'warehouse';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
22
app/common/model/warehouse_product/WarehouseProduct.php
Normal file
22
app/common/model/warehouse_product/WarehouseProduct.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\warehouse_product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品仓储信息模型
|
||||||
|
* Class WarehouseProduct
|
||||||
|
* @package app\common\model\warehouse_product
|
||||||
|
*/
|
||||||
|
class WarehouseProduct extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'warehouse_product';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\warehouse_product_storege;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库商品存储
|
||||||
|
* Class WarehouseProductStorege
|
||||||
|
* @package app\common\model\warehouse_product_storege
|
||||||
|
*/
|
||||||
|
class WarehouseProductStorege extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'warehouse_product_storege';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -3,12 +3,14 @@
|
|||||||
namespace app\queue\redis;
|
namespace app\queue\redis;
|
||||||
|
|
||||||
use app\admin\logic\store_product\StoreProductLogic;
|
use app\admin\logic\store_product\StoreProductLogic;
|
||||||
|
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue;
|
use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue;
|
||||||
use app\common\model\store_branch_product_exchange\StoreBranchProductExchange;
|
use app\common\model\store_branch_product_exchange\StoreBranchProductExchange;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||||
use app\common\model\system_store_storage\SystemStoreStorage;
|
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||||
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use Webman\RedisQueue\Consumer;
|
use Webman\RedisQueue\Consumer;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -31,6 +33,7 @@ class StoreStorageSend implements Consumer
|
|||||||
$store_id = $data['store_id'];
|
$store_id = $data['store_id'];
|
||||||
$stock_type = $data['stock_type'];
|
$stock_type = $data['stock_type'];
|
||||||
$admin_id = $data['admin_id'];
|
$admin_id = $data['admin_id'];
|
||||||
|
$warehouse_id = $data['warehouse_id'];
|
||||||
$find = StoreProduct::where('id', $product_arr['id'])->findOrEmpty()->toArray();
|
$find = StoreProduct::where('id', $product_arr['id'])->findOrEmpty()->toArray();
|
||||||
if($stock_type == 1){
|
if($stock_type == 1){
|
||||||
$this->ordinary($product_arr,$store_id,$admin_id,$find);
|
$this->ordinary($product_arr,$store_id,$admin_id,$find);
|
||||||
@ -40,7 +43,7 @@ class StoreStorageSend implements Consumer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**普通 */
|
/**普通 */
|
||||||
public function ordinary($product_arr,$store_id,$admin_id,$find){
|
public function ordinary($product_arr,$store_id,$admin_id,$find,$warehouse_id){
|
||||||
$store_find = StoreBranchProduct::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray();
|
$store_find = StoreBranchProduct::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray();
|
||||||
if ($find && !$store_find) {
|
if ($find && !$store_find) {
|
||||||
$attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty();
|
$attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty();
|
||||||
@ -82,7 +85,7 @@ class StoreStorageSend implements Consumer
|
|||||||
];
|
];
|
||||||
StoreBranchProductAttrValue::create($arr);
|
StoreBranchProductAttrValue::create($arr);
|
||||||
if ($product_arr['stock'] > 0) {
|
if ($product_arr['stock'] > 0) {
|
||||||
$this->storage($find, $store_id, $admin_id, $product_arr);
|
$this->storage($find, $store_id, $admin_id, $product_arr,$warehouse_id);
|
||||||
}
|
}
|
||||||
StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id);
|
StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -109,7 +112,7 @@ class StoreStorageSend implements Consumer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**兑换 */
|
/**兑换 */
|
||||||
public function exchange($product_arr,$store_id,$admin_id,$find){
|
public function exchange($product_arr,$store_id,$admin_id,$find,$warehouse_id){
|
||||||
$store_find = StoreBranchProductExchange::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray();
|
$store_find = StoreBranchProductExchange::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray();
|
||||||
if ($find && !$store_find) {
|
if ($find && !$store_find) {
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
@ -133,7 +136,7 @@ class StoreStorageSend implements Consumer
|
|||||||
];
|
];
|
||||||
StoreBranchProductExchange::create($product);
|
StoreBranchProductExchange::create($product);
|
||||||
if ($product_arr['stock'] > 0) {
|
if ($product_arr['stock'] > 0) {
|
||||||
$this->storage($find, $store_id, $admin_id, $product_arr);
|
$this->storage($find, $store_id, $admin_id, $product_arr,$warehouse_id);
|
||||||
}
|
}
|
||||||
// StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id);
|
// StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -158,7 +161,7 @@ class StoreStorageSend implements Consumer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function storage($find, $store_id, $admin_id, $product_arr,$stock_type=1)
|
public function storage($find, $store_id, $admin_id, $product_arr,$stock_type=1,$warehouse_id=0)
|
||||||
{
|
{
|
||||||
$storage = [
|
$storage = [
|
||||||
'product_id' => $product_arr['id'],
|
'product_id' => $product_arr['id'],
|
||||||
@ -167,12 +170,27 @@ class StoreStorageSend implements Consumer
|
|||||||
'admin_id' => $admin_id,
|
'admin_id' => $admin_id,
|
||||||
'type' => $stock_type,
|
'type' => $stock_type,
|
||||||
];
|
];
|
||||||
if ($find['stock'] < $product_arr['stock']) {
|
$data=[
|
||||||
|
'warehouse_id'=>$warehouse_id,
|
||||||
|
'product_id' => $product_arr['id'],
|
||||||
|
'financial_pm' => 0,
|
||||||
|
'batch' => $product_arr['batch']??1,
|
||||||
|
'nums' => $product_arr['stock'],
|
||||||
|
'status' =>1,
|
||||||
|
'admin_id' =>$admin_id,
|
||||||
|
];
|
||||||
|
$warehouse=WarehouseProductStorege::where('warehouse_id',$warehouse_id)->where('product_id',$product_arr['id'])->find();
|
||||||
|
if ($warehouse) {
|
||||||
|
if($warehouse['nums']< $product_arr['stock']){
|
||||||
$storage['status'] = -1;
|
$storage['status'] = -1;
|
||||||
$storage['mark'] = '库存不足,主库存为:' . $find['stock'];
|
$storage['mark'] = '库存不足,分库存为:' .$warehouse['nums'];
|
||||||
|
$data['mark'] = '库存不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock'];
|
||||||
|
}
|
||||||
SystemStoreStorage::create($storage);
|
SystemStoreStorage::create($storage);
|
||||||
|
WarehouseProductLogic::add($data);
|
||||||
} else {
|
} else {
|
||||||
SystemStoreStorage::create($storage);
|
SystemStoreStorage::create($storage);
|
||||||
|
WarehouseProductLogic::add($data);
|
||||||
StoreProduct::where('id', $product_arr['id'])->dec('stock', $product_arr['stock'])->update();
|
StoreProduct::where('id', $product_arr['id'])->dec('stock', $product_arr['stock'])->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user