'ID', 'store_id' => 'Store ID', 'user_id' => 'User ID', 'saas_id' => 'Saas ID', 'goods_id' => 'Goods ID', 'created_at' => 'Addtime', 'is_delete' => 'Is Delete', 'price' => '期望价格', ]; } /** * 模块名:sendMsg * 代码描述:发送降价通知 * 作者:WPing丶 * 创建时间:2024/03/09 16:47:50 * @param int goods_id 商品id * @param int store_id 商城id * @param int price 商品修改后的价格 */ public static function sendMsg($goods_id, $store_id, $before_goods) { //debug_log('走到sendMsg'); $goods = Goods::find()->where(['id' => $goods_id])->select('id,price,name,attr,is_level,mch_id')->asArray()->one(); // $goods['diff_price'] = bcsub($before_price,$price,2); $list = self::find()->where(['goods_id' => $goods_id, 'is_delete' => 0, 'store_id' => $store_id])->asArray()->all(); foreach($list as $item) { $user = User::findOne($item['user_id']); if(!$user) { continue; } $res = CommonGoods::getMemberPrice($goods,[],$user); $old_res = CommonGoods::getMemberPrice($before_goods,[],$user); $user_min_price = $res['min_member_price'] ? $res['min_member_price'] : $goods['price']; $old_user_min_price = $old_res['min_member_price'] ? $old_res['min_member_price'] : $before_goods['price']; // //debug_log($user); $goods['diff_price'] = bcsub($old_user_min_price,$user_min_price,2); $goods['user_min_price'] = $user_min_price; if($user_min_price < $old_user_min_price) {//判断修改后的价格是否达用户设定的期望价格 NoticeSend::LoweringPrice($item['user_id'],$goods); $lowering = GoodsLoweringPrice::findOne(['user_id' => $item['user_id'], 'goods_id' => $goods_id, 'store_id' => $store_id, 'is_delete' => 0]); $lowering->price = $user_min_price; $lowering->save(); } } } }