From a7a1c0bff4ca3be6e68904823ba5e42594a3cae2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 9 Dec 2024 17:04:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=20DemoLogic=20?= =?UTF-8?q?=E7=B1=BB=E5=92=8C=20test=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 DemoLogic 类,继承自 BaseLogic - 实现 test 方法,用于同步不同群体的价格信息 - 支持门店供货、种养殖、酒店、一条龙、厨师、商户会员和食堂会员等群体的价格更新 --- app/api/logic/DemoLogic.php | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app/api/logic/DemoLogic.php diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php new file mode 100644 index 000000000..6e8fb6791 --- /dev/null +++ b/app/api/logic/DemoLogic.php @@ -0,0 +1,62 @@ +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)]); + } + } + } +}