fix(api): 修复价格更新和库存扣减问题
- 更新产品价格信息,包括供货价、成本价、会员价和零售价 - 添加活动价更新逻辑,针对特定客户群体 - 实现库存扣减功能,根据购物车数量更新门店库存 - 优化代码格式和结构,提高可读性
This commit is contained in:
parent
19d9ca9734
commit
945097566e
@ -3,6 +3,7 @@
|
|||||||
namespace app\api\logic;
|
namespace app\api\logic;
|
||||||
|
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -67,6 +68,23 @@ class DemoLogic extends BaseLogic
|
|||||||
} else {
|
} else {
|
||||||
StoreProductGroupPrice::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)]);
|
StoreProductGroupPrice::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)]);
|
||||||
}
|
}
|
||||||
|
//活动价
|
||||||
|
$find42 = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', 42)->find();
|
||||||
|
if ($find42) {
|
||||||
|
$find42->save(['price' => bcadd($v['price4'], 0, 2)]);
|
||||||
|
} else {
|
||||||
|
StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 42, 'price' => bcadd($v['price9'], 0, 2), 'price_type' => 3, 'base_rate' =>0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function test2($store_id, $srr)
|
||||||
|
{
|
||||||
|
foreach ($srr as $k => $v) {
|
||||||
|
$find = StoreBranchProduct::where('store_id', $store_id)->where('product_id', $v['product_id'])->find();
|
||||||
|
$find->stock = bcsub($find->stock, $v['cart_num'], 2);
|
||||||
|
$find->save();
|
||||||
|
SqlChannelLog('StoreBranchProduct', $find['id'], $v['cart_num'], -1, Request()->url(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user