feat: 重构了库存管理功能,优化了库存添加逻辑,新增了库存状态查询功能
This commit is contained in:
parent
780248aff4
commit
dbb933f12f
@ -2,17 +2,20 @@
|
|||||||
|
|
||||||
namespace app\admin\logic\store_product;
|
namespace app\admin\logic\store_product;
|
||||||
|
|
||||||
|
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
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_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||||
use app\common\model\store_product_cate\StoreProductCate;
|
use app\common\model\store_product_cate\StoreProductCate;
|
||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
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 app\Request;
|
use app\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
@ -392,4 +395,162 @@ class StoreProductLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**普通 */
|
||||||
|
public static 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();
|
||||||
|
if ($find && !$store_find) {
|
||||||
|
//创建门店商品
|
||||||
|
$attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty();
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$dealCate = self::dealChangeCate($find['cate_id']);
|
||||||
|
$product = [
|
||||||
|
'product_id' => $find['id'],
|
||||||
|
'image' => $find['image'],
|
||||||
|
'store_name' => $find['store_name'],
|
||||||
|
'store_info' => $find['store_info'],
|
||||||
|
'keyword' => $find['keyword'],
|
||||||
|
'bar_code' => $find['bar_code'],
|
||||||
|
'cate_id' => $find['cate_id'],
|
||||||
|
'top_cate_id' => $dealCate['top_cate_id'],
|
||||||
|
'two_cate_id' => $dealCate['two_cate_id'],
|
||||||
|
'price' => $find['price'],
|
||||||
|
// 'cost' => $find['cost'], //v1.0
|
||||||
|
'cost' => $find['cost'],
|
||||||
|
'purchase' => $find['purchase'],
|
||||||
|
'vip_price' => $find['vip_price'],
|
||||||
|
'manufacturer_information' => $find['manufacturer_information']??'',
|
||||||
|
'unit' => $find['unit'],
|
||||||
|
'batch' => $find['batch'],
|
||||||
|
'store_id' => $store_id,
|
||||||
|
'sales' => 0,
|
||||||
|
'product_type' => $find['product_type'],
|
||||||
|
'stock' => 0,
|
||||||
|
'rose' => $find['rose'],
|
||||||
|
];
|
||||||
|
$branch = StoreBranchProduct::create($product);
|
||||||
|
$arr = [
|
||||||
|
'product_id' => $product_arr['id'],
|
||||||
|
'store_id' => $store_id,
|
||||||
|
'unique' => setUnique($branch['id'], '', 0),
|
||||||
|
'sales' => 0,
|
||||||
|
'type' => 0,
|
||||||
|
'bar_code' => $attr_value['bar_code']
|
||||||
|
];
|
||||||
|
StoreBranchProductAttrValue::create($arr);
|
||||||
|
if ($product_arr['stock'] > 0) {
|
||||||
|
self::storage($find, $store_id, $admin_id, $product_arr,$warehouse_id);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//更新门店库存
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
if ($product_arr['stock'] > 0) {
|
||||||
|
self::storage($find, $store_id, $admin_id, $product_arr,1,$warehouse_id);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**兑换 */
|
||||||
|
public static 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();
|
||||||
|
if ($find && !$store_find) {
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$product = [
|
||||||
|
'product_id' => $find['id'],
|
||||||
|
'image' => $find['image'],
|
||||||
|
'store_name' => $find['store_name'],
|
||||||
|
'store_info' => $find['store_info'],
|
||||||
|
'keyword' => $find['keyword'],
|
||||||
|
'bar_code' => $find['bar_code'],
|
||||||
|
'cate_id' => $find['cate_id'],
|
||||||
|
'price' => $find['price'],
|
||||||
|
'cost' => $find['cost'],
|
||||||
|
'purchase' => $find['purchase'],
|
||||||
|
'vip_price' => $find['vip_price'],
|
||||||
|
'unit' => $find['unit'],
|
||||||
|
'store_id' => $store_id,
|
||||||
|
'sales' => 0,
|
||||||
|
'stock' => 0,
|
||||||
|
];
|
||||||
|
StoreBranchProductExchange::create($product);
|
||||||
|
if ($product_arr['stock'] > 0) {
|
||||||
|
self::storage($find, $store_id, $admin_id, $product_arr,$warehouse_id);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
if ($product_arr['stock'] > 0) {
|
||||||
|
self::storage($find, $store_id, $admin_id, $product_arr,2,$warehouse_id);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static function storage($find, $store_id, $admin_id, $product_arr,$stock_type=1,$warehouse_id=0)
|
||||||
|
{
|
||||||
|
$storage = [
|
||||||
|
'product_id' => $product_arr['id'],
|
||||||
|
'store_id' => $store_id,
|
||||||
|
'nums' => $product_arr['stock'],
|
||||||
|
'admin_id' => $admin_id,
|
||||||
|
'type' => $stock_type,
|
||||||
|
'warehouse_id'=>$warehouse_id,
|
||||||
|
];
|
||||||
|
$data=[
|
||||||
|
'warehouse_id'=>$warehouse_id,
|
||||||
|
'product_id' => $product_arr['id'],
|
||||||
|
'store_id' => $store_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;
|
||||||
|
$data['status'] = -1;
|
||||||
|
$storage['mark'] = '库存不足,分库存为:' .$warehouse['nums'];
|
||||||
|
$data['mark'] = '库存不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock'];
|
||||||
|
}
|
||||||
|
$res=WarehouseProductLogic::add($data);
|
||||||
|
$storage['outbound_id']=$res['id']??0;
|
||||||
|
SystemStoreStorage::create($storage);
|
||||||
|
} else {
|
||||||
|
$res=WarehouseProductLogic::add($data);
|
||||||
|
$storage['outbound_id']=$res['id']??0;
|
||||||
|
SystemStoreStorage::create($storage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,6 @@ class SystemStoreStorageLogic extends BaseLogic
|
|||||||
'mark' => '',
|
'mark' => '',
|
||||||
]);
|
]);
|
||||||
StoreProduct::where('id', $params['product_id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update();
|
StoreProduct::where('id', $params['product_id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update();
|
||||||
WarehouseProductStorege::where('id',$productStorege['id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update();
|
|
||||||
WarehouseProduct::where('id',$find['outbound_id'])->update(['nums',$params['nums']]);
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -7,6 +7,7 @@ use app\common\model\warehouse_product\WarehouseProduct;
|
|||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -57,7 +58,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$res = WarehouseProduct::create($data);
|
$res = WarehouseProduct::create($data);
|
||||||
self::enter($res['id'], $params['financial_pm']);
|
self::enter($res['id'], $params['financial_pm']);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return $res;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
Log::error($e->getMessage().',file:'.$e->getFile().',line:'.$e->getLine());
|
Log::error($e->getMessage().',file:'.$e->getFile().',line:'.$e->getLine());
|
||||||
@ -122,12 +123,12 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$find->save();
|
$find->save();
|
||||||
|
|
||||||
$storege = WarehouseProductStorege::where('warehouse_id', $find['warehouse_id'])->where('product_id', $find['product_id'])->find();
|
$storege = WarehouseProductStorege::where('warehouse_id', $find['warehouse_id'])->where('product_id', $find['product_id'])->find();
|
||||||
if ($financial_pm == 0) {
|
// if ($financial_pm == 0) {
|
||||||
StoreProduct::where('id', $find['product_id'])->dec('stock', $find['nums'])->update();
|
// StoreProduct::where('id', $find['product_id'])->dec('stock', $find['nums'])->update();
|
||||||
} else {
|
// } else {
|
||||||
StoreProduct::where('id', $find['product_id'])->inc('stock', $find['nums'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]);
|
// StoreProduct::where('id', $find['product_id'])->inc('stock', $find['nums'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]);
|
||||||
StoreBranchProduct::where('product_id', $find['product_id'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]);
|
// StoreBranchProduct::where('product_id', $find['product_id'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ($storege) {
|
if ($storege) {
|
||||||
if ($financial_pm == 0) {
|
if ($financial_pm == 0) {
|
||||||
@ -156,9 +157,21 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function delete(array $params): bool
|
public static function delete(array $params): bool
|
||||||
{
|
{
|
||||||
return WarehouseProduct::destroy($params['id']);
|
$res=WarehouseProduct::where('id',$params['id'])->find();
|
||||||
}
|
if($res){
|
||||||
|
$res->delete();
|
||||||
|
if($res['financial_pm']==1){
|
||||||
|
WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->dec('nums',$res['nums'])->update();
|
||||||
|
}elseif($res['financial_pm']==0){
|
||||||
|
WarehouseProductStorege::where('warehouse_id',$res['warehouse_id'])->inc('nums',$res['nums'])->update();
|
||||||
|
SystemStoreStorage::where(['outbound_id'=>$res['id']])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取商品仓储信息详情
|
* @notes 获取商品仓储信息详情
|
||||||
|
@ -36,166 +36,12 @@ class StoreStorageSend implements Consumer
|
|||||||
$warehouse_id = $data['warehouse_id']??0;
|
$warehouse_id = $data['warehouse_id']??0;
|
||||||
$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,$warehouse_id);
|
StoreProductLogic::ordinary($product_arr,$store_id,$admin_id,$find,$warehouse_id);
|
||||||
}elseif($stock_type == 2){
|
}elseif($stock_type == 2){
|
||||||
$this->exchange($product_arr,$store_id,$admin_id,$find,$warehouse_id);
|
StoreProductLogic::exchange($product_arr,$store_id,$admin_id,$find,$warehouse_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**普通 */
|
|
||||||
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();
|
|
||||||
if ($find && !$store_find) {
|
|
||||||
$attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty();
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
$dealCate = self::dealChangeCate($find['cate_id']);
|
|
||||||
$product = [
|
|
||||||
'product_id' => $find['id'],
|
|
||||||
'image' => $find['image'],
|
|
||||||
'store_name' => $find['store_name'],
|
|
||||||
'store_info' => $find['store_info'],
|
|
||||||
'keyword' => $find['keyword'],
|
|
||||||
'bar_code' => $find['bar_code'],
|
|
||||||
'cate_id' => $find['cate_id'],
|
|
||||||
'top_cate_id' => $dealCate['top_cate_id'],
|
|
||||||
'two_cate_id' => $dealCate['two_cate_id'],
|
|
||||||
'price' => $find['price'],
|
|
||||||
// 'cost' => $find['cost'], //v1.0
|
|
||||||
'cost' => $find['cost'],
|
|
||||||
'purchase' => $find['purchase'],
|
|
||||||
'vip_price' => $find['vip_price'],
|
|
||||||
'manufacturer_information' => $find['manufacturer_information']??'',
|
|
||||||
'unit' => $find['unit'],
|
|
||||||
'batch' => $find['batch'],
|
|
||||||
'store_id' => $store_id,
|
|
||||||
'sales' => 0,
|
|
||||||
'product_type' => $find['product_type'],
|
|
||||||
'stock' => 0,
|
|
||||||
'rose' => $find['rose'],
|
|
||||||
];
|
|
||||||
$branch = StoreBranchProduct::create($product);
|
|
||||||
$arr = [
|
|
||||||
'product_id' => $product_arr['id'],
|
|
||||||
'store_id' => $store_id,
|
|
||||||
'unique' => setUnique($branch['id'], '', 0),
|
|
||||||
'sales' => 0,
|
|
||||||
'type' => 0,
|
|
||||||
'bar_code' => $attr_value['bar_code']
|
|
||||||
];
|
|
||||||
StoreBranchProductAttrValue::create($arr);
|
|
||||||
if ($product_arr['stock'] > 0) {
|
|
||||||
$this->storage($find, $store_id, $admin_id, $product_arr,$warehouse_id);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
if ($product_arr['stock'] > 0) {
|
|
||||||
$this->storage($find, $store_id, $admin_id, $product_arr,1,$warehouse_id);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**兑换 */
|
|
||||||
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();
|
|
||||||
if ($find && !$store_find) {
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
$product = [
|
|
||||||
'product_id' => $find['id'],
|
|
||||||
'image' => $find['image'],
|
|
||||||
'store_name' => $find['store_name'],
|
|
||||||
'store_info' => $find['store_info'],
|
|
||||||
'keyword' => $find['keyword'],
|
|
||||||
'bar_code' => $find['bar_code'],
|
|
||||||
'cate_id' => $find['cate_id'],
|
|
||||||
'price' => $find['price'],
|
|
||||||
'cost' => $find['cost'],
|
|
||||||
'purchase' => $find['purchase'],
|
|
||||||
'vip_price' => $find['vip_price'],
|
|
||||||
'unit' => $find['unit'],
|
|
||||||
'store_id' => $store_id,
|
|
||||||
'sales' => 0,
|
|
||||||
'stock' => 0,
|
|
||||||
];
|
|
||||||
StoreBranchProductExchange::create($product);
|
|
||||||
if ($product_arr['stock'] > 0) {
|
|
||||||
$this->storage($find, $store_id, $admin_id, $product_arr,$warehouse_id);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
if ($product_arr['stock'] > 0) {
|
|
||||||
$this->storage($find, $store_id, $admin_id, $product_arr,2,$warehouse_id);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function storage($find, $store_id, $admin_id, $product_arr,$stock_type=1,$warehouse_id=0)
|
|
||||||
{
|
|
||||||
$storage = [
|
|
||||||
'product_id' => $product_arr['id'],
|
|
||||||
'store_id' => $store_id,
|
|
||||||
'nums' => $product_arr['stock'],
|
|
||||||
'admin_id' => $admin_id,
|
|
||||||
'type' => $stock_type,
|
|
||||||
'warehouse_id'=>$warehouse_id,
|
|
||||||
];
|
|
||||||
$data=[
|
|
||||||
'warehouse_id'=>$warehouse_id,
|
|
||||||
'product_id' => $product_arr['id'],
|
|
||||||
'store_id' => $store_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;
|
|
||||||
$data['status'] = -1;
|
|
||||||
$storage['mark'] = '库存不足,分库存为:' .$warehouse['nums'];
|
|
||||||
$data['mark'] = '库存不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock'];
|
|
||||||
}
|
|
||||||
$res=WarehouseProductLogic::add($data);
|
|
||||||
$storage['outbound_id']=$res['id']??0;
|
|
||||||
SystemStoreStorage::create($storage);
|
|
||||||
} else {
|
|
||||||
$res=WarehouseProductLogic::add($data);
|
|
||||||
$storage['outbound_id']=$res['id']??0;
|
|
||||||
SystemStoreStorage::create($storage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onConsumeFailure(\Throwable $e, $package)
|
public function onConsumeFailure(\Throwable $e, $package)
|
||||||
{
|
{
|
||||||
@ -204,30 +50,4 @@ class StoreStorageSend implements Consumer
|
|||||||
return $package;
|
return $package;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 传入三级或者二级分类返还上级分类 一级那全是相同
|
|
||||||
*/
|
|
||||||
public static function dealChangeCate($cate_id)
|
|
||||||
{
|
|
||||||
$value =[];
|
|
||||||
$last_cate = Db::name('store_category')->where('id',$cate_id)->value('pid');
|
|
||||||
if(!empty($last_cate)){
|
|
||||||
//2
|
|
||||||
$value['two_cate_id'] = $last_cate;
|
|
||||||
//1
|
|
||||||
$first_cate = Db::name('store_category')->where('id',$value['two_cate_id'])->value('pid');
|
|
||||||
if(empty($first_cate)){//顶级了
|
|
||||||
$value['two_cate_id'] = $cate_id;
|
|
||||||
$value['top_cate_id'] = $last_cate;
|
|
||||||
}else{
|
|
||||||
$value['top_cate_id'] = $first_cate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
//1-2 选的1级目录
|
|
||||||
$value['two_cate_id'] = $cate_id;
|
|
||||||
$value['top_cate_id'] = $cate_id;
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
return SystemStoreStorage::where($this->searchWhere)
|
return SystemStoreStorage::where($this->searchWhere)
|
||||||
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums', 'mark', 'status'])
|
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums', 'mark', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['status' => 'aes'])
|
->order(['id'=>'desc','status' => 'aes'])
|
||||||
->select()->each(function ($item) {
|
->select()->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['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
|
$item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user