30], [['refund_limit_day', 'refund_limit_time'], 'string', 'max' => 20], [['tourist_name', 'tourist_sub_head'], 'string', 'max' => 200], [['tourist_type'], 'string', 'max' => 3], [['end_area_list', 'list_image_url', 'top_image_url', 'message'], 'string', 'max' => 255], [['pre_time'], 'string', 'max' => 5], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'tourist_id' => 'Tourist ID', 'tourist_code' => 'Tourist Code', 'main_corp_id' => 'Main Corp ID', 'supplier_id' => 'Supplier ID', 'tourist_name' => 'Tourist Name', 'tourist_sub_head' => 'Tourist Sub Head', 'is_onsale' => 'Is Onsale', 'cancel_flag' => 'Cancel Flag', 'create_user_id' => 'Create User ID', 'create_time' => 'Create Time', 'update_user_id' => 'Update User ID', 'update_time' => 'Update Time', 'tourist_description' => 'Tourist Description', 'min_people_num' => 'Min People Num', 'day_num' => 'Day Num', 'night_num' => 'Night Num', 'tourist_type' => 'Tourist Type', 'start_area_id' => 'Start Area ID', 'end_area_list' => 'End Area List', 'pre_days' => 'Pre Days', 'pre_time' => 'Pre Time', 'list_image_url' => 'List Image Url', 'top_image_url' => 'Top Image Url', 'message' => 'Message', ]; } public static function getOperaTouristCommonOne($tourist_id) { $data = self::findOne(['tourist_id' => $tourist_id, 'cancel_flag' => 0]); return $data; } /** * Function Description:判断自由行产品是否在允许售卖日期内 * Function Name: judgeTouristTimeAllow * @param int $tourist_id 自由行产品id * @param string $run_date 出发日期 * @return bool * * @author 温依莅 */ public static function judgeTouristTimeAllow($tourist_id, $run_date) { $res = self::find()->select('tourist_id,is_onsale,pre_days,pre_time') ->where('tourist_id=' . $tourist_id) ->asArray()->limit(1)->one(); $time_diff = strtotime('-' . $res['pre_days'] . ' day', strtotime($run_date . ' ' . $res['pre_time'] . ':00')) - time(); $time_allow = $time_diff > 0 ? 1 : 0;//是否在可售时间内 if (!$time_allow) { return false; } return true; } /** * Function Description:获取自由行产品短信模板 * Function Name: getTouristMsg * @param $tourist_id * @return array * @author 温依莅 */ public static function getTouristMsg($tourist_id) { $res = self::find()->select('tourist_id,message')->where(['tourist_id' => $tourist_id])->asArray()->one(); return $res; } /** * Function Description:根据tourist_id获取自由行行程天数 * Function Name: getDays * @param $tourist_id * @return array|null|\yii\db\ActiveRecord * @author 田玲菲 */ public function getDays($tourist_id) { $res = self::find()->select('day_num')->where(['tourist_id' => $tourist_id])->asArray()->one(); return $res; } /** * Function Description:判断自由行产品是否已过取消限制时间 * Function Name: checkRefundTime * @param $tourist_id,$date * * @return bool * * @author 娄梦宁 */ public function checkRefundTime($tourist_id,$date) { $refund_limit = self::find()->select('refund_limit_day,refund_limit_time')->from(self::tableName()) ->where(['and', ['=', 'cancel_flag', 0], ['=', 'tourist_id', $tourist_id]]) ->asArray()->one(); if ($refund_limit['refund_limit_day'] == '-1') { return true; } $time_diff = strtotime('-' . $refund_limit['refund_limit_day'] . ' day', strtotime($date . ' ' . $refund_limit['refund_limit_time'] . ':00')) - time(); $time_allow = $time_diff > 0 ? 1 : 0;//是否在可取消时间内 if (!$time_allow) { return false; } return true; } /** * Des:更加code获取 ID * Name: getTouristByCode * @param $code * @return int * @author 倪宗锋 */ public function getTouristByCode($code) { $where = ['tourist_code' => $code, 'cancel_flag' => 0]; $data = self::find()->select(['tourist_id']) ->where($where) ->asArray() ->one(); return empty($data['tourist_id']) ? 0 : $data['tourist_id']; } }