feat(api): 添加 DemoLogic 类和 test 方法
- 新增 DemoLogic 类,继承自 BaseLogic - 实现 test 方法,用于同步不同群体的价格信息 - 支持门店供货、种养殖、酒店、一条龙、厨师、商户会员和食堂会员等群体的价格更新
This commit is contained in:
parent
dd1033aee9
commit
a7a1c0bff4
62
app/api/logic/DemoLogic.php
Normal file
62
app/api/logic/DemoLogic.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use think\facade\Db;
|
||||
|
||||
class DemoLogic extends BaseLogic
|
||||
{
|
||||
public static function test()
|
||||
{
|
||||
$arr = Db::name('ceshi_two')->select();
|
||||
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)]);
|
||||
//种养殖
|
||||
$find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find();
|
||||
if ($find) {
|
||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->update(['price' => bcadd($v['price8'], 0, 2)]);
|
||||
} 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)]);
|
||||
}
|
||||
//酒店
|
||||
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find();
|
||||
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)]);
|
||||
} 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)]);
|
||||
}
|
||||
//一条龙
|
||||
$find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find();
|
||||
if ($find3) {
|
||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->update(['price' => bcadd($v['price5'], 0, 2)]);
|
||||
} else {
|
||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 18, 'price' => bcadd($v['price5'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv5'], 100), 100, 2)]);
|
||||
}
|
||||
//厨师
|
||||
$find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 1)->find();
|
||||
if ($find4) {
|
||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 1)->update(['price' => bcadd($v['price7'], 0, 2)]);
|
||||
} else {
|
||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 1, 'price' => bcadd($v['price7'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv7'], 100), 100, 2)]);
|
||||
}
|
||||
//商户会员
|
||||
$find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 19)->find();
|
||||
if ($find4) {
|
||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 19)->update(['price' => bcadd($v['price2'], 0, 2)]);
|
||||
} else {
|
||||
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();
|
||||
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)]);
|
||||
} else {
|
||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 20, 'price' => bcadd($v['price4'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv4'], 100), 100, 2)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user