|
|
@@ -5,6 +5,7 @@ use app\common\logic\BaseLogic;
|
|
|
use app\common\model\coupon\CouponRules;
|
|
|
use app\common\model\goods\Goods;
|
|
|
use app\common\model\goods_category\GoodsCategory;
|
|
|
+use app\common\model\property\PropertyActivity;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Log;
|
|
|
|
|
|
@@ -19,6 +20,17 @@ class ActivityLogic extends BaseLogic
|
|
|
public static function getHomepageByActivityId($params){
|
|
|
$res = [];
|
|
|
try{
|
|
|
+ $propertyActivity = PropertyActivity::with(['propertyHeadInfo'])->where('id',$params['property_activity_id'])->findOrEmpty();
|
|
|
+ if($propertyActivity->isEmpty()){
|
|
|
+ throw new \Exception('活动不存在');
|
|
|
+ }
|
|
|
+ if(!empty($propertyActivity->getData('activity_start_time')) && $propertyActivity->getData('activity_start_time') > time()){
|
|
|
+ throw new \Exception('活动未开始');
|
|
|
+ }
|
|
|
+ if(!empty($propertyActivity->getData('activity_end_time')) && $propertyActivity->getData('activity_end_time') < time()){
|
|
|
+ throw new \Exception('活动已结束');
|
|
|
+ }
|
|
|
+ $res['activity_info'] = $propertyActivity->toArray();
|
|
|
$res['coupons'] = CouponRules::where('property_activity_id',$params['property_activity_id'])
|
|
|
->select()
|
|
|
->toArray();
|
|
|
@@ -30,8 +42,7 @@ class ActivityLogic extends BaseLogic
|
|
|
->toArray();
|
|
|
return $res;
|
|
|
}catch(\Exception $e){
|
|
|
- Log::info('getHomepageByActivityId:'.$e->getMessage());
|
|
|
- return $res;
|
|
|
+ throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|