|
@@ -8,54 +8,215 @@
|
|
|
|
|
|
class GetKennelDetailWorkCommand extends CConsoleCommand {
|
|
|
public function run($args){
|
|
|
- error_reporting(E_ALL);
|
|
|
+ //error_reporting(E_ERROR);
|
|
|
ini_set('memory_limit', '256M');
|
|
|
+ //ini_set('mongo.long_as_object',1);
|
|
|
set_time_limit(0);
|
|
|
- self::getData();
|
|
|
+ self::getKennel();
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function getData()
|
|
|
+ public function getKennel()
|
|
|
{
|
|
|
- $data = array();
|
|
|
- $data['act'] = 'get_user_balance';
|
|
|
- $data['page'] = 1;
|
|
|
- $data['size'] = 15;
|
|
|
- $data['currency_type'] = 2;
|
|
|
- $data['recharge_type'] = -1;
|
|
|
- $url = 'http://m.opencom.cn/ajax/cf_list.php?appid=41807';
|
|
|
- $cookie = 'UM_distinctid=15bccaf972e1b5-08d94ddabbc11e-396a7807-13c680-15bccaf972fe96; pgv_pvi=8607036416; opencom_uniqid=5909643f83a5d; Hm_lvt_b8c68976fe13d819f264767901121325=1493787711; _qddaz=QD.llwk1x.hu5sy6.j28imwkb; __AdinAll_SSP_UID=69e283776863251851c351e2f5fb3a39; __AdinAll_SSP_NUID=f16139fe947b0a7d80182d0b30e72b03; OpenCom=PyLb51cJswsP0ulwiLzvA0TRhGwXkeAGppX0n0uLf%2BCe3ulyexQRPTeoICuLRZ83RU2miHJHN2n04JeXI8pivHmPESIAsGspJy19E7Sj01HCDOrVXRaaMdJEC%2BSnl21zeyDrk8yp2IgbG7A9UWXaQxJekYp2OuQOxvdY5U2eUcfQ6BEgsSNPmmbqbul1z%2FfyL33omsLJfmb2FylAbafsMW7MvyKWxrMzXDJCEt55f4I%2Bkz6EluHcIFSbsliNmU%2FNtEs3K7saGZ3aNyEQqTeM97fNL%2FLtwcEHQlnKuApVpqX8hb7vb%2BFDq%2ByONGird3L1CKbTSMDy8bqaJ6CqKw%2BMG2EE1ePgyQ3b%2BnH9Xsj%2B6x7%2FpmakDALSZ7XAWKsxORsH9njYEiZWXzHTJQ3fgq6i4CYfMQOSg85pWGjsVYE3cFxc4rcHxU61f7uAXCxOeay1XDkljzDdOBlqd6Cr4gqqrt2Flp4uTDu8yxyJk396DoPmFImjQF5yo%2Bt6SNlGHU2gFUv620nfKEyShX4F%2Fn4UV3m7wjoW1aw2Cd3dnLLZyawufe57pjGmflmhe4nei2%2Br7iCM27tgrRYwVjQxnNHmPfun8Grnk%2F6qquseZ%2FxUx5spnpgliPN1absctRwt5RG%2FE78yGEVx7Wzz1%2FCXsMgBiYuAqlosIYV%2Ff39KVZbVFjXzVf%2F5EO0xECgomSvBZc6jyFWyq5Pu0kPIfYgrtdRE48uYrHZorWGoW9SFKawnF0UCyWmbbLHxsL0gCtIzGQPOa5Qyui7ZMOnI%2FDeectrNetzrFxbJzzosNIiZ1LVB%2FJ3JK%2B1hVmT5vxT7H%2BzGeOkAOMIofqEMGoJhaicKQgjzvyVCpIWZ6ajhwjlcEJTNMwo6nyrhgU0TThUki5kCAJOMNuakEJ0bKSh3E%2Bupp%2FaikX4v8XT8dBI%2B4yIegxaNosb602TUb3%2BbGPLRR13fMIfQTHul7DRVFp0svfu1gMK5Lg%3D%3D; oc_login_name=Sama; oc_login_uid=1575621; oc_reg_time=1452572196; oc_img_id=65194238; PHPSESSID=lgb1q0rrkpkqdeubmh8cvf24s5; tanindex_20160405=2017-06-14';
|
|
|
- var_dump(self::http_post($data,$url,$cookie));exit;
|
|
|
+ $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']);
|
|
|
+ }
|
|
|
|
|
|
- public function http_post($data,$url,$cookie){
|
|
|
- $str = '';
|
|
|
- $dat = '';
|
|
|
- foreach ($data as $key => $value) {
|
|
|
- $str .= $key.'='.$value.'&';
|
|
|
- $dat .= $key.'='.urlencode($value).'&';
|
|
|
+ $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);
|
|
|
+ }
|
|
|
}
|
|
|
- $str = rtrim(trim($str),'&');
|
|
|
-
|
|
|
- $str .= $str.Yii::app()->params['shMd5Key'];
|
|
|
-
|
|
|
- $data['sign'] = strtoupper(md5($str));
|
|
|
- $dat .= 'sign='.urlencode($data['sign']);//构建post 参数
|
|
|
- $ch = curl_init();
|
|
|
- curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
|
|
|
- curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
- curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
- curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
|
|
- curl_setopt($ch, CURLOPT_POSTFIELDS, $dat);
|
|
|
- curl_setopt($ch,CURLOPT_COOKIE,$cookie);
|
|
|
-
|
|
|
- $result = curl_exec($ch);
|
|
|
- curl_close($ch);
|
|
|
- $res = json_decode($result,true);
|
|
|
- return $res;
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|