request->post(); $model = new \backend\server\TinyPng(); Yii::info(json_encode($input)); $model->CompressImg($input); } /* * 报名数据接口 */ public function actionSignup() { $input = Yii::$app->request->post(); $model = new \common\models\Enroll(); $row = $model->getList($input); if($row['data']) { $equipmentArr = [1=>'m', 2=>'pc']; $ip = array_column($row['data'],'ip'); $m = new \common\models\HttpRecord(); $IpRecord = $m->GetList(['ip'=>$ip,'create_at'=>$input['add_time']]); $ipArr = []; if($IpRecord) { foreach ($IpRecord as &$val) { $val['add_time'] = date('Y-m-d H:i',$val['create_at']); $ipArr[$val['ip']][] = $val; } } $mobile = (new \common\models\EnrollSource())->TypeColumn(1); $pc = (new \common\models\EnrollSource())->TypeColumn(2); foreach ($row['data'] as &$v) { if (isset($pc[$v['source']]) && $v['equipment'] == 2) { $v['source'] = $pc[$v['source']]; } if (isset($mobile[$v['source']]) && $v['equipment'] == 1) { $v['source'] = $mobile[$v['source']]; } $v['equipment'] = $equipmentArr[$v['equipment']]; if(isset($ipArr[$v['ip']])) { $v['ip_record'][] = $ipArr[$v['ip']][0]; foreach ($ipArr[$v['ip']] as $item) { if($v['create_at'] == $item['create_at']) { $v['ip_record'][] = $item; } } } if(empty($v['city_name'])) { $referer = urldecode($v['ip_record'][1]['referer']); $refererQuery = parse_url($referer); if(isset($refererQuery['query'])) { $UrlParams = self::ConvertUrlQuery($refererQuery['query']); } if(isset($UrlParams['city']) || isset($UrlParams['py'])) { $v['city_name'] = \common\models\CategoryCity::find()->andWhere(['del'=>1])->andWhere(['id'=>$UrlParams['city']])->one()['city_name']; }else{ $UrlPath = explode('/',$refererQuery['path']); //相册 if(strpos($refererQuery['path'],'house') !== false && strpos($refererQuery['path'],'album') !== false){ foreach ($UrlPath as $album) { if(is_numeric($album)) { $hid = \common\models\House::find()->andWhere(['id'=>$album])->one(); } } } //户型 if(strpos($refererQuery['path'],'house') !== false && strpos($refererQuery['path'],'type') !== false){ foreach ($UrlPath as $type) { if(is_numeric($type)) { $hid = \common\models\House::find()->andWhere(['id'=>$type])->one(); } } } //楼盘首页 if(strpos($refererQuery['path'],'house') !== false && strpos($refererQuery['path'],'-') !== false){ foreach ($UrlPath as $house) { if(strpos($house,'-') !== false ) { $hid = \common\models\House::find()->andWhere(['id'=>explode('-',$house)[1]])->one(); } } } if(isset($hid) && !empty($hid)) { $v['city_name'] = \common\models\CategoryCity::findOne($hid['city'])['city_name']; } } } } return Help::JsonCode(Help::SUCCESS,'成功',$row['data']); } return Help::JsonCode(Help::ERROR,'暂无数据'); } public static function ConvertUrlQuery($query) { $queryParts = explode('&', $query); $params = array(); foreach ($queryParts as $param) { $item = explode('=', $param); $params[$item[0]] = $item[1]; } return $params; } /* * 用于发送邮件 * */ public function actionSendemail() { $input = Yii::$app->request->post(); $email = new \common\api\EmailServer(); // Yii::info(json_encode($input)); $model = new \common\models\Enroll(); $row = $model->FindById($input['id']); $arr = []; $arr['tel'] = $row['mobile']; $arr['sid'] = 2; if(!empty($row['hid'])) { $house = new \common\models\House(); $HouseName = $house->FindById($row['hid']); if(!empty($HouseName)) { $arr['ascription'] = $HouseName['name']; $city = new \common\models\CategoryCity(); $cityName = $city->FindById($HouseName['city']); if(!empty($cityName)) { $arr['city'] = $cityName['city_name']; } } } $curl = new \linslin\yii2\curl\Curl(); $response = $curl->reset() ->setOption( CURLOPT_POSTFIELDS, $arr ) ->post('http://jixiaoadmin.pinfangw.com/.php?m=Home&c=Stats&a=SignUp'); $result = $email->SendOut($input['email'],$input['title'],$input['content']); if($result === true) { if(!empty($input['id'])) { $row->state = 2; $row->save(false); } } // $input = Yii::$app->request->post(); // $email = new \common\api\EmailServer(); // $result = $email->SendOut($input['email'],$input['title'],$input['content']); // if($result == true) // { // if(!empty($input['id'])) // { // $model = new \common\models\Enroll(); // $row = $model->FindById($input['id']); // $row->state = 2; // $row->save(false); // } // } } }