feat(DemoLogic): 更新产品价格并添加酒店价格设置
- 在更新 StoreProduct 价格后,添加成功更新的逻辑,将 ceshi_two 表中的状态设置为 1 - 新增酒店价格设置,与食堂价格设置类似 - 优化代码结构,提高可读性和维护性
This commit is contained in:
parent
58224a6e62
commit
2bafdff052
@ -13,7 +13,10 @@ class DemoLogic extends BaseLogic
|
|||||||
$arr = Db::name('ceshi_two')->select();
|
$arr = Db::name('ceshi_two')->select();
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
//门店供货、商户、零售
|
//门店供货、商户、零售
|
||||||
StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]);
|
$res=StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]);
|
||||||
|
if($res){
|
||||||
|
Db::name('ceshi_two')->where('product_id', $v['product_id'])->update(['status' => 1]);
|
||||||
|
}
|
||||||
//种养殖
|
//种养殖
|
||||||
$find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find();
|
$find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
@ -21,13 +24,20 @@ class DemoLogic extends BaseLogic
|
|||||||
} else {
|
} else {
|
||||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 5, 'price' => bcadd($v['price8'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv8'], 100), 100, 2)]);
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 5, 'price' => bcadd($v['price8'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv8'], 100), 100, 2)]);
|
||||||
}
|
}
|
||||||
//酒店
|
//食堂
|
||||||
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find();
|
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find();
|
||||||
if ($find2) {
|
if ($find2) {
|
||||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->update(['price' => bcadd($v['price3'], 0, 2)]);
|
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->update(['price' => bcadd($v['price3'], 0, 2)]);
|
||||||
} else {
|
} else {
|
||||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 7, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]);
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 7, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]);
|
||||||
}
|
}
|
||||||
|
//酒店
|
||||||
|
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 6)->find();
|
||||||
|
if ($find2) {
|
||||||
|
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 6)->update(['price' => bcadd($v['price3'], 0, 2)]);
|
||||||
|
} else {
|
||||||
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 6, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]);
|
||||||
|
}
|
||||||
//一条龙
|
//一条龙
|
||||||
$find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find();
|
$find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find();
|
||||||
if ($find3) {
|
if ($find3) {
|
||||||
@ -50,7 +60,6 @@ class DemoLogic extends BaseLogic
|
|||||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 19, 'price' => bcadd($v['price2'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv2'], 100), 100, 2)]);
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 19, 'price' => bcadd($v['price2'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv2'], 100), 100, 2)]);
|
||||||
}
|
}
|
||||||
//食堂会员
|
//食堂会员
|
||||||
|
|
||||||
$find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->find();
|
$find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->find();
|
||||||
if ($find4) {
|
if ($find4) {
|
||||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->update(['price' => bcadd($v['price4'], 0, 2)]);
|
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->update(['price' => bcadd($v['price4'], 0, 2)]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user