ソースを参照

Merge branch 'dev-mysql' of ssh://10.10.100.21/source/platform-b2c into dev-mysql

yujia 8 年 前
コミット
13f6f32652
100 ファイル変更2915 行追加782 行削除
  1. 29 1
      pom.xml
  2. 2 1
      src/main/java/com/uas/platform/b2c/advertise/ad/api/CarouselsController.java
  3. 2 1
      src/main/java/com/uas/platform/b2c/advertise/ad/service/CarouselService.java
  4. 24 4
      src/main/java/com/uas/platform/b2c/advertise/ad/service/impl/CarouselsServiceImpl.java
  5. 25 2
      src/main/java/com/uas/platform/b2c/common/account/controller/AuthenticationController.java
  6. 21 0
      src/main/java/com/uas/platform/b2c/common/account/controller/SecurityController.java
  7. 5 3
      src/main/java/com/uas/platform/b2c/common/account/controller/UserController.java
  8. 15 0
      src/main/java/com/uas/platform/b2c/common/account/dao/UserLoginTimeDao.java
  9. 4 4
      src/main/java/com/uas/platform/b2c/common/account/model/UsageLog.java
  10. 19 4
      src/main/java/com/uas/platform/b2c/common/account/model/User.java
  11. 100 15
      src/main/java/com/uas/platform/b2c/common/account/model/UserInfo.java
  12. 89 0
      src/main/java/com/uas/platform/b2c/common/account/model/UserLoginTime.java
  13. 16 8
      src/main/java/com/uas/platform/b2c/common/account/v2/service/impl/UserServiceImpl.java
  14. 111 0
      src/main/java/com/uas/platform/b2c/common/search/constant/SearchParam.java
  15. 22 0
      src/main/java/com/uas/platform/b2c/common/search/controller/SearcherController.java
  16. 14 0
      src/main/java/com/uas/platform/b2c/common/search/dao/SearchHistoryDao.java
  17. 5 5
      src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java
  18. 4 4
      src/main/java/com/uas/platform/b2c/common/search/rpc/service/SearchService.java
  19. 14 0
      src/main/java/com/uas/platform/b2c/common/search/service/SearcherService.java
  20. 247 211
      src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java
  21. 32 0
      src/main/java/com/uas/platform/b2c/common/search/util/CollectField.java
  22. 235 0
      src/main/java/com/uas/platform/b2c/common/search/util/PageParams.java
  23. 100 0
      src/main/java/com/uas/platform/b2c/common/search/util/SPage.java
  24. 96 0
      src/main/java/com/uas/platform/b2c/common/search/util/Sort.java
  25. 1 1
      src/main/java/com/uas/platform/b2c/core/filter/SSOInterceptor.java
  26. 23 14
      src/main/java/com/uas/platform/b2c/external/erp/commodity/service/impl/ProductDetailERPServiceImpl.java
  27. 2 1
      src/main/java/com/uas/platform/b2c/external/erp/commodity/util/ModelConverter.java
  28. 1 0
      src/main/java/com/uas/platform/b2c/external/erp/order/service/impl/OrderServiceImpl.java
  29. 2 1
      src/main/java/com/uas/platform/b2c/fa/settlement/service/impl/BillSubmitServiceImpl.java
  30. 53 0
      src/main/java/com/uas/platform/b2c/logistics/constant/TipType.java
  31. 9 0
      src/main/java/com/uas/platform/b2c/logistics/controller/DistributionRuleController.java
  32. 36 0
      src/main/java/com/uas/platform/b2c/logistics/controller/TipRecordController.java
  33. 8 0
      src/main/java/com/uas/platform/b2c/logistics/dao/DistributionRuleDao.java
  34. 31 0
      src/main/java/com/uas/platform/b2c/logistics/dao/TipRecordDao.java
  35. 84 0
      src/main/java/com/uas/platform/b2c/logistics/model/TipRecord.java
  36. 24 0
      src/main/java/com/uas/platform/b2c/logistics/model/UsableRuleInfo.java
  37. 7 0
      src/main/java/com/uas/platform/b2c/logistics/service/DistributionRuleService.java
  38. 22 0
      src/main/java/com/uas/platform/b2c/logistics/service/TipRecordService.java
  39. 42 11
      src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributionRuleServiceImpl.java
  40. 63 0
      src/main/java/com/uas/platform/b2c/logistics/service/impl/TipRecordServiceImpl.java
  41. 14 0
      src/main/java/com/uas/platform/b2c/prod/commodity/model/Product.java
  42. 2 2
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java
  43. 22 20
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java
  44. 23 4
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java
  45. 24 0
      src/main/java/com/uas/platform/b2c/prod/product/brand/api/BrandController.java
  46. 9 2
      src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandDao.java
  47. 14 0
      src/main/java/com/uas/platform/b2c/prod/product/brand/service/BrandService.java
  48. 34 1
      src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandServiceImpl.java
  49. 43 0
      src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java
  50. 10 44
      src/main/java/com/uas/platform/b2c/prod/product/component/controller/ComponentSubmitController.java
  51. 6 0
      src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentCrawlDao.java
  52. 8 0
      src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentDao.java
  53. 19 0
      src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentInfoDao.java
  54. 8 0
      src/main/java/com/uas/platform/b2c/prod/product/component/modal/Component.java
  55. 14 0
      src/main/java/com/uas/platform/b2c/prod/product/component/modal/ComponentInfo.java
  56. 27 0
      src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java
  57. 9 8
      src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentSubmitService.java
  58. 5 5
      src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentGoodsServiceImpl.java
  59. 27 5
      src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java
  60. 329 301
      src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentSubmitServiceImpl.java
  61. 3 3
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java
  62. 3 3
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java
  63. 1 1
      src/main/java/com/uas/platform/b2c/trade/order/status/OrderStatus.java
  64. 1 1
      src/main/java/com/uas/platform/b2c/trade/order/status/PurchaseStatus.java
  65. 10 10
      src/main/java/com/uas/platform/b2c/trade/presale/model/Collection.java
  66. 4 1
      src/main/java/com/uas/platform/b2c/trade/rate/service/impl/RateServiceImpl.java
  67. 1 2
      src/main/resources/dev/jdbc.properties
  68. 2 2
      src/main/resources/dev/sys.properties
  69. 0 4
      src/main/resources/prod/jdbc.properties
  70. 1 2
      src/main/resources/test/jdbc.properties
  71. 2 2
      src/main/resources/test/sys.properties
  72. 2 0
      src/main/webapp/WEB-INF/views/normal/adminWithNav.html
  73. 1 1
      src/main/webapp/resources/css/commonComponent.css
  74. BIN
      src/main/webapp/resources/img/tour/1.gif
  75. BIN
      src/main/webapp/resources/img/tour/2.gif
  76. BIN
      src/main/webapp/resources/img/tour/3.gif
  77. BIN
      src/main/webapp/resources/img/tour/4.gif
  78. BIN
      src/main/webapp/resources/img/tour/4.png
  79. BIN
      src/main/webapp/resources/img/tour/5.gif
  80. BIN
      src/main/webapp/resources/img/tour/5.png
  81. 7 0
      src/main/webapp/resources/js/admin/app.js
  82. 62 0
      src/main/webapp/resources/js/admin/controllers/ads/ads_component.js
  83. 6 6
      src/main/webapp/resources/js/admin/controllers/product/UploadComponentCrawlCtrl.js
  84. 9 2
      src/main/webapp/resources/js/common/controllers/commonCtrls.js
  85. 95 0
      src/main/webapp/resources/js/common/directives.js
  86. 1 1
      src/main/webapp/resources/js/common/module/chat_web_module.js
  87. 1 1
      src/main/webapp/resources/js/common/query/chat.js
  88. 12 2
      src/main/webapp/resources/js/common/query/component.js
  89. 15 0
      src/main/webapp/resources/js/common/query/logisticsPort.js
  90. 1 1
      src/main/webapp/resources/js/sale/app.js
  91. 1 1
      src/main/webapp/resources/js/usercenter/app.js
  92. 1 1
      src/main/webapp/resources/js/usercenter/controllers/forstore/order_detail_ctrl.js
  93. 46 2
      src/main/webapp/resources/js/vendor/app.js
  94. 1 1
      src/main/webapp/resources/js/vendor/controllers/forstore/purchase_detail.js
  95. 54 1
      src/main/webapp/resources/js/vendor/controllers/forstore/vendor_deliveryRule_ctrl.js
  96. 56 26
      src/main/webapp/resources/js/vendor/controllers/forstore/vendor_index_ctrl.js
  97. 62 19
      src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js
  98. 32 1
      src/main/webapp/resources/js/vendor/controllers/forstore/vendor_onSaleCtrl.js
  99. 34 2
      src/main/webapp/resources/js/vendor/controllers/forstore/vendor_upload_ctrl.js
  100. 102 0
      src/main/webapp/resources/lib/ui-tour/tour.js

+ 29 - 1
pom.xml

@@ -316,7 +316,18 @@
 		<dependency>
 			<groupId>org.apache.poi</groupId>
 			<artifactId>poi</artifactId>
-			<version>3.9</version>
+			<version>3.17</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi-ooxml</artifactId>
+			<version>3.17</version>
+			<exclusions>
+				<exclusion>
+					<groupId>org.apache.poi</groupId>
+					<artifactId>poi</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 		<!-- BeeCloud支付集成SDK -->
 		<dependency>
@@ -436,6 +447,23 @@
 			<groupId>javax.servlet</groupId>
 			<artifactId>servlet-api</artifactId>
 		</dependency>
+		<!--Hutool POI工具类(对MS Office操作)-->
+		<!--<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi-ooxml</artifactId>
+			<version>3.17</version>
+		</dependency>-->
+		<dependency>
+			<groupId>com.xiaoleilu</groupId>
+			<artifactId>hutool-poi</artifactId>
+			<version>3.2.2</version>
+			<exclusions>
+				<exclusion>
+					<groupId>org.apache.poi</groupId>
+					<artifactId>poi-ooxml</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
 	</dependencies>
 	<build>
 		<finalName>platform-b2c</finalName>

+ 2 - 1
src/main/java/com/uas/platform/b2c/advertise/ad/api/CarouselsController.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.LinkedHashMap;
 import java.util.List;
 
 /**
@@ -30,7 +31,7 @@ public class CarouselsController {
      * @return the carousels
      */
     @RequestMapping(value = "/{module}", method = RequestMethod.GET)
-    public List<JSONObject> getCarousels(@PathVariable("module") String module) {
+    public List<LinkedHashMap> getCarousels(@PathVariable("module") String module) {
         return carouselService.getCarousels(module);
     }
 }

+ 2 - 1
src/main/java/com/uas/platform/b2c/advertise/ad/service/CarouselService.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2c.advertise.ad.service;
 
 import net.sf.json.JSONObject;
 
+import java.util.LinkedHashMap;
 import java.util.List;
 
 /**
@@ -18,5 +19,5 @@ public interface CarouselService {
      * @param usedFor the used for
      * @return carousels carousels
      */
-    List<JSONObject> getCarousels(String usedFor);
+    List<LinkedHashMap> getCarousels(String usedFor);
 }

+ 24 - 4
src/main/java/com/uas/platform/b2c/advertise/ad/service/impl/CarouselsServiceImpl.java

@@ -3,12 +3,13 @@ package com.uas.platform.b2c.advertise.ad.service.impl;
 import com.uas.platform.b2c.advertise.ad.service.CarouselService;
 import com.uas.platform.b2c.core.config.MicroServicesConf;
 import com.uas.platform.b2c.core.utils.JsonUtil;
+import net.sf.json.JSONException;
 import net.sf.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
-import java.util.List;
+import java.util.*;
 
 /**
  * The type Carousels service implementation.
@@ -30,10 +31,29 @@ public class CarouselsServiceImpl implements CarouselService{
 	}
 
 	@Override
-	public List<JSONObject> getCarousels(String usedFor) {
+	public List<LinkedHashMap> getCarousels(String usedFor) {
 		String url = conf.getRequestUrlForCarousel(20030, "/carousels?usedFor=" + usedFor);
 		String result = restTemplate.getForEntity(url, String.class).getBody();
-		List<JSONObject> r = JsonUtil.parseJsonToObject(result);
-		return r;
+		List<LinkedHashMap> jsonValues = JsonUtil.parseJsonToObject(result);
+
+		Collections.sort( jsonValues, new Comparator<LinkedHashMap>() {
+			private static final String KEY_NAME = "orderNumber";
+
+			@Override
+			public int compare(LinkedHashMap a, LinkedHashMap b) {
+				String valA = new String();
+				String valB = new String();
+
+				try {
+					valA = String.valueOf(a.get(KEY_NAME));
+					valB = String.valueOf(b.get(KEY_NAME));
+				}
+				catch (JSONException e) {
+				}
+				return valA.compareTo(valB);
+			}
+		});
+
+		return jsonValues;
 	}
 }

+ 25 - 2
src/main/java/com/uas/platform/b2c/common/account/controller/AuthenticationController.java

@@ -1,7 +1,9 @@
 package com.uas.platform.b2c.common.account.controller;
 
+import com.uas.platform.b2c.common.account.dao.UserLoginTimeDao;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.model.UserInfo;
+import com.uas.platform.b2c.common.account.model.UserLoginTime;
 import com.uas.platform.b2c.common.account.model.UserQuestion;
 import com.uas.platform.b2c.common.account.service.UserQuestionService;
 import com.uas.platform.b2c.common.account.service.UserService;
@@ -10,6 +12,7 @@ import java.util.List;
 import net.sf.ehcache.CacheManager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -27,6 +30,9 @@ public class AuthenticationController {
 	@Autowired
 	private UserQuestionService userQuestionService;
 
+	@Autowired
+	private UserLoginTimeDao userLoginTimeDao;
+
 	@RequestMapping(method = RequestMethod.GET, headers = "Accept=application/json")
 	@ResponseBody
 	@ResponseStatus(value = HttpStatus.OK)
@@ -75,9 +81,26 @@ public class AuthenticationController {
 	@ResponseBody
 	public void switchEnterprise(@PathVariable("enUU") long enUU) {
 		User user = SystemSession.getUser();
-		if ( enUU == 0L){
+		//保存登录时间
+		List<UserLoginTime> userLoginTimeList = userLoginTimeDao.findByUserUUAndEnUU(user.getUserUU(), user.getEnterprise() == null ? 0L : user.getEnterprise().getUu());
+		UserLoginTime userLoginTime;
+		if (!CollectionUtils.isEmpty(userLoginTimeList)) {
+			userLoginTime = userLoginTimeList.get(0);
+		} else {
+			userLoginTime = new UserLoginTime();
+			userLoginTime.setUserUU(user.getUserUU());
+			userLoginTime.setEnUU(user.getEnterprise() == null ? 0L : user.getEnterprise().getUu());
+		}
+		userLoginTime.setLoginTime(System.currentTimeMillis());
+		try {
+			userLoginTimeDao.save(userLoginTime);
+		} catch (Exception e) {
+
+		}
+
+		if ( enUU == 0L) {
 			user.setEnterprise(null);
-		}else {
+		} else {
 			user.setCurrentEnterprise(enUU);
 		}
 	}

+ 21 - 0
src/main/java/com/uas/platform/b2c/common/account/controller/SecurityController.java

@@ -2,9 +2,11 @@ package com.uas.platform.b2c.common.account.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.uas.account.entity.UserView;
+import com.uas.platform.b2c.common.account.dao.UserLoginTimeDao;
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.SigninLog;
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.account.model.UserLoginTime;
 import com.uas.platform.b2c.common.account.service.SigninLogService;
 import com.uas.platform.b2c.common.account.service.UserService;
 import com.uas.platform.b2c.core.support.SystemSession;
@@ -24,12 +26,14 @@ import org.springframework.mobile.device.LiteDeviceResolver;
 import org.springframework.mobile.device.site.SitePreference;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.io.IOException;
+import java.util.List;
 
 /**
  * 处理登录和登录跳转
@@ -45,6 +49,9 @@ public class SecurityController {
 	private UserService userService;
 	@Autowired
 	private SigninLogService signinLogService;
+	@Autowired
+	private UserLoginTimeDao userLoginTimeDao;
+
 	private final DeviceResolver deviceResolver = new LiteDeviceResolver();
 
 	/**
@@ -281,6 +288,20 @@ public class SecurityController {
 						// 企业资料在所有系统公认的唯一标识,这里使用商业登记证号
 						if (tokenUser.getSpaceUID().equals(enterprise.getEnBussinessCode())) {
 							authedUser.setEnterprise(enterprise);
+							//保存登录时间
+							List<UserLoginTime> userLoginTimeList = userLoginTimeDao.findByUserUUAndEnUU(authedUser.getUserUU(),enterprise.getUu());
+							UserLoginTime userLoginTime;
+							if (!CollectionUtils.isEmpty(userLoginTimeList)){
+								userLoginTime = userLoginTimeList.get(0);
+							}else {
+								userLoginTime = new UserLoginTime();
+								userLoginTime.setUserUU(authedUser.getUserUU());
+								userLoginTime.setEnUU(enterprise.getUu());
+							}
+							userLoginTime.setLoginTime(System.currentTimeMillis());
+							try {
+								userLoginTimeDao.save(userLoginTime);
+							}catch (Exception e){}
 							break;
 						}
 					}

+ 5 - 3
src/main/java/com/uas/platform/b2c/common/account/controller/UserController.java

@@ -767,10 +767,12 @@ public class UserController {
 	 * @return
 	 */
 	@RequestMapping(value = "/updateIdEnable", method = RequestMethod.POST)
-	public ResponseEntity<String> updateIdEnable(final User user,HttpServletRequest request) {
-		User newUser = userService.saveRealAuth(user);
+	public ResponseEntity<String> updateIdEnable(final User user) {
+		User oldUser = userService.findUserByUserUU(user.getUserUU());
+		oldUser.setIdEnable(user.getIdEnable());
+		User newUser = userService.saveRealAuth(oldUser);
 		assert logger != null;
-		logger.log("用户信息", SystemSession.getUser().getUserUU()+"后台审核实名认证,UU:" + newUser.getUserUU());
+		logger.log("用户信息", SystemSession.getUser().getUserUU()+"后台审核实名认证,UU:" +  newUser.getUserUU());
 		return new ResponseEntity<String>(HttpStatus.OK);
 	}
 }

+ 15 - 0
src/main/java/com/uas/platform/b2c/common/account/dao/UserLoginTimeDao.java

@@ -0,0 +1,15 @@
+package com.uas.platform.b2c.common.account.dao;
+
+
+import com.uas.platform.b2c.common.account.model.UserLoginTime;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface UserLoginTimeDao extends JpaSpecificationExecutor<UserLoginTime>, JpaRepository<UserLoginTime, Long> {
+
+    List<UserLoginTime> findByUserUUAndEnUU (Long userUU, Long enUU);
+}

+ 4 - 4
src/main/java/com/uas/platform/b2c/common/account/model/UsageLog.java

@@ -197,7 +197,7 @@ public class UsageLog extends BufferedLogable implements Serializable {
 		if(user != null && user.getUserTel()!=null){
 			return user.getUserTel().substring(0,user.getUserTel().length()-(user.getUserTel().substring(3)).length())+"****"+user.getUserTel().substring(7);
 		}
-		return user.getUserTel();
+		return null;
 	}
 
 	public String getUserEmail() {
@@ -209,14 +209,14 @@ public class UsageLog extends BufferedLogable implements Serializable {
 			else
 				return org.apache.commons.lang.StringUtils.rightPad(org.apache.commons.lang.StringUtils.left(email, 1), index, "*").concat(org.apache.commons.lang.StringUtils.mid(email, index, org.apache.commons.lang.StringUtils.length(email)));
 		}
-		return user.getUserEmail();
+		return null;
 	}
 
 	public String getUserName() {
-		if(user.getUserName()!=null){
+		if(user != null && user.getUserName() != null){
 			return user.getUserName().substring(0,1)+"**";
 		}
-		return user.getUserName();
+		return null;
 	}
 
 	public UsageLog() {

+ 19 - 4
src/main/java/com/uas/platform/b2c/common/account/model/User.java

@@ -2,7 +2,9 @@ package com.uas.platform.b2c.common.account.model;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import com.uas.platform.core.model.Constant;
-import java.util.Date;
+
+import java.util.*;
+
 import org.codehaus.jackson.annotate.JsonIgnore;
 import org.hibernate.annotations.Cache;
 import org.hibernate.annotations.CacheConcurrencyStrategy;
@@ -13,9 +15,6 @@ import org.springframework.util.CollectionUtils;
 import javax.persistence.*;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
 
 /**
  * 用户信息
@@ -128,6 +127,14 @@ public class User implements Serializable {
 	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
 	private Set<Enterprise> enterprises;
 
+	/**
+	 * 所属公司的最后登陆时间
+	 */
+	@JoinColumn(name = "user_uu")
+	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
+	@OrderBy("login_time")
+	private Set<UserLoginTime> userLoginTimeSet;
+
 	/**
 	 * 所属当前登录公司
 	 */
@@ -426,6 +433,14 @@ public class User implements Serializable {
 		this.ip = ip;
 	}
 
+	public Set<UserLoginTime> getUserLoginTimeSet() {
+		return userLoginTimeSet;
+	}
+
+	public void setUserLoginTimeSet(Set<UserLoginTime> userLoginTimeSet) {
+		this.userLoginTimeSet = userLoginTimeSet;
+	}
+
 	/**
 	 * 获取用户所属企业UU号
 	 *

+ 100 - 15
src/main/java/com/uas/platform/b2c/common/account/model/UserInfo.java

@@ -5,10 +5,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 用户简单信息,前台程序使用
@@ -37,20 +34,34 @@ public class UserInfo {
 		}
 		if (!CollectionUtils.isEmpty(user.getEnterprises())) {
 			Enterprise current = user.getEnterprise();
-			List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+			List<SimpleEnterpriseInfo> list = new ArrayList<SimpleEnterpriseInfo>();
 			for (Enterprise enterprise : user.getEnterprises()) {
-				Map<String, Object> map = new HashMap<String, Object>();
-				map.put("enName", enterprise.getEnName());
-				map.put("uu", enterprise.getUu());
-				map.put("isVendor",enterprise.getEnMallVendorStatus());
+				SimpleEnterpriseInfo simpleEnterpriseInfo= new SimpleEnterpriseInfo();
+				simpleEnterpriseInfo.setEnName(enterprise.getEnName());
+				simpleEnterpriseInfo.setUu(enterprise.getUu());
+				simpleEnterpriseInfo.setIsVendor(enterprise.getEnMallVendorStatus());
 				if(enterprise.getEnSaasStatus() != null && enterprise.getEnSaasStatus() == Status.ENABLED.value()) {
-					map.put("enSaasUrl", enterprise.getEnSaasUrl());
+					simpleEnterpriseInfo.setEnSaasUrl(enterprise.getEnSaasUrl());
 				}
 				if (enterprise.equals(current)){
-					map.put("current", true);
+					simpleEnterpriseInfo.setCurrent(true);
 				}
-				list.add(map);
+				for (UserLoginTime userLoginTime : user.getUserLoginTimeSet()){
+					if (userLoginTime.getEnUU().equals(enterprise.getUu())){
+						simpleEnterpriseInfo.setLastLoginTime(userLoginTime.getLoginTime());
+					}
+				}
+				list.add(simpleEnterpriseInfo);
 			}
+
+			Collections.sort(list,new Comparator(){
+				@Override
+				public int compare(Object o1, Object o2) {
+					SimpleEnterpriseInfo s1 = (SimpleEnterpriseInfo) o1;
+					SimpleEnterpriseInfo s2 = (SimpleEnterpriseInfo)o2;
+					return s1.getLastLoginTime().compareTo(s2.getLastLoginTime());
+				}
+			});
 			this.enterprises = list;
 		}
 		this.havePayPwd = user.getUserPay()==null || user.getUserPay().equals("") ?false:true;
@@ -111,7 +122,7 @@ public class UserInfo {
 
 	private Short idEnable;
 
-	private List<Map<String, Object>> enterprises;
+	private List<SimpleEnterpriseInfo> enterprises;
 
 	private boolean havePayPwd;
 
@@ -121,6 +132,8 @@ public class UserInfo {
 
 	private Long lastLoginTime;
 
+	private Set<UserLoginTime> userLoginTimeSet;
+
 	public Long getLastLoginTime() {
 		return lastLoginTime;
 	}
@@ -217,11 +230,19 @@ public class UserInfo {
 		this.role = role;
 	}
 
-	public List<Map<String, Object>> getEnterprises() {
+	public Set<UserLoginTime> getUserLoginTimeSet() {
+		return userLoginTimeSet;
+	}
+
+	public void setUserLoginTimeSet(Set<UserLoginTime> userLoginTimeSet) {
+		this.userLoginTimeSet = userLoginTimeSet;
+	}
+
+	public List<SimpleEnterpriseInfo> getEnterprises() {
 		return enterprises;
 	}
 
-	public void setEnterprises(List<Map<String, Object>> enterprises) {
+	public void setEnterprises(List<SimpleEnterpriseInfo> enterprises) {
 		this.enterprises = enterprises;
 	}
 
@@ -234,3 +255,67 @@ public class UserInfo {
 	}
 
 }
+
+/**
+ * 返回给前端的简单企业信息数据
+ */
+class SimpleEnterpriseInfo{
+	String enName;
+	Long uu;
+	Short isVendor;
+	String enSaasUrl;
+	boolean current;
+	Long lastLoginTime;
+
+	public SimpleEnterpriseInfo(){
+		this.setLastLoginTime(0L);
+	}
+
+	public String getEnName() {
+		return enName;
+	}
+
+	public void setEnName(String enName) {
+		this.enName = enName;
+	}
+
+	public Long getUu() {
+		return uu;
+	}
+
+	public void setUu(Long uu) {
+		this.uu = uu;
+	}
+
+	public Short getIsVendor() {
+		return isVendor;
+	}
+
+	public void setIsVendor(Short isVendor) {
+		this.isVendor = isVendor;
+	}
+
+	public String getEnSaasUrl() {
+		return enSaasUrl;
+	}
+
+	public void setEnSaasUrl(String enSaasUrl) {
+		this.enSaasUrl = enSaasUrl;
+	}
+
+	public boolean isCurrent() {
+		return current;
+	}
+
+	public void setCurrent(boolean current) {
+		this.current = current;
+	}
+
+	public Long getLastLoginTime() {
+		return lastLoginTime;
+	}
+
+	public void setLastLoginTime(Long lastLoginTime) {
+		this.lastLoginTime = lastLoginTime;
+	}
+}

+ 89 - 0
src/main/java/com/uas/platform/b2c/common/account/model/UserLoginTime.java

@@ -0,0 +1,89 @@
+package com.uas.platform.b2c.common.account.model;
+
+
+import org.hibernate.annotations.Cache;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "sec$userslogintime")
+public class UserLoginTime implements Serializable{
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+    /**
+     * ID
+     */
+    @Id
+    @GeneratedValue
+    @Column(name = "id")
+    private Long id;
+
+    /**
+     * uu号
+     */
+    @Column(name = "user_uu")
+    private Long userUU;
+
+    /**
+     * enuu
+     */
+    @Column(name = "enuu")
+    private Long enUU;
+
+    /**
+     * 信息
+     */
+    @OneToOne(cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
+    @JoinColumn(name = "enuu", insertable = false, updatable = false)
+    private Enterprise enterprise;
+
+    /**
+     * 登陆时间
+     */
+    @Column(name = "login_time")
+    private Long loginTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getLoginTime() {
+        return loginTime;
+    }
+
+    public void setLoginTime(Long loginTime) {
+        this.loginTime = loginTime;
+    }
+
+    public Enterprise getEnterprise() {
+        return enterprise;
+    }
+
+    public void setEnterprise(Enterprise enterprise) {
+        this.enterprise = enterprise;
+    }
+}

+ 16 - 8
src/main/java/com/uas/platform/b2c/common/account/v2/service/impl/UserServiceImpl.java

@@ -66,23 +66,31 @@ public class UserServiceImpl implements UserService {
 //        }
 
     }
-    private void oneSave(User user , com.uas.platform.b2c.common.account.model.User u){
-        u.setUserPwd(user.getPassword());
-        u.setUserName(user.getName());
-        u.setUserTel(user.getUid());
+    private void oneSave(User user , com.uas.platform.b2c.common.account.model.User u) {
+        if (user.getPassword() != null) {
+            u.setUserPwd(user.getPassword());
+        }
+        if (user.getName() != null) {
+            u.setUserName(user.getName());
+        }
+        if (user.getUid() != null) {
+            u.setUserTel(user.getUid());
+        }
         u.setEnable((short) 1);
-        u.setUserEmail(user.getSecondUID());
+        if (user.getSecondUID() != null) {
+            u.setUserEmail(user.getSecondUID());
+        }
         if (!StringUtils.isEmpty(user.getDialectUID())) {
             u.setUserUU(Long.valueOf(user.getDialectUID()));
         }
-        if (user.getPwdSecLevel()!=null) {
+        if (user.getPwdSecLevel() != null) {
             u.setPwdSecLevel(user.getPwdSecLevel());
         }
-        if(user.getLastLoginTime()!=null){
+        if (user.getLastLoginTime() != null) {
             u.setLastLoginTime(user.getLastLoginTime());
         }
         Enterprise enterprise = null;
-        if(user.getSpaceDialectUID()!=null){
+        if (user.getSpaceDialectUID() != null){
             enterprise = enterpriseDao.findByUu(Long.valueOf(user.getSpaceDialectUID()));
         }
         if (null != enterprise) {

+ 111 - 0
src/main/java/com/uas/platform/b2c/common/search/constant/SearchParam.java

@@ -0,0 +1,111 @@
+package com.uas.platform.b2c.common.search.constant;
+
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import com.uas.search.model.Sort;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SearchParam implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private int page;
+    private int size;
+    private Map<FilterField, Object> filters;
+    private List<Sort> sort;
+
+    public SearchParam() {
+    }
+
+    public SearchParam(int page, int size) {
+        this.page = page;
+        this.size = size;
+    }
+
+    public int getPage() {
+        return this.page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getSize() {
+        return this.size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public Map<SearchParam.FilterField, Object> getFilters() {
+        return this.filters;
+    }
+
+    public void setFilters(Map<SearchParam.FilterField, Object> filters) {
+        this.filters = filters;
+    }
+
+    public void filter(SearchParam.FilterField key, Object value) {
+        if(this.filters == null) {
+            this.filters = new HashMap();
+        }
+
+        this.filters.put(key, value);
+    }
+
+    public void removeFilter(SearchParam.FilterField key) {
+        if(this.filters != null) {
+            this.filters.remove(key);
+        }
+
+    }
+
+    public List<Sort> getSort() {
+        return this.sort;
+    }
+
+    public void setSort(List<Sort> sort) {
+        this.sort = sort;
+    }
+
+    public String toString() {
+        return "PageParams [page=" + this.page + ", size=" + this.size + ", filters=" + this.filters + ", sort=" + this.sort + "]";
+    }
+
+    public static enum FilterField {
+        COMPONENT_KINDID,
+        COMPONENT_BRANDID,
+        COMPONENT_PROPERTIES,
+        COMPONENT_HAS_RESERVE,
+        COMPONENT_HAS_SAMPLE,
+        COMPONENT_HAS_ORIGINAL,
+        COMPONENT_HAS_INACTION_STOCK,
+        GOODS_KINDID,
+        GOODS_BRANDID,
+        GOODS_STORE_TYPE,
+        GOODS_CRNAME,
+        GOODS_MINPRICERMB,
+        GOODS_MAXPRICERMB,
+        GOODS_MINPRICEUSD,
+        GOODS_MAXPRICEUSD,
+        GOODS_STATUS,
+        ORDER_STATUS,
+        ORDER_BUYER_UU,
+        ORDER_BUYER_EN_UU,
+        ORDER_SELLER_EN_UU,
+        ORDER_MIN_TIME,
+        ORDER_MAX_TIME;
+
+        private FilterField() {
+        }
+    }
+}

+ 22 - 0
src/main/java/com/uas/platform/b2c/common/search/controller/SearcherController.java

@@ -7,6 +7,7 @@ import com.uas.platform.b2c.common.search.service.SearcherService;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.commodity.service.StockInOutHistService;
+import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
 import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.presale.service.StoreFocusService;
@@ -211,6 +212,20 @@ public class SearcherController {
 		map = searcherService.searchComponent(w, page);
 		return map;
 	}
+	/**
+	 * 分页按首字母搜索器件
+	 *
+	 * @param w 关键词
+	 * @param page 分页参数
+	 * @return
+	 * @throws InterruptedException
+	 * @throws IOException
+	 */
+	@RequestMapping(value = "/component/first", method = RequestMethod.GET)
+	@ResponseBody
+	public Page<ComponentInfo> searchComponentByFirst(String w, PageParams page) {
+		return searcherService.searchComponentByFirst(w, page);
+	}
 
 	/**
 	 * 器件搜索结果的类目统计
@@ -358,4 +373,11 @@ public class SearcherController {
 			return searchHistoryDao.findByUserUUAndUserEnuuOrderBySearchTimeDesc(SystemSession.getUser().getUserUU(),SystemSession.getUser().getEnterprise() != null ?SystemSession.getUser().getEnterprise().getUu():null);
 		}
 	}
+
+	@RequestMapping(value = "/searchHistory", method = RequestMethod.DELETE)
+	@ResponseBody
+	public int deleteSearchHistory(HttpServletRequest request){
+		SystemSession.setUser((User)request.getSession().getAttribute("user"));
+		return searcherService.deleteSearchHistoryByuserUUAndenUU();
+	}
 }

+ 14 - 0
src/main/java/com/uas/platform/b2c/common/search/dao/SearchHistoryDao.java

@@ -3,7 +3,11 @@ package com.uas.platform.b2c.common.search.dao;
 import com.uas.platform.b2c.common.search.model.SearchHistory;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -16,4 +20,14 @@ public interface SearchHistoryDao extends JpaSpecificationExecutor<SearchHistory
     List<SearchHistory> findByUserUUAndUserEnuuOrderBySearchTimeDesc(Long userUU,Long userEnuu);
 
     List<SearchHistory> findByKeywordAndUserUUAndUserEnuu(String keyword,Long userUU,Long userEnuu);
+
+    /**
+     * 根据用户企业删除搜索记录
+     * @param userUU
+     * @param userEnuu
+     */
+    @Transactional
+    @Modifying
+    @Query(value = "delete from SearchHistory s where s.userUU =:userUU and s.userEnuu = :enUU")
+    int deleteByUserUUAndUserEnuu(@Param("userUU") Long userUU, @Param("enUU") Long userEnuu);
 }

+ 5 - 5
src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java

@@ -8,9 +8,9 @@ import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import com.uas.search.exception.SearchException;
-import com.uas.search.model.CollectField;
-import com.uas.search.model.PageParams;
-import com.uas.search.model.SPage;
+import com.uas.platform.b2c.common.search.util.CollectField;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.common.search.util.SPage;
 import org.apache.commons.collections.map.HashedMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -92,14 +92,14 @@ public class SearchServiceImpl implements SearchService{
     }
 
     @Override
-    public SPage<Map<String, List<Integer>>> getBrands(String keyword, Integer page, Integer size) throws SearchException {
+    public SPage<Map<String, Object>> getBrands(String keyword, Integer page, Integer size) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
         String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.BRAND_INFO_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
             try {
-                SPage<Map<String, List<Integer>>> sPage = FastjsonUtils.fromJson(str, SPage.class);
+                SPage<Map<String, Object>> sPage = FastjsonUtils.fromJson(str, SPage.class);
                 return sPage;
             }catch (Exception e) {
                 e.printStackTrace();

+ 4 - 4
src/main/java/com/uas/platform/b2c/common/search/rpc/service/SearchService.java

@@ -6,9 +6,9 @@ package com.uas.platform.b2c.common.search.rpc.service;
  * 通过http方式调用远端的搜索接口
  */
 import com.uas.search.exception.SearchException;
-import com.uas.search.model.CollectField;
-import com.uas.search.model.PageParams;
-import com.uas.search.model.SPage;
+import com.uas.platform.b2c.common.search.util.CollectField;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.common.search.util.SPage;
 
 import java.util.List;
 import java.util.Map;
@@ -21,7 +21,7 @@ public interface SearchService {
 
     SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws SearchException;
 
-    SPage<Map<String, List<Integer>>> getBrands(String keyword, Integer page, Integer size) throws SearchException;
+    SPage<Map<String, Object>> getBrands(String keyword, Integer page, Integer size) throws SearchException;
 
     Map<String, Object> getComponentIds(String keyword, PageParams var2) throws SearchException;
 

+ 14 - 0
src/main/java/com/uas/platform/b2c/common/search/service/SearcherService.java

@@ -1,7 +1,9 @@
 package com.uas.platform.b2c.common.search.service;
 
+import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.search.exception.SearchException;
+import org.springframework.data.domain.Page;
 import org.springframework.ui.ModelMap;
 
 import javax.servlet.http.HttpServletRequest;
@@ -49,6 +51,17 @@ public interface SearcherService {
 	 * @throws IOException
 	 */
 	public ModelMap searchComponent(String keyword, PageParams page);
+
+	/**
+	 * 首字母搜索器件
+	 *
+	 * @param keyword 关键词
+	 * @param page 分页参数
+	 * @return total, 搜索结果总数; page, 页码; size, 每页个数; components, 搜索结果集
+	 * @throws InterruptedException
+	 * @throws IOException
+	 */
+	public Page<ComponentInfo> searchComponentByFirst(String keyword, PageParams page);
 	/**
 	 * 智能搜索批次
 	 *
@@ -139,4 +152,5 @@ public interface SearcherService {
 	 */
 	public List<Map<String, Object>> getSimilarBrands(String brandName);
 
+	public int deleteSearchHistoryByuserUUAndenUU();
 }

+ 247 - 211
src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java

@@ -1,6 +1,8 @@
 package com.uas.platform.b2c.common.search.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.search.constant.SearchParam;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.search.dao.SearchHistoryDao;
 import com.uas.platform.b2c.common.search.model.SearchHistory;
@@ -19,13 +21,15 @@ import com.uas.platform.core.exception.SystemException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.search.exception.SearchException;
-import com.uas.search.model.CollectField;
-import com.uas.search.model.PageParams.FilterField;
-import com.uas.search.model.SPage;
-import com.uas.search.model.Sort;
+import com.uas.platform.b2c.common.search.util.CollectField;
+import com.uas.platform.b2c.common.search.util.PageParams.FilterField;
+import com.uas.platform.b2c.common.search.util.SPage;
+import com.uas.platform.b2c.common.search.util.Sort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.mobile.device.DeviceResolver;
 import org.springframework.mobile.device.LiteDeviceResolver;
 import org.springframework.stereotype.Service;
@@ -68,52 +72,72 @@ public class SearcherServiceImpl implements SearcherService {
 	private Logger logger = LoggerFactory.getLogger(getClass());
 	private final DeviceResolver deviceResolver = new LiteDeviceResolver();
 
-	/**
-	 * 智能搜索类目
-	 *
-	 * @param keyword
-	 * @param field
-	 * @return
-	 * @throws IOException
-	 * @throws InterruptedException
-	 */
-	@Override
-	public ModelMap searchKind(String keyword, String field) {
-		ModelMap map = new ModelMap();
-		SPage<Map<String, Object>> kinds = null;
-		try {
-			kinds = searchService.getKinds(keyword,1,1024*1024*1024);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		map.put("total", kinds.getTotalElement());// 结果总数
-		map.put("kinds", kinds.getContent());
-		return map;
-	}
+    private final int DEFAULT_PAGE = 1;
+
+    private final int DEFAULT_SIZE = 1024 * 1024 * 1024;
+
+    /**
+     * 智能搜索类目
+     *
+     * @param keyword
+     * @param field
+     * @return
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    @Override
+    public ModelMap searchKind(String keyword, String field) {
+        ModelMap map = new ModelMap();
+        SPage<Map<String, Object>> kinds = null;
+        try {
+            kinds = searchService.getKinds(keyword, DEFAULT_PAGE, DEFAULT_SIZE);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        map.put("total", kinds.getTotalElement());// 结果总数
+        map.put("kinds", kinds.getContent());
+        return map;
+    }
+
+    /**
+     * 智能搜索品牌
+     *
+     * @param keyword
+     * @param field
+     * @return
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    @Override
+    public ModelMap searchBrand(String keyword, String field) {
+        ModelMap map = new ModelMap();
+        SPage<Map<String, Object>> brands = null;
+        try {
+            brands = searchService.getBrands(keyword, DEFAULT_PAGE, DEFAULT_SIZE);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        map.put("brands", brands.getContent());// 结果集
+        map.put("total", brands.getTotalElement());// 结果总数
+        return map;
+    }
 
 	/**
-	 * 智能搜索品牌
+	 * 首字母搜索器件
 	 *
 	 * @param keyword
-	 * @param field
 	 * @return
-	 * @throws IOException
 	 * @throws InterruptedException
+	 * @throws IOException
 	 */
+	@SuppressWarnings("unchecked")
 	@Override
-	public ModelMap searchBrand(String keyword, String field) {
-		ModelMap map = new ModelMap();
-		SPage<Map<String, List<Integer>>> brands = null;
-		try {
-			brands = searchService.getBrands(keyword,1,1024*1024*1024);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		map.put("brands", brands.getContent());// 结果集
-		map.put("total", brands.getTotalElement());// 结果总数
-		return map;
+	public Page<ComponentInfo> searchComponentByFirst(String keyword, PageParams page) {
+		Pageable pageable = new PageInfo(page);
+		return componentInfoDao.findByFirst(keyword,pageable);
 	}
 
+
 	/**
 	 * 智能搜索器件
 	 *
@@ -227,189 +251,201 @@ public class SearcherServiceImpl implements SearcherService {
 			map.put("components", components);// 当前页器件内容
 		}
 
-		map.put("total", results.get("total"));// 搜索结果总数
-		map.put("page", results.get("page"));// 当前页面
-		map.put("size", results.get("size"));// 每页个数
+        map.put("total", results.get("total"));// 搜索结果总数
+        map.put("page", results.get("page"));// 当前页面
+        map.put("size", results.get("size"));// 每页个数
 
-		return map;
-	}
-	/**
-	 * 批次搜索数量统计
-	 *
-	 * @param keyword
-	 * @param page
-	 * @return
-	 * @throws InterruptedException
-	 * @throws IOException
-	 */
-	@SuppressWarnings("unchecked")
-	@Override
-	public ModelMap searchComponentGoodsNums(String keyword, PageParams page) {
-		ModelMap map = new ModelMap();
-		Map<String, Object> results = null;
-		//Map<String, Object> results = new HashMap<>();
-		try {
-			results = searchService.getGoodsIds(keyword, convertPageParams(page));
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		map.put("total", results.get("total"));// 搜索结果总数
-		return map;
-	}
+        return map;
+    }
 
+    /**
+     * 批次搜索数量统计
+     *
+     * @param keyword
+     * @param page
+     * @return
+     * @throws InterruptedException
+     * @throws IOException
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public ModelMap searchComponentGoodsNums(String keyword, PageParams page) {
+        ModelMap map = new ModelMap();
+        Map<String, Object> results = null;
+        //Map<String, Object> results = new HashMap<>();
+        try {
+            results = searchService.getGoodsIds(keyword, convertPageParams(page));
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        map.put("total", results.get("total"));// 搜索结果总数
+        return map;
+    }
 
 
-	/**
-	 * 获取器件搜索的类目统计
-	 *
-	 * @param keyword
-	 * @return
-	 */
-	@Override
-	public List<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId) {
-		List<Map<String, Object>> kinds = new ArrayList<>();
-		try {
-			kinds = searchService.getKindsBySearchComponent(keyword, brandId);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		return kinds;
-	}
+    /**
+     * 获取器件搜索的类目统计
+     *
+     * @param keyword
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId) {
+        List<Map<String, Object>> kinds = new ArrayList<>();
+        try {
+            kinds = searchService.getKindsBySearchComponent(keyword, brandId);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        return kinds;
+    }
 
-	/**
-	 * 获取器件搜索的品牌统计列表
-	 *
-	 * @param keyword
-	 * @return
-	 */
-	@Override
-	public List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) {
-		List<Map<String, Object>> brands = new ArrayList<>();
-		try {
-			brands = searchService.getBrandsBySearchComponent(keyword, kindId);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		return brands;
-	}
-	/**
-	 * 批次搜索结构的类目,器件,店铺类型,货币类型统计
-	 *
-	 * @param keyword
-	 * @return
-	 */
-	@Override
-	public List<Map<String, Object>> getCollectlistBySearchComponentGoods(String keyword, String collectList, String paramJSON , HttpServletRequest request) {
-		List<Map<String, Object>> collectResult = new ArrayList<>();
-		JSONObject jsonObject = FastjsonUtils.parseObject(paramJSON);
-		Set<Entry<String,Object>> paramEntry = jsonObject.entrySet();
-		Map<com.uas.search.model.PageParams.FilterField,Object> param= new LinkedHashMap<>();
-		for (Entry<String, Object> entry : paramEntry) {
-			param.put(FilterField.valueOf(entry.getKey().toUpperCase()), entry.getValue());
-		}
-		try {
-			collectResult = searchService.collectBySearchGoods(keyword, CollectField.valueOf(collectList.toUpperCase()),param);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		if ("goods_brand".equals(collectList)) {
-			if (this.deviceResolver.resolveDevice(request).isMobile()) {
-				for (Map<String, Object> m : collectResult) {
-					m.put("logoUrl", brandDao.findOne(Long.parseLong(m.get("br_id").toString())).getLogoUrl());
-				}
-			}
-		}
-		return collectResult;
-	}
+    /**
+     * 获取器件搜索的品牌统计列表
+     *
+     * @param keyword
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) {
+        List<Map<String, Object>> brands = new ArrayList<>();
+        try {
+            brands = searchService.getBrandsBySearchComponent(keyword, kindId);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        return brands;
+    }
 
-	@Override
-	public Map<String,Object> getSimilarKeywords(String keyword) {
-		Map<String,Object> result = null;
-		try {
-			result = searchService.getSimilarKeywords(keyword);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		for (Entry<String, Object> entry : result.entrySet()) {
-			if(((List)entry.getValue()).size()>8){
-				entry.setValue(((List)entry.getValue()).subList(0,8));
-			}
-		}
-		return result;
-	}
+    /**
+     * 批次搜索结构的类目,器件,店铺类型,货币类型统计
+     *
+     * @param keyword
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> getCollectlistBySearchComponentGoods(String keyword, String collectList, String paramJSON, HttpServletRequest request) {
+        List<Map<String, Object>> collectResult = new ArrayList<>();
+        JSONObject jsonObject = FastjsonUtils.parseObject(paramJSON);
+        Set<Entry<String, Object>> paramEntry = jsonObject.entrySet();
+        Map<com.uas.platform.b2c.common.search.util.PageParams.FilterField, Object> param = new LinkedHashMap<>();
+        for (Entry<String, Object> entry : paramEntry) {
+            param.put(FilterField.valueOf(entry.getKey().toUpperCase()), entry.getValue());
+        }
+        try {
+            collectResult = searchService.collectBySearchGoods(keyword, CollectField.valueOf(collectList.toUpperCase()), param);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        if ("goods_brand".equals(collectList)) {
+            if (this.deviceResolver.resolveDevice(request).isMobile()) {
+                for (Map<String, Object> m : collectResult) {
+                    m.put("logoUrl", brandDao.findOne(Long.parseLong(m.get("br_id").toString())).getLogoUrl());
+                }
+            }
+        }
+        return collectResult;
+    }
 
-	@Override
-	public List<Map<String, Object>> getSimilarComponents(String componentCode) {
-		List<Map<String, Object>> components = new ArrayList<>();
-		try {
-			components = searchService.getSimilarComponents(componentCode);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		return components;
-	}
+    @Override
+    public Map<String, Object> getSimilarKeywords(String keyword) {
+        Map<String, Object> result = null;
+        try {
+            result = searchService.getSimilarKeywords(keyword);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        for (Entry<String, Object> entry : result.entrySet()) {
+            if (((List) entry.getValue()).size() > 8) {
+                entry.setValue(((List) entry.getValue()).subList(0, 8));
+            }
+        }
+        return result;
+    }
 
-	/**
-	 * 把平台中PageParams对象转化为搜索API封装的PageParams对象
-	 *
-	 * @param params
-	 * @return
-	 */
-	private com.uas.search.model.PageParams convertPageParams(PageParams params) {
-		PageInfo pageinfo = new PageInfo(params);
-		com.uas.search.model.PageParams pageParams = new com.uas.search.model.PageParams();
-		pageParams.setPage(params.getPage());
-		pageParams.setSize(params.getCount());
-		if (!StringUtils.isEmpty(params.getFilter())) {
-			JSONObject jsonObject = FastjsonUtils.parseObject(params.getFilter());
-			Set<Entry<String, Object>> entrySet = jsonObject.entrySet();
-			for (Entry<String, Object> entry : entrySet) {
-				pageParams.filter(FilterField.valueOf(entry.getKey().toUpperCase()), entry.getValue());
-			}
-		}
-		if (!StringUtils.isEmpty(params.getSorting())){
-			//com.alibaba.fastjson.JSONObject sort = FastjsonUtils.parseObject(params.getSorting());
-			Iterator<org.springframework.data.domain.Sort.Order> iterator = pageinfo.getSort().iterator();
-			List<Sort> psort = new ArrayList<>();
-			while (iterator.hasNext()){
-				org.springframework.data.domain.Sort.Order order = iterator.next();
-				boolean reverse= false;
-				if ( "DESC".equals( order.getDirection().toString())){
-					reverse = true;
-				}
-				Sort b= new Sort( Sort.Field.valueOf(order.getProperty()),reverse);
-				psort.add(b);
-			}
-			pageParams.setSort(psort);
-		}
-		return pageParams;
-	}
+    @Override
+    public List<Map<String, Object>> getSimilarComponents(String componentCode) {
+        List<Map<String, Object>> components = new ArrayList<>();
+        try {
+            components = searchService.getSimilarComponents(componentCode);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        return components;
+    }
 
-	@Override
-	public List<Map<String, Object>> getSimilarKinds(String kindName) {
-		List<Map<String, Object>> kinds = new ArrayList<>();
-		try {
-			kinds = searchService.getSimilarKinds(kindName);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		return kinds;
-	}
+    /**
+     * 把平台中PageParams对象转化为搜索API封装的PageParams对象
+     *
+     * @param params
+     * @return
+     */
+    private com.uas.platform.b2c.common.search.util.PageParams convertPageParams(PageParams params) {
+        PageInfo pageinfo = null;
+        if (null == params.getSorting() || "".equals(params.getSorting()) || "{}".equals(params.getSorting()) || JSON.parseObject(params.getSorting()).size() == 0) {
+            pageinfo = new PageInfo();
+        } else {
+            pageinfo = new PageInfo(params);
+        }
+        com.uas.platform.b2c.common.search.util.PageParams pageParams = new com.uas.platform.b2c.common.search.util.PageParams();
+        pageParams.setPage(params.getPage());
+        pageParams.setSize(params.getCount());
+        if (!StringUtils.isEmpty(params.getFilter())) {
+            JSONObject jsonObject = FastjsonUtils.parseObject(params.getFilter());
+            Set<Entry<String, Object>> entrySet = jsonObject.entrySet();
+            for (Entry<String, Object> entry : entrySet) {
+                pageParams.filter(FilterField.valueOf(entry.getKey().toUpperCase()), entry.getValue());
+            }
+        }
+        if (!StringUtils.isEmpty(pageinfo.getSort())) {
+            //com.alibaba.fastjson.JSONObject sort = FastjsonUtils.parseObject(params.getSorting());
+            Iterator<org.springframework.data.domain.Sort.Order> iterator = pageinfo.getSort().iterator();
+            com.uas.platform.b2c.common.search.util.Sort sort = new com.uas.platform.b2c.common.search.util.Sort();
+            Sort newSort = null;
+            while (iterator.hasNext()) {
+                org.springframework.data.domain.Sort.Order order = iterator.next();
+                boolean reverse = false;
+                if ("DESC".equals(order.getDirection().toString())) {
+                    reverse = true;
+                }
+                newSort = new Sort(Sort.Field.valueOf(order.getProperty()), reverse);
+            }
+            pageParams.setSort(newSort);
+        }
+        return pageParams;
+    }
 
-	@Override
-	public List<Map<String, Object>> getSimilarLeafKinds(String kindName) {
-		return searchService.getSimilarLeafKinds(kindName);
-	}
+    @Override
+    public List<Map<String, Object>> getSimilarKinds(String kindName) {
+        List<Map<String, Object>> kinds = new ArrayList<>();
+        try {
+            kinds = searchService.getSimilarKinds(kindName);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        return kinds;
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarLeafKinds(String kindName) {
+        return searchService.getSimilarLeafKinds(kindName);
+    }
+
+    @Override
+    public List<Map<String, Object>> getSimilarBrands(String brandName) {
+        List<Map<String, Object>> brands = new ArrayList<Map<String, Object>>();
+        try {
+            brands = searchService.getSimilarBrands(brandName);
+        } catch (SearchException e) {
+            throwSystemException(e);
+        }
+        return brands;
+    }
 
 	@Override
-	public List<Map<String, Object>> getSimilarBrands(String brandName) {
-		List<Map<String, Object>> brands = new ArrayList<Map<String, Object>>();
-		try {
-			brands = searchService.getSimilarBrands(brandName);
-		} catch (SearchException e) {
-			throwSystemException(e);
-		}
-		return brands;
+	public int deleteSearchHistoryByuserUUAndenUU() {
+		return searchHistoryDao.deleteByUserUUAndUserEnuu(SystemSession.getUser().getUserUU(),
+				SystemSession.getUser().getEnterprise() == null ? null : SystemSession.getUser().getEnterprise().getUu() );
 	}
 
 	/**

+ 32 - 0
src/main/java/com/uas/platform/b2c/common/search/util/CollectField.java

@@ -0,0 +1,32 @@
+package com.uas.platform.b2c.common.search.util;
+
+
+/**
+ * 统计信息时需要的字段
+ *
+ * @author sunyj
+ * @since 2017年7月12日 上午9:03:29
+ */
+public enum CollectField {
+
+    // 批次统计
+    /**
+     * 类目
+     */
+    GOODS_KIND,
+
+    /**
+     * 品牌
+     */
+    GOODS_BRAND,
+
+    /**
+     * 货源
+     */
+    GOODS_STORE_TYPE,
+
+    /**
+     * 货币
+     */
+    GOODS_CRNAME;
+}

+ 235 - 0
src/main/java/com/uas/platform/b2c/common/search/util/PageParams.java

@@ -0,0 +1,235 @@
+package com.uas.platform.b2c.common.search.util;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 分页参数
+ *
+ * @author suntg
+ * @since 2016年8月3日下午9:10:47
+ */
+public class PageParams implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 页码
+     */
+    private int page;
+
+    /**
+     * 页大小
+     */
+    private int size;
+
+    /**
+     * 过滤
+     */
+    private Map<FilterField, Object> filters;
+
+    /**
+     * 排序
+     */
+    private Sort sort;
+
+    public PageParams() {
+    }
+
+    /**
+     * @param page
+     *            页码
+     * @param size
+     *            页大小
+     */
+    public PageParams(int page, int size) {
+        this.page = page;
+        this.size = size;
+    }
+
+    /**
+     * @return 页码
+     */
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    /**
+     * @return 页大小
+     */
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    /**
+     * @return 过滤
+     */
+    public Map<FilterField, Object> getFilters() {
+        return filters;
+    }
+
+    public void setFilters(Map<FilterField, Object> filters) {
+        this.filters = filters;
+    }
+
+    public void filter(FilterField key, Object value) {
+        if (this.filters == null) {
+            this.filters = new HashMap<FilterField, Object>();
+        }
+        this.filters.put(key, value);
+    }
+
+    public void removeFilter(FilterField key) {
+        if (this.filters != null) {
+            this.filters.remove(key);
+        }
+    }
+
+    /**
+     * @return 排序
+     */
+    public Sort getSort() {
+        return sort;
+    }
+
+    public void setSort(Sort sort) {
+        this.sort = sort;
+    }
+
+    @Override
+    public String toString() {
+        return "PageParams [page=" + page + ", size=" + size + ", filters=" + filters + ", sort=" + sort + "]";
+    }
+
+    /**
+     * 过滤的字段
+     *
+     * @author sunyj
+     * @since 2017年7月8日 下午5:00:55
+     */
+    public enum FilterField {
+
+        // 器件搜索
+        /**
+         * 类目id
+         */
+        COMPONENT_KINDID,
+
+        /**
+         * 品牌id
+         */
+        COMPONENT_BRANDID,
+
+        /**
+         * 属性信息
+         */
+        COMPONENT_PROPERTIES,
+
+        /**
+         * 有库存
+         */
+        COMPONENT_HAS_RESERVE,
+
+        /**
+         * 有样品
+         */
+        COMPONENT_HAS_SAMPLE,
+
+        /**
+         * 有现货
+         */
+        COMPONENT_HAS_ORIGINAL,
+
+        /**
+         * 有呆滞库存
+         */
+        COMPONENT_HAS_INACTION_STOCK,
+
+        // 批次搜索
+        /**
+         * 类目id
+         */
+        GOODS_KINDID,
+
+        /**
+         * 品牌id
+         */
+        GOODS_BRANDID,
+
+        /**
+         * 货源
+         */
+        GOODS_STORE_TYPE,
+
+        /**
+         * 货币
+         */
+        GOODS_CRNAME,
+
+        /**
+         * 状态
+         */
+        GOODS_STATUS,
+
+        /**
+         * 价格区间过滤:人民币最低价格
+         */
+        GOODS_MINPRICERMB,
+
+        /**
+         * 价格区间过滤:人民币最高价格
+         */
+        GOODS_MAXPRICERMB,
+
+        /**
+         * 价格区间过滤:美元最低价格
+         */
+        GOODS_MINPRICEUSD,
+
+        /**
+         * 价格区间过滤:美元最高价格
+         */
+        GOODS_MAXPRICEUSD,
+
+        // 以下字段用于单据搜索
+
+        /**
+         * 订单状态
+         */
+        ORDER_STATUS,
+
+        /**
+         * 买方个人uu号
+         */
+        ORDER_BUYER_UU,
+
+        /**
+         * 买方企业UU号
+         */
+        ORDER_BUYER_EN_UU,
+
+        /**
+         * 卖方企业UU号
+         */
+        ORDER_SELLER_EN_UU,
+
+        /**
+         * 单据搜索时,若限定时间范围,可以键值对的形式传递参数,该键代表最小(远)时间
+         */
+        ORDER_MIN_TIME,
+
+        /**
+         * 单据搜索时,若限定时间范围,可以键值对的形式传递参数,该键代表最大(近)时间
+         */
+        ORDER_MAX_TIME;
+    }
+}

+ 100 - 0
src/main/java/com/uas/platform/b2c/common/search/util/SPage.java

@@ -0,0 +1,100 @@
+package com.uas.platform.b2c.common.search.util;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class SPage<T> implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private int totalPage;
+
+    private long totalElement;
+
+    private int page;
+
+    private int size;
+
+    private boolean first;
+
+    private boolean last;
+
+    private List<T> content;
+
+    public SPage() {
+        super();
+    }
+
+    public SPage(int totalPage, long totalElement, int page, int size, boolean first, boolean last) {
+        super();
+        this.totalPage = totalPage;
+        this.totalElement = totalElement;
+        this.page = page;
+        this.size = size;
+        this.first = first;
+        this.last = last;
+    }
+
+    public int getTotalPage() {
+        return totalPage;
+    }
+
+    public void setTotalPage(int totalPage) {
+        this.totalPage = totalPage;
+    }
+
+    public long getTotalElement() {
+        return totalElement;
+    }
+
+    public void setTotalElement(long totalElement) {
+        this.totalElement = totalElement;
+    }
+
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public boolean isFirst() {
+        return first;
+    }
+
+    public void setFirst(boolean first) {
+        this.first = first;
+    }
+
+    public boolean isLast() {
+        return last;
+    }
+
+    public void setLast(boolean last) {
+        this.last = last;
+    }
+
+    public List<T> getContent() {
+        return content;
+    }
+
+    public void setContent(List<T> content) {
+        this.content = content;
+    }
+
+    @Override
+    public String toString() {
+        return "SPage [totalPage=" + totalPage + ", totalElement=" + totalElement + ", page=" + page + ", size=" + size
+                + ", first=" + first + ", last=" + last + ", content=" + content + "]";
+    }
+
+}

+ 96 - 0
src/main/java/com/uas/platform/b2c/common/search/util/Sort.java

@@ -0,0 +1,96 @@
+package com.uas.platform.b2c.common.search.util;
+
+import java.io.Serializable;
+
+/**
+ * 排序
+ *
+ * @author sunyj
+ * @since 2016年11月23日 下午1:47:44
+ */
+public class Sort implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 排序的字段
+     */
+    private Field field;
+
+    /**
+     * 排序默认为升序,若为true,则进行反转
+     */
+    private boolean reverse = false;
+
+    /**
+     * @param field
+     *            排序的字段
+     * @param reverse
+     *            如果为true,则反转默认的升序
+     */
+    public Sort(Field field, boolean reverse) {
+        this.field = field;
+        this.reverse = reverse;
+    }
+
+    /**
+     * @param field
+     *            排序的字段
+     */
+    public Sort(Field field) {
+        this(field, false);
+    }
+
+    public Sort() {
+
+    }
+
+    /**
+     * @return 排序的字段
+     */
+    public Field getField() {
+        return field;
+    }
+
+    public void setField(Field field) {
+        this.field = field;
+    }
+
+    /**
+     * 排序是否应该被反转
+     *
+     * @return 如果为true,则反转默认的升序
+     */
+    public boolean isReverse() {
+        return reverse;
+    }
+
+    public void setReverse(boolean reverse) {
+        this.reverse = reverse;
+    }
+
+    @Override
+    public String toString() {
+        return "Sort [field=" + field + ", reverse=" + reverse + "]";
+    }
+
+    /**
+     * 排序的字段
+     *
+     * @author sunyj
+     * @since 2017年7月8日 下午5:12:07
+     */
+    public enum Field {
+
+        /**
+         * 库存
+         */
+        RESERVE,
+
+        /**
+         * 价格(人民币)
+         */
+        PRICE
+    }
+
+}

+ 1 - 1
src/main/java/com/uas/platform/b2c/core/filter/SSOInterceptor.java

@@ -171,7 +171,7 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
      */
     private void accessDecision(HttpServletRequest request, User user) {
         Collection<ConfigAttribute> configAttributes = getAttributes(request);
-        if (null == configAttributes || configAttributes.size() == 0 || user.isSys()) {
+        if (null == configAttributes || configAttributes.size() == 0) {
             return;
         }
         Iterator<ConfigAttribute> iterator = configAttributes.iterator();

+ 23 - 14
src/main/java/com/uas/platform/b2c/external/erp/commodity/service/impl/ProductDetailERPServiceImpl.java

@@ -57,12 +57,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
     @Override
     public boolean uploadProductDetailERP(List<ProductDetailERP> productDetailERPList) {
         List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
+        List<Product> productList = new ArrayList<Product>();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         for (ProductDetailERP productDetailERP : productDetailERPList) {
             ProductDetail productDetail = ModelConverter.convert(productDetailERP);
 
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetail.getCode());
             if (!CollectionUtils.isEmpty(products)) {
+                products.get(0).setErpReserve(productDetailERP.getReserve());
+                productList.add(products.get(0));
+
                 productDetail.setProductId(products.get(0).getId());
             }
             // 如果已存在物料交易信息删除之前那一条,保存新的物料交易信息
@@ -72,6 +76,8 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
             }
             productDetails.add(productDetail);
         }
+
+        productDao.save(productList);
         productDetailDao.save(productDetails);
         logger.log("物料交易详情", "初始化交易详情,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
         return true;
@@ -85,16 +91,16 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
 
     @Override
     public void updateReserve(List<ProductDetailERP> productDetailERPList) {
-        List<ProductDetail> productDetails = new ArrayList<ProductDetail>();
+        List<Product> productList = new ArrayList<Product>();
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         for (ProductDetailERP productDetailERP : productDetailERPList) {
             List<Product> products = productDao.getProductByEnUUAndProdNum(enuu, productDetailERP.getCode());// 获取对应商城物料信息
             if (!CollectionUtils.isEmpty(products)) {
-                ProductDetail productDetail = productDetailDao.findByProductId(products.get(0).getId());// 获取商城物料信息
-                if (productDetail == null) {// 如果物料交易详情为空,新增物料交易详情
-                    productDetail = new ProductDetail();
-                    productDetail.setProductId(products.get(0).getId());
-                }
+//                ProductDetail productDetail = productDetailDao.findByProductId(products.get(0).getId());// 获取商城物料信息
+//                if (productDetail == null) {// 如果物料交易详情为空,新增物料交易详情
+//                    productDetail = new ProductDetail();
+//                    productDetail.setProductId(products.get(0).getId());
+//                }
 
                 if (products.get(0).getCmpUuId() != null) {// 如果为标准器件,更新在售商品信息
                     Double b2cReserve = goodsDao.getSumReserveByEnUUAndUuidAndStatus(enuu, products.get(0).getCmpUuId(), Status.AVAILABLE.value());
@@ -117,8 +123,13 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                                     good.setReserve(BigDecimal.valueOf(good.getReserve()).subtract(subtractDecimal).doubleValue());
                                     good.setSelfSale(sysConf.getStoreid().equals(good.getStoreid())? IntegerConstant.B2C_SALE.toString() : IntegerConstant.SELF_SALE.toString());// 设置自营寄售
                                     loggerInfo.info(SystemSession.getUser().getEnterprise().getEnName() + "更新库存: " + products.get(0).getProdNum() + ",self is" + good.getSelfSale());
-                                    goodsService.updateGoods(nowGood, good);
-                                    goodsService.updateComponentTradeInfos(nowGood.getUuid());
+                                    // 如果调整后的库存小于最小起订量直接下架
+                                    if (good.getReserve() < good.getMinBuyQty()) {
+                                        goodsService.offShelfGoodsByProvider(good.getBatchCode());
+                                    } else {
+                                        goodsService.updateGoods(nowGood, good);
+                                        goodsService.updateComponentTradeInfos(nowGood.getUuid());
+                                    }
                                     break;
                                 }
 
@@ -131,13 +142,11 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                     }
                 }
 
-                if (productDetail != null) {
-                    productDetail.setReserve(productDetailERP.getReserve());
-                    productDetails.add(productDetail);
-                }
+                products.get(0).setErpReserve(productDetailERP.getReserve());
+                productList.add(products.get(0));
             }
         }
-        logger.log("物料详情", "更新物料库存信息,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productDetails.size());
-        productDetailDao.save(productDetails);
+        logger.log("物料详情", "更新物料库存信息,企业:" + SystemSession.getUser().getEnterprise().getEnName() + ",数量:" + productList.size());
+        productDao.save(productList);
     }
 }

+ 2 - 1
src/main/java/com/uas/platform/b2c/external/erp/commodity/util/ModelConverter.java

@@ -197,7 +197,8 @@ public class ModelConverter {
 		productDetail.setPackaging(productDetailERP.getPackaging());
 		productDetail.setPrice(productDetailERP.getPrice());
 		productDetail.setProduceDate(productDetailERP.getProduceDate());
-		productDetail.setReserve(productDetailERP.getReserve());
+		// 暂时将ERP空闲库存放置在product中
+//		productDetail.setReserve(productDetailERP.getReserve());
 		productDetail.setCode(productDetailERP.getCode());
 		productDetail.setBreakUp(productDetailERP.getBreakUp());
 		return productDetail;

+ 1 - 0
src/main/java/com/uas/platform/b2c/external/erp/order/service/impl/OrderServiceImpl.java

@@ -186,4 +186,5 @@ public class OrderServiceImpl implements OrderService {
 		logger.log("销售订单", "回写已下载订单,企业:" + SystemSession.getUser().getEnterprise().getEnName() + "数量:" + orderids.length);
 		return true;
 	}
+
 }

+ 2 - 1
src/main/java/com/uas/platform/b2c/fa/settlement/service/impl/BillSubmitServiceImpl.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2c.fa.settlement.service.impl;
 
 import com.uas.platform.b2c.core.constant.SplitChar;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.fa.settlement.dao.BillDao;
 import com.uas.platform.b2c.fa.settlement.dao.BillSubmitDao;
 import com.uas.platform.b2c.fa.settlement.model.Bill;
@@ -181,7 +182,7 @@ public class BillSubmitServiceImpl implements BillSubmitService {
         billSubmit.setSellerenuu(order.getSellerenuu());
 
         order.setInvoicetype(bill.getKind());
-        order.setInvoiceAddress(bill.getArea() + "," + bill.getDetailAddress());
+        order.setInvoiceAddress(FastjsonUtils.toJson(bill));
         order.setInvoiceid(bill.getId());
         order.setInvoicetitle(bill.getHead());
         order.setVatBillStatus(Status.TOBEMAKE_BILL.value());

+ 53 - 0
src/main/java/com/uas/platform/b2c/logistics/constant/TipType.java

@@ -0,0 +1,53 @@
+package com.uas.platform.b2c.logistics.constant;
+
+/**
+ * 提示类型码
+ * @author hulh 10点16分
+ */
+public enum TipType {
+	/**
+	 * {@code 1201 适用于普通订单}
+	 */
+	TIP_LOGISTICS(101, "配送规则提示");
+
+
+	TipType(int value, String phrase) {
+		this.value = value;
+		this.phrase = phrase;
+	}
+	private final int value;
+
+	private final String phrase;
+
+	public int getValue() {
+		return this.value;
+	}
+
+	public String getPhrase() {
+		return this.phrase;
+	}
+
+	/**
+	 * @param statusCode 状态的编码
+	 * @return 状态
+	 * @throws IllegalArgumentException
+	 *             如果statusCode不存在的话
+	 */
+	public static TipType valueOf(int statusCode) {
+		for (TipType status : values()) {
+			if (status.value == statusCode) {
+				return status;
+			}
+		}
+		throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的类型");
+	}
+
+	/**
+	 * 返回状态码的编号
+	 * @return
+	 */
+	@Override
+	public String toString() {
+		return Integer.toString(value);
+	}
+}

+ 9 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/DistributionRuleController.java

@@ -90,6 +90,15 @@ public class DistributionRuleController {
 		return distributionRuleService.findCountRule();
 	}
 
+	/**
+	 * 返回当前enuu启用配送规则总数
+	 * @return
+	 */
+	@RequestMapping(value = "/active/count", method = RequestMethod.GET)
+	public ResultMap findActiveRuleCount(){
+		return distributionRuleService.findCountActiveRule();
+	}
+
 	/**
 	 * 查找配送规则名是否存在
 	 * @param id

+ 36 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/TipRecordController.java

@@ -0,0 +1,36 @@
+package com.uas.platform.b2c.logistics.controller;
+
+import com.uas.platform.b2c.logistics.model.TipRecord;
+import com.uas.platform.b2c.logistics.service.TipRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 提示记录Controller
+ * @author hulh
+ */
+@RestController
+@RequestMapping("/tip/record")
+public class TipRecordController {
+
+	@Autowired
+	private TipRecordService tipRecordService;
+
+	/**
+	 * 根据当前userUu查询配送规则提示
+	 */
+	@RequestMapping(value = "/rule", method = RequestMethod.GET)
+	public TipRecord findTipRecordOfRule() {
+		return tipRecordService.findByUserUuOfRule();
+	}
+
+	/**
+	 * 根据当前userUu切换配送规则提示
+	 */
+	@RequestMapping(value = "/rule/close", method = RequestMethod.PUT)
+	public TipRecord turnTipRecordOfRule() {
+		return tipRecordService.turnTipRecordOfRule();
+	}
+}

+ 8 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/DistributionRuleDao.java

@@ -33,6 +33,14 @@ public interface DistributionRuleDao extends JpaSpecificationExecutor<Distributi
 	@Query(value = "select count(1) from DistributionRule d where d.enuu = :enuu")
 	int findCountByEnuu(@Param("enuu") Long enuu);
 
+	/**
+	 * 根据enuu查询启用的配送规则数
+	 * @param enuu
+	 * @return
+	 */
+	@Query(value = "select count(1) from DistributionRule d where d.enuu = :enuu and d.active = 1")
+	int findCountByEnuuAndActive(@Param("enuu") Long enuu);
+
 	/**
 	 * 根据enuu获取所有的配送规则
 	 * @param enuu

+ 31 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/TipRecordDao.java

@@ -0,0 +1,31 @@
+package com.uas.platform.b2c.logistics.dao;
+
+import com.uas.platform.b2c.logistics.model.TipRecord;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * 提示记录dao层
+ */
+@Repository
+public interface TipRecordDao extends JpaSpecificationExecutor<TipRecord>, JpaRepository<TipRecord, Long> {
+
+	/**
+	 * 根据类型返回提示记录
+	 * @param useruu
+	 * @param type
+	 * @return
+	 */
+	List<TipRecord> findByUseruuAndTypeOrderByTipAgainDesc(Long useruu, Integer type);
+
+	/**
+	 * 根据类型返回不再提示记录
+	 * @param useruu
+	 * @param type
+	 * @return
+	 */
+	List<TipRecord> findByUseruuAndTypeAndTipAgainOrderByTipAgainDesc(Long useruu, Integer type, Short tipAgain);
+}

+ 84 - 0
src/main/java/com/uas/platform/b2c/logistics/model/TipRecord.java

@@ -0,0 +1,84 @@
+package com.uas.platform.b2c.logistics.model;
+
+import javax.persistence.*;
+
+/**
+ * 提示记录
+ * @author hulh
+ */
+@Entity
+@Table(name = "tip_record")
+public class TipRecord {
+
+	/**
+	 * 主键id
+	 */
+	@Id
+	@GeneratedValue
+	@Column(name = "tip_id")
+	private Long id;
+
+	/**
+	 * 用户uu
+	 */
+	@Column(name = "tip_uu")
+	private Long useruu;
+
+	/**
+	 * 企业enuu
+	 */
+	@Column(name = "tip_enuu")
+	private Long enuu;
+
+	/**
+	 * 是否再提示 1 再提示 0 不再提示
+	 */
+	@Column(name = "tip_again")
+	private Short tipAgain;
+
+	/**
+	 * 提示类型
+	 */
+	@Column(name = "tip_type")
+	private Integer type;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getUseruu() {
+		return useruu;
+	}
+
+	public void setUseruu(Long useruu) {
+		this.useruu = useruu;
+	}
+
+	public Long getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(Long enuu) {
+		this.enuu = enuu;
+	}
+
+	public Short getTipAgain() {
+		return tipAgain;
+	}
+
+	public void setTipAgain(Short tipAgain) {
+		this.tipAgain = tipAgain;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+}

+ 24 - 0
src/main/java/com/uas/platform/b2c/logistics/model/UsableRuleInfo.java

@@ -1,10 +1,34 @@
 package com.uas.platform.b2c.logistics.model;
 
+import com.uas.platform.b2c.core.constant.Type;
+
 /**
  * Created by hulh on 2017/9/13.
  * 适用的配送规则简要信息
  */
 public class UsableRuleInfo {
+
+	/**
+	 * 单例实现共用的上门自提配送规则
+	 */
+	private static volatile UsableRuleInfo TAKE_SELF_RULE = null;
+	private static final String TAKE_SELF_NAME = "上门自提免运费";
+
+	public static UsableRuleInfo getTakeSelfRule(){
+		if (TAKE_SELF_RULE == null){
+			synchronized (UsableRuleInfo.class){
+				if (TAKE_SELF_RULE == null){
+					TAKE_SELF_RULE = new UsableRuleInfo();
+					TAKE_SELF_RULE.setMethod(Type.Delivery_BySelf_Code.value());
+					TAKE_SELF_RULE.setRuleName(TAKE_SELF_NAME);
+					TAKE_SELF_RULE.setFare(0d); //运费默认为0
+					TAKE_SELF_RULE.setFareType((short)1); //运费类型默认为统一运费
+				}
+			}
+		}
+		return TAKE_SELF_RULE;
+	}
+
 	/**
 	 * 配送id
 	 */

+ 7 - 0
src/main/java/com/uas/platform/b2c/logistics/service/DistributionRuleService.java

@@ -58,6 +58,13 @@ public interface DistributionRuleService {
 	 */
 	ResultMap findCountRule();
 
+	/**
+	 * 返回当前enuu下启用配送规则总数
+	 * @return
+	 */
+	ResultMap findCountActiveRule();
+
+
 	/**
 	 * 查找是否已存在该名称
 	 * @param id

+ 22 - 0
src/main/java/com/uas/platform/b2c/logistics/service/TipRecordService.java

@@ -0,0 +1,22 @@
+package com.uas.platform.b2c.logistics.service;
+
+import com.uas.platform.b2c.logistics.model.TipRecord;
+
+/**
+ * 提示记录Service
+ * @author hulh
+ */
+public interface TipRecordService {
+
+	/**
+	 * 根据userUu查询配送规则提示记录
+	 * @return
+	 */
+	TipRecord findByUserUuOfRule();
+
+	/**
+	 * 根据userUu查询配送规则提示记录
+	 * @return
+	 */
+	TipRecord turnTipRecordOfRule();
+}

+ 42 - 11
src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributionRuleServiceImpl.java

@@ -4,15 +4,15 @@ import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.ShortConstant;
 import com.uas.platform.b2c.core.constant.SplitChar;
+import com.uas.platform.b2c.core.constant.Type;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.logistics.dao.AddressTakeSelfDao;
 import com.uas.platform.b2c.logistics.dao.DistributionRuleDao;
-import com.uas.platform.b2c.logistics.model.DistributionRule;
-import com.uas.platform.b2c.logistics.model.RuleQtyArea;
-import com.uas.platform.b2c.logistics.model.RuleQtyFare;
-import com.uas.platform.b2c.logistics.model.UsableRuleInfo;
+import com.uas.platform.b2c.logistics.model.*;
 import com.uas.platform.b2c.logistics.service.DistributionRuleService;
 import com.uas.platform.b2c.prod.store.dao.StoreInDao;
 import com.uas.platform.b2c.prod.store.model.StoreIn;
+import com.uas.platform.b2c.prod.store.model.StoreStatus;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
@@ -47,6 +47,9 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 	@Autowired
 	private StoreInDao storeInDao;
 
+	@Autowired
+	private AddressTakeSelfDao takeSelfDao;
+
 	@Autowired
 	private SysConf sysConf;
 
@@ -225,6 +228,26 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 		return ResultMap.success(count);
 	}
 
+	/**
+	 * 查询已设置配送规则的数量,启用的,返回是否显示提示
+	 * @return
+	 */
+	@Override
+	public ResultMap findCountActiveRule() {
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		List<StoreIn> storeList = storeInDao.findByEnUU(enuu);
+		int count = distributionRuleDao.findCountByEnuuAndActive(enuu);
+		if (!CollectionUtils.isEmpty(storeList)){
+			StoreIn storeIn = storeList.get(0);
+			if (count == 0 && storeIn.getStatus() == StoreStatus.OPENED){
+				return ResultMap.success(true);
+			}else {
+				return ResultMap.success(false);
+			}
+		}
+		return ResultMap.success(false);
+	}
+
 	/**
 	 * 根据配送规则名称查询是否已存在
 	 * @param id
@@ -287,12 +310,14 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 			throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
 		}
 		for (UsableRuleInfo info : ruleList){
-			DistributionRule rule = distributionRuleDao.findOne(info.getId());
-			if (rule == null){
-				throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
+			if (info.getId() != null && info.getMethod() != Type.Delivery_BySelf_Code.value()){
+				DistributionRule rule = distributionRuleDao.findOne(info.getId());
+				if (rule == null){
+					throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
+				}
+				Double fare = getFareOfRule(rule, price);
+				info.setFare(fare);
 			}
-			Double fare = getFareOfRule(rule, price);
-			info.setFare(fare);
 		}
 		return ruleList;
 	}
@@ -332,7 +357,8 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 		List<UsableRuleInfo> ruleInfoList = new ArrayList<>();
 		List<Integer> methodList = new ArrayList<>();
 		for (DistributionRule rule : allRuleList){
-			if (!methodList.contains(rule.getShippingMethod())){
+			if (!methodList.contains(rule.getShippingMethod()) &&
+					!rule.getShippingMethod().equals(Type.Delivery_BySelf_Code.value())){
 				List<RuleQtyArea> qtyArea = rule.getAreas();
 				//转化分段地区信息
 				Map<String, Map<String, List<String>>> resultMap = convertArea(qtyArea);
@@ -347,10 +373,15 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 					ruleInfoList.add(info);
 				}
 			}
-			if (methodList.size() == 3){
+			if (methodList.size() == 2){
 				break;
 			}
 		}
+		List<AddressTakeSelf> takeSelfList = takeSelfDao.findByEnuuAndActiveOrderByCreatetimeDesc(store.getEnUU(), ShortConstant.YES_SHORT);
+		if (!CollectionUtils.isEmpty(takeSelfList)){
+			UsableRuleInfo takeRule = UsableRuleInfo.getTakeSelfRule();
+			ruleInfoList.add(takeRule);
+		}
 		return ruleInfoList;
 	}
 

+ 63 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/TipRecordServiceImpl.java

@@ -0,0 +1,63 @@
+package com.uas.platform.b2c.logistics.service.impl;
+
+import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.core.constant.ShortConstant;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.logistics.constant.TipType;
+import com.uas.platform.b2c.logistics.dao.TipRecordDao;
+import com.uas.platform.b2c.logistics.model.TipRecord;
+import com.uas.platform.b2c.logistics.service.TipRecordService;
+import com.uas.platform.core.exception.IllegalOperatorException;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author hulh
+ */
+@Service
+public class TipRecordServiceImpl implements TipRecordService {
+
+	@Autowired
+	private TipRecordDao tipRecordDao;
+
+	@Override
+	public TipRecord findByUserUuOfRule() {
+		User user = SystemSession.getUser();
+		List<TipRecord> recordList =  tipRecordDao.findByUseruuAndTypeOrderByTipAgainDesc(user.getUserUU(),
+				TipType.TIP_LOGISTICS.getValue());
+		if (CollectionUtils.isEmpty(recordList)){
+			return newOneRecord(user);
+		}
+
+		return recordList.get(0);
+	}
+
+	@Override
+	public TipRecord turnTipRecordOfRule() {
+		User user = SystemSession.getUser();
+		List<TipRecord> recordList =  tipRecordDao.findByUseruuAndTypeOrderByTipAgainDesc(user.getUserUU(),
+				TipType.TIP_LOGISTICS.getValue());
+		if (CollectionUtils.isEmpty(recordList)){
+			throw new IllegalOperatorException("操作异常");
+		}
+		TipRecord record = recordList.get(0);
+		if (record.getTipAgain() == 1)
+			return record;
+		record.setTipAgain(ShortConstant.YES_SHORT);
+		return tipRecordDao.save(record);
+	}
+
+	@Transactional
+	private TipRecord newOneRecord(User user){
+		TipRecord record = new TipRecord();
+		record.setEnuu(user.getEnterprise().getUu());
+		record.setUseruu(user.getUserUU());
+		record.setType(TipType.TIP_LOGISTICS.getValue());
+		record.setTipAgain(ShortConstant.NO_SHORT);
+		return tipRecordDao.save(record);
+	}
+}

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/Product.java

@@ -73,6 +73,12 @@ public class Product {
 	@Column(name = "pr_stock")
 	private Double stock;
 
+	/**
+	 * ERP空闲库存
+	 */
+	@Column(name = "pr_reserve")
+	private Double erpReserve;
+
 	/**
 	 * 价格
 	 */
@@ -355,6 +361,14 @@ public class Product {
 		return this;
 	}
 
+	public Double getErpReserve() {
+		return erpReserve;
+	}
+
+	public void setErpReserve(Double erpReserve) {
+		this.erpReserve = erpReserve;
+	}
+
 	public Double getPrice() {
 		return price;
 	}

+ 2 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -570,9 +570,9 @@ public class GoodsServiceImpl implements GoodsService {
 		ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
 		if (productDetail == null) {
 			productDetail = new ProductDetail();
-		} else if (productDetail.getReserve() != null) {
+		} else if (product.getErpReserve() != null) {
 			ProductDetail newProductDetail = productService.findByProductId(product.getId());
-			if (productDetail.getReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
+			if (product.getErpReserve() < goods.getReserve() + newProductDetail.getB2cReserve()) {
 				throw new IllegalOperatorException("本次上架数量和已上架数量之和不可超过ERP空闲库存数量");
 			}
 		}

+ 22 - 20
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -46,9 +46,8 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
-import org.springframework.jdbc.core.CallableStatementCallback;
-import org.springframework.jdbc.core.CallableStatementCreator;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.StatementCallback;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
@@ -58,9 +57,9 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import java.lang.reflect.Field;
-import java.sql.CallableStatement;
-import java.sql.Connection;
+import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -320,23 +319,26 @@ public class ProductServiceImpl implements ProductService {
 
     @Override
     public Integer matchAll() {
-//        jdbcTemplate.execute("call TRADE_UPDATE_AVAILABLE_DAYS(" + SystemSession.getUser().getEnterprise().getUu() + ")");
-        Integer updateCount = (Integer) jdbcTemplate.execute(
-            new CallableStatementCreator() {
-                public CallableStatement createCallableStatement(Connection con) throws SQLException {
-                    String sp = "{call vendor_match_products(?,?)}";
-                    CallableStatement cs = con.prepareCall(sp);
-                    cs.setLong(1, SystemSession.getUser().getEnterprise().getUu());
-                    cs.registerOutParameter(2, OracleType.STYLE_INT);
-                    return cs;
-                }
-            }, new CallableStatementCallback() {
-                public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
-                    cs.execute();
-                    return cs.getInt(2);
+        Long enuu = SystemSession.getUser().getEnterprise().getUu();
+        String sql = "/*#mycat:db_type=master*/ call vendor_match_products(%s, @out); select @out";
+        final String querySql = String.format(sql, enuu);
+        String updateCount = jdbcTemplate.execute(new StatementCallback<String>() {
+
+            @Override
+            public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
+                stmt.executeQuery(querySql);
+                ResultSet rs = stmt.getResultSet();
+                if (rs != null) {
+                    rs.next();
+                    return rs.getString(1);
                 }
-            });
-        return updateCount;
+                return null;
+            }
+        });
+        if (StringUtils.isEmpty(updateCount)) {
+            return 0;
+        }
+        return Integer.valueOf(updateCount);
     }
 
 

+ 23 - 4
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -449,7 +449,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 		commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
 		Long userUU = SystemSession.getUser().getUserUU();
-		releaseProductByBatchDao.callValidProcedure(userUU, batch);
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		callValidProcedure(enuu, batch);
 		Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
 		Integer success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
 		modelMap.put("total", total);
@@ -460,6 +461,25 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		return modelMap;
 	}
 
+	/**
+	 * 使用mycat注解方式调用存储过程
+	 * @param enuu  卖家uu
+	 * @param batch 批次号
+	 */
+	private void callValidProcedure(Long enuu, String batch) {
+		final Object[] obj = new Object[]{enuu, batch};
+		String sql = "/*#mycat:db_type=master*/ call PRODUCT_RELEASE_VALID(%s, '%s')";
+		final String updateSql = String.format(sql, obj);
+		jdbcTemplate.execute(new StatementCallback<String>() {
+
+			@Override
+			public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
+				Integer count = stmt.executeUpdate(updateSql);
+				return count.toString();
+			}
+		});
+	}
+
 	/**
 	 * 分析分段的价格
  	 */
@@ -822,14 +842,13 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	public String publishByBatch(String batch) {
 		Enterprise enterprise = SystemSession.getUser().getEnterprise();
 		final Object [] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
-		String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call product_release_batch_publish(@enuu, @enName, @batch, @out)";
+		String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call product_release_batch_publish(@enuu, @enName, @batch, @out); select @out";
 		final String updateSql = String.format(sql, obj);
 		String num = jdbcTemplate.execute(new StatementCallback<String>() {
 
 			@Override
 			public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
-				stmt.executeUpdate(updateSql);
-				stmt.execute("select @out");
+				stmt.executeQuery(updateSql);
 				ResultSet rs = stmt.getResultSet();
 				if (null != rs) {
 					rs.next();

+ 24 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/api/BrandController.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.product.brand.api;
 
+import com.uas.platform.b2c.core.support.log.ControllerUsageLog;
 import com.uas.platform.b2c.prod.product.brand.modal.Brand;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandInfo;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandMostSimpleInfo;
@@ -109,6 +110,19 @@ public class BrandController {
 		return brandService.getBrandInfoPage(info, keyword);
 	}
 
+	/**
+	 * 查找所有详细有效品牌信息
+	 * @param keyword 关键词
+	 * @param params
+	 *            分页信息
+	 * @return 品牌简易信息
+	 */
+	@RequestMapping(value = "/Brand/ByPage", method = RequestMethod.GET)
+	public Map<String,Object> getBrandPage(PageParams params, String keyword) {
+		PageInfo info = new PageInfo(params);
+		return brandService.getBrandPage(info, keyword);
+	}
+
 	/**
 	 * 查找所有简单有效品牌信息,并按首字母过滤
 	 * @param keyword 关键词
@@ -230,4 +244,14 @@ public class BrandController {
 	public List<BrandMostSimpleInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
 		return brandService.getBatchBrandMostSimpleInfs(batchIds);
 	}
+
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return 品牌信息
+	 */
+	@RequestMapping(value = "/mostSearchBrands", method = RequestMethod.GET)
+	@ControllerUsageLog(module = "品牌查询接口", detail = "获取搜索量最高的2个品牌")
+	public List<Brand> getMostSearchBrands() {
+		return brandService.getMostSearchBrands();
+	}
 }

+ 9 - 2
src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandDao.java

@@ -78,8 +78,15 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	 * @param initals
 	 * @return
 	 */
-	@Query(value = "select b from Brand b  where b.inital in :initals and (b.nameEn like %:keyword% or b.nameCn like %:keyword%)")
-	public Page<Brand> findInInitalsPage(@Param("initals") String[] initals ,@Param("keyword") String keyword, Pageable pageable);
+	@Query(value = "select b from Brand b  where b.inital in :initals")
+	public Page<Brand> findInInitalsPage(@Param("initals") String[] initals , Pageable pageable);
+
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return
+	 */
+	@Query(nativeQuery = true , value = "select * from product$brand order by br_search_count desc LIMIT 2")
+	public List<Brand> findMostSearchBrands();
 
 	/**
 	 * 器件点击次数加一

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/service/BrandService.java

@@ -83,6 +83,14 @@ public interface BrandService {
 	 */
 	public Page<BrandInfo> getBrandInfoPage(PageInfo pageInfo, String keyword);
 
+	/**
+	 * 获取Brand分页数据
+	 * @param keyword 关键词
+	 * @param pageInfo 分页信息
+	 * @return 品牌简易信息
+	 */
+	public Map<String,Object> getBrandPage(PageInfo pageInfo, String keyword);
+
 	/**
 	 * 获取BrandInfo分页数据
 	 * @param keyword 关键词
@@ -179,6 +187,12 @@ public interface BrandService {
 	 */
 	public List<BrandMostSimpleInfo> getBatchBrandMostSimpleInfs(List<Long> batchIds);
 
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return 品牌信息
+	 */
+	public List<Brand> getMostSearchBrands();
+
 	/**
 	 * 器件点击次数加一
 	 * @param uuid

+ 34 - 1
src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.product.brand.service.impl;
 
+import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.core.utils.PinyinUtils;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandInfoDao;
@@ -17,6 +18,8 @@ import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.CriterionExpression.Operator;
 import com.uas.platform.core.persistence.criteria.LogicalExpression;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
+import com.uas.search.exception.SearchException;
+import com.uas.platform.b2c.common.search.util.SPage;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -50,6 +53,9 @@ public class BrandServiceImpl implements BrandService {
 	@Autowired
 	private JdbcTemplate jdbcTemplate;
 
+	@Autowired
+	private SearchService searchService;
+
 	@Autowired
 	private BrandMostSimpleInfoDao brandMostSimpleInfoDao;
 
@@ -136,7 +142,11 @@ public class BrandServiceImpl implements BrandService {
 	@Override
 	public Page<Brand> getInitialSimpleInfoByFirst(String key , PageParams params ,String keyword) {
 		Pageable pageable = new PageInfo(params);
-		return brandDao.findInInitalsPage(new String[]{key},keyword, pageable);
+		if ("0~9".equals(key)) {
+			return brandDao.findInInitalsPage(new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}, pageable);
+		}else {
+			return brandDao.findInInitalsPage(new String[]{key}, pageable);
+		}
 	}
 
 	// 判断一个字符串是否含有中文
@@ -199,6 +209,24 @@ public class BrandServiceImpl implements BrandService {
 		}, pageInfo);
 	}
 
+	@Override
+	public Map<String,Object> getBrandPage(final PageInfo pageInfo, String keyword) {
+		SPage<Map<String, Object>> brands = null;
+		try {
+			brands = searchService.getBrands(keyword,pageInfo.getPageNumber(),pageInfo.getPageSize());
+		} catch (SearchException e) {}
+		List<Map<String, Object>> brandPage = brands.getContent();
+		List<Brand> brandList = new ArrayList<>();
+		for (Map<String, Object> a : brandPage){
+			brandList.add(brandDao.findOne(Long.parseLong(a.get("id").toString())));
+		}
+		Map<String,Object> map = new HashMap<>();
+		map.put("content",brandList);
+		map.put("totalPages",brands.getTotalPage());
+		map.put("totalElements",brands.getTotalElement());
+		return map;
+	}
+
 	@Override
 	public Brand findByUuid(String uuid) {
 		// 这个因为是接口错误的话直接返回
@@ -385,6 +413,11 @@ public class BrandServiceImpl implements BrandService {
 		return brandMostSimpleInfoDao.findBatchBrands(batchIds);
 	}
 
+	@Override
+	public List<Brand> getMostSearchBrands() {
+		return brandDao.findMostSearchBrands();
+	}
+
 	@Override
 	public void addVisitCount(String uuid) {
 		brandDao.addVisitCount(uuid);

+ 43 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.prod.product.component.api;
 
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.core.support.log.ControllerUsageLog;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.product.component.modal.Component;
@@ -120,6 +121,17 @@ public class ComponentController {
 		return componentService.findInfoPage(info);
 	}
 
+	/**
+	 * 查找所有简单有效品牌信息
+	 *
+	 * @return 品牌简易信息
+	 */
+	@RequestMapping(value = "/Info", method = RequestMethod.GET)
+	public List<ComponentInfo> getComonentInfo() {
+		return componentService.getAllComponentInfo();
+	}
+
+
 	/**
 	 * 根据UUId获取器件摘要
 	 * 
@@ -277,4 +289,35 @@ public class ComponentController {
 	public List<ComponentInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
 		return componentService.getBatchComponents(batchIds);
 	}
+
+	/**
+	 * 查找已推广的按权重排序的器件信息
+	 *
+	 * @return 器件简易信息
+	 */
+	@RequestMapping(value = "/searchWeight", method = RequestMethod.GET)
+	public List<ComponentInfo> getComponentInfoOrderByWeight() {
+		return componentService.getAllComponentInfoByWeight();
+	}
+
+	/**
+	 * 修改某个器件的 权重
+	 *
+	 * @return 器件简易信息
+	 */
+	@RequestMapping(value = "/searchWeight", method = RequestMethod.PUT)
+	public ComponentInfo updateBrankInfoOrderByWeight(@RequestBody ComponentInfo componentInfo ,@RequestParam Double weight) {
+		return componentService.updateComponentInfoInfoOrderByWeight(componentInfo,weight);
+	}
+
+
+	/**
+	 * 获取搜索量最高的2个器件
+	 * @return 品牌信息
+	 */
+	@RequestMapping(value = "/mostSearchComponent", method = RequestMethod.GET)
+	@ControllerUsageLog(module = "品牌查询接口", detail = "获取搜索量最高的2个器件")
+	public List<Component> getMostSearchBrands() {
+		return componentService.getMostSearchComponent();
+	}
 }

+ 10 - 44
src/main/java/com/uas/platform/b2c/prod/product/component/controller/ComponentSubmitController.java

@@ -9,6 +9,7 @@ import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.external.erp.product.service.OperationInfoService;
 import com.uas.platform.b2c.prod.product.component.modal.*;
 import com.uas.platform.b2c.prod.product.component.service.ComponentSubmitService;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
@@ -28,7 +29,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -428,63 +428,29 @@ public class ComponentSubmitController {
 
 	/**
 	 * 上传器件数据到爬虫库(没有参数对应关系)
-	 * 
+	 *
 	 * @param uploadItem 文件
 	 * @return 爬取器件信息
 	 */
 	@Transactional
 	@RequestMapping(value = "upload/componentCrawls", method = RequestMethod.POST)
-	public List<ComponentCrawl> uploadComponentCrawl(FileUpload uploadItem) {
-		String fileName = uploadItem.getFile().getOriginalFilename();
-		String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
-		InputStream is = null;
-		Workbook workbook = null;
-		List<ComponentCrawl> componentCrawls = new ArrayList<ComponentCrawl>();
-		try {
-			is = uploadItem.getFile().getInputStream();
-			if ("xls".equals(suffix)) {
-				workbook = new HSSFWorkbook(is);
-			} else if ("xlsx".equals(suffix)) {
-				workbook = new XSSFWorkbook(is);
-			} else {
-				throw new IllegalOperatorException("文件格不正确,请上传.xls或.xlsx的文件");
-			}
-			componentCrawls = componentSubmitService.uploadComponentCrawl(workbook, fileName);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return componentCrawls;
+	public ResultMap uploadComponentCrawlV2(FileUpload uploadItem) {
+		logger.log("器件上传", "器件上传");
+		return componentSubmitService.uploadComponentCrawl(uploadItem);
 	}
-	
+
 	/**
 	 * 上传器件数据到爬虫库(已有参数对应关系)
-	 * 
+	 *
 	 * @param uploadItem 文件
 	 * @param kindContrastId 对应关系id
 	 * @return 爬取器件信息
 	 */
 	@Transactional
 	@RequestMapping(value = "upload/componentCrawlsWithSame/{kindContrastId}", method = RequestMethod.POST)
-	public List<ComponentCrawl> uploadComponentCrawlWithSame(FileUpload uploadItem, @PathVariable("kindContrastId") Long kindContrastId) {
-		String fileName = uploadItem.getFile().getOriginalFilename();
-		String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
-		InputStream is = null;
-		Workbook workbook = null;
-		List<ComponentCrawl> componentCrawls = new ArrayList<ComponentCrawl>();
-		try {
-			is = uploadItem.getFile().getInputStream();
-			if ("xls".equals(suffix)) {
-				workbook = new HSSFWorkbook(is);
-			} else if ("xlsx".equals(suffix)) {
-				workbook = new XSSFWorkbook(is);
-			} else {
-				throw new IllegalOperatorException("文件格不正确,请上传.xls或.xlsx的文件");
-			}
-			componentCrawls = componentSubmitService.uploadComponentCrawlWithSame(workbook, fileName, kindContrastId);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return componentCrawls;
+	public ResultMap uploadComponentCrawlWithSame(FileUpload uploadItem, @PathVariable("kindContrastId") Long kindContrastId) {
+		logger.log("器件上传", "器件重新上传");
+		return componentSubmitService.uploadComponentCrawlWithSame(uploadItem, kindContrastId);
 	}
 	
 	

+ 6 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentCrawlDao.java

@@ -30,6 +30,12 @@ public interface ComponentCrawlDao extends JpaSpecificationExecutor<ComponentCra
 	 */
 	public List<ComponentCrawl> findByTask(Long task);
 
+	/**
+	 * 通过任务但id删除数据
+	 * @param task
+	 */
+	public void deleteByTask(Long task);
+
 	/**
 	 * 通过任务id获取去重后的爬取图片路径
 	 * @param task

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentDao.java

@@ -121,6 +121,14 @@ public interface ComponentDao extends JpaSpecificationExecutor<Component>, JpaRe
 	@Query("select count(1) from Component")
 	public Integer findAllCount();
 
+	/**
+	 * 获取搜索量最高的2个器件
+	 * @return
+	 */
+	@Query(nativeQuery = true , value = "select * from product$component order by cmp_search_count desc LIMIT 2")
+	public List<Component> findMostSearchComponent();
+
+
 	/**
 	 * 器件点击次数加一
 	 * @param uuid

+ 19 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentInfoDao.java

@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
@@ -88,4 +89,22 @@ public interface ComponentInfoDao extends JpaSpecificationExecutor<ComponentInfo
 	 */
 	@Query(nativeQuery = true, value = "select * from product$component where cmp_id in :batchids")
 	public List<ComponentInfo> findByBatchids(@Param("batchids") List<Long> batchids);
+
+	@Query("select c from ComponentInfo c where c.code like :q%")
+	public Page<ComponentInfo> findByFirst(@Param("q") String keyword,Pageable pageable);
+
+	/**
+	 * 根据权重倒序排列品牌信息
+	 * @return
+	 */
+	@Query(value = "select b from ComponentInfo b where b.searchWeight is not null and b.searchWeight <> 0 order by b.searchWeight desc")
+	public List<ComponentInfo> findBySearchWeight();
+
+	/**
+	 * 根据权重倒序排列品牌信息
+	 * @return
+	 */
+	@Modifying
+	@Query(value = "update ComponentInfo b set b.searchWeight = :increaseNum where b.uuid = :uuid")
+	public int setWeight(@Param("uuid") String uuid, @Param("increaseNum") Double increaseNum);
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/modal/Component.java

@@ -607,6 +607,14 @@ public class Component implements Serializable {
 		this.company = company;
 	}
 
+	public Integer getLifecycle() {
+		return lifecycle;
+	}
+
+	public void setLifecycle(Integer lifecycle) {
+		this.lifecycle = lifecycle;
+	}
+
 	public String getCompanyUrl() {
 		return companyUrl;
 	}

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/modal/ComponentInfo.java

@@ -97,6 +97,12 @@ public class ComponentInfo implements Serializable {
 	@Column(name = "cmp_weight")
 	private Float weight;
 
+	/**
+	 * 搜索排序权重
+	 */
+	@Column(name = "searchweight")
+	private Double searchWeight;
+
 	/**
 	 * 附件id
 	 */
@@ -263,6 +269,14 @@ public class ComponentInfo implements Serializable {
 		this.weight = weight;
 	}
 
+	public Double getSearchWeight() {
+		return searchWeight;
+	}
+
+	public void setSearchWeight(Double searchWeight) {
+		this.searchWeight = searchWeight;
+	}
+
 	public String getAttach() {
 		if(SystemSession.getUser() != null) {
 			return attach;

+ 27 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java

@@ -103,6 +103,13 @@ public interface ComponentService {
 	 */
 	public Page<ComponentInfo> findInfoPage(PageInfo info);
 
+	/**
+	 * 获取所有的简易器件信息
+	 * @author yujia
+	 * @return 器件简易信息
+	 */
+	public List<ComponentInfo> getAllComponentInfo();
+
 	/**
 	 * 关联的goods数据会被set进去
 	 * @param info 分页参数
@@ -211,10 +218,30 @@ public interface ComponentService {
 	 */
 	List<ComponentInfo> getBatchComponents(List<Long> batchIds);
 
+	/**
+	 * 查找已推广的按权重排序的器件信息
+	 * @author wangdy
+	 * @return 品牌简易信息
+	 */
+	public List<ComponentInfo> getAllComponentInfoByWeight();
+
+	/**
+	 * 修改某个品牌的 权重
+	 * @return 品牌简易信息
+	 */
+	public ComponentInfo updateComponentInfoInfoOrderByWeight(ComponentInfo componentInfo , Double weight);
+
 	/**
 	 * 器件点击次数加一
 	 * @param uuid
 	 * @return
 	 */
 	public void addVisitCount(String uuid);
+
+	/**
+	 * 获取搜索量最高的2个器件
+	 * @return 品牌信息
+	 */
+	public List<Component> getMostSearchComponent();
+
 }

+ 9 - 8
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentSubmitService.java

@@ -1,6 +1,8 @@
 package com.uas.platform.b2c.prod.product.component.service;
 
+import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.prod.product.component.modal.*;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.data.domain.Page;
@@ -116,19 +118,18 @@ public interface ComponentSubmitService {
 	public ComponentCrawlSubmit saveBatch(List<ComponentCrawlSubDetail> details);
 
 	/**
-	 * 上传器件爬取数据(没有参数对应关系)
-	 * 
-	 * @param workbook 表格
+	 * 上传器件爬取数据
+	 * @param uploadItem 上传文件
 	 * @return 爬取器件
 	 */
-	public List<ComponentCrawl> uploadComponentCrawl(Workbook workbook, String fileName);
+	public ResultMap uploadComponentCrawl(FileUpload uploadItem);
 
 	/**
 	 * 上传器件爬取数据(已有参数对应关系)
-	 * @param workbook 表格
-	 * @param fileName 文件名
-	 * @param kindContrastId 参数关系id
+	 * @param uploadItem 上传文件
+	 * @param kindContrastId 对应参数对应id
 	 * @return 爬取器件
 	 */
-	public List<ComponentCrawl> uploadComponentCrawlWithSame(Workbook workbook, String fileName, Long kindContrastId);
+	public ResultMap uploadComponentCrawlWithSame(FileUpload uploadItem, Long kindContrastId);
+
 }

+ 5 - 5
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentGoodsServiceImpl.java

@@ -9,8 +9,8 @@ import com.uas.platform.b2c.prod.product.kind.service.KindService;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
-import com.uas.search.model.PageParams;
-import com.uas.search.model.PageParams.FilterField;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.common.search.util.PageParams.FilterField;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
@@ -53,9 +53,9 @@ public class ComponentGoodsServiceImpl implements ComponentGoodsService {
 			if(filter.get("properties") != null) {
 				String property = filter.get("properties").toString();
 				PageParams pageParams = new PageParams(info.getPageNumber(), info.getPageSize());
-				pageParams.filter(FilterField.COMPONENT_PROPERTIES, property);
-				pageParams.filter(FilterField.COMPONENT_KINDID, filter.get("kindid"));
-				pageParams.filter(FilterField.COMPONENT_BRANDID, filter.get("brandid"));
+				pageParams.filter(PageParams.FilterField.COMPONENT_PROPERTIES, property);
+				pageParams.filter(PageParams.FilterField.COMPONENT_KINDID, filter.get("kindid"));
+				pageParams.filter(PageParams.FilterField.COMPONENT_BRANDID, filter.get("brandid"));
 				filter.remove("properties");
 				filter.remove("kindid");
 				filter.remove("brandid");

+ 27 - 5
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java

@@ -30,8 +30,8 @@ import com.uas.platform.core.model.Type;
 import com.uas.platform.core.persistence.criteria.CriterionExpression.Operator;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
-import com.uas.search.model.PageParams;
-import com.uas.search.model.PageParams.FilterField;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.common.search.util.PageParams.FilterField;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -176,6 +176,11 @@ public class ComponentServiceImpl implements ComponentService {
 		return componentInfoDao.findByCode("416F374X2ALT").get(0);
 	}
 
+	@Override
+	public List<ComponentInfo> getAllComponentInfo() {
+		return componentInfoDao.findAll();
+	}
+
 	@Override
 	public Page<ComponentInfo> findInfoPage(final PageInfo info) {
 		Map<String, Object> filter = info.getFilters();
@@ -192,9 +197,9 @@ public class ComponentServiceImpl implements ComponentService {
 			if (filter.get("properties") != null) {
 				String property = filter.get("properties").toString();
 				PageParams pageParams = new PageParams(info.getPageNumber(), info.getPageSize());
-				pageParams.filter(FilterField.COMPONENT_PROPERTIES, property);
-				pageParams.filter(FilterField.COMPONENT_KINDID, filter.get("kindid"));
-				pageParams.filter(FilterField.COMPONENT_BRANDID, filter.get("brandid"));
+				pageParams.filter(PageParams.FilterField.COMPONENT_PROPERTIES, property);
+				pageParams.filter(PageParams.FilterField.COMPONENT_KINDID, filter.get("kindid"));
+				pageParams.filter(PageParams.FilterField.COMPONENT_BRANDID, filter.get("brandid"));
 //				pageParams.filter("code", filter.get("code"));
 				filter.remove("properties");
 				filter.remove("kindid");
@@ -544,8 +549,25 @@ public class ComponentServiceImpl implements ComponentService {
 		return componentInfoDao.findByBatchids(batchIds);
 	}
 
+	@Override
+	public List<ComponentInfo> getAllComponentInfoByWeight() {
+		return componentInfoDao.findBySearchWeight();
+	}
+
+	@Override
+	@Transactional
+	public ComponentInfo updateComponentInfoInfoOrderByWeight(ComponentInfo componentInfo, Double weight) {
+		componentInfoDao.setWeight(componentInfo.getUuid(),weight);
+		return componentInfoDao.findOne(componentInfo.getId());
+	}
+
 	@Override
 	public void addVisitCount(String uuid) {
 		componentDao.addVisitCount(uuid);
 	}
+
+	@Override
+	public List<Component> getMostSearchComponent() {
+		return componentDao.findMostSearchComponent();
+	}
 }

+ 329 - 301
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentSubmitServiceImpl.java

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.prod.product.component.service.impl;
 
 import com.uas.platform.b2c.common.account.dao.UserBaseInfoDao;
+import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.common.base.service.SendMessageService;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
@@ -17,11 +18,10 @@ import com.uas.platform.b2c.prod.product.kind.dao.KindDao;
 import com.uas.platform.b2c.prod.product.kind.dao.KindPropertyDao;
 import com.uas.platform.b2c.prod.product.kind.model.Kind;
 import com.uas.platform.b2c.prod.product.kind.model.KindCrawl;
-import com.uas.platform.b2c.prod.product.kind.model.KindProperty;
 import com.uas.platform.b2c.prod.product.property.dao.PropertyDao;
-import com.uas.platform.b2c.prod.product.property.model.Property;
 import com.uas.platform.b2c.prod.product.property.model.PropertyValueCrawl;
 import com.uas.platform.b2c.prod.product.property.model.PropertyValueSubmit;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.EncodingRulesConstant;
 import com.uas.platform.core.model.PageInfo;
@@ -31,7 +31,10 @@ import com.uas.platform.core.persistence.criteria.CriterionExpression.Operator;
 import com.uas.platform.core.persistence.criteria.LogicalExpression;
 import com.uas.platform.core.persistence.criteria.PredicateUtils;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
+import com.xiaoleilu.hutool.poi.excel.ExcelReader;
+import com.xiaoleilu.hutool.poi.excel.ExcelUtil;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.map.HashedMap;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -48,6 +51,8 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -532,211 +537,339 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 	}
 
 	@Override
-	public List<ComponentCrawl> uploadComponentCrawl(Workbook workbook, String fileName) {
-		List<ComponentCrawl> components = new ArrayList<ComponentCrawl>();
-		Sheet sheet = workbook.getSheetAt(0);
-		int rowNum = sheet.getLastRowNum();
-		if (rowNum > 10000)
-			throw new IllegalOperatorException("上传文件不可超过10000行");
-		Row fourthRow = sheet.getRow(3);
-		if (fourthRow.getCell(1) != null && fourthRow.getCell(2) != null && fourthRow.getCell(3) != null && fourthRow.getCell(4) != null) {
-			// 商城类目
-			fourthRow.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
-			List<Kind> kinds = kindDao.findByNameCn(fourthRow.getCell(1).getStringCellValue().trim());
-			if (CollectionUtils.isEmpty(kinds)) {
-				throw new IllegalOperatorException("商城类目不存在");
-			}
-			Kind kind = kinds.get(0);
+	public ResultMap uploadComponentCrawl(FileUpload uploadItem) {
+		ResultMap resultMap = new ResultMap();
+		// 验证表格格式
+		Map<String, Object> map = validateExcel(uploadItem);
+		List<List<Object>> rows = (List<List<Object>>)(List)map.get("rows");
+		String fileName = map.get("fileName").toString();
+		if (rows == null || StringUtils.isEmpty(fileName)) {
+			throw new IllegalOperatorException("表格或文件名错误,请核对后重新上传");
+		}
 
-			// 目标类目
-			fourthRow.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
-			String kindName = fourthRow.getCell(2).getStringCellValue().trim();
+		List<ComponentCrawl> components = new ArrayList<ComponentCrawl>();
 
-			// 商城品牌
-			fourthRow.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
-			List<Brand> brands = brandDao.findByNameEn(fourthRow.getCell(3).getStringCellValue().trim());
-			if (CollectionUtils.isEmpty(brands)) {
-				throw new IllegalOperatorException("商城品牌不存在");
-			}
-			Brand brand = brands.get(0);
+		// 提取公共数据
+		List<Object> firstRow = rows.get(1);
+		Map<String, Object> commonData = validateCommonData(firstRow);
+		// 商城类目
+		Kind b2cKind = (Kind)commonData.get("b2cKind");
+		// 目标类目
+		String kindName = commonData.get("kindName").toString();
+		// 商城品牌
+		Brand b2cBrand = (Brand)commonData.get("b2cBrand");
+		// url
+		String url = commonData.get("url").toString();
+
+		// 如果参数参数对应关系出现重复返回前台提示是否新增参数对应关系
+		List<KindCrawl> existKindCrawls = kindContrastDao.findByKindNameAndB2cKiIdAndResourceAndB2cBrIdAndUrl(kindName, b2cKind.getId(), b2cBrand.getNameEn(), b2cBrand.getId(), url);
+		if (CollectionUtils.isNotEmpty(existKindCrawls)) {
+			ComponentCrawl isRepeated = new ComponentCrawl();
+			isRepeated.setB2cKiId(existKindCrawls.get(0).getId());
+			isRepeated.setVersion((short) -1);
+			components.add(isRepeated);
+
+			resultMap.setCode(405);
+			resultMap.setData(existKindCrawls.get(0).getId());
+			return resultMap;
+		}
+
+		// 生成参数对应关系
+		KindCrawl kindCrawl = initKindCrawl(b2cKind.getId(), b2cBrand, kindName, url, fileName);
+
+		// 生成数据解析任务
+		ComponentCrawlTask task = initComponentCrawlTask(kindCrawl, fileName);
+
+		// 写入器件数据
+		components = writeComponentCrawls(rows, b2cBrand, b2cKind, kindName, task);
+		componentCrawlDao.save(components);
+
+		resultMap.setCode(200);
+		resultMap.setData(components.size());
+		return resultMap;
+	}
 
-			// url
-			fourthRow.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
-			String url = fourthRow.getCell(4).getStringCellValue().trim();
-
-			// 如果参数参数对应关系出现重复返回前台提示是否新增参数对应关系
-			List<KindCrawl> existKindCrawls = kindContrastDao.findByKindNameAndB2cKiIdAndResourceAndB2cBrIdAndUrl(kindName, kind.getId(), brand.getNameEn(), brand.getId(), url);
-			if (CollectionUtils.isNotEmpty(existKindCrawls)) {
-				ComponentCrawl isRepeated = new ComponentCrawl();
-				isRepeated.setB2cKiId(existKindCrawls.get(0).getId());
-				isRepeated.setVersion((short) -1);
-				components.add(isRepeated);
-				return components;
-			}
-			
-			Date date = new Date();
-			// 生成参数对应关系
-			KindCrawl kindCrawl = new KindCrawl();
-			kindCrawl.setResource(brand.getNameEn());
-			kindCrawl.setB2cBrId(brand.getId());
-			kindCrawl.setKindName(kindName);
-			kindCrawl.setB2cKiId(kind.getId());
-			kindCrawl.setUrl(url);
-			kindCrawl.setCreateDate(date);
-			kindCrawl.setCreaterUu(SystemSession.getUser().getUserUU());
-			kindCrawl.setInTask((short) 1);// 参数对应关系直接设置为已提交
-			kindCrawl.setUpdateDate(date);
-			kindCrawl.setUpdaterUu(SystemSession.getUser().getUserUU());
-			kindCrawl.setFile(fileName);// 设置上传文件名
-			
-			kindCrawl = kindContrastDao.save(kindCrawl);
-			kindCrawl = kindContrastDao.findOne(kindCrawl.getId());// 因为save返回的对象没有关联的实体信息只有id,所以需要重新查询一次,为后续生成json存入任务做准备
-			// 生成数据爬取任务
-			ComponentCrawlTask task = new ComponentCrawlTask();
-			task.setContrastId(kindCrawl.getId());
-			task.setContrast(FastjsonUtils.toJson(kindCrawl));
-			task.setCreateDate(date);
-			task.setCreaterUu(SystemSession.getUser().getUserUU());
-			task.setStatus(Status.TO_CROWL.value());
-			task.setFile(fileName);
-			task.setTaskId(EncodingRulesConstant.COMPONENT_CRAWL_TASK.replaceFirst("_TIMESTAP_NUMBER", createNumberService.getTimeNumber("product$component_crawl_task", 8)));
-			
-			task = componentCrawlTaskDao.save(task);
-			
-			kindCrawl.setTaskid(task.getTaskId());// 将数据爬取任务号回写到参数对应关系中
-			kindContrastDao.save(kindCrawl);
-			
-//			// 任务
-//			fourthRow.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
-//			ComponentCrawlTask task = componentCrawlTaskDao.findByTaskId(fourthRow.getCell(5).getStringCellValue().trim());
-
-			// 取目标参数
-			Row thirdRow = sheet.getRow(2);
-			if (thirdRow.getCell(7) != null) {
-				int i = 7;
-				List<String> proeprtyNames = new ArrayList<String>();
-				while (thirdRow.getCell(i) != null) {
-					thirdRow.getCell(i).setCellType(Cell.CELL_TYPE_STRING);
-					proeprtyNames.add(thirdRow.getCell(i).getStringCellValue().trim());
-					i++;
-				}
+	/**
+	 * 写入器件数据
+	 * @param rows excel信息
+	 * @param b2cBrand 商城品牌
+	 * @param b2cKind 商城类目
+	 * @param kindName 目标类目
+	 * @param task 解析任务
+	 * @return
+	 */
+	private List<ComponentCrawl> writeComponentCrawls(List<List<Object>> rows, Brand b2cBrand, Kind b2cKind, String kindName, ComponentCrawlTask task) {
+		List<ComponentCrawl> components = new ArrayList<ComponentCrawl>();
 
-				// 取标准参数
-				Row firstRow = sheet.getRow(0);
-				List<Property> properties = new ArrayList<Property>();
-				for (int j = 7; j <= i; j++) {
-					if (firstRow.getCell(j) != null && !firstRow.getCell(j).getStringCellValue().trim().equals("") && !firstRow.getCell(j).getStringCellValue().trim().equals(" ")) {
-						firstRow.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-						List<Property> propertyList = propertyDao.findByLabelCn(firstRow.getCell(j).getStringCellValue().trim());
-						if (CollectionUtils.isEmpty(propertyList)) {
-							throw new IllegalOperatorException(firstRow.getCell(j).getStringCellValue().trim() + ",此标准参数不存在");
-						}
-						properties.add(propertyDao.findByLabelCn(firstRow.getCell(j).getStringCellValue().trim()).get(0));
-					} else {
-						properties.add(new Property());
+		// 取表头信息
+		List<String> propertyNames = (List<String>)(List)rows.get(0);
+		int maxSize = propertyNames.size();
+
+		for (int i = 1; i < rows.size(); i++) {
+			List<Object> row = rows.get(i);
+            if (row != null && row.size() > 0) {
+                ComponentCrawl component = new ComponentCrawl();
+
+                // 型号
+                Object code = row.get(0);
+                if (code != null && StringUtils.hasText(code.toString())) {
+                    component.setCode(code.toString().trim());
+                } else {
+                    throw new IllegalOperatorException(String.format("第%s行型号为空", (i + 1)));
+                }
+
+                // 规格书
+                Object attach = row.get(5);
+                if (attach != null && StringUtils.hasText(attach.toString())) {
+                    component.setAttach(attach.toString().trim());
+                }
+
+                // 图片
+                Object img = row.get(6);
+                if (img != null && StringUtils.hasText(img.toString())) {
+                    component.setImg(img.toString().trim());
+                }
+
+				/**
+				 * 生命周期 (器件所处生命周期)
+				 * ACTIVE 815 正常
+				 * DISCONTINUED 816 即将停产
+				 * OBSOLETE 817 停产
+				 * PRELIMINARY 818 新品
+				 */
+                Object lifecycle = row.get(7);
+				if (lifecycle != null && StringUtils.hasText(String.valueOf(lifecycle))) {
+					try {
+						component.setLifecycle(Integer.valueOf(String.valueOf(lifecycle)));
+					} catch (NumberFormatException e) {
 					}
+				}
 
+                // 描述
+                Object description = row.get(8);
+                if (description != null && StringUtils.hasText(description.toString())) {
+                    component.setDescription(description.toString().trim());
+                } else {
+					throw new IllegalOperatorException(String.format("第%s行描述为空,请补充完全", i + 1));
 				}
 
-				// 取标准参数单位
-				Row secondRow = sheet.getRow(1);
-				List<String> units = new ArrayList<String>();
-				if (secondRow != null) {
-					for (int j = 7; j <= i; j++) {
-						if (secondRow.getCell(j) != null) {
-							secondRow.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-							units.add(secondRow.getCell(j).getStringCellValue().trim());
+                // 参数值
+                Set<PropertyValueCrawl> propertyValues = new HashSet<PropertyValueCrawl>();
+                for (int j = 9; j < maxSize && j < row.size(); j++) {
+                    Object property = row.get(j);
+                    if (property != null && StringUtils.hasText(property.toString())) {
+                        PropertyValueCrawl propertyValue = new PropertyValueCrawl();
+                        propertyValue.setValue(property.toString().trim());
+                        propertyValue.setPropertyName(String.valueOf(propertyNames.get(j)).trim());
+                        propertyValues.add(propertyValue);
+                    }
+                }
+
+                component.setProperties(propertyValues);
+                // 设置基本参数
+                component.setB2cBrId(b2cBrand.getId());
+                component.setB2cKiId(b2cKind.getId());
+                component.setKindName(kindName);
+                component.setTask(task.getId());
+
+                components.add(component);
+            }
+		}
+		return components;
+	}
+
+	/**
+	 * 验证表格格式
+	 * @param uploadItem
+	 * @return
+	 */
+	private Map<String, Object> validateExcel(FileUpload uploadItem) {
+		Map<String, Object> map = new HashedMap();
+		String fileName = uploadItem.getFile().getOriginalFilename();
+		List<ComponentCrawl> componentCrawls = new ArrayList<ComponentCrawl>();
+
+		try {
+			InputStream is = uploadItem.getFile().getInputStream();
+			ExcelReader reader = ExcelUtil.getReader(is);
+
+			// 获取表头数据
+			List<List<Object>> headers = reader.read(0, 0);
+			if (headers != null && headers.size() > 0) {
+
+				// 验证表头信息
+				List<Object> header = headers.get(0).subList(0, 9);
+				List<Object> exceptHeader = new ArrayList<Object>();
+				exceptHeader.add("型号");
+				exceptHeader.add("商城类目");
+				exceptHeader.add("目标类目");
+				exceptHeader.add("商城品牌");
+				exceptHeader.add("来源网址");
+				exceptHeader.add("规格书");
+				exceptHeader.add("图片");
+                exceptHeader.add("生命周期");
+				exceptHeader.add("描述");
+
+				if (header.equals(exceptHeader)) {
+					// 获取全表数据
+					List<List<Object>> rows = reader.read();
+					int size = rows.size();
+
+					if (size > 0 && size < 10000) {
+						int rowSize = headers.get(0).size();
+						if (rowSize < 50) {
+							// 列数超过34的文件不得超过2000行
+							if (rowSize > 34 && size > 2000) {
+								throw new IllegalOperatorException("属性超过25个时,文件只允许上传2000行");
+							}
+							map.put("rows", rows);
+							map.put("fileName", fileName);
+							return map;
+							// 整体列数不得超过50
 						} else {
-							units.add("");
+							throw new IllegalOperatorException("属性值不得超过41个");
 						}
+						// 文件不得超过10000行
+					} else {
+						throw new IllegalOperatorException("上传文件必须大于0行小于10000行");
 					}
+				} else {
+					throw new IllegalOperatorException("表头格式错误,前8列应为 \'型号\',\'商城类目\',\'目标类目\',\'商城品牌\',\'来源网址\',\'规格书\',\'图片\',\'描述\'");
 				}
+			} else {
+				throw new IllegalOperatorException("表头信息错误,请核对后再上传");
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return map;
+	}
 
-				// 去具体器件参数
-				for (int r = 3; r <= rowNum; r++) {
-					Row row = sheet.getRow(r);
-					if (row != null && row.getCell(0) != null) {
-						ComponentCrawl component = new ComponentCrawl();
-						// 原厂型号
-						row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
-						component.setCode(row.getCell(0).getStringCellValue().trim());
-
-						// 规格书
-						if (row.getCell(5) != null) {
-							row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
-							component.setAttach(row.getCell(5).getStringCellValue().trim());
-						}
+	/**
+	 * 初始化数据解析任务
+	 * @param kindCrawl 参数对应关系
+	 * @param fileName 上传文件名
+	 * @return
+	 */
+	private ComponentCrawlTask initComponentCrawlTask(KindCrawl kindCrawl, String fileName) {
+		// 生成数据解析任务
+		ComponentCrawlTask task = new ComponentCrawlTask();
+		task.setContrastId(kindCrawl.getId());
+		task.setContrast(FastjsonUtils.toJson(kindCrawl));
+		task.setCreateDate(new Date());
+		task.setCreaterUu(SystemSession.getUser().getUserUU());
+		task.setStatus(Status.TO_CROWL.value());
+		task.setFile(fileName);
+		task.setTaskId(EncodingRulesConstant.COMPONENT_CRAWL_TASK.replaceFirst("_TIMESTAP_NUMBER", createNumberService.getTimeNumber("product$component_crawl_task", 8)));
+
+		kindCrawl.setTaskid(task.getTaskId());// 将数据解析任务号回写到参数对应关系中
+		kindContrastDao.save(kindCrawl);
+
+		return componentCrawlTaskDao.save(task);
+	}
 
-						// 图片
-						if (row.getCell(6) != null) {
-							row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
-							component.setImg(row.getCell(6).getStringCellValue().trim());
-						}
+	/**
+	 * 初始化标准参数对应关系
+	 * @param b2cKindId 商城类目id
+	 * @param b2cBrand 商城品牌
+	 * @param kindName 目标类目
+	 * @param url 官网地址
+	 * @param fileName 上传文件名
+	 * @return
+	 */
+	private KindCrawl initKindCrawl(Long b2cKindId, Brand b2cBrand, String kindName, String url, String fileName) {
+		Date date = new Date();
+		KindCrawl kindCrawl = new KindCrawl();
+		kindCrawl.setResource(b2cBrand.getNameEn());
+		kindCrawl.setB2cBrId(b2cBrand.getId());
+		kindCrawl.setKindName(kindName);
+		kindCrawl.setB2cKiId(b2cKindId);
+		kindCrawl.setUrl(url);
+		kindCrawl.setCreateDate(date);
+		kindCrawl.setCreaterUu(SystemSession.getUser().getUserUU());
+		kindCrawl.setInTask((short) 1);// 参数对应关系直接设置为已提交
+		kindCrawl.setUpdateDate(date);
+		kindCrawl.setUpdaterUu(SystemSession.getUser().getUserUU());
+		kindCrawl.setFile(fileName);// 设置上传文件名
+
+		kindCrawl = kindContrastDao.save(kindCrawl);
+		return kindContrastDao.findOne(kindCrawl.getId());// 因为save返回的对象没有关联的实体信息只有id,所以需要重新查询一次,为后续生成json存入任务做准备
+	}
 
-						// 参数值
-						Set<PropertyValueCrawl> propertyValues = new HashSet<PropertyValueCrawl>();
-						for (int j = 7; j <= i; j++) {
-							if (row.getCell(j) != null) {
-								row.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-								if (!row.getCell(j).getStringCellValue().trim().equals("") && !row.getCell(j).getStringCellValue().trim().equals(" ")) {
-									PropertyValueCrawl propertyValue = new PropertyValueCrawl();
-									row.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-									propertyValue.setValue(row.getCell(j).getStringCellValue().trim());
-									if (secondRow != null) {
-										propertyValue.setUnit(units.get(j - 7));
-									}
-									propertyValue.setPropertyName(proeprtyNames.get(j - 7));
-									propertyValue.setPropertyId(properties.get(j - 7).getId());
-									if (properties.get(j - 7).getId() != null) {
-										KindProperty kindProperty = kindPropertyDao.findByKindIdAndPropertyId(kind.getId(), properties.get(j - 7).getId());
-										if (kindProperty == null) {
-											throw new IllegalOperatorException("标准参数不存在");
-										}
-										propertyValue.setDetno(kindProperty.getDetno());
-										propertyValue.setType(kindProperty.getType());
-										propertyValues.add(propertyValue);
-									}
-								}
-							}
-						}
+	/**
+	 * 验证公共数据
+	 * @param firstRow
+	 * @return
+	 */
+	private Map<String, Object> validateCommonData(List<Object> firstRow) {
+		if (CollectionUtils.isNotEmpty(firstRow)) {
+			Map<String, Object> commonData = new HashedMap();
 
-						component.setProperties(propertyValues);
+			// 商城类目
+			Object b2cKindName = firstRow.get(1);
+			if (b2cKindName != null && StringUtils.hasText(b2cKindName.toString())) {
+				List<Kind> kinds = kindDao.findByNameCn(b2cKindName.toString().trim());
+				if (CollectionUtils.isEmpty(kinds)) {
+					throw new IllegalOperatorException("商城类目不存在");
+				}
+				commonData.put("b2cKind", kinds.get(0));
+			} else {
+				throw new IllegalOperatorException("商城类目为空");
+			}
 
-						// 设置基本参数
-						component.setB2cBrId(brand.getId());
-						component.setB2cKiId(kind.getId());
-						component.setKindName(kindName);
-						component.setTask(task.getId());
+			// 目标类目
+			Object kindName = firstRow.get(2);
+			if (kindName != null &&  StringUtils.hasText(kindName.toString())) {
+				commonData.put("kindName", kindName.toString().trim());
+			} else {
+				throw new IllegalOperatorException("目标类目为空");
+			}
 
-						components.add(component);
-					}
+			// 商城品牌
+			Object brandName = firstRow.get(3);
+			if (brandName != null && StringUtils.hasText(brandName.toString())) {
+				List<Brand> brands = brandDao.findByUpperNameEn(brandName.toString().trim());
+				if (CollectionUtils.isEmpty(brands)) {
+					throw new IllegalOperatorException("商城品牌不存在");
 				}
-				components = componentCrawlDao.save(components);
-			} else {
-				throw new IllegalOperatorException("目标参数不完善或格式错误");
+				commonData.put("b2cBrand", brands.get(0));
+			}
+
+			// url
+			Object url = firstRow.get(4);
+			if (url != null && StringUtils.hasText(url.toString())) {
+				commonData.put("url", url.toString().trim());
 			}
+
+			return commonData;
 		} else {
-			throw new IllegalOperatorException("基本数据不完善");
+			throw new IllegalOperatorException("第二列数据不存在");
 		}
-		return components;
 	}
 
 	@Override
-	public List<ComponentCrawl> uploadComponentCrawlWithSame(Workbook workbook, String fileName, Long kindContrastId) {
+	public ResultMap uploadComponentCrawlWithSame(FileUpload uploadItem, Long kindContrastId) {
+		ResultMap resultMap = new ResultMap();
+		// 验证表格格式
+		Map<String, Object> map = validateExcel(uploadItem);
+		List<List<Object>> rows = (List<List<Object>>)(List)map.get("rows");
+		String fileName = map.get("fileName").toString();
+		if (rows == null || StringUtils.isEmpty(fileName)) {
+			throw new IllegalOperatorException("表格或文件名错误,请核对后重新上传");
+		}
+
 		List<ComponentCrawl> components = new ArrayList<ComponentCrawl>();
-		Sheet sheet = workbook.getSheetAt(0);
-		int rowNum = sheet.getLastRowNum();
-		if (rowNum > 10000)
-			throw new IllegalOperatorException("上传文件不可超过10000行");
-		Date date = new Date();
-		
+
+		// 获取对应的参数对应关系
 		KindCrawl kindCrawl = kindContrastDao.findOne(kindContrastId);
-		ComponentCrawlTask task = new ComponentCrawlTask();
-		
+		if (kindCrawl == null) {
+			throw new IllegalOperatorException("对应参数关系不存在,请重新核对信息");
+		}
 		// 如果参数对应关系为进行中状态,则不可上传数据
 		if (kindCrawl.getInTask().shortValue() == 2) {
 			throw new IllegalOperatorException("参数对应关系所关联任务正在进行中,如需重新上传数据,请联系相关人员");
 		}
+
+		ComponentCrawlTask task = new ComponentCrawlTask();
 		// 如果参数对应关系为已提交状态,将任务号延用;否则生成新任务
 		if (kindCrawl.getInTask().shortValue() == 1) {
 			task = componentCrawlTaskDao.findByTaskId(kindCrawl.getTaskid());
@@ -747,135 +880,30 @@ public class ComponentSubmitServiceImpl implements ComponentSubmitService {
 				task.setFile(fileName);
 				componentCrawlTaskDao.save(task);
 				
-				List<ComponentCrawl> componentCrawls = componentCrawlDao.findByTask(task.getId());// 删除之前任务上传的数据
-				if (CollectionUtils.isNotEmpty(componentCrawls)) {
-					componentCrawlDao.delete(componentCrawls);
-				}
+				componentCrawlDao.deleteByTask(task.getId());// 删除之前任务上传的数据
 			}
 		} else {
-			// 生成数据爬取任务
-			task.setContrastId(kindContrastId);
-			task.setContrast(FastjsonUtils.toJson(kindCrawl));
-			task.setCreateDate(date);
-			task.setCreaterUu(SystemSession.getUser().getUserUU());
-			task.setFile(fileName);
-			task.setStatus(Status.TO_CROWL.value());
-			task.setTaskId(EncodingRulesConstant.COMPONENT_CRAWL_TASK.replaceFirst("_TIMESTAP_NUMBER", createNumberService.getTimeNumber("product$component_crawl_task", 8)));
-			
-			task = componentCrawlTaskDao.save(task);
-			
-			// 将数据爬取任务号回写到参数对应关系中
-			kindCrawl.setTaskid(task.getTaskId());
-			kindCrawl.setInTask((short) 1);// 参数对应关系直接设置为已提交
-			kindCrawl.setFile(fileName);// 设置上传文件名
-			kindContrastDao.save(kindCrawl);
-		}
-		
-		// 取目标参数
-		Row thirdRow = sheet.getRow(2);
-		if (thirdRow.getCell(7) != null) {
-			int i = 7;
-			List<String> proeprtyNames = new ArrayList<String>();
-			while (thirdRow.getCell(i) != null) {
-				thirdRow.getCell(i).setCellType(Cell.CELL_TYPE_STRING);
-				proeprtyNames.add(thirdRow.getCell(i).getStringCellValue().trim());
-				i++;
-			}
-
-			// 取标准参数
-			Row firstRow = sheet.getRow(0);
-			List<Property> properties = new ArrayList<Property>();
-			for (int j = 7; j <= i; j++) {
-				if (firstRow.getCell(j) != null && !firstRow.getCell(j).getStringCellValue().trim().equals("") && !firstRow.getCell(j).getStringCellValue().trim().equals(" ")) {
-					firstRow.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-					List<Property> propertyList = propertyDao.findByLabelCn(firstRow.getCell(j).getStringCellValue().trim());
-					if (CollectionUtils.isEmpty(propertyList)) {
-						throw new IllegalOperatorException(firstRow.getCell(j).getStringCellValue().trim() + ",此标准参数不存在");
-					}
-					properties.add(propertyDao.findByLabelCn(firstRow.getCell(j).getStringCellValue().trim()).get(0));
-				} else {
-					properties.add(new Property());
-				}
-
-			}
-
-			// 取标准参数单位
-			Row secondRow = sheet.getRow(1);
-			List<String> units = new ArrayList<String>();
-			if (secondRow != null) {
-				for (int j = 7; j <= i; j++) {
-					if (secondRow.getCell(j) != null) {
-						secondRow.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-						units.add(secondRow.getCell(j).getStringCellValue().trim());
-					} else {
-						units.add("");
-					}
-				}
-			}
-
-			// 取具体器件参数
-			for (int r = 3; r <= rowNum; r++) {
-				Row row = sheet.getRow(r);
-				if (row != null && row.getCell(0) != null) {
-					ComponentCrawl component = new ComponentCrawl();
-					// 原厂型号
-					row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
-					component.setCode(row.getCell(0).getStringCellValue().trim());
-
-					// 规格书
-					if (row.getCell(5) != null) {
-						row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
-						component.setAttach(row.getCell(5).getStringCellValue().trim());
-					}
-
-					// 图片
-					if (row.getCell(6) != null) {
-						row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
-						component.setImg(row.getCell(6).getStringCellValue().trim());
-					}
-
-					// 参数值
-					Set<PropertyValueCrawl> propertyValues = new HashSet<PropertyValueCrawl>();
-					for (int j = 7; j <= i; j++) {
-						if (row.getCell(j) != null) {
-							row.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-							if (!row.getCell(j).getStringCellValue().trim().equals("") && !row.getCell(j).getStringCellValue().trim().equals(" ")) {
-								PropertyValueCrawl propertyValue = new PropertyValueCrawl();
-								row.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
-								propertyValue.setValue(row.getCell(j).getStringCellValue().trim());
-								if (secondRow != null) {
-									propertyValue.setUnit(units.get(j - 7));
-								}
-								propertyValue.setPropertyName(proeprtyNames.get(j - 7));
-								propertyValue.setPropertyId(properties.get(j - 7).getId());
-								if (properties.get(j - 7).getId() != null) {
-									KindProperty kindProperty = kindPropertyDao.findByKindIdAndPropertyId(kindCrawl.getB2cKiId(), properties.get(j - 7).getId());
-									if (kindProperty == null) {
-										throw new IllegalOperatorException("标准参数不存在");
-									}
-									propertyValue.setDetno(kindProperty.getDetno());
-									propertyValue.setType(kindProperty.getType());
-									propertyValues.add(propertyValue);
-								}
-							}
-						}
-					}
+			// 生成数据解析任务
+			task = initComponentCrawlTask(kindCrawl, fileName);
+		}
 
-					component.setProperties(propertyValues);
+		// 对应商城品牌
+		Brand brand = brandDao.findOne(kindCrawl.getB2cBrId());
+		if (brand == null) {
+			throw new IllegalOperatorException("对应参数关系商城品牌不存在");
+		}
+		// 对应商城类目
+		Kind kind = kindDao.findOne(kindCrawl.getB2cKiId());
+		if (kind == null) {
+			throw new IllegalOperatorException("对应参数关系商城类目不存在");
+		}
 
-					// 设置基本参数
-					component.setB2cBrId(kindCrawl.getB2cBrId());
-					component.setB2cKiId(kindCrawl.getB2cKiId());
-					component.setKindName(kindCrawl.getKindName());
-					component.setTask(task.getId());
+		// 写入器件数据
+		components = writeComponentCrawls(rows, brand, kind, kindCrawl.getKindName(), task);
+		componentCrawlDao.save(components);
 
-					components.add(component);
-				}
-			}
-			components = componentCrawlDao.save(components);
-		} else {
-			throw new IllegalOperatorException("目标参数不完善或格式错误");
-		}
-		return components;
+		resultMap.setCode(200);
+		resultMap.setData(components.size());
+		return resultMap;
 	}
 }

+ 3 - 3
src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java

@@ -1436,9 +1436,9 @@ public class OrderServiceImpl implements OrderService {
                 purchaseDao.save(purchase);
 
                 // 如果买家需要开发票,则生成发票申请
-//                if (Type.Bill_No.value() != newOrder.getInvoicetype().intValue()) {
-//                    billSubmitService.saveByAdmin(newOrder);
-//                }
+                if (Type.Bill_No.value() != newOrder.getInvoicetype().intValue()) {
+                    billSubmitService.saveByAdmin(newOrder);
+                }
 
                 //发送短信,异常不作处理
                 try {

+ 3 - 3
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java

@@ -712,9 +712,9 @@ public class PurchaseServiceImpl implements PurchaseService {
             if (isReceived) {
                 purchase.setStatusComfirmed(userUU);
 				// 如果买家需要开发票,则生成发票申请
-//				if (Type.Bill_No.value() != newOrder.getInvoicetype().intValue()) {
-//					billSubmitService.saveByAdmin(newOrder);
-//				}
+				if (Type.Bill_No.value() != newOrder.getInvoicetype().intValue()) {
+					billSubmitService.saveByAdmin(newOrder);
+				}
             } else {
                 purchase.setStatusToBePaidAgain(userUU);
             }

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/order/status/OrderStatus.java

@@ -14,7 +14,7 @@ public enum OrderStatus {
 	/**
 	 * {@code tobepaid 待付款}
 	 */
-	TOBEPAID("tobepaid", "503-504"), //504时已付款但商城未收款,这种情况视为未付款
+	TOBEPAID("tobepaid", "503-504-524-525"), //504时已付款但商城未收款,这种情况视为未付款
 
 	/**
 	 * {@code tobedeliver 待发货}

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/order/status/PurchaseStatus.java

@@ -10,7 +10,7 @@ public enum PurchaseStatus {
 	/**
 	 * {@code tobeconfirmed 意向订单}
 	 */
-	TOBECONFIRMED("tobeconfirmed", "501-504"),
+	TOBECONFIRMED("tobeconfirmed", "501-504-524-525"),
 	/**
 	 * {@code comfirmed 待发货}
 	 */

+ 10 - 10
src/main/java/com/uas/platform/b2c/trade/presale/model/Collection.java

@@ -21,64 +21,64 @@ public class Collection implements Serializable {
 	private static final long serialVersionUID = 1L;
 	
 	@Id
-	@Column(name = "store$id")
+	@Column(name = "store_id")
 	@GeneratedValue
 	private Long id;
 	
 	/**
 	  * 收藏的器件id
 	  */
-	@Column(name = "store$compid")
+	@Column(name = "store_compid")
 	private Long componentid;
 	
 	/**
 	  * 关联的器件简单信息
 	  */
 	@OneToOne(cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
-	@JoinColumn(name = "store$compid", insertable = false, updatable = false)
+	@JoinColumn(name = "store_compid", insertable = false, updatable = false)
 	private ComponentInfo componentinfo;
 	
 	/**
 	  * 器件id
 	  */
-	@Column(name = "store$brandid")
+	@Column(name = "store_brandid")
 	private Long brandid;
 
 	/**
 	 * 关联的品牌简单信息
 	 */
 	@OneToOne(cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
-	@JoinColumn(name = "store$brandid", insertable = false, updatable = false)
+	@JoinColumn(name = "store_brandid", insertable = false, updatable = false)
 	private BrandInfo brandinfo;
 	
 	/**
 	  * 收藏的类型  1 代表品牌  2 代表器件
 	  */
-	@Column(name = "store$kind")
+	@Column(name = "store_kind")
 	private Integer kind;
 	
 	/**
 	  * 收藏时间
 	  */
-	@Column(name = "store$createtime")
+	@Column(name = "store_createtime")
 	private Date createtime;
 	
 	/**
 	  * 收藏人的uu号
 	  */
-	@Column(name = "store$useruu")
+	@Column(name = "store_useruu")
 	private Long useruu;
 	
 	/**
 	  * 收藏人的enuu号
 	  */
-	@Column(name = "store$enuu")
+	@Column(name = "store_enuu")
 	private Long enuu;
 
 	/**
 	 * 是否个人用户
 	 */
-	@Column(name = "store$dissociative")
+	@Column(name = "store_dissociative")
 	private Integer dissociative;
 
 	public Long getId() {

+ 4 - 1
src/main/java/com/uas/platform/b2c/trade/rate/service/impl/RateServiceImpl.java

@@ -107,7 +107,10 @@ public class RateServiceImpl implements RateService{
             String[] idArray = ids.split(SplitChar.HYPHEN);
             for (String id : idArray) {
                 Order order = orderDao.findByOrderid(id);
-                if(order.getRateStatus() == 523 || order.getRateStatus() == 522){continue;}
+                if (null == order){
+                    continue;
+                }
+                if (order.getRateStatus() == 523 || order.getRateStatus() == 522) { continue;}
                 rateGoodsDao.delete(rateGoodsDao.findByOrderId(order.getOrderid()));
                 for (OrderDetail orderDetail : order.getOrderDetails()){
                     RateGoods rateGoods = new RateGoods();

+ 1 - 2
src/main/resources/dev/jdbc.properties

@@ -1,6 +1,5 @@
 jdbc.driverClassName=com.mysql.jdbc.Driver
-#jdbc.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
-jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe6946c98747cbe3897b66b5c4cb4985aa8f22aa1cbab4bc6bfe12e09403e6255e2fda2f113bc366bbfc5d9a2cf99c34ce47ba6bd752a9bf5f04c3faf83464996ab6930a84c7d3b9f62d759eb691bc8cd1fe3225f6e7efa5ab3a583896b06178e65c56c3c4e448a0ae4fe
+jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe694e129681326fc2cb1b5fe058042985e2f72b57c8be4fa3e1544065eabf2ab94ad017d02162675aa969997adc7fd7bd04c0eb8bcc3a1733fe6a27f40bcf87efef4566f5872030efe79859a9abb7cbad9c1aa1ae7c2bb1cb23007adc91d94a9369cec407809597189c5
 jdbc.username=474e1aeadeeecac5
 jdbc.password=48981af937f010627b96e886a0d38aad
 jdbc.initialSize=1

+ 2 - 2
src/main/resources/dev/sys.properties

@@ -28,8 +28,8 @@ reportUploadUrl=http://print.ubtob.com/report/fileUpload?userName=B2C
 microServiceIp=10.10.101.23
 newsMicroServiceIp=news.usoftchina.com
 newsRedisRefresh=3600
-floorMicroServiceIp=10.10.101.23
-carouselMicroServiceIp=10.10.101.23
+floorMicroServiceIp=10.10.100.23
+carouselMicroServiceIp=10.10.100.23
 storecmsMicroServiceIp=192.168.253.12
 endpointUri=10.10.101.23
 recommendPort=20100

+ 0 - 4
src/main/resources/prod/jdbc.properties

@@ -1,7 +1,3 @@
-#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
-#jdbc.url=jdbc:oracle:thin:@10.10.100.200:1521:orcl
-#jdbc.username=platform$b2b
-#jdbc.password=select*fromuu
 jdbc.driverClassName=com.mysql.jdbc.Driver
 jdbc.url=7e5ef205e2ff4ca46e29823f9c378880524d69d6c11d8c1c3688f4f0b3712ba1385b2cecff54843db21897fe0c75f0a36c7921cab8fadf398fa33412ca529b7f04233bf4ae6fd3870626fa79ef7f87cb7a8905195ea37bd042b530659d0e82dda7359ee0139e0d6fb23654ba47f5f4b8c682a3c72b9d81e7
 jdbc.username=73f3cd5578b9e08b

+ 1 - 2
src/main/resources/test/jdbc.properties

@@ -1,6 +1,5 @@
 jdbc.driverClassName=com.mysql.jdbc.Driver
-#jdbc.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
-jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe6946c98747cbe3897b66b5c4cb4985aa8f22aa1cbab4bc6bfe12e09403e6255e2fda2f113bc366bbfc5d9a2cf99c34ce47ba6bd752a9bf5f04c3faf83464996ab6930a84c7d3b9f62d759eb691bc8cd1fe3225f6e7efa5ab3a583896b06178e65c56c3c4e448a0ae4fe
+jdbc.url=7e5ef205e2ff4ca4ac98c9f833880ec6e2fe1a4579ebe694e129681326fc2cb1b5fe058042985e2f72b57c8be4fa3e1544065eabf2ab94ad017d02162675aa969997adc7fd7bd04c0eb8bcc3a1733fe6a27f40bcf87efef4566f5872030efe79859a9abb7cbad9c1aa1ae7c2bb1cb23007adc91d94a9369cec407809597189c5
 jdbc.username=474e1aeadeeecac5
 jdbc.password=48981af937f010627b96e886a0d38aad
 jdbc.initialSize=1

+ 2 - 2
src/main/resources/test/sys.properties

@@ -28,8 +28,8 @@ reportUploadUrl=http://print.ubtob.com/report/fileUpload?userName=B2C
 microServiceIp=10.10.101.23
 newsMicroServiceIp=news.usoftchina.com
 newsRedisRefresh=3600
-floorMicroServiceIp=10.10.101.23
-carouselMicroServiceIp=10.10.101.23
+floorMicroServiceIp=10.10.100.23
+carouselMicroServiceIp=10.10.100.23
 storecmsMicroServiceIp=192.168.253.12
 endpointUri=10.10.101.23
 recommendPort=20100

+ 2 - 0
src/main/webapp/WEB-INF/views/normal/adminWithNav.html

@@ -210,6 +210,8 @@
 			<li class="nav-header">推广管理</li>
 			<li class="nav-node"><a href="#ads/brand" ><i
 					class="fa fa-upload"></i><span> 品牌推广</span></a></li>
+			<li class="nav-node"><a href="#ads/component" ><i
+					class="fa fa-upload"></i><span> 器件推广</span></a></li>
 
 			<li class="nav-header">搜索预览</li>
 			<li class="nav-node"><a href="#search/see" ><i

+ 1 - 1
src/main/webapp/resources/css/commonComponent.css

@@ -547,7 +547,7 @@ div.tip{
     font-size: 12px;
     cursor: pointer;
 }
-.com-sub-pager .pagination li:first-child a, .pagination li:last-child a{
+.com-sub-pager .pagination li:first-child a, .com-sub-pager .pagination li:last-child a{
     font-size: 20px;
 }
 .com-sub-pager ul.pagination.ng-table-pagination > li > a > span {

BIN
src/main/webapp/resources/img/tour/1.gif


BIN
src/main/webapp/resources/img/tour/2.gif


BIN
src/main/webapp/resources/img/tour/3.gif


BIN
src/main/webapp/resources/img/tour/4.gif


BIN
src/main/webapp/resources/img/tour/4.png


BIN
src/main/webapp/resources/img/tour/5.gif


BIN
src/main/webapp/resources/img/tour/5.png


+ 7 - 0
src/main/webapp/resources/js/admin/app.js

@@ -734,6 +734,13 @@
             controller: 'adsBrandCtrl',
             controllerUrl: 'app/controllers/ads/ads_brand',
             title: '品牌推广'
+        })).state('adsComponent', angularAMD.route({
+            //品牌推广
+            url : '/ads/component',
+            templateUrl: 'static/view/admin/ads/ads_component.html',
+            controller: 'adsComponentCtrl',
+            controllerUrl: 'app/controllers/ads/ads_component',
+            title: '器件推广'
         })).state('searchSee', angularAMD.route({
             //搜索预览
             url : '/search/see',

+ 62 - 0
src/main/webapp/resources/js/admin/controllers/ads/ads_component.js

@@ -0,0 +1,62 @@
+define([ 'app/app' ], function(app) {
+    //器件推广
+    app.register.controller('adsComponentCtrl', ['$scope', 'NgTableParams', 'ComponentActive', 'toaster', 'BaseService', function($scope, NgTableParams, ComponentActive ,toaster, BaseService) {
+        BaseService.scrollBackToTop();
+        $scope.isDisable = true;
+
+        $scope.load =  function(params) {
+            if (params == "weight") {
+                ComponentActive.getSimpleInfoByWeight({}, {}, function(data) {
+                    $scope.brands =data;
+                    $scope.isDisable = true;
+                    $scope.brandsTableParams = new NgTableParams({}, { dataset: $scope.brands});
+                }, function(){
+
+                })
+            } else {
+                $scope.isDisable = false;
+                loadData();
+            }
+        };
+
+        var loadData = function(){
+            ComponentActive.getSimpleInfoByWeight({}, {}, function(data){
+                $scope.brands = data;
+                $scope.brandsTableParams = new NgTableParams({}, { dataset: $scope.brands});
+            }, function(){
+            })
+        };
+
+        loadData();
+
+        $scope.weight = function(brand){
+            ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                toaster.pop('success', '处理成功', '【' + data[0].nameCn + '】' + '禁用成功');
+                loadData();
+            }, function(res){
+                toaster.pop('error', '错误', res.data);
+            })
+        };
+        $scope.disweight = function(brand){
+            ComponentActive.setSimpleInfoWeight({weight: 0}, brand, function(data){
+                if (data.searchWeight == 0){
+                    toaster.pop('success', '处理成功', '【' + data.nameCn + '】' + '已取消推广');
+                    $scope.load('weight');
+                } else{
+                    toaster.pop('error', '错误', '取消推广失败');
+                }
+            }, function(res){
+                toaster.pop('error', '错误', res.data);
+            })
+        };
+        $scope.updateweight = function(brand){
+            ComponentActive.setSimpleInfoWeight({weight: brand.inputWeight}, brand, function(data){
+                toaster.pop('success', '处理成功', '【' + data.nameCn + '】' + '已修改推广');
+                $scope.load('weight');
+            }, function(res){
+                toaster.pop('error', '错误', res.data);
+            })
+        };
+
+    }]);
+});

+ 6 - 6
src/main/webapp/resources/js/admin/controllers/product/UploadComponentCrawlCtrl.js

@@ -95,8 +95,8 @@ define(['app/app'], function(app) {
 				file: file,
 				method: 'POST'
 			}).success(function(data) {
-				if(data[0].version == -1) {
-					var kindContrastId = data[0].b2cKiId;
+				if(data.code == 405) {
+					var kindContrastId = data.data;
 					$modal.open({
 						animation: true,
 						size: 'md',
@@ -115,8 +115,8 @@ define(['app/app'], function(app) {
 						return;
 					});
 				} else {
-					toaster.pop('success', '提示', '提交成功');
-					window.location.reload();
+					toaster.pop('success', '提示', '成功上传' + data.data + '条');
+					// window.location.reload();
 				}
 			}).error(function(response) {
 				toaster.pop('error', '提示', response);
@@ -130,8 +130,8 @@ define(['app/app'], function(app) {
 				file: myFile,
 				method: 'POST'
 			}).success(function(data) {
-				toaster.pop('success', '提示', '提交成功');
-				window.location.reload();
+				toaster.pop('success', '提示', '成功上传' + data.data + '条');
+				// window.location.reload();
 			}).error(function(response) {
 				toaster.pop('error', '提示', response);
 			});

+ 9 - 2
src/main/webapp/resources/js/common/controllers/commonCtrls.js

@@ -131,7 +131,14 @@ define([ 'app/app' ], function(app) {
 						}
 					}
 					$scope.userInfo = data;
-					// 增加收藏功能的代码
+                    $scope.sortEnterprises = $scope.userInfo.enterprises || [];
+                    if ($scope.sortEnterprises.length) {
+                        $scope.sortEnterprises.sort(function (a, b) {
+                            return b.lastLoginTime - a.lastLoginTime;
+                        })
+                    }
+
+                    // 增加收藏功能的代码
 					$rootScope.userInfo = data;
 					$rootScope.brandCount = 0;
 					$rootScope.componentCount = 0;
@@ -1014,7 +1021,7 @@ define([ 'app/app' ], function(app) {
 			ChatBusinessLayer.visitWebChat(chatInfoDto, 'LIST').then(function (gid) {
 				console.log(gid);
 				//newTab.location.href = 'http://192.168.253.31:20220/chat/visit?gid=' + gid;
-				newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
+				newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + gid;
 			}, function (error) {
 				console.log(error);
 				newTab.close();

+ 95 - 0
src/main/webapp/resources/js/common/directives.js

@@ -867,4 +867,99 @@ define(['angular', 'showdown', 'angular-toaster'], function(angular) {
 			}
 		};
 	}]);
+	/*global angular */
+	/**
+	 * uiTour directive
+	 *
+	 * @example:
+	 *   <ul ui-tour="currentStep">
+	 *     <li target="#someId">
+	 *       First Tooltip
+	 *       <a ng-click="currentStep=currentStep+1">Next</a>
+	 *     </li>
+	 *     <li target=".items:eq(2)" name="two">
+	 *       Second Tooltip
+	 *       <a ng-click="currentStep=currentStep-1">Prev</a>
+	 *     </li>
+	 *     <li target=".items:eq(2)">
+	 *       Third Tooltip
+	 *       <a ng-click="currentStep='two'">Go directly to 'two'</a>
+	 *       <a ng-click="currentStep=0">Done</a>
+	 *     </li>
+	 *   </ul>
+	 */
+	angular.module('ui.tour', [])
+
+		.directive('uiTour', ['$timeout', '$parse', function($timeout, $parse){
+			return {
+				link: function($scope, $element, $attributes) {
+					var model = $parse($attributes.uiTour);
+
+					// Watch model and change steps
+					$scope.$watch($attributes.uiTour, function(newVal, oldVal){
+						if (angular.isNumber(newVal)) {
+							showStep(newVal)
+						} else {
+							if (angular.isString(newVal)) {
+								var stepNumber = 0,
+									children = $element.children()
+								angular.forEach(children, function(step, index) {
+									if (angular.element(step).attr('name') === newVal)
+										stepNumber = index+1;
+								});
+								model.assign($scope, stepNumber);
+							} else {
+								model.assign($scope, newVal && 1 || 0);
+							}
+						}
+					});
+
+					// Show step
+					function showStep(stepNumber) {
+						var elm, at, children = $element.children().removeClass('active');
+						elm = children.eq(stepNumber - 1);
+						if (stepNumber) {
+							at = elm.attr('at');
+							$timeout(function(){
+								var target = angular.element(elm.attr('target'))[0];
+
+
+								if (elm.attr('overlay') !== undefined) {
+									$('.tour-overlay').addClass('active').css({
+										// marginLeft: target.offsetLeft + target.offsetWidth / 2 - 150,
+										// marginTop: target.offsetTop + target.offsetHeight / 2 - 150
+									}).addClass('in');
+								}
+								// offset = {};
+                                //
+								// offset.top = target.offsetTop;
+								// offset.left = target.offsetLeft;
+
+								elm.addClass('active');
+
+								// if (at.indexOf('bottom') > -1) {
+								// 	offset.top += target.offsetHeight;
+								// } else if (at.indexOf('top') > -1) {
+								// 	offset.top -= elm[0].offsetHeight;
+								// } else {
+								// 	offset.top += target.offsetHeight / 2 - elm[0].offsetHeight / 2;
+								// }
+								// if (at.indexOf('left') > -1) {
+								// 	offset.left -= elm[0].offsetWidth;
+								// } else if (at.indexOf('right') > -1) {
+								// 	offset.left += target.offsetWidth;
+								// } else {
+								// 	offset.left += target.offsetWidth / 2 - elm[0].offsetWidth / 2;
+								// }
+                                //
+								// elm.css(offset);
+							});
+						} else {
+							$('.tour-overlay').removeClass('in');
+								$('.tour-overlay').removeClass('active');
+						}
+					}
+				}
+			};
+		}]);
 });

+ 1 - 1
src/main/webapp/resources/js/common/module/chat_web_module.js

@@ -175,7 +175,7 @@ define([ 'common/query/chat', 'common/query/enterprise' ], function() {
                     return;
                 }
                 //newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
-                newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
+                newTab.location.href = 'https://im.ubtob.com/chat/visit?gid=' + gid;
             }, function (error) {
                 console.log(error);
                 newTab.close();

+ 1 - 1
src/main/webapp/resources/js/common/query/chat.js

@@ -1,7 +1,7 @@
 define([ 'ngResource' ], function() {
 	angular.module('ChatService', [ 'ngResource' ]).factory('Chat', ['$resource', function($resource) {
 
-		var address = 'http://im.ubtob.com/';
+		var address = 'https://im.ubtob.com/';
 		//var address = 'http://192.168.253.31:20220/';
 
 		return $resource('api/chat/infos', {}, {

+ 12 - 2
src/main/webapp/resources/js/common/query/component.js

@@ -166,8 +166,18 @@ define([ 'ngResource' ], function() {
 			 */
 			//根据kindid获得ComponentsActiveSimpleInfo的分页数据
 			getSimpleInfo : {
-				url : 'api/product/component/simpleInfo',
-				method : 'GET'
+				url : 'api/product/component/info',
+				method : 'GET',
+                isArray : true
+			},
+            getSimpleInfoByWeight: {
+                url : 'api/product/component/searchWeight',
+                method : 'GET',
+                isArray : true
+			},
+            setSimpleInfoWeight: {
+                url : 'api/product/component/searchWeight',
+                method : 'PUT'
 			},
 			//获取ComponentInfo的分页数据
 			getInfoPage: {

+ 15 - 0
src/main/webapp/resources/js/common/query/logisticsPort.js

@@ -107,6 +107,10 @@ define([ 'ngResource' ], function() {
 				url: 'trade/distributionRule/count',
 				method: 'GET'
 			},
+			findCountOfActiveRule : {
+				url: 'trade/distributionRule/active/count',
+				method: 'GET'
+			},
 			checkRuleName : {
 				url: 'trade/distributionRule/checkName',
 				method: 'GET'
@@ -126,5 +130,16 @@ define([ 'ngResource' ], function() {
 				method: 'POST'
 			}
 		})
+	}]).factory('TipRecord', ['$resource', function ($resource) {
+		return $resource('tip/record', {}, {
+			findTipRecordOfRule : {
+				url: 'tip/record/rule',
+				method: 'GET'
+			},
+			turnTipRecordOfRule : {
+				url: 'tip/record/rule/close',
+				method: 'PUT'
+			}
+		})
 	}]);
 });

+ 1 - 1
src/main/webapp/resources/js/sale/app.js

@@ -57,7 +57,7 @@ define([ 'angularAMD', 'ngRoute', 'ui-bootstrap', 'ngLocal', 'common/services',
 	    $scope.userInfo = {};
 	    AuthenticationService.getAuthentication().success(function(data){
 	    	$scope.userInfo = data;
-	    	
+
 			//增加收藏功能的代码
 			$rootScope.userInfo = data;
 			$rootScope.brandCount = 0;

+ 1 - 1
src/main/webapp/resources/js/usercenter/app.js

@@ -705,7 +705,7 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'commo
 			if (!status || status == '') {
 				status = 501;
 			}
-			if (status == 501 || status == 503 || status == 504) {
+			if (status == 501 || status == 503 || status == 504 || status == 524 || status == 525) {
 				return '待付款';
 			} else if (status == 505 || status == 406 || status == 407 || status == 403 || status == 408) {
 				return '待发货';

+ 1 - 1
src/main/webapp/resources/js/usercenter/controllers/forstore/order_detail_ctrl.js

@@ -88,7 +88,7 @@ define(['app/app'], function(app) {
 				}
 			});
 
-			if (status == 501 || status == 503 || status == 504) {
+			if (status == 501 || status == 503 || status == 504 || status == 524 || status == 525) {
 				$scope.steps.step1 = true;
 				$scope.steps.time1 = $scope.getTimeOfStatus(status);
 			} else if (status == 505 || status == 406 || status == 407 || status == 403 || status == 408) {

+ 46 - 2
src/main/webapp/resources/js/vendor/app.js

@@ -8,7 +8,7 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
 		return this.length > 0 ? this[this.length - 1] : null;
 	};
 
-	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ui.form', 'ui.jquery', 'toaster', 'ngDraggable', 'tool.directives', 'ngSanitize', 'common.query.kind', 'common.services', 'brandServices', 'componentServices', 'goodsServices',  'rateServices','cartServices', 'orderServices', 'addressServices', 'invoiceServices', 'common.query.propertyAdvice', 'propertyServices', 'returnServices' , 'changeServices',  'logisticsServices', 'common.query.kindAdvice', 'ngTable', 'ngDynamicInput', 'common.directives', 'angularFileUpload', 'urlencryptionServices', 'purchaseServices', 'vendorServices', 'goodsServices', 'bankTransfer', 'common.query.enterprise', 'billServices', 'receiptServices', 'collection', 'expressServices', 'bankInfo','Charge', 'statisticsServices', 'currencyService', 'responseLogisticsService', 'PriceServices', 'addressServices', 'searchService', 'urlencryptionServices', 'ReleaseProductByBatchService', 'makerDemand', 'afterSaleService', 'messageBoardServices', 'logisticsServices', 'table.directives', 'storeInfoServices', 'recommendation', 'common.query.user', 'logisticsPortService', 'cmsService', 'materialServices', 'StoreCmsServices', 'productImportModule', 'stockInOutModule', 'StoreCmsModule', 'WebChatModule', 'StandardPutOnAdminModule', 'StoreViolationsServices', 'internalMessageServices', 'installmentServices']);
+	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ui.form', 'ui.jquery', 'toaster', 'ngDraggable', 'tool.directives', 'ngSanitize', 'common.query.kind', 'common.services', 'brandServices', 'componentServices', 'goodsServices',  'rateServices','cartServices', 'orderServices', 'addressServices', 'invoiceServices', 'common.query.propertyAdvice', 'propertyServices', 'returnServices' , 'changeServices',  'logisticsServices', 'common.query.kindAdvice', 'ngTable', 'ngDynamicInput', 'common.directives', 'angularFileUpload', 'urlencryptionServices', 'purchaseServices', 'vendorServices', 'goodsServices', 'bankTransfer', 'common.query.enterprise', 'billServices', 'receiptServices', 'collection', 'expressServices', 'bankInfo','Charge', 'statisticsServices', 'currencyService', 'responseLogisticsService', 'PriceServices', 'addressServices', 'searchService', 'urlencryptionServices', 'ReleaseProductByBatchService', 'makerDemand', 'afterSaleService', 'messageBoardServices', 'logisticsServices', 'table.directives', 'storeInfoServices', 'recommendation', 'common.query.user', 'logisticsPortService', 'cmsService', 'materialServices', 'StoreCmsServices', 'productImportModule', 'stockInOutModule', 'StoreCmsModule', 'WebChatModule', 'StandardPutOnAdminModule', 'StoreViolationsServices', 'internalMessageServices', 'installmentServices', 'ui.tour']);
 	//初始化,启动时载入app
 	app.init = function() {
 		angularAMD.bootstrap(app);
@@ -924,6 +924,50 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
         });*/
 	}]);
 
+	/**
+	 * 配送规则提示共用控制器
+	 */
+	app.controller('rule_tip_ctrl', ['$scope', 'toaster', '$modalInstance', 'type', 'tipModal', function ($scope, toaster, $modalInstance, type, tipModal) {
+		$scope.tipModal = tipModal;
+		$scope.type = type;
+
+		$scope.cancelDelete = function () {
+			$scope.tipModal = false;
+			$modalInstance.dismiss();
+		};
+
+		$scope.hrefToRule = function () {
+			$modalInstance.dismiss();
+			window.location.href = 'vendor#vendor_deliveryRule';
+		};
+
+		/**
+		 * 监听点击的事件
+		 */
+		document.onclick = function (event) {
+			if($scope.tipModal) {
+				if(event) {
+					var tag = event.target;
+					if(tag) {
+						var attribute = tag.getAttribute("name");
+						while(tag.nodeName != 'BODY') {
+							if(attribute == 'rule_model' ||
+								attribute == 'rule_cancel' || attribute == 'rule_href') {
+								return ;
+							}
+							tag = tag.parentElement;
+							attribute = tag.getAttribute("name");
+						}
+						$scope.$apply(function () {
+							$scope.tipModal = false;
+							$modalInstance.close();
+						});
+
+					}
+				}
+			}
+		};
+	}]);
 
 	//币别的过滤器
 	app.filter('currencySysmbol', function() {
@@ -957,7 +1001,7 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
 			if (!status || status == '') {
 				status = 501;
 			}
-			if (status == 501 || status == 504) {
+			if (status == 501 || status == 504 || status == 524 || status == 525) {
 				return '待付款';
 			} else if (status == 502 || status == 406) {
 				return '待发货';

+ 1 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/purchase_detail.js

@@ -336,7 +336,7 @@ define(['app/app'], function(app) {
 				}
 			});
 
-			if (status == 501) {
+			if (status == 501 || status == 524 || status == 525) {
 				$scope.steps.step1 = true;
 				$scope.steps.time1 = $scope.getTimeOfStatus(status);
 			} else if (status == 502 || status == 406) {

+ 54 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_deliveryRule_ctrl.js

@@ -1,11 +1,14 @@
 define([ 'app/app' ], function(app) {
     'use strict';
-    app.register.controller('vendorDeliveryRuleCtrl', ['$scope', '$rootScope', 'ngTableParams', 'DistributionRule', 'BaseService', 'toaster', '$state', '$http', 'Enterprise', 'TreeData','$q','NumberService', function ($scope, $rootScope, ngTableParams, DistributionRule, BaseService, toaster, $state, $http, Enterprise, TreeData,$q,NumberService) {
+    app.register.controller('vendorDeliveryRuleCtrl', ['$scope', '$rootScope', 'ngTableParams', 'DistributionRule', 'BaseService', 'toaster', '$state', '$http', 'Enterprise', 'TreeData','$q','NumberService','TipRecord', function ($scope, $rootScope, ngTableParams, DistributionRule, BaseService, toaster, $state, $http, Enterprise, TreeData,$q,NumberService,TipRecord) {
         $rootScope.active = 'vendor_logistics';
         $scope.tab = 'deliverRule';
         $scope.title = '配送规则';
         $scope.$$rule = {};
+        $scope.currentStep = 1;
         document.title = '配送规则-优软商城';
+        $scope.imgIndex = ['static/img/tour/1.gif','static/img/tour/2.gif','static/img/tour/3.gif','static/img/tour/4.gif','static/img/tour/5.png'];
+        $scope.imagesObject = [{'img' : 'static/img/tour/1.gif'},{'img' : ''},{'img' : ''},{'img' : ''},{'img' : ''}];
         $scope.ruleTableParams = new ngTableParams({
             page : 1,
             count : 10,
@@ -39,6 +42,15 @@ define([ 'app/app' ], function(app) {
             $scope.tab = tab;
         };
 
+        var getTipRecord = function () {
+            TipRecord.findTipRecordOfRule({}, {}, function (data) {
+                $scope.showOperate = data.tipAgain == 0;
+            }, function (error) {
+                toaster.pop("error", error.data);
+            });
+        };
+        getTipRecord();
+
         /**
          * 编辑或新增配送规则,初始化
          * @param data
@@ -141,6 +153,47 @@ define([ 'app/app' ], function(app) {
                 $scope.fareArray.push(secondFare);
             }
         };
+        // 新手引导
+        $scope.prevIndex = function () {
+            $scope.currentStep =  $scope.currentStep - 1;
+            angular.forEach ($scope.imagesObject, function (object, index) {
+                object.img = '';
+                if ($scope.currentStep == index + 1) {
+                    object.img = $scope.imgIndex[index];
+                }
+            })
+        };
+        $scope.currentIndex = function (idx) {
+            $scope.currentStep = idx;
+            angular.forEach ($scope.imagesObject, function (object, index) {
+                object.img = '';
+                if ($scope.currentStep == index + 1) {
+                    object.img = $scope.imgIndex[index];
+                }
+            })
+        };
+        $scope.nextIndex = function () {
+            $scope.currentStep =  $scope.currentStep + 1;
+            angular.forEach ($scope.imagesObject, function (object, index) {
+                object.img = '';
+                if ($scope.currentStep == index + 1) {
+                    object.img = $scope.imgIndex[index];
+                }
+            })
+
+        };
+
+        $scope.cancelOperateTip = function (noTip) {
+            if (noTip){
+                TipRecord.turnTipRecordOfRule({}, {}, function (data) {
+                    
+                },function (error) {
+                    toaster.pop("error", error.data)
+                })
+            }
+            $scope.currentStep = 1;
+            $scope.showOperate = false;
+        };
 
         //配送方式类型
         $scope.deliveryMethod = {

+ 56 - 26
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_index_ctrl.js

@@ -4,7 +4,7 @@
  */
 define(['app/app', 'calendar'], function(app) {
     'use strict';
-    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter','$modal', function($scope, toaster, VendorService, $rootScope, News, $filter,$modal) {
+    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter', '$modal', 'DistributionRule', '$q', function($scope, toaster, VendorService, $rootScope, News, $filter, $modal, DistributionRule, $q) {
         $rootScope.active = 'index';
         $scope.userInfo = $rootScope.userInfo;
         //个人账户
@@ -41,34 +41,64 @@ define(['app/app', 'calendar'], function(app) {
         //
         // });
 
-      //安全设置提醒框
-      $scope.openHomeCenterModel = function() {
-        var modalInstance = $modal.open({
-          animation: true,
-          templateUrl: $rootScope.rootPath + '/static/view/usercenter/modal/homeCenter_modal.html',
-          controller:'homeModalCtrl'
-        });
-        modalInstance.result.then(function(){
-        }, function(){
-        });
-      }
+        var initRuleCount = function () {
+            return DistributionRule.findCountOfActiveRule({},{},function (data) {
+                if (data.success){
+                    $scope.needShowTip = data.data;
+                }
+            }, function (error) {
+                toaster.pop("error", error.data);
+            })
+        };
+
+        //安全设置提醒框
+        $scope.openHomeCenterModel = function() {
+            var modalInstance = $modal.open({
+              animation: true,
+              templateUrl: $rootScope.rootPath + '/static/view/usercenter/modal/homeCenter_modal.html',
+              controller:'homeModalCtrl'
+            });
+            modalInstance.result.then(function(){
+            }, function(){
+            });
+        }
 
-      //安全级别
-      if(!($scope.userInfo.pwdEnable && $scope.userInfo.haveUserQuestion && ($scope.userInfo.userEmail==null?false:true))){
-        $scope.openHomeCenterModel();
-      }
+        //安全级别
+        if(!($scope.userInfo.pwdEnable && $scope.userInfo.haveUserQuestion && ($scope.userInfo.userEmail==null?false:true))){
+            $scope.openHomeCenterModel();
+        } else {
+            $q.all([initRuleCount().$promise]).then(function (data) {
+                if (data){
+                    if ($scope.needShowTip){
+                        $modal.open({
+                            animation: true,
+                            templateUrl: 'static/view/common/modal/delivery_rule_modal.html',
+                            controller: 'rule_tip_ctrl',
+                            resolve : {
+                                type : function() {
+                                    return 'center';
+                                },
+                                tipModal : function() {
+                                    return true;
+                                }
+                            }
+                        });
+                    }
+                }
+            });
+        }
 
     }]);
 
-  app.register.controller('homeModalCtrl', ['$scope',  '$modalInstance', 'toaster', '$http', 'ShippingAddress','$state', function($scope, $modalInstance, toaster, $http, ShippingAddress,$state){
-    console.info($scope.userInfo);
-    $scope.goLink = function(op){
-      $state.go('vendor_account_management',{op:op});
-      $modalInstance.dismiss('cancel');
-    }
+    app.register.controller('homeModalCtrl', ['$scope',  '$modalInstance', 'toaster', '$http', 'ShippingAddress','$state', function($scope, $modalInstance, toaster, $http, ShippingAddress,$state){
+        console.info($scope.userInfo);
+        $scope.goLink = function(op) {
+            $state.go('vendor_account_management',{op:op});
+            $modalInstance.dismiss('cancel');
+        }
 
-    $scope.cancel = function (){
-      $modalInstance.dismiss('cancel');
-    }
-  }]);
+        $scope.cancel = function () {
+            $modalInstance.dismiss('cancel');
+        }
+    }]);
 });

+ 62 - 19
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -1,10 +1,10 @@
 define([ 'app/app', 'jquery-uploadify' ], function(app) {
 	'use strict';
-	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI) {
+	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', 'DistributionRule', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI, DistributionRule) {
 		$rootScope.active = 'vendor_material';
 		document.title = '卖家产品库-优软商城';
 		$scope.tab = 'material';
-		$scope.standard_tab = $stateParams.standardParam?$stateParams.standardParam:'standard';
+		$scope.standard_tab = $stateParams.standardParam ? $stateParams.standardParam : 'standard';
 		$scope.choosedIds = [];
 		$scope.deleteDiv = false;
 
@@ -18,6 +18,20 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
             type : "standard"
         };
 
+        $scope.sortByERP = 'none';
+        $scope.sortByERPReserve = function () {
+			if ($scope.sortByERP == 'none') {
+				$scope.sortByERP = 'DESC'
+			} else if ($scope.sortByERP == 'DESC') {
+				$scope.sortByERP = 'ASC'
+			} else {
+				$scope.sortByERP = 'none'
+			}
+			$scope.param.sorting = $scope.sortByERP == 'none' ? {id : 'DESC'} : {'erpReserve': $scope.sortByERP};
+			// $scope.sortByERP = type == $scope.sortByERP ? 'none' : type;
+			loadData();
+		}
+
 		if ($location.$$path.endsWith('vendor_material_unstandard_erp')) {
 			$scope.tab = 'unstandard_material';
 			// $scope.standard_tab = 'unstandard';
@@ -162,6 +176,16 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			checkChoosedAll();
 		};
 
+		var initRuleCount = function () {
+			return DistributionRule.findCountOfActiveRule({},{},function (data) {
+				if (data.success){
+					$scope.needShowTip = data.data;
+				}
+			}, function (error) {
+				toaster.pop("error", error.data);
+			})
+		};
+
 		//获取选中之后的信息
 		$scope.getChoosedInfo = function () {
 			angular.forEach($scope.currenctMaterial, function (material) {
@@ -529,23 +553,42 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 		function publishGoods(product) {
 			if (!validateGoods($scope.goods)) return ;
 
-			$scope.goods.breakUp = 1 === $scope.goods.breakUp;
-			$scope.isSelfSupport = 1 === $scope.goods.isSelfSupport;
-			if (product.sourceApp == 'ERP') {
-				if ($scope.goods.erpReserve < $scope.goods.b2cReserve + $scope.goods.reserve) {
-					toaster.pop('error', '本次上架数量和已上架数量之和不可超过ERP空闲库存数量');
-					return;
-				}
-			}
-			Material.newStockByStandardProduct({ id: product.id, isSelfSupport: $scope.isSelfSupport}, $scope.goods, function (result) {
-				if (result.success) {
-					toaster.pop('success', '商品上架成功');
-					closeShelArea(product);
-				} else {
-					toaster.pop('error', result.message);
+			$q.all([initRuleCount().$promise]).then(function (data) {
+				if (data){
+					if ($scope.needShowTip){
+						$modal.open({
+							templateUrl: 'static/view/common/modal/delivery_rule_modal.html',
+							controller: 'rule_tip_ctrl',
+							resolve : {
+								type : function() {
+									return 'product';
+								},
+								tipModal : function() {
+									return true;
+								}
+							}
+						});
+						return ;
+					}
+					$scope.goods.breakUp = 1 === $scope.goods.breakUp;
+					$scope.isSelfSupport = 1 === $scope.goods.isSelfSupport;
+					if (product.sourceApp == 'ERP') {
+						if ($scope.goods.erpReserve < $scope.goods.b2cReserve + $scope.goods.reserve) {
+							toaster.pop('error', '本次上架数量和已上架数量之和不可超过ERP空闲库存数量');
+							return;
+						}
+					}
+					Material.newStockByStandardProduct({ id: product.id, isSelfSupport: $scope.isSelfSupport}, $scope.goods, function (result) {
+						if (result.success) {
+							toaster.pop('success', '商品上架成功');
+							closeShelArea(product);
+						} else {
+							toaster.pop('error', result.message);
+						}
+					}, function (error) {
+						toaster.pop('error', error.data);
+					});
 				}
-			}, function (error) {
-				toaster.pop('error', error.data);
 			});
 		}
 
@@ -1173,7 +1216,7 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 					return;
 				}
 				BrandSubmit.unstandardSubmit({}, material.submitProduct, function (data) {
-					
+
 				}, function (response) {
 
 				})

+ 32 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_onSaleCtrl.js

@@ -1,6 +1,6 @@
 define([ 'app/app' ], function(app) {
     'use strict';
-    app.register.controller('vendor_onSaleCtrl', ['$scope', '$rootScope', 'Goods', '$modal', 'toaster', 'Loading', 'StoreInfo', 'AuthenticationService', '$q', 'StoreCms', 'NumberService', 'Enterprise', function ($scope, $rootScope, Goods, $modal, toaster, Loading, StoreInfo, AuthenticationService, $q, StoreCms, NumberService, Enterprise) {
+    app.register.controller('vendor_onSaleCtrl', ['$scope', '$rootScope', 'Goods', '$modal', 'toaster', 'Loading', 'StoreInfo', 'AuthenticationService', '$q', 'StoreCms', 'NumberService', 'Enterprise', 'DistributionRule', function ($scope, $rootScope, Goods, $modal, toaster, Loading, StoreInfo, AuthenticationService, $q, StoreCms, NumberService, Enterprise, DistributionRule) {
         $rootScope.active = 'vendor_material';
         $scope.keyword = '';
         $scope.tab = 'onSale';
@@ -1314,6 +1314,37 @@ define([ 'app/app' ], function(app) {
             getDownLoadStatus();
         };
 
+        var initRuleCount = function () {
+            return DistributionRule.findCountOfActiveRule({},{},function (data) {
+                if (data.success){
+                    $scope.needShowTip = data.data;
+                }
+            }, function (error) {
+                toaster.pop("error", error.data);
+            })
+        };
+        initRuleCount();
+
+        $q.all([initRuleCount().$promise]).then(function (data) {
+            if (data){
+                if ($scope.needShowTip){
+                    $modal.open({
+                        animation: true,
+                        templateUrl: 'static/view/common/modal/delivery_rule_modal.html',
+                        controller: 'rule_tip_ctrl',
+                        resolve : {
+                            type : function() {
+                                return 'product';
+                            },
+                            tipModal : function() {
+                                return true;
+                            }
+                        }
+                    });
+                }
+            }
+        });
+
         // 点击下架操作
         $scope.soldOut = function (commodity) {
             $scope.isSoldOut = true;

+ 34 - 2
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_upload_ctrl.js

@@ -8,7 +8,7 @@ define([ 'app/app' ], function(app) {
 	}]);
 
 	//批量上架的Ctrl
-	app.register.controller('batchPutOnCtrl', ['$scope', '$rootScope', 'ngTableParams', '$upload', '$q', 'AuthenticationService', 'BaseService', 'StoreInfo', 'SessionService', '$modal', 'toaster', 'ReleaseProductByBatch', 'Loading', 'Enterprise', function ($scope, $rootScope, ngTableParams, $upload, $q, AuthenticationService, BaseService, StoreInfo, SessionService, $modal, toaster, ReleaseProductByBatch, Loading, Enterprise) {
+	app.register.controller('batchPutOnCtrl', ['$scope', '$rootScope', 'ngTableParams', '$upload', '$q', 'AuthenticationService', 'BaseService', 'StoreInfo', 'SessionService', '$modal', 'toaster', 'ReleaseProductByBatch', 'Loading', 'Enterprise', 'DistributionRule', function ($scope, $rootScope, ngTableParams, $upload, $q, AuthenticationService, BaseService, StoreInfo, SessionService, $modal, toaster, ReleaseProductByBatch, Loading, Enterprise, DistributionRule) {
 
 		//获取币别信息
 		Enterprise.getCurrencyByRegisterAddress(null, function (data) {
@@ -90,6 +90,17 @@ define([ 'app/app' ], function(app) {
 			});
 		};
 
+		var initRuleCount = function () {
+			return DistributionRule.findCountOfActiveRule({},{},function (data) {
+				if (data.success){
+					$scope.needShowTip = data.data;
+				}
+			}, function (error) {
+				toaster.pop("error", error.data);
+			})
+		};
+		initRuleCount();
+
 		// 查看范例
 		$scope.showImg = function() {
 			var src = '';
@@ -235,7 +246,27 @@ define([ 'app/app' ], function(app) {
 		$scope.publish = function(event) {
 			if ($scope.pageParams.totalElements > 0) {
 				ReleaseProductByBatch.batchRelease({batch : $scope.result.batch}, null, function(data) {
-					toaster.pop("success", "提示", "发布成功 :" + data.data + "条");
+					if ($scope.needShowTip){
+						$scope.relTableParams.page(1);
+						$scope.relTableParams.reload();
+						$scope.result.success = 0;//设置成0,让前端用户不能点击
+						$modal.open({
+							animation : true,
+							templateUrl : 'static/view/common/modal/product_upload_modal.html',
+							controller : 'rule_tip_ctrl',
+							resolve : {
+								type : function() {
+									return 'upload';
+								},
+								tipModal : function() {
+									return true;
+								}
+							}
+						});
+						return ;
+					}
+					// toaster.pop("success", "提示", "发布成功 :" + data.data + "条");
+					toaster.pop("success", "提示", "发布成功");
 					$scope.relTableParams.page(1);
 					$scope.relTableParams.reload();
 					$scope.result.success = 0;//设置成0,让前端用户不能点击
@@ -302,4 +333,5 @@ define([ 'app/app' ], function(app) {
 			$modalInstance.dismiss();
 		};
 	}]);
+
 });

+ 102 - 0
src/main/webapp/resources/lib/ui-tour/tour.js

@@ -0,0 +1,102 @@
+/*global angular */
+/**
+ * uiTour directive
+ *
+ * @example:
+ *   <ul ui-tour="currentStep">
+ *     <li target="#someId">
+ *       First Tooltip
+ *       <a ng-click="currentStep=currentStep+1">Next</a>
+ *     </li>
+ *     <li target=".items:eq(2)" name="two">
+ *       Second Tooltip
+ *       <a ng-click="currentStep=currentStep-1">Prev</a>
+ *     </li>
+ *     <li target=".items:eq(2)">
+ *       Third Tooltip
+ *       <a ng-click="currentStep='two'">Go directly to 'two'</a>
+ *       <a ng-click="currentStep=0">Done</a>
+ *     </li>
+ *   </ul>
+ */
+angular.module('ui.tour', [])
+
+.directive('uiTour', ['$timeout', '$parse', function($timeout, $parse){
+  return {
+    link: function($scope, $element, $attributes) {
+      var model = $parse($attributes.uiTour);
+
+      // Watch model and change steps
+      $scope.$watch($attributes.uiTour, function(newVal, oldVal){
+        if (angular.isNumber(newVal)) {
+          showStep(newVal)
+        } else {
+          if (angular.isString(newVal)) {
+            var stepNumber = 0,
+              children = $element.children()
+            angular.forEach(children, function(step, index) {
+              if (angular.element(step).attr('name') === newVal)
+                stepNumber = index+1;
+            });
+            model.assign($scope, stepNumber);
+          } else {
+            model.assign($scope, newVal && 1 || 0);
+          }
+        }
+      });
+
+      // Show step
+      function showStep(stepNumber) {
+        var elm, at, children = $element.children().removeClass('active');
+        elm = children.eq(stepNumber - 1);
+        if (stepNumber && elm.length) {
+          at = elm.attr('at');
+          $timeout(function(){
+            var target = angular.element(elm.attr('target'))[0];
+
+
+            if (elm.attr('overlay') !== undefined) {
+              $('.tour-overlay').addClass('active').css({
+                marginLeft: target.offsetLeft + target.offsetWidth / 2 - 150,
+                marginTop: target.offsetTop + target.offsetHeight / 2 - 150
+              }).addClass('in');
+            } else {
+              $('.tour-overlay').removeClass('in');
+              setTimeout(function(){
+                $('.tour-overlay').removeClass('active');
+              }, 1000);
+            }
+            offset = {};
+            
+            offset.top = target.offsetTop;
+            offset.left = target.offsetLeft;
+
+            elm.addClass('active');
+              
+            if (at.indexOf('bottom') > -1) {
+              offset.top += target.offsetHeight;
+            } else if (at.indexOf('top') > -1) {
+              offset.top -= elm[0].offsetHeight;
+            } else {
+              offset.top += target.offsetHeight / 2 - elm[0].offsetHeight / 2;
+            }
+            if (at.indexOf('left') > -1) {
+              offset.left -= elm[0].offsetWidth;
+            } else if (at.indexOf('right') > -1) {
+              offset.left += target.offsetWidth;
+            } else {
+              offset.left += target.offsetWidth / 2 - elm[0].offsetWidth / 2;
+            }
+            
+            elm.css(offset);
+          });
+        } else {
+          $('.tour-overlay').removeClass('in');
+          setTimeout(function(){
+            $('.tour-overlay').removeClass('active');
+          }, 1000);
+        }
+      }
+    }
+  };
+}]);

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません