Merge pull request 'feat: 添加仓库信息功能' (#73) from erp into rose

Reviewed-on: #73
This commit is contained in:
mkm 2024-08-01 15:46:53 +08:00
commit 55daad5815
3 changed files with 30 additions and 13 deletions

View File

@ -8,6 +8,7 @@ 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;
use app\common\model\warehouse\Warehouse;
/**
* 商品仓储信息列表
@ -68,6 +69,11 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
}else{
$item->store_name='';
}
if($item->warehouse_id){
$item->warehouse_name=Warehouse::where('id',$item->warehouse_id)->value('name');
}else{
$item->warehouse_name='';
}
$item->expiration_date=$item->expiration_date?date('Y-m-d',$item->expiration_date):'';
$item->manufacture=$item->manufacture?date('Y-m-d',$item->manufacture):'';
})

View File

@ -7,6 +7,7 @@ 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 support\Log;
use think\facade\Db;
@ -30,7 +31,7 @@ class WarehouseProductLogic extends BaseLogic
{
Db::startTrans();
try {
$res=WarehouseProduct::create([
$data=[
'warehouse_id' => $params['warehouse_id'],
'product_id' => $params['product_id'],
'financial_pm' => $params['financial_pm'],
@ -40,11 +41,16 @@ class WarehouseProductLogic extends BaseLogic
'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']??'',
]);
];
if(isset($params['manufacture']) &&$params['manufacture']!=''){
$data['manufacture']=strtotime($params['manufacture']);
}
if(isset($params['expiration_date']) &&$params['expiration_date']!=''){
$data['expiration_date']=strtotime($params['expiration_date']);
}
$res=WarehouseProduct::create($data);
self::enter($res['id']);
Db::commit();
return true;
@ -67,7 +73,7 @@ class WarehouseProductLogic extends BaseLogic
{
Db::startTrans();
try {
WarehouseProduct::where('id', $params['id'])->update([
$data=[
'warehouse_id' => $params['warehouse_id'],
'product_id' => $params['product_id'],
'financial_pm' => $params['financial_pm'],
@ -77,9 +83,14 @@ class WarehouseProductLogic extends BaseLogic
'admin_id' => $params['admin_id'],
'total_price' => $params['total_price'],
'code' => $params['code'],
'manufacture' => strtotime($params['manufacture']),
'expiration_date' => strtotime($params['expiration_date']),
]);
];
if(isset($params['manufacture']) &&$params['manufacture']!=''){
$data['manufacture']=strtotime($params['manufacture']);
}
if(isset($params['expiration_date']) &&$params['expiration_date']!=''){
$data['expiration_date']=strtotime($params['expiration_date']);
}
WarehouseProduct::where('id', $params['id'])->update($data);
Db::commit();
return true;

View File

@ -33,12 +33,12 @@ class StoreStorageSend implements Consumer
$store_id = $data['store_id'];
$stock_type = $data['stock_type'];
$admin_id = $data['admin_id'];
$warehouse_id = $data['warehouse_id'];
$warehouse_id = $data['warehouse_id']??0;
$find = StoreProduct::where('id', $product_arr['id'])->findOrEmpty()->toArray();
if($stock_type == 1){
$this->ordinary($product_arr,$store_id,$admin_id,$find);
$this->ordinary($product_arr,$store_id,$admin_id,$find,$warehouse_id);
}elseif($stock_type == 2){
$this->exchange($product_arr,$store_id,$admin_id,$find);
$this->exchange($product_arr,$store_id,$admin_id,$find,$warehouse_id);
}
}
@ -99,7 +99,7 @@ class StoreStorageSend implements Consumer
Db::startTrans();
try {
if ($product_arr['stock'] > 0) {
$this->storage($find, $store_id, $admin_id, $product_arr,1);
$this->storage($find, $store_id, $admin_id, $product_arr,1,$warehouse_id);
}
Db::commit();
return true;
@ -150,7 +150,7 @@ class StoreStorageSend implements Consumer
Db::startTrans();
try {
if ($product_arr['stock'] > 0) {
$this->storage($find, $store_id, $admin_id, $product_arr,2);
$this->storage($find, $store_id, $admin_id, $product_arr,2,$warehouse_id);
}
Db::commit();
return true;