feat: 修改了库存管理逻辑和分类接口
This commit is contained in:
parent
e913dcb2ca
commit
2d189279cf
@ -66,26 +66,22 @@ class StoreProductLogic extends BaseLogic
|
||||
"unique" => setUnique($res['id'], '', 0),
|
||||
'sales' => 0,
|
||||
]);
|
||||
StoreCategory::where('id', $params['cate_id'])->inc('three')->update();
|
||||
|
||||
Db::commit();
|
||||
|
||||
if ($params['is_store_all'] == 1) {
|
||||
$store_arr = SystemStore::where('is_show', 1)->column('id');
|
||||
foreach($store_arr as $store_id){
|
||||
Redis::send('store-storage', ['product_arr' => ['id'=>$res['id'],'stock'=>0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
|
||||
foreach ($store_arr as $store_id) {
|
||||
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
|
||||
}
|
||||
// Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]);
|
||||
} else {
|
||||
if (is_array($params['store_arr']) && count($params['store_arr']) > 0) {
|
||||
foreach($params['store_arr'] as $key =>$store_id){
|
||||
Redis::send('store-storage', ['product_arr' => ['id'=>$res['id'],'stock'=>0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
|
||||
foreach ($params['store_arr'] as $key => $store_id) {
|
||||
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
|
||||
}
|
||||
// Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
@ -185,30 +181,27 @@ class StoreProductLogic extends BaseLogic
|
||||
*/
|
||||
public static function updateGoodsclass($cate_id, $type = 0)
|
||||
{
|
||||
$pid = StoreCategory::where('id', $cate_id)->value('pid');
|
||||
if ($pid) {
|
||||
$one = StoreCategory::where('id', $cate_id)->find();
|
||||
if ($one) {
|
||||
//查二级分类
|
||||
$StoreCategory = StoreCategory::where('id', $pid)->find();
|
||||
if ($StoreCategory) {
|
||||
$StoreCategory = StoreCategory::where('id', $StoreCategory['id'])->find();
|
||||
self::cate_update($cate_id,0,3);
|
||||
self::cate_update($pid,0,2);
|
||||
self::cate_update($StoreCategory['id'],0,1);
|
||||
} else {
|
||||
self::cate_update($cate_id,0,2);
|
||||
self::cate_update($pid,0,1);
|
||||
$two = StoreCategory::where('id', $one['pid'])->find();
|
||||
if ($two) {
|
||||
if ($two['pid'] != 0) {
|
||||
self::cate_update($cate_id,$two['id'],0,3);
|
||||
self::cate_update($two['id'],$two['pid'],0,2);
|
||||
self::cate_update($two['pid'],0,0,1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self::cate_update($cate_id,0,1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function cate_update($cate_id=0,$product_id=0,$leve=1){
|
||||
$find=Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id,'leve'=>$leve])->find();
|
||||
if($find){
|
||||
Db::name('store_product_cate')->where('id',$find['id'])->inc('count',1)->update();
|
||||
}else{
|
||||
Db::name('store_product_cate')->insert(['store_id' => 1, 'cate_id' => $cate_id,'count'=>1,'leve'=>$leve,'create_time'=>time(),'update_time'=>time()]);
|
||||
public static function cate_update($cate_id = 0,$pid=0, $product_id = 0, $leve = 1)
|
||||
{
|
||||
$find = Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id, 'leve' => $leve])->find();
|
||||
if ($find) {
|
||||
Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update();
|
||||
} else {
|
||||
Db::name('store_product_cate')->insert(['pid'=>$pid,'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'leve' => $leve, 'create_time' => time(), 'update_time' => time()]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -277,10 +270,11 @@ class StoreProductLogic extends BaseLogic
|
||||
/**
|
||||
* 增加库存
|
||||
*/
|
||||
public static function stock($data){
|
||||
public static function stock($data)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$find=StoreBranchProduct::where(['id' => $data['id']])->find();
|
||||
$find = StoreBranchProduct::where(['id' => $data['id']])->find();
|
||||
SystemStoreStorage::create([
|
||||
'product_id' => $find['product_id'],
|
||||
'store_id' => $find['store_id'],
|
||||
@ -294,6 +288,5 @@ class StoreProductLogic extends BaseLogic
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => [ 'name', 'data', 'store_id', 'sort'],
|
||||
'=' => ['name', 'data', 'store_id', 'sort', 'pid'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user