time()) { return '未开始'; } if ($data['end_time'] < time()) { return '已结束'; } if ($data['start_time'] < time() && $data['end_time'] > time()) { return '生效-进行中'; } return ''; } /** *关联商品表 */ public function product() { return $this->hasMany('app\\common\\model\\plus\\bargain\\BargainProduct', 'bargain_id', 'bargain_id'); } /** *关联图片 */ public function file() { return $this->hasOne('app\\common\\model\\file\\UploadFile', 'file_id', 'image_id'); } /** * 砍价活动详情 */ public static function detail($bargain_activity_id, $with = []) { return (new static())->with($with)->find($bargain_activity_id); } /** * 处理过的详情数据 */ public static function detailWithTrans($bargain_activity_id) { $model = (new static())->with(['file'])->where('bargain_activity_id', '=', $bargain_activity_id)->find(); return [ 'title' => $model['title'], 'image_id' => $model['image_id'], 'file_path' => $model['file']['file_path'], 'sort' => $model['sort'], 'is_delete' => $model['is_delete'], 'conditions' => $model['conditions'], 'together_time' => $model['together_time'], 'status' => $model['status'], 'start_time' => date('Y-m-d H:i:s', $model['start_time']), 'end_time' => date('Y-m-d H:i:s', $model['end_time']), ]; } }