user; $time = time(); $data = is_array($form->data) ? $form->data : Json::decode($form->data, true); $bargain_active = BargainActive::findOne(['id' => $data['active_id'], 'mall_id' => $form->mall_id]); if (empty($bargain_active)) throw new \Exception('活动不存在'); if ($time < $bargain_active['begin_time']) throw new \Exception('活动还没开始'); if ($time > $bargain_active['end_time']) throw new \Exception('活动已过期'); if ($bargain_active['type'] == 1) { $goods = Goods::getOne([ ['mall_id' => $form->mall_id], ['id' => $bargain_active['goods_id']], ['status' => StatusEnum::ENABLED] ], true, [], null, 'goods_name'); if ($bargain_active['stock'] <= 0) throw new \Exception($goods['goods_name'] . '商品已售罄,暂时无法购买哦~'); } } }