修改分类更新小程序查询的商户分类 更新短信验证码模板
This commit is contained in:
parent
f1219258c3
commit
2a9887e632
@ -9,6 +9,7 @@ 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_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\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\Request;
|
use app\Request;
|
||||||
@ -94,6 +95,34 @@ class StoreProductLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function deleteRelatedData($cate_id)
|
||||||
|
{
|
||||||
|
$data_to_delete = StoreProductCate::where('cate_id', $cate_id)->select();
|
||||||
|
foreach ($data_to_delete as $item) {
|
||||||
|
|
||||||
|
if ($item['pid'] != 0) {
|
||||||
|
self::deleteRelatedData($item['pid']);
|
||||||
|
StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($item['pid'] == 0 && in_array($item['count'],[0,1])){
|
||||||
|
StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 递归减少分类数据的count值
|
||||||
|
public static function decreaseCount($cate_id)
|
||||||
|
{
|
||||||
|
$data_to_decrease = StoreProductCate::where('cate_id', $cate_id)->select();
|
||||||
|
foreach ($data_to_decrease as $item) {
|
||||||
|
if ($item['pid'] != 0) {
|
||||||
|
self::decreaseCount($item['pid']);
|
||||||
|
}
|
||||||
|
StoreProductCate::where('id', $item['id'])->update(['count' => $item['count'] - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 编辑商品列表
|
* @notes 编辑商品列表
|
||||||
@ -119,15 +148,36 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'is_return' => $params['is_return'],
|
'is_return' => $params['is_return'],
|
||||||
'price' => $params['price'],
|
'price' => $params['price'],
|
||||||
'vip_price' => $params['vip_price'],
|
'vip_price' => $params['vip_price'],
|
||||||
'cost' => $params['cost'],
|
|
||||||
'swap' => $params['swap'] ?? 0,
|
'swap' => $params['swap'] ?? 0,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
StoreProduct::where('id', $params['id'])->update($data);
|
StoreProduct::where('id', $params['id'])->update($data);
|
||||||
|
$old_cate = StoreBranchProduct::where('product_id', $params['id'])->field('cate_id,store_id')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
// 获取分类ID
|
||||||
|
foreach ($old_cate as $vv) {
|
||||||
|
$related_data = Db::name('store_product_cate')->where('cate_id', $vv['cate_id'])->select();
|
||||||
|
//删除之前的分类
|
||||||
|
foreach ($related_data as $value) {
|
||||||
|
if ($value['count'] == 1) {
|
||||||
|
self::deleteRelatedData($value['cate_id']);
|
||||||
|
} elseif ($value['count'] > 1) {
|
||||||
|
self::decreaseCount($value['cate_id']);
|
||||||
|
}
|
||||||
|
//新增对应的分类
|
||||||
|
self::updateGoodsclass($params['cate_id'], $value['store_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//修改
|
||||||
StoreBranchProduct::where('product_id', $params['id'])->update([
|
StoreBranchProduct::where('product_id', $params['id'])->update([
|
||||||
'price' => $params['price'], 'vip_price' => $params['vip_price'],
|
'price' => $params['price'], 'vip_price' => $params['vip_price'],
|
||||||
'cost' => $params['cost']
|
'cost' => $params['cost'], 'cate_id' => $params['cate_id']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -213,6 +263,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => $store_id, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]);
|
Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => $store_id, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复制商品到门店
|
* 复制商品到门店
|
||||||
*/
|
*/
|
||||||
|
14
app/common/model/store_product_cate/StoreProductCate.php
Normal file
14
app/common/model/store_product_cate/StoreProductCate.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\store_product_cate;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
class StoreProductCate extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'store_product_cate';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user