コード例 #1
0
 public function actionCitychain()
 {
     \yii::$app->user->setIdentity(\common\models\User::findByUsername('admin'));
     $usersData = \yii::$app->oldcmsdb->createCommand("SELECT * \n                    FROM \n                        tc_group_city_mapping")->query();
     while ($row = $usersData->read()) {
         $attributes = array('Id' => $row['id'], 'chainId' => $row['chain_id'], 'cityId' => $row['city_id'], 'name' => htmlspecialchars_decode($row['establishment_name'], ENT_QUOTES), 'website' => $row['establishment_website'], 'pricefortwo' => $row['price_for_two'], 'cusinies' => $row['cusinies'], 'specilities' => $row['specilities'], 'whichType' => $row['est_which_type'], 'crowd' => $row['crowd'], 'type' => $row['establishment_type'], 'facebookUrl' => $row['facebook_url'], 'serves' => $row['serves'], 'guid' => $row['guid'], 'createdBy' => 40, 'updatedBy' => 40, 'createdOn' => $row['insert_date'], 'updatedOn' => $row['modified_date'], 'status' => $row['status']);
         if (($brand = BrandsCityMap::findOne($attributes['Id'])) !== null) {
         } else {
             $brand = new BrandsCityMap();
         }
         $chainImage = \yii::$app->oldcmsdb->createCommand("select * from tc_est_media where est_flag = 'chainCityMapp' and est_id='" . $row['id'] . "' and status=1 order by est_priority")->query();
         $images = [];
         while ($img = $chainImage->read()) {
             $images[] = ['media_id' => $img['est_media_id'], 'media_name' => $img['est_media_name'], 'media_caption' => $img['est_media_caption'], 'flag' => $img['est_flag'], 'created_by' => $img['created_by'], 'insertdate' => $img['insertdate'], 'IP' => $img['IP'], 'priority' => $img['est_priority']];
         }
         $attributes['media'] = Import::importMediaData($images, $brand->imagePath);
         $chainmenu = \yii::$app->oldcmsdb->createCommand("select * from tc_est_media where est_flag = 'chainmenu' and est_id='" . $row['id'] . "' and status=1 order by est_priority")->query();
         $images = [];
         while ($img = $chainmenu->read()) {
             $images[] = ['media_id' => $img['est_media_id'], 'media_name' => $img['est_media_name'], 'media_caption' => $img['est_media_caption'], 'flag' => $img['est_flag'], 'created_by' => $img['created_by'], 'insertdate' => $img['insertdate'], 'IP' => $img['IP'], 'priority' => $img['est_priority']];
         }
         $attributes['menu'] = Import::importMediaData($images, $brand->menuimagePath);
         $brand->detachBehavior('timestamp');
         $brand->detachBehavior('user');
         $brand->setAttributes($attributes);
         $brand->Id = $attributes['Id'];
         if ($brand->save(false, null, $attributes, false)) {
             echo "Map Id:" . $attributes['Id'] . ": imported\n";
         } else {
             echo "Map Id:" . $attributes['Id'] . ": not imported\n";
         }
     }
 }
コード例 #2
0
ファイル: Venue.php プロジェクト: rajanishtimes/partnerapi
 /**
  * 
  * @param string $jsonDOC
  * @return boolean
  */
 public function import($jsonDOC)
 {
     //echo $jsonDOC."\n";
     $docObj = Json::decode($jsonDOC, true);
     $mappingVanue = ["_id" => "Id", "venue_name" => "name", "venue_cat" => "categoryId", "city_id" => "cityId", "zone_id" => "zoneId", "locality_id" => "localityId", "city_name" => false, "zone_name" => false, "locality_name" => false, "address1" => "address", "address2" => false, "landmark" => "landmark", "phone" => false, "toll_no" => "tollfree", "mobile" => false, "gps" => false, 'gpsLat' => 'gpsLat', 'gpsLong' => 'gpsLong', "venue_brands" => "brand", "venue_mall" => "mall", "venue_type" => "venueType", "venue_facility" => false, "venue_capacity" => "capacity", "venue_desc" => "description", "venue_contact_person" => "contactName", "venue_email" => "email", "venue_url" => "url", "venue_fb_url" => "facebookUrl", "venue_seat_type" => "seatType", "venue_tags" => false, "reservation_info" => "reservationInfo", "start_time" => "startTime", "end_time" => "endTime", "IP" => "ip", "venue_is_reccomended" => "IsReccomended", "status" => "status", "insert_date" => "createdOn", "flag" => "flag", "oldguid" => "oldGuid", "guid" => "guid", "created_by" => "createdBy", "modified_by" => "updatedBy", "modified_date" => "updatedOn", "deleted_by" => false, "deleted_date" => false, "moderated_by" => false, "moderation_status" => false, "video_flag" => false, "image_flag" => false, "is_editable" => false, "assigned_to" => false, "csv_remarks" => "csvRemarks", "is_csv_upload" => "csvUpload", "tmp_venue_landline" => false, "tmp_venue_mobile" => false, "imagesArr" => false, "venue_type_name" => false, 'state' => 'state'];
     $mappingfunction = ["name" => function ($data, $row) {
         return addslashes(str_replace("\\'", "", $row['venue_name']));
     }, "address" => function ($data, $row) {
         return addslashes(str_replace("\\'", "", $row['address1']));
     }, "description" => function ($data, $row) {
         return addslashes(str_replace("\\'", "", $row['venue_desc']));
     }, "landmark" => function ($data, $row) {
         return addslashes(str_replace("\\'", "", $row['landmark']));
     }, "insert_date" => function ($data, $row) {
         return date('Y-m-d H:i:s', $data['sec']);
     }, "modified_date" => function ($data, $row) {
         return date('Y-m-d H:i:s', $data['sec']);
     }, "gpsLat" => function ($data, $row) {
         if (isset($row['gps']) && $row['gps'] != '') {
             $gps = explode('||', $row['gps']);
             return $gps[0];
         } else {
             return '';
         }
     }, "gpsLong" => function ($data, $row) {
         if (isset($row['gps']) && $row['gps'] != '') {
             $gps = explode('||', $row['gps']);
             return $gps[1];
         } else {
             return '';
         }
     }, "state" => function ($data, $row) {
         switch ((int) $row['status']) {
             case 1:
                 $ret = AppActiveRecord::STATUS_PUBLISH;
                 break;
             case 0:
                 $ret = AppActiveRecord::STATUS_DELETE;
                 break;
             default:
                 $ret = AppActiveRecord::STATUS_UNPUBLISH;
                 break;
         }
         return $ret;
     }];
     $data = ['media' => Import::importMediaData($docObj['extrafields']['images']['entity'], $this->imagePath), 'phone' => $this->converttoArray($docObj['phone']), 'mobile' => $this->converttoArray($docObj['mobile']), 'tag' => $this->converttoArray($docObj['venue_tags']), 'facilityId' => explode(',', $docObj['venue_facility'])];
     return Import::importData($this, $docObj, $mappingVanue, $mappingfunction, $data);
 }
コード例 #3
0
 /**
  * 
  * @param string $jsonDOC
  * @return boolean
  */
 public function import($jsonDOC)
 {
     //echo $jsonDOC."\n";
     Yii::info("Restaurant input:" . $jsonDOC);
     $docObj = Json::decode($jsonDOC, true);
     $mappingVanue = ["_id" => "Id", "est_name" => "name", "est_add2" => false, "est_add1" => "address", "est_landmark" => "landmark", "est_phone" => false, "est_mobile" => false, "est_toll_free" => "tollfree", "est_hotel_name" => "hotelId", "est_two_price" => "priceForTwo", "est_happy_hours" => false, "est_tips" => "tips", "est_specialities" => "specialities", "est_famous_for" => "famousFor", "est_which_type" => false, "est_which_type_id" => "entityType", "est_is_featured" => false, "criticName" => false, "criticImage" => false, "critic_name" => false, "critic_review" => false, "critic_food_rate" => false, "critic_service_rate" => false, "critic_decor_rate" => false, "critic_review_date" => false, "totalAvgRatingUser" => false, "user_food_rate_avg" => false, "user_service_rate_avg" => false, "user_decor_rate_avg" => false, "user_rating_count" => false, "critic_updated_date" => false, "userReviewArr" => false, "criticReviewArr" => false, "est_review_cnt" => false, "est_tags" => false, "est_viewcount" => false, "est_rate_cnt" => false, "est_launch_date" => 'launchdate', "est_pin_code" => "pin", "zone_name" => false, "zone_label" => false, "city_name" => false, "popularity_score" => false, "is_best" => false, "is_best_priority" => false, "deals" => false, "is_table_reservation_available" => false, "online_order_flag" => false, "gourmetitup_available" => false, "logo" => false, "loc_name" => false, "est_loc_id" => "localityId", "loc_name_alias" => false, "est_grp_id" => 'chainId', "est_group" => false, "est_grp_name" => false, "est_group_count" => false, "cuisine_priorities_list" => false, "est_flag" => false, "logo" => false, "image_url" => false, "is_image" => false, "est_menu" => false, "video_link" => false, "video_data" => false, "cuisines_name" => false, "est_type_name" => false, "service_name" => false, "feature_name" => false, "total_events" => false, "guid" => "guid", "loc_name_ft" => false, "est_name_cl" => false, "est_video_present" => false, "est_status" => "status", "est_hotel_name_ft" => false, "feature_tags" => false, "whats_new_rest" => false, "whats_new_bar" => false, "est_phone_alias" => "phoneAlias", "est_is_awarded" => false, "or_total_sum" => false, "or_users_count" => false, "std_code" => false, "est_email" => "email", "establishment_website" => "website", "located_in" => false, "suggestedDishesArr" => false, "popular_dishes" => false, "suggested_dishes" => false, "created_date" => "createdOn", "modified_date" => "updatedOn", "est_city_id" => "cityId", "est_types_id" => false, "lat_lng" => false, "loc_long_lat" => false, 'gpsLat' => 'gpsLat', 'gpsLong' => 'gpsLong', "rand" => false, "georand" => false, "is_whats_hot" => false, "whats_hot_image" => false, "whats_hot_priority" => false, "popular_pubs" => 'popularpubs', "awardsArr" => false, "extrafields" => false, "facebook" => "facebook", "ip" => "ip", 'createdBy' => "createdBy", 'updatedBy' => "updatedBy", 'coverFee' => "coverFee", 'entryFee' => "entryFee", 'ladiesFee' => "ladiesFee", 'capacity' => 'capacity', 'source_id' => 'sourceId', 'zoneId' => 'zoneId', 'oldguid' => 'old_guid', 'owner_name' => 'owner', 'manager_name' => 'manager', 'desc' => 'description', 'informar_name' => 'alias', 'est_cat_id' => false, 'typesid' => false, 'crowdids' => false, 'servicesid' => false, 'featuresid' => false, 'cuisinesid' => false, 'musicids' => false, 'paymentids' => false, 'est_usp_id' => false, 'state' => 'state'];
     $mappingfunction = ["est_hotel_name" => function ($data, $row) {
         return isset($row['extrafields']['hotelid']) ? $row['extrafields']['hotelid'] : 0;
     }, "est_launch_date" => function ($data, $row) {
         return $data['sec'] > 0 ? date('Y-m-d', $data['sec']) : '';
     }, 'gpsLat' => function ($data, $row) {
         return isset($row['loc_long_lat'][0]) ? $row['loc_long_lat'][0] : 0;
     }, 'gpsLong' => function ($data, $row) {
         return isset($row['loc_long_lat'][1]) ? $row['loc_long_lat'][1] : 0;
     }, 'facebook' => function ($data, $row) {
         return isset($row['extrafields']['facebook']) ? $row['extrafields']['facebook'] : '';
     }, 'ip' => function ($data, $row) {
         return isset($row['extrafields']['ip']) ? $row['extrafields']['ip'] : '';
     }, 'createdBy' => function ($data, $row) {
         return isset($row['extrafields']['created_by']) ? $row['extrafields']['created_by'] : 0;
     }, 'updatedBy' => function ($data, $row) {
         return isset($row['extrafields']['modified_by']) ? $row['extrafields']['modified_by'] : 0;
     }, 'coverFee' => function ($data, $row) {
         return isset($row['extrafields']['fee']['cover']) && $row['extrafields']['fee']['cover'] > 0 ? $row['extrafields']['fee']['cover'] : 0;
     }, 'entryFee' => function ($data, $row) {
         return isset($row['extrafields']['fee']['entry']) && $row['extrafields']['fee']['entry'] > 0 ? $row['extrafields']['fee']['entry'] : 0;
     }, 'ladiesFee' => function ($data, $row) {
         return isset($row['extrafields']['fee']['ladies']) && $row['extrafields']['fee']['ladies'] > 0 ? $row['extrafields']['fee']['ladies'] : 0;
     }, 'capacity' => function ($data, $row) {
         return isset($row['extrafields']['capacity']) && $row['extrafields']['capacity'] > 0 ? $row['extrafields']['capacity'] : 0;
     }, 'est_famous_for' => function ($data, $row) {
         return implode(', ', $data);
     }, 'source_id' => function ($data, $row) {
         return isset($row['extrafields']['source_id']) && $row['extrafields']['source_id'] > 0 ? $row['extrafields']['source_id'] : 0;
     }, 'est_two_price' => function ($data, $row) {
         return $data > 0 ? (int) $data : 0;
     }, 'zoneId' => function ($data, $row) {
         return isset($row['extrafields']['zoneid']) && $row['extrafields']['zoneid'] > 0 ? $row['extrafields']['zoneid'] : 0;
     }, 'oldguid' => function ($data, $row) {
         return isset($row['extrafields']['oldguid']) && $row['extrafields']['oldguid'] != '' ? $row['extrafields']['oldguid'] : '';
     }, 'owner_name' => function ($data, $row) {
         return isset($row['extrafields']['owner_name']) && $row['extrafields']['owner_name'] != '' ? $row['extrafields']['owner_name'] : '';
     }, 'manager_name' => function ($data, $row) {
         return isset($row['extrafields']['manager_name']) && $row['extrafields']['manager_name'] != '' ? $row['extrafields']['manager_name'] : '';
     }, 'desc' => function ($data, $row) {
         return isset($row['extrafields']['desc']) && $row['extrafields']['desc'] != '' ? $row['extrafields']['desc'] : '';
     }, 'informar_name' => function ($data, $row) {
         return isset($row['extrafields']['informar_name']) && $row['extrafields']['informar_name'] != '' ? $row['extrafields']['informar_name'] : '';
     }, "state" => function ($date, $row) {
         switch ((int) $row['est_status']) {
             case 1:
                 $ret = AppActiveRecord::STATUS_PUBLISH;
                 break;
             case 0:
                 $ret = AppActiveRecord::STATUS_DELETE;
                 break;
             default:
                 $ret = AppActiveRecord::STATUS_UNPUBLISH;
                 break;
         }
         return $ret;
     }];
     $data = ['media' => Import::importMediaData($docObj['extrafields']['images']['entity'], $this->imagePath), 'menu' => Import::importMediaData($docObj['extrafields']['images']['menu'], $this->menuimagePath), 'video' => Import::importvideoData($docObj['extrafields']['video']['entity']), 'phone' => $this->converttoArray($docObj['est_phone']), 'mobile' => $this->converttoArray($docObj['est_mobile']), 'category' => explode(',', $docObj['extrafields']['est_cat_id']), 'types' => explode(',', $docObj['extrafields']['typesid']), 'crowd' => explode(',', $docObj['extrafields']['crowdids']), 'service' => explode(',', $docObj['extrafields']['servicesid']), 'feature' => explode(',', $docObj['extrafields']['featuresid']), 'cuisines' => explode(',', $docObj['extrafields']['cuisinesid']), 'music' => explode(',', $docObj['extrafields']['musicids']), 'payment' => explode(',', $docObj['extrafields']['paymentids']), 'usp' => explode(',', $docObj['extrafields']['est_usp_id']), 'tag' => $docObj['est_tags']];
     return Import::importData($this, $docObj, $mappingVanue, $mappingfunction, $data);
 }
コード例 #4
0
ファイル: Event.php プロジェクト: rajanishtimes/partnerapi
 /**
  * 
  * @param string $jsonDOC
  * @return boolean
  */
 public function import($jsonDOC)
 {
     //echo $jsonDOC."\n";
     $docObj = Json::decode($jsonDOC, true);
     $mappingVanue = ["_id" => "Id", "event_title" => "name", "event_total" => false, "event_cat_name" => false, "event_cat_id" => false, "event_cat_sub_id" => false, "event_flag" => false, "event_desc" => "description", "city_name" => false, "eventImagesData" => false, "city_id" => "cityId", "zone_label" => false, "zone_name" => false, "est_loc_id" => "localityId", "locality_name" => false, "event_status" => "status", "isfeatured" => "isfeature", "isfeatured_priority" => "featurepriority", "address1" => "address", "address2" => false, "event_landmark" => "landmark", "event_pincode" => "pincode", "event_contact_name" => "contactName", "event_email" => "email", "event_url" => "url", "event_start_date" => "startDate", "event_end_date" => "endDate", "event_start_time" => "startTime", "event_end_time" => "endTime", "event_time_multiple" => "multipleTimings", "site_event_date" => false, "site_event_days" => false, "event_flag_for_sort" => false, "event_tags" => false, "event_image_path" => false, "category_image_path" => false, "event_price" => "price", "event_viewcount" => false, "event_attendeecount" => false, "insert_date" => "createdOn", "event_is_recommended" => false, "is_recursive" => "isRecursive", "weekdays_checklist" => "weekdaysChecklist", "event_type" => "type", "recursion_data" => "recursionData", "isRecursive" => "isRecursive", "guid" => "guid", "redirect_guid" => "oldGuid", "event_venue_est_id" => false, "cuisine_name" => false, "rand" => false, "georand" => false, "event_phone_number" => false, "event_phone_number_formated" => false, "gps_string" => false, "gps" => false, "gpsLat" => "gpsLat", "gpsLong" => "gpsLong", "ip" => 'ip', "modified_by" => "updatedBy", "author_id" => "createdBy", "modified_date" => "updatedOn", 'phone' => 'phone', 'toll_free' => 'tollfree', 'mobile' => 'mobile', 'alias' => 'alias', "categoryId" => "categoryId", 'extra' => false, 'event_venue_est_name' => false, 'event_venue_est_type' => false, 'venue_catId' => false, 'loc_long_lat' => false, 'state' => 'state'];
     $mappingfunction = ["address1" => function ($data, $row) {
         return implode(', ', $data);
     }, "redirect_guid" => function ($data, $row) {
         return implode('', $data);
     }, "event_pincode" => function ($data, $row) {
         return implode('', $data);
     }, "event_time_multiple" => function ($data, $row) {
         return $data != "" ? implode(' ', $data) : '';
     }, "event_tags" => function ($data, $row) {
         return implode(', ', $data);
     }, "event_type" => function ($data, $row) {
         return isset($row['extra']['eventtype']) && $row['extra']['eventtype'] > 0 ? $row['extra']['eventtype'] : 0;
     }, "insert_date" => function ($data, $row) {
         return date('Y-m-d H:i:s', $data['sec']);
     }, "modified_date" => function ($data, $row) {
         return date('Y-m-d H:i:s', $data['sec']);
     }, "event_start_date" => function ($data, $row) {
         return date('Y-m-d', $data['sec']);
     }, "event_end_date" => function ($data, $row) {
         return date('Y-m-d', $data['sec']);
     }, "event_start_time" => function ($data, $row) {
         return date('H:i:s', $data['sec']);
     }, "event_end_time" => function ($data, $row) {
         return date('H:i:s', $data['sec']);
     }, "phone" => function ($data, $row) {
         return isset($row['extra']["phone"]) ? $row['extra']["phone"] : '';
     }, "toll_free" => function ($data, $row) {
         return isset($row['extra']["tollfree"]) ? $row['extra']["tollfree"] : '';
     }, "mobile" => function ($data, $row) {
         return isset($row['extra']["mobile"]) ? $row['extra']["mobile"] : "";
     }, "gpsLat" => function ($data, $row) {
         if (isset($row['gps_string']) && $row['gps_string'] != '') {
             $gps = explode('||', $row['gps_string']);
             return $gps[0];
         } else {
             if (isset($row['gps']["gpsLat"]) && $row['gps']["gpsLat"] != '') {
                 return $row['gps']["gpsLat"];
             } else {
                 return '';
             }
         }
     }, "gpsLong" => function ($data, $row) {
         if (isset($row['gps_string']) && $row['gps_string'] != '') {
             $gps = explode('||', $row['gps_string']);
             return $gps[0];
         } else {
             if (isset($row['gps']["gpsLong"]) && $row['gps']["gpsLong"] != '') {
                 return $row['gps']["gpsLong"];
             } else {
                 return '';
             }
         }
     }, "state" => function ($data, $row) {
         switch ((int) $row['event_status']) {
             case 1:
                 $ret = AppActiveRecord::STATUS_PUBLISH;
                 break;
             case 0:
                 $ret = AppActiveRecord::STATUS_DELETE;
                 break;
             default:
                 $ret = AppActiveRecord::STATUS_UNPUBLISH;
                 break;
         }
         return $ret;
     }, "alias" => function ($data, $row) {
         return isset($row['event_phone_number_formated']["alias"]) ? $row['event_phone_number_formated']["alias"] : '';
     }, "event_cat_sub_id" => function ($data, $row) {
         return $data[0];
     }, "isRecursive" => function ($data, $row) {
         if ($row['recursion_data'] != '') {
             return 1;
         } else {
             return 0;
         }
     }];
     $data = ['media' => Import::importMediaData($docObj['extra']['images']['entity'], $this->imagePath), 'phone' => $this->converttoArray($docObj['phone']), 'mobile' => $this->converttoArray($docObj['mobile']), 'category' => $docObj['extra']['category'], 'tag' => $docObj['event_tags'], 'venue' => $docObj['extra']['map']['venue']];
     Yii::info($data, __METHOD__);
     return Import::importData($this, $docObj, $mappingVanue, $mappingfunction, $data);
 }
コード例 #5
0
ファイル: Movie.php プロジェクト: rajanishtimes/partnerapi
 /**
  * 
  * @param string $jsonDOC
  * @return boolean
  */
 public function import($jsonDOC)
 {
     //echo $jsonDOC."\n";
     Yii::info("Restaurant input:" . $jsonDOC);
     $docObj = Json::decode($jsonDOC, true);
     $mappingVanue = ["_id" => "Id", "movie_name" => "name", "cast" => 'cast', "synopsis" => "synopsis", "languageId" => "launguageId", "parentalGuidance" => "parentalGuidance", "editor_rating" => "starRating", "old_editor_rating" => "oldStarRating", "users_rating" => "avgerageUserRate", "review_count" => "reviewCount", "releasedate" => "releaseDate", "status" => "status", "movieshortname" => "alias", "tagline" => "tagline", "review" => "review", "length" => "length", "moviedirector" => "movieDirector", "musicdirector" => "musicDirector", "movie_guid" => "guid", "toi_movie_id" => "toiMovieId", "genres" => false, 'extrafields' => false, 'languageName' => false, 'theaterid' => false, 'movieimage' => false, 'genres_name_ft' => false, 'movie_video_present' => false, 'languageName_ft' => false, 'movie_name_cl' => false, 'parentalGuidance_ft' => false, 'popularity_score' => false, 'rand' => false, 'georand' => false, 'movie_video_code' => false, 'is_showtime' => false, 'state' => 'state'];
     $mappingfunction = ["releasedate" => function ($data, $row) {
         return $data['sec'] > 0 ? date('Y-m-d', $data['sec']) : '';
     }, "cast" => function ($data, $row) {
         return is_array($data) ? implode(', ', $data) : $data;
     }, "state" => function ($date, $row) {
         switch ((int) $row['status']) {
             case 1:
                 $ret = AppActiveRecord::STATUS_PUBLISH;
                 break;
             case 0:
                 $ret = AppActiveRecord::STATUS_DELETE;
                 break;
             default:
                 $ret = AppActiveRecord::STATUS_UNPUBLISH;
                 break;
         }
         return $ret;
     }];
     $data = ['media' => Import::importMediaData($docObj['extrafields']['images']['entity'], $this->imagePath), 'video' => Import::importvideoData($docObj['extrafields']['video']['entity']), 'genres' => explode(',', $docObj['extrafields']['genres'])];
     return Import::importData($this, $docObj, $mappingVanue, $mappingfunction, $data);
 }