|
@@ -18,205 +18,59 @@ class GetKennelDetailWorkCommand extends CConsoleCommand {
|
|
|
|
|
|
public function getKennel()
|
|
|
{
|
|
|
- $ids = array('26737', '19744', '7264', '24762', '26243', '21163', '25702', '26552', '25352', '20506', '26346', '26733', '13358', '26609', '26810', '11641', '26406',
|
|
|
- '25053', '26809', '26770', '26205', '24236', '26539', '24955', '15889', '24187', '12154', '26635', '18058', '24727', '26517', '26536', '21612', '26155', '25251',
|
|
|
- '25187', '26722', '23874', '16066', '26289', '26731', '18368', '11105', '14849', '16628', '25181', '26489', '25130', '26427', '26245', '22978', '26492',
|
|
|
- '8855', '21275', '5526', '12401', '26317', '17554', '25565', '26280', '26530', '26410', '26776', '26412', '10290', '26560', '22937', '26594', '26268', '23248',
|
|
|
- '21521', '26240', '26372', '26653', '26261', '20856', '26470', '24999', '26531', '26534', '15783', '26326', '25745', '22007', '26599', '26253', '26545',
|
|
|
- '13588', '22358', '26674', '25950', '26474', '22848', '26661', '26555', '26681', '26631', '14496', '26377', '26593', '4113', '26794', '26342', '26696',
|
|
|
- '26425', '26759', '26327', '25974', '22718', '26683', '12019', '25849', '25291', '25052', '24803', '26451', '26395', '19333', '14448', '26702', '26348', '26529',
|
|
|
- '25296', '26509', '24060', '26633', '17127', '12685', '26475', '24871', '15031', '25241', '26331', '24724', '26394', '26340', '10606', '26757',
|
|
|
- '26423', '26026', '23852', '26478', '26133', '19653', '25860', '26668', '26441', '26198', '24083', '26636', '26347', '26226', '26578', '26415', '19249', '24781',
|
|
|
- '26535', '25430', '26471', '26351', '26780', '26457', '24927', '26788', '26806', '26646', '24796', '26453', '26484', '26499', '25230', '26416', '25104', '25223', '21627', '26516', '24254',
|
|
|
- '23520', '23117', '26357', '26488', '26704', '23685', '26328', '19194', '2145', '26707', '25341', '20746', '59', '4337', '24098', '26726', '10861', '21888',
|
|
|
- '24224', '26600', '25090', '15634', '7655', '26504', '26764', '25999', '25967', '26591', '21514', '26184', '19908', '21870', '7927', '26749', '20436', '26361',
|
|
|
- '21770', '24730', '22868', '18966', '26246', '26449', '25288', '1850', '2872', '21648', '6740', '26501', '16656', '23552', '26659', '16823', '22362', '23444',
|
|
|
- '26565', '24916', '1774', '25263', '23275', '26494', '26306', '26746', '26111', '26665', '26298', '26431', '24395', '19549'
|
|
|
- );
|
|
|
- $petTypesId = array();
|
|
|
- $petTypes = array();
|
|
|
- foreach ($ids as $id) {
|
|
|
-
|
|
|
- $url = "http://pet.appcute.im/api/user/get?id=" . $id;
|
|
|
- $res = CommonFn::replaceUrl(CommonFn::simple_http($url));
|
|
|
-
|
|
|
- $res = json_decode($res, true);
|
|
|
-
|
|
|
- if ($res['error'] == 10000) {
|
|
|
-
|
|
|
- $value = $res['data'];
|
|
|
-
|
|
|
-
|
|
|
- $kennel = new Kennel();
|
|
|
-
|
|
|
- $kennel->status = 1;
|
|
|
-
|
|
|
- $kennel->name = $value['nickname'];
|
|
|
- if ($value['avatar'] == 'http://pet.appcute.im/bundles/cuteapi/static/no.png') {
|
|
|
- $value['avatar'] = 'http://icons.maiyizhi.cn/image_default.png';
|
|
|
- }
|
|
|
- $kennel->avatar = $value['avatar'];
|
|
|
- $kennel->join_time = time();
|
|
|
- $kennel->type = 2;
|
|
|
-
|
|
|
- $kennel->address = $value['contact']['address'];
|
|
|
- $kennel->desc = $value['desc'];
|
|
|
- $kennel->phone = $value['contact']['mobile'];
|
|
|
- $kennel->from = 'chongwushichang';
|
|
|
-
|
|
|
- $kennel->save();
|
|
|
-
|
|
|
- $petUrl = "http://pet.appcute.im/api/user/pets?id=".$id."&limit=500&offset=0";
|
|
|
-
|
|
|
- $res_pets = CommonFn::replaceUrl(CommonFn::simple_http($petUrl));
|
|
|
- $res_pets = json_decode($res_pets, true);
|
|
|
-
|
|
|
- //获取商家宠物 信息
|
|
|
-
|
|
|
-
|
|
|
- if ($res_pets['error'] == 10000) {
|
|
|
- $tmps = $res_pets['data']['values'];
|
|
|
- foreach ($tmps as $key=> $tmp) {
|
|
|
-
|
|
|
-
|
|
|
- $dealPet = new DealPet();
|
|
|
-
|
|
|
- if(in_array($tmp['cat']['id'],$petTypesId)) {
|
|
|
-
|
|
|
- $pet_type = PetTypes::model()->get(new MongoId($petTypes[$tmp['cat']['id']]));
|
|
|
-
|
|
|
- } else {
|
|
|
- $petTypesId[] = $tmp['cat']['id'];
|
|
|
- $pet_type = new PetTypes();
|
|
|
- $pet_type->name = $tmp['cat']['name'];
|
|
|
- if ($tmp['cat']['type'] == 1 ){//猫
|
|
|
- $pet_type->parent = new MongoId("546805e40eb9fb32018b45fe");
|
|
|
- } else if($tmp['cat']['type'] == 2 ){//狗
|
|
|
- $pet_type->parent = new MongoId("54671c4b0eb9fb89048b45f5");
|
|
|
- } else {
|
|
|
- $pet_type->parent = new MongoId("56a88c7ba84ea0e0478d6d2b");
|
|
|
- }
|
|
|
- $pet_type->pic = $tmp['cat']['pic'];
|
|
|
- $pet_type->level = 2;
|
|
|
- $pet_type->save();
|
|
|
- $petTypes[$tmp['cat']['id']] = (string)$pet_type->_id;
|
|
|
- }
|
|
|
-
|
|
|
- $dealPet->pet_type = new MongoId($pet_type->_id);
|
|
|
-
|
|
|
- $dealPet->name = $tmp['name'];
|
|
|
- $dealPet->status = 1;
|
|
|
- $dealPet->price = $tmp['price'];
|
|
|
- $dealPet->pics = array();
|
|
|
- foreach ($tmp['photos'] as $key =>$v) {
|
|
|
- $pic = array();
|
|
|
- $size = CommonFn::getPicSize($v);
|
|
|
- if (isset($size['width']) && isset($size['height'])) {
|
|
|
- $pic['width'] = intval($size['width']);
|
|
|
- $pic['height'] = intval($size['height']);
|
|
|
- }
|
|
|
-
|
|
|
- $pic['url'] = $v;
|
|
|
- $dealPet->pics[] = (object)$pic;
|
|
|
- }
|
|
|
-
|
|
|
- $dealPet->kennel = $kennel->_id;
|
|
|
- //$dealPet->pet_type = new MongoId($tmp['pet_type']);
|
|
|
- $dealPet->birth_date = intval($tmp['birthday']);
|
|
|
- $dealPet->gender = $tmp['sex'];
|
|
|
- /*$dealPet->tags = array();
|
|
|
- foreach ($tmp['tags'] as $v){
|
|
|
- $dealPet->tags[] = $v;
|
|
|
- }*/
|
|
|
- $father_info = array();
|
|
|
- $mother_info = array();
|
|
|
- if (isset($tmp['extra']['parents'][0]['pic']))
|
|
|
- $father_info['avatar'] = $tmp['extra']['parents'][0]['pic'];
|
|
|
- if (isset($tmp['extra']['parents'][1]['pic']))
|
|
|
- $mother_info['avatar'] = $tmp['extra']['parents'][1]['pic'];
|
|
|
-
|
|
|
- $dealPet->father_info = (object)$father_info;
|
|
|
- var_dump($dealPet->father_info);exit;
|
|
|
- $dealPet->mother_info = (object)$mother_info;
|
|
|
- $dealPet->desc = $tmp['desc'];
|
|
|
- $dealPet->vaccine_info = array();
|
|
|
- if (isset($tmp['extra'])){
|
|
|
- foreach ($tmp['extra']['vaccined'] as $v) {
|
|
|
-
|
|
|
-
|
|
|
- $datetime = date_create($v['date'])->format('U');
|
|
|
- $vaccine_info['time'] = intval($datetime);
|
|
|
- $vaccine_info['brand'] = $v['value'];
|
|
|
- $dealPet->vaccine_info[] = (object)$vaccine_info;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- $dealPet->add_time = time();
|
|
|
- //$dealPet->sort_weight = $tmp['sort_weight'];
|
|
|
- //$dealPet->delivery_time = $tmp['delivery_time'];
|
|
|
- //$dealPet->delivery_date = $tmp['delivery_date'];
|
|
|
- $tmp['deworming_info'] = array();
|
|
|
- if (!empty($tmp['parasited'])) {
|
|
|
-
|
|
|
- $tmp['deworming_info']['brand'] = $tmp['parasited']['value'];
|
|
|
- ;
|
|
|
- $tmp['deworming_info']['time'] = intval(date_create($tmp['parasited']['date'])->format('U'));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $dealPet->deworming_info = array();
|
|
|
- $dealPet->deworming_info[] = (Object)$tmp['deworming_info'];
|
|
|
-
|
|
|
- if (isset($value['videos']['length'])) {
|
|
|
- $value['video']['length'] = floatval($value['video']['length']);
|
|
|
- }
|
|
|
- $dealPet->video = (Object)$tmp['videos'];
|
|
|
-
|
|
|
- //$dealPet->carriage = (Object)$tmp['carriage'];
|
|
|
- //$dealPet->last_modify = $tmp['last_modify'];
|
|
|
- //$dealPet->view_count = $tmp['view_count'];
|
|
|
- //$dealPet->contact_count = $tmp['contact_count'];
|
|
|
- if ( $tmp['lat'] != 0 && $tmp['lng'] != 0){
|
|
|
- $position = CommonFn::GCJTobaidu($tmp['lat'], $tmp['lng']);
|
|
|
- $location = $position['lat'] . ',' . $position['lng'];
|
|
|
-
|
|
|
- $res = CommonFn::simple_http('http://api.map.baidu.com/geocoder/v2/?ak=B349f0b32ef6e78b2e678f45cb9fddaf&location=' . $location . '&output=json&pois=0');
|
|
|
- $info = json_decode($res);
|
|
|
- $cityinfo = array();
|
|
|
- if ($info || $info->status == 0) {
|
|
|
- $info = $info->result->addressComponent;
|
|
|
- if (!empty($info->province) && !empty($info->city)) {
|
|
|
- $cityinfo['province'] = $info->province;
|
|
|
- $cityinfo['city'] = $info->city;
|
|
|
- $cityinfo['area'] = $info->district;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- $cityinfo['province'] = '';
|
|
|
- $cityinfo['city'] = '';
|
|
|
- $cityinfo['area'] = '';
|
|
|
- }
|
|
|
-
|
|
|
- $tmp['region']['province'] = $cityinfo['province'];
|
|
|
- $tmp['region']['city'] = $cityinfo['city'];
|
|
|
- $tmp['region']['area'] = $cityinfo['area'];
|
|
|
-
|
|
|
-
|
|
|
- $dealPet->region = (Object)$tmp['region'];
|
|
|
- //$dealPet->last_deny_reason = $tmp['last_deny_reason'];
|
|
|
- $dealPet->from = 'chongwushichang';
|
|
|
-
|
|
|
- $dealPet->save();
|
|
|
- sleep(1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- sleep(1);
|
|
|
+ $user = RUser::model()->findAll();
|
|
|
+ $i = 0;
|
|
|
+ foreach ($user as $v) {
|
|
|
+ $data['UName'] = 'JGJZ';
|
|
|
+ $data['Pass'] = 'j1g2j3z40420';
|
|
|
+ $data['FID'] = (string)$v->_id;
|
|
|
+ $data['Source'] = $v->source;
|
|
|
+ $data['WXName'] = $v->user_name;
|
|
|
+
|
|
|
+ $data['FName'] = isset($v->user_info['name']) ? $v->user_info['name'] : '测试';
|
|
|
+ $data['Phone'] = isset($v->user_info['mobile']) ? $v->user_info['mobile'] : '123123';
|
|
|
+ $data['City'] = $v->source;
|
|
|
+ $data['CreatTime'] = date('Y-m-d', $v->register_time);
|
|
|
+ $data['OpenID'] = $v->wx_pub_openid;
|
|
|
+ $res = self::post(json_encode($data));
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ if ($i == 4) {
|
|
|
+ exit;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ public function post($data)
|
|
|
+ {
|
|
|
+ $curl = curl_init();
|
|
|
+
|
|
|
+ curl_setopt_array($curl, array(
|
|
|
+ CURLOPT_URL => "http://218.242.55.86/dsrest/datasnap/rest/TServerMethods1/AddFans",
|
|
|
+ CURLOPT_RETURNTRANSFER => true,
|
|
|
+ CURLOPT_ENCODING => "",
|
|
|
+ CURLOPT_MAXREDIRS => 10,
|
|
|
+ CURLOPT_TIMEOUT => 30,
|
|
|
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
|
+ CURLOPT_CUSTOMREQUEST => "POST",
|
|
|
+ CURLOPT_POSTFIELDS => $data,
|
|
|
+ CURLOPT_HTTPHEADER => array(
|
|
|
+ "content-type: application/json",
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response = curl_exec($curl);
|
|
|
+ $err = curl_error($curl);
|
|
|
+
|
|
|
+ curl_close($curl);
|
|
|
+
|
|
|
+ if ($err) {
|
|
|
+ echo "cURL Error #:" . $err;
|
|
|
+ } else {
|
|
|
+ echo $response;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|