Authored by yangyang

并行搜索地址写到helpersrarch文件中

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace Plugin; 3 namespace Plugin;
4 use Plugin\Paging; 4 use Plugin\Paging;
5 use LibModels\Web\Product\BrandData; 5 use LibModels\Web\Product\BrandData;
  6 +use Api\Yohobuy;
6 /** 7 /**
7 * 搜索辅助类 8 * 搜索辅助类
8 */ 9 */
@@ -1112,4 +1113,151 @@ class HelperSearch @@ -1112,4 +1113,151 @@ class HelperSearch
1112 } 1113 }
1113 1114
1114 } 1115 }
  1116 +
  1117 + /**
  1118 + * 并行调接口url获取(搜索产品数据)
  1119 + * @param
  1120 + */
  1121 + public static function getProductUrl($condition)
  1122 + {
  1123 + // 排序数据映射表
  1124 + $orderMaps = array(
  1125 + 's_t_desc' => 'shelve_time:desc',
  1126 + 's_t_asc' => 'shelve_time:asc',
  1127 + 's_p_asc' => 'sales_price:asc',
  1128 + 's_p_desc' => 'sales_price:desc',
  1129 + 'p_d_desc' => 'discount:desc',
  1130 + 'p_d_asc' => 'discount:asc',
  1131 + 'skn_desc' => 'product_skn:desc',
  1132 + 'skn_asc' => 'product_skn:asc',
  1133 + 'activities_desc' => 'activities.order_by:desc',
  1134 + 'activities_asc' => 'activities.order_by:asc',
  1135 + 's_n_asc' => 'sales_num:asc',
  1136 + 's_n_desc' => 'sales_num:desc',
  1137 + 'activities_id_desc' => 'activities.activity_id:desc',
  1138 + 'activities_id_asc' => 'activities.activity_id:asc',
  1139 + );
  1140 +
  1141 + $param = array();
  1142 + $param['status'] = 1; // 是否上架,1表示在架,2表示不在
  1143 + $param['sales'] = 'Y'; // 只搜索销售的产品
  1144 + $param['stocknumber'] = 1; // 过滤掉已售罄的商品
  1145 + // $param['needFilter'] = 1; // 是否需要返回筛选条件
  1146 + if (!isset($condition['order'])) {
  1147 + $param['order'] = $orderMaps['s_t_desc'];
  1148 + } else {
  1149 + $param['order'] = $orderMaps[$condition['order']];
  1150 + }
  1151 + if (!isset($condition['page'])) {
  1152 + $param['page'] = 1;
  1153 + }
  1154 +
  1155 + if(isset($condition['viewNum'])) {
  1156 + $param['viewNum'] = $condition['viewNum'];
  1157 + } else if (!isset($condition['limit'])) {
  1158 + $param['viewNum'] = 60;
  1159 + } else {
  1160 + $param['viewNum'] = $condition['limit'];
  1161 + unset($condition['limit']);
  1162 + }
  1163 + if (!empty($condition)) {
  1164 + $param += $condition;
  1165 + }
  1166 +
  1167 + return Yohobuy::httpBuildQuery(self::getUrl(), $param);
  1168 + }
  1169 +
  1170 + /**
  1171 + * 并行调接口url获取(产品分类)
  1172 + * @param
  1173 + */
  1174 +
  1175 + public static function getClassesUrl($condition)
  1176 + {
  1177 +
  1178 + $condition['sales'] = 'Y'; //在销售商品分类
  1179 + $condition['status'] = 1; //上架商品分类
  1180 + $condition['stocknumber'] = 1; //过滤掉已售罄
  1181 +
  1182 + return Yohobuy::httpBuildQuery(self::getUrl('sort'), $condition);
  1183 + }
  1184 +
  1185 + /**
  1186 + * 并行调接口url获取(获取折扣区间)
  1187 + * @param
  1188 + */
  1189 +
  1190 + public static function getDiscountUrl($param = array())
  1191 + {
  1192 + return Yohobuy::httpBuildQuery(self::getUrl('discount'), $param);
  1193 + }
  1194 +
  1195 + /**
  1196 + * 并行调接口url获取(获取最新上架)
  1197 + */
  1198 + public static function getRecentShelveUrl($param = array())
  1199 + {
  1200 + return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param);
  1201 + }
  1202 +
  1203 + /**
  1204 + * 并行调接口url获取(获取用户浏览记录)
  1205 + */
  1206 +// public static function getReviewUrl($param = array())
  1207 +// {
  1208 +// return Yohobuy::httpBuildQuery(self::getUrl('review'), $param);
  1209 +// }
  1210 +
  1211 +
  1212 +
  1213 + /**
  1214 + * 获取搜索的服务地址
  1215 + *
  1216 + * 备注:此处是根据环境来确定使用阿里云内网还是外网的URL
  1217 + *
  1218 + * @return string
  1219 + */
  1220 + private static function getUrl($type = 'search')
  1221 + {
  1222 + defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
  1223 + switch (APPLICATION_ENV) {
  1224 + case 'release':
  1225 + if ($type == 'sort') {
  1226 + return 'http://100.98.132.63/yohosearch/sortgroup.json';
  1227 + }
  1228 + elseif ($type == 'discount') {
  1229 + return 'http://100.98.132.63/yohosearch/discount.json';
  1230 + }
  1231 + elseif ($type == 'recent') {
  1232 + return 'http://100.98.132.63/yohosearch/recent.json';
  1233 + }
  1234 +// elseif ($type == 'review') {
  1235 +//
  1236 +// }
  1237 + elseif ($type == 'shop') {
  1238 + return 'http://100.98.132.63/yohosearch/shops.json';
  1239 + }
  1240 + return 'http://100.98.132.63/yohosearch/search.json';
  1241 + case 'test':
  1242 + case 'preview':
  1243 + case 'developer':
  1244 + default:
  1245 + if ($type == 'sort') {
  1246 + return 'http://101.200.31.165/yohosearch/sortgroup.json';
  1247 + }
  1248 + elseif ($type == 'discount') {
  1249 + return 'http://101.200.31.165/yohosearch/discount.json';
  1250 + }
  1251 + elseif ($type == 'recent') {
  1252 + return 'http://101.200.31.165/yohosearch/recent.json';
  1253 + }
  1254 +// elseif ($type == 'review') {
  1255 +//
  1256 +// }
  1257 + elseif ($type == 'shop') {
  1258 + return 'http://101.200.31.165/yohosearch/shops.json';
  1259 + }
  1260 + return 'http://101.200.31.165/yohosearch/search.json';
  1261 + }
  1262 + }
1115 } 1263 }
@@ -17,10 +17,10 @@ class IndexController extends WebAction @@ -17,10 +17,10 @@ class IndexController extends WebAction
17 $uid = $this->getUid(); 17 $uid = $this->getUid();
18 //根据品牌域名获取品牌id(同时判断品牌域名是否有效) 18 //根据品牌域名获取品牌id(同时判断品牌域名是否有效)
19 $brandInfo = BrandData::getBrandLogoByDomain($domain); 19 $brandInfo = BrandData::getBrandLogoByDomain($domain);
20 - if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){ 20 + if (!empty($brandInfo['data']) && $brandInfo['code'] === 200) {
21 $brandId = $brandInfo['data']['id']; 21 $brandId = $brandInfo['data']['id'];
22 $node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false; 22 $node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false;
23 - }else{ 23 + } else {
24 $this->go(SITE_MAIN); 24 $this->go(SITE_MAIN);
25 } 25 }
26 26
@@ -60,7 +60,7 @@ class IndexController extends WebAction @@ -60,7 +60,7 @@ class IndexController extends WebAction
60 $condition['gender'] = $gender; 60 $condition['gender'] = $gender;
61 61
62 //每页显示商品数 62 //每页显示商品数
63 - if(!isset($condition['viewNum']) || empty($condition['viewNum'])){ 63 + if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
64 $condition['viewNum'] =60; 64 $condition['viewNum'] =60;
65 } 65 }
66 $view_num_arr = array(60, 100, 200); 66 $view_num_arr = array(60, 100, 200);
@@ -68,7 +68,7 @@ class IndexController extends WebAction @@ -68,7 +68,7 @@ class IndexController extends WebAction
68 $condition['viewNum'] = 60; 68 $condition['viewNum'] = 60;
69 } 69 }
70 //每行显示的商品数量 70 //每行显示的商品数量
71 - if(!isset($condition['rowNum']) || empty($condition['rowNum'])){ 71 + if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
72 $condition['rowNum'] =5; 72 $condition['rowNum'] =5;
73 } 73 }
74 if ($condition['rowNum'] == 6) { 74 if ($condition['rowNum'] == 6) {