Browse Source

Merge remote-tracking branch 'origin/release-201830-wangcz' into release-201830-wangcz

shenjj 7 years ago
parent
commit
ee1d99ee9e

+ 13 - 29
src/main/java/com/uas/platform/b2c/common/weixin/contoller/WeChatController.java

@@ -10,7 +10,6 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.ui.Model;
 import org.springframework.ui.ModelMap;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -18,10 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
 import java.util.List;
 
 /**
@@ -52,32 +47,20 @@ public class WeChatController {
     /**
      * 与微信服务器接口配置
      *
-     * @param model
-     * @param request
-     * @param response
+     * @param signature 与微信服务器接口配置
+     * @param timestamp 时间戳
+     * @param nonce 随机数
+     * @param echostr 随机字符串
      */
     @RequestMapping(value = "/check", method = RequestMethod.GET)
-    public void wenxinCheck(Model model, HttpServletRequest request, HttpServletResponse response) {
-        // 微信加密签名
-        String signature = request.getParameter("signature");
-        // 时间戳
-        String timestamp = request.getParameter("timestamp");
-        // 随机数
-        String nonce = request.getParameter("nonce");
-        // 随机字符串
-        String echostr = request.getParameter("echostr");
+    public String wenxinCheck(String signature, String timestamp, String nonce, String echostr) {
         logger.info("与微信服务器接口配置 with signature: {} and timestamp: {} and nonce: {} and echostr: {}", signature, timestamp, nonce, echostr);
-        PrintWriter print;
+
         // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
         if (signature != null && CheckoutUtil.checkSignature(signature, timestamp, nonce)) {
-            try {
-                print = response.getWriter();
-                print.write(echostr);
-                print.flush();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
+            return echostr;
         }
+        return null;
     }
 
     /**
@@ -96,7 +79,8 @@ public class WeChatController {
     /**
      * 发送模板消息
      *
-     * @return
+     * @param messages 需要发送模板的实体,包括uu号
+     * @return 提示信息
      */
     @RequestMapping(value = "/sendTemplateMessage", method = RequestMethod.POST)
     public ModelMap sendTemplateMessage(@RequestBody List<MessageModel> messages) {
@@ -107,8 +91,8 @@ public class WeChatController {
     /**
      * 绑定用户
      *
-     * @param user
-     * @return
+     * @param user 用户包装类型。传入 code 或密码
+     * @return 正确信息或者错误信息,前端使用
      */
     @RequestMapping(value = "/bindUser", method = RequestMethod.POST)
     public ModelMap bindUser(@RequestBody UserVo user) {
@@ -119,7 +103,7 @@ public class WeChatController {
     /**
      * 发送手机验证码
      * @param mobile 手机号
-     * @return
+     * @return 前端使用的提示信息
      */
     @RequestMapping(value = "/sendSmsCode", method = RequestMethod.GET)
     public ModelMap sendSmsCode(String mobile) {

+ 3 - 1
src/main/java/com/uas/platform/b2c/common/weixin/model/MessageModel.java

@@ -1,7 +1,9 @@
 package com.uas.platform.b2c.common.weixin.model;
 
 /**
- * 消息
+ * 模板消息实体类
+ * @author liuam
+ * @date 2018年9月25日17:11:32
  */
 public class MessageModel {
     /**

+ 10 - 4
src/main/java/com/uas/platform/b2c/common/weixin/service/impl/WeChatServiceImpl.java

@@ -38,6 +38,7 @@ import java.util.TreeMap;
 import java.util.concurrent.TimeUnit;
 
 /**
+ * 微信服务类
  * @author liusw
  * @date 2018-05-30 9:24
  */
@@ -55,12 +56,12 @@ public class WeChatServiceImpl implements WeChatService{
     /**
      * 保存到 redis 里的 ACCESS_TOKEN 过期时间(second)
      */
-    private static final Integer ACCESS_TOKEN_EXPIRES_IN = 3600;
+    private static final int ACCESS_TOKEN_EXPIRES_IN = 3600;
 
     /**
      * 保存到 redis 里的验证码过期时间(second)
      */
-    private static final Integer SMS_EXPIRES_IN = 10 * 60;
+    private static final int SMS_EXPIRES_IN = 10 * 60;
 
     @Override
     public ModelMap getWxUserInfo(String code, String state, String openId) {
@@ -100,6 +101,11 @@ public class WeChatServiceImpl implements WeChatService{
         return result;
     }
 
+    /**
+     * User 类型转换成 UserAccout 类型,账户中心使用
+     * @param user 商城 user 实体
+     * @return
+     */
     private UserAccount convertUserAccount(User user) {
         UserAccount userAccount = new UserAccount();
         userAccount.setAppId("mall");
@@ -257,7 +263,7 @@ public class WeChatServiceImpl implements WeChatService{
      * 通过code获取用户openId
      * @param code
      */
-    private AuthUserInfo getAccessTokenByCode(String code) throws Exception {
+    private AuthUserInfo getAccessTokenByCode(String code) throws WeChatException {
         logger.info("通过code获取用户openId, code: {}", code);
         long start = System.currentTimeMillis();
         AuthTokenParams authTokenParams = new AuthTokenParams(WeChatUtil.APPID, WeChatUtil.APPSECRET, code, "authorization_code");
@@ -281,7 +287,7 @@ public class WeChatServiceImpl implements WeChatService{
      * @param openId
      * @return
      */
-    private AuthUserInfo getUserInfo(String accessToken, String openId) throws Exception {
+    private AuthUserInfo getUserInfo(String accessToken, String openId) throws WeChatException {
         logger.info("获取用户信息 accessToken: {}, openId: {}", accessToken, openId);
         // 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语
         AuthUserParams authUserParams = new AuthUserParams(accessToken, openId, "zh_CN");

+ 4 - 5
src/main/java/com/uas/platform/b2c/common/weixin/util/CheckoutUtil.java

@@ -25,7 +25,6 @@ public class CheckoutUtil {
     public static boolean checkSignature(String signature, String timestamp, String nonce) {
         String[] arr = new String[] { token, timestamp, nonce };
         // 将token、timestamp、nonce三个参数进行字典序排序
-        // Arrays.sort(arr);
         sort(arr);
         StringBuilder content = new StringBuilder();
         for (int i = 0; i < arr.length; i++) {
@@ -69,14 +68,14 @@ public class CheckoutUtil {
      * @return
      */
     private static String byteToHexStr(byte mByte) {
-        char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+        char[] digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
         char[] tempArr = new char[2];
-        tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
-        tempArr[1] = Digit[mByte & 0X0F];
+        tempArr[0] = digit[(mByte >>> 4) & 0X0F];
+        tempArr[1] = digit[mByte & 0X0F];
         String s = new String(tempArr);
         return s;
     }
-    public static void sort(String a[]) {
+    public static void sort(String[] a) {
         for (int i = 0; i < a.length - 1; i++) {
             for (int j = i + 1; j < a.length; j++) {
                 if (a[j].compareTo(a[i]) < 0) {

+ 0 - 1
src/main/java/com/uas/platform/b2c/common/weixin/util/HttpReqUtil.java

@@ -82,7 +82,6 @@ public class HttpReqUtil {
                         hasParams = true;
                     }
                     if (charset != null && !"".equals(charset)) {
-                        // builder.append(key).append("=").append(URLDecoder.(value,charset));
                         builder.append(key).append("=").append(urlEncode(value, charset));
                     } else {
                         builder.append(key).append("=").append(value);

+ 5 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/constant/StringConstant.java

@@ -51,4 +51,9 @@ public class StringConstant {
      * 在售产品默认的生辰日期
      */
     public static final String DEFAULT_PRODUCEDATE = "2018-08-20";
+
+    /**
+     * 应用来源
+     */
+    public static final String SOURCE = "MALL";
 }

+ 1 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ReleaseProductByBatchDao.java

@@ -25,13 +25,12 @@ public interface ReleaseProductByBatchDao
     /**
      * 创建时间 :2016年12月22日 上午10:16:26
      *
-     * @param publisherUu the publisher uu 发部分enuu
      * @param relbatchid  the relbatchid 单号
      * @param releaseCode the release code 发布状态编号
      * @return list
      * @Description: 通过uu查找对应的信息
      */
-    public List<ReleaseProductByBatch> findByPublisherUuAndRelbatchidAndReleaseCode(Long publisherUu, String relbatchid, Integer releaseCode);
+    List<ReleaseProductByBatch> findByRelbatchidAndReleaseCode(String relbatchid, Integer releaseCode);
 
 	@Query("select r from ReleaseProductByBatch r where r.publisherUu =:publisherUu and r.relbatchid =:relbatchid and r.releaseCode in :failCodes")
 	List<ReleaseProductByBatch> findByPublisherUuAndRelbatchidAndFailCode(@Param("publisherUu") Long publisherUu, @Param("relbatchid") String relbatchid, @Param("failCodes") List<Integer> failCodes);

+ 28 - 26
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseProductServiceImpl.java

@@ -6,6 +6,7 @@ import com.uas.platform.b2c.core.constant.ReleaseStatus;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
+import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
 import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
 import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
 import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
@@ -105,8 +106,6 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
             // 验证模板是否为商城模板
             validateTemplate(headerRow, colNum);
-            // 去重后的数据
-            List<ReleaseProductByBatch> uniqueBatchList = new ArrayList<>();
             // 为空的个数
             int blankNum;
             // 本次上传总数
@@ -128,16 +127,13 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
                     blankNum = convertValueToProduct(row, releaseProductByBatch, r);
                     if (blankNum != 4) {
                         // 验证表格中数据是否重复,重复的取第一条数据
-                        ReleaseProductByBatch uniquerProduct = validateRepeatInExcel(releaseProductByBatchArrayList, releaseProductByBatch);
-                        if (null != uniquerProduct) {
-                            uniqueBatchList.add(uniquerProduct);
-                        }
+                        validateRepeatInExcel(releaseProductByBatchArrayList, releaseProductByBatch);
                         releaseProductByBatchArrayList.add(releaseProductByBatch);
                         total++;
                     }
                 }
             }
-            // 保存临时表信息
+            // 保存验证不通过临时表信息
             releaseProductByBatchDao.save(releaseProductByBatchArrayList);
             Long enUU = SystemSession.getUser().getEnterprise().getUu();
             // 验证数据信息是否重复
@@ -147,6 +143,8 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             assignmentProductInfo(enUU, modelMap, batch);
             // 验证成功后进行绑定处理
             Integer assignNumber = 0;
+            // 去重后的数据
+            List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCode(batch, ReleaseStatus.unreleased.value());
             if (!CollectionUtils.isEmpty(uniqueBatchList)) {
                 assignNumber = assignBatch(uniqueBatchList);
             }
@@ -270,7 +268,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
     private Integer assignBatch(List<ReleaseProductByBatch> uniqueBatchList) {
         List<Product> productList = covert(uniqueBatchList);
         try {
-            String res = HttpUtil.doPost(productServiceIp + "/product/update/addToProductUser", FlexJsonUtils.toJsonDeep(productList));
+            String res = HttpUtil.doPost("http://10.1.51.24:8080" + "/product/update/addToProductUser", FlexJsonUtils.toJsonDeep(productList));
             JSONObject response = JSON.parseObject(res);
             if (TRUE_SIGN.equals(response.get(SUCCESS_CODE))) {
                 return Integer.valueOf(response.get("result").toString());
@@ -303,24 +301,23 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      * @param 	aBatch 单个数据
      * @return 判断是否重复的数据
      */
-    private ReleaseProductByBatch validateRepeatInExcel(List<ReleaseProductByBatch> batchList, ReleaseProductByBatch aBatch) {
-        if (CollectionUtils.isEmpty(batchList) || !StringUtils.isEmpty(aBatch.getErrmsg())) {
-            return null;
-        }
-        for (ReleaseProductByBatch each : batchList) {
-            // 返回符合标准的唯一的物料信息
-            if (aBatch.compareSameProductTagInfo(each)) {
-                aBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
-                aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
-                aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
-                if (aBatch.getErrmsg().substring(0, 1).equals(",")) {
-                    aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
+    private void validateRepeatInExcel(List<ReleaseProductByBatch> batchList, ReleaseProductByBatch aBatch) {
+        if (CollectionUtils.isNotEmpty(batchList) && StringUtils.isEmpty(aBatch.getErrmsg())) {
+            for (ReleaseProductByBatch each : batchList) {
+                // 返回符合标准的唯一的物料信息
+                if (aBatch.compareSameProductTagInfo(each)) {
+                    aBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+                    aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+                    aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+                    if (aBatch.getErrmsg().substring(0, 1).equals(",")) {
+                        aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
+                    }
+                } else {
+                    aBatch.setReleaseStatus(ReleaseStatus.unreleased.getPhrase());
+                    aBatch.setReleaseCode(ReleaseStatus.unreleased.value());
                 }
-            } else {
-                return aBatch;
             }
         }
-        return null;
     }
 
     /**
@@ -334,12 +331,15 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         uniqueBatchList.forEach(batch -> {
             Product product = new Product();
             product.setSpec(batch.getSpec());
-            product.setBrand(batch.getBrandNameEn() != null ? batch.getBrandNameEn() : batch.getBrandNameCn());
+            String brand = batch.getBrandNameEn() != null ? batch.getBrandNameEn() : batch.getBrandNameCn();
+            product.setBrand(brand);
+            product.setpBrand(brand);
             product.setUserUU(SystemSession.getUser().getUserUU());
-            product.setCode(batch.getCode());
+            product.setCmpCode(batch.getCode());
+            product.setpCmpCode(batch.getCode());
             // 没有编号设置编号
             if (null == product.getCode()) {
-                String code = "B2CPR" + StringUtilB2C.getRandomNumber(6);
+                String code = "PNUM" + StringUtilB2C.getRandomNumber(6);
                 product.setCode(code);
             }
             // 交期默认赋值为0
@@ -351,6 +351,8 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             product.setKind(batch.getKindName());
             product.setUnit(batch.getUnit());
             product.setTitle(batch.getKindName());
+            product.setId(batch.getProductid());
+            product.setSourceApp(StringConstant.SOURCE);
             productList.add(product);
         });
         return productList;

+ 1 - 1
src/main/webapp/WEB-INF/views/normal/admin.html

@@ -39,7 +39,7 @@
 		<p class="pull-left muted">
 			&copy;&nbsp;2016&nbsp;深圳市优软科技有限公司&nbsp;版权所有</p>
 		<p class="pull-right">
-			技术支持: <a href="http://www.usoftchina.com" target="_blank">深圳市优软科技有限公司</a>
+			技术支持: <a href="http://www.uas.usoftchina.com" target="_blank">深圳市优软科技有限公司</a>
 		</p>
 	</footer>
 	<!-- footer end -->

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

@@ -271,7 +271,7 @@
 				&copy;2016 深圳市优软科技有限公司 版权所有
 			</div>
 			<div class="pull-right">
-				技术支持: <a href="http://www.usoftchina.com" target="_blank">深圳市优软科技有限公司</a>
+				技术支持: <a href="http://www.uas.usoftchina.com" target="_blank">深圳市优软科技有限公司</a>
 			</div>
 		</div>
 	</footer>

+ 42 - 38
src/main/webapp/resources/js/usercenter/controllers/forstore/product_upload_ctrl.js

@@ -270,44 +270,48 @@ define([ 'app/app' ], function(app) {
 
                 // $scope.uploadProgressText = progressPercentage + '%'
                 // console.log('progess:' + progressPercentage + '%' + evt.config.file.name);
-              }).success(function(data) {
-				$scope.selectFile(' ');
-				$scope.batch.myFiles = [];
-				$scope.proInfo = data.info;
-				$scope.result = data;
-				$scope.hadImport = false;
-				// var message = "";
-				// if($scope.result.success) {
-				// 	message = '标准产品' + $scope.result.success + '个';
-				// }
-				// if($scope.result.failure) {
-				// 	if(message) {
-				// 		message = message + ',非标产品' + $scope.result.failure +  '个';
-				// 	}else {
-				// 		message = '非标产品' + $scope.result.failure +  '个';
-				// 	}
-				// }
-				// if($scope.result.filter) {
-				// 	if(message) {
-				// 		message = message + ',过滤' + $scope.result.filter +  '条';
-				// 	}else {
-				// 		message = '过滤' + $scope.result.filter +  '条';
-				// 	}
-				// }
-				// if(!message) {
-				// 	message = '没有提交任何信息'
-                    // }
-                if ($scope.result.filter && $scope.result.filter > 0) {
-                    toaster.pop('warning', '警告', '存在导入失败产品,可下载导入失败表格查看详情');
-                } else {
-                    toaster.pop('success', '提示', '上传完成');
-                }
-                $scope.showCanvas = false;
-                $scope.relTableParams.page(1);
-				$scope.relTableParams.reload();
-                // if ($rootScope.$$productOn.tab === 'bathOnPerson') {
-                //     publicPersonProduct();
-                // }
+              }).success(function(res) {
+                  if(res.data.success) {
+                      $scope.selectFile(' ');
+                      $scope.batch.myFiles = [];
+                      // $scope.proInfo = res.data.info;
+                      $scope.result = res.data.data;
+                      $scope.hadImport = false;
+                      // var message = "";
+                      // if($scope.result.success) {
+                      // 	message = '标准产品' + $scope.result.success + '个';
+                      // }
+                      // if($scope.result.failure) {
+                      // 	if(message) {
+                      // 		message = message + ',非标产品' + $scope.result.failure +  '个';
+                      // 	}else {
+                      // 		message = '非标产品' + $scope.result.failure +  '个';
+                      // 	}
+                      // }
+                      // if($scope.result.filter) {
+                      // 	if(message) {
+                      // 		message = message + ',过滤' + $scope.result.filter +  '条';
+                      // 	}else {
+                      // 		message = '过滤' + $scope.result.filter +  '条';
+                      // 	}
+                      // }
+                      // if(!message) {
+                      // 	message = '没有提交任何信息'
+                      // }
+                      if ($scope.result.filter && $scope.result.filter > 0) {
+                          toaster.pop('warning', '警告', '存在导入失败产品,可下载导入失败表格查看详情');
+                      } else {
+                          toaster.pop('success', '提示', '上传完成');
+                      }
+                      $scope.showCanvas = false;
+                      $scope.relTableParams.page(1);
+                      $scope.relTableParams.reload();
+                      // if ($rootScope.$$productOn.tab === 'bathOnPerson') {
+                      //     publicPersonProduct();
+                      // }
+                  } else {
+                      toaster.pop('error', '上传失败!');
+                  }
                 }).error(function(response) {
                     $scope.result = {};
                     $scope.result.total = 0;

+ 2 - 2
src/main/webapp/resources/view/common/footer.html

@@ -109,7 +109,7 @@ a:hover {
 		<li>
 			<h3>更多服务</h3>
 			<ul class="list-unstyled">
-				<li><a href="http://www.usoftchina.com/usoft/"  target="_blank" target="_blank">优软科技</a></li>
+				<li><a href="http://www.uas.usoftchina.com/usoft/"  target="_blank" target="_blank">优软科技</a></li>
 				<li><a href="http://www.usoftchina.com/" target="_blank" target="_blank">优软云</a></li>
 			</ul>
 		</li>
@@ -126,7 +126,7 @@ a:hover {
 		<span>友情链接:</span>
 		<a href="http://www.worldshine.net" target="_blank" title="深圳华商龙">深圳华商龙</a>|
 		<a href="http://www.yitoa.com" target="_blank" title="深圳市英唐智能科技">深圳市英唐智能科技</a>|
-		<a href="http://www.usoftchina.com/usoft/" target="_blank" title="深圳市优软科技">深圳市优软科技</a>|
+		<a href="http://www.uas.usoftchina.com/usoft/" target="_blank" title="深圳市优软科技">深圳市优软科技</a>|
 		<a href="http://www.fantem.com" target="_blank" title="丰唐物联技术(深圳)">丰唐物联技术(深圳)</a>|
 		<a href="http://www.hiways.com" target="_blank" title="深圳市海威思科技">深圳市海威思科技</a>|
 		<a href="http://www.huashangweitai.com" target="_blank" title="深圳市华商维泰显示科技">深圳市华商维泰显示科技</a>|

+ 1 - 1
src/main/webapp/resources/view/usercenter/forstore/product_upload.html

@@ -630,7 +630,7 @@
                                 </span>
                             </div>-->
                         </div>
-                        <div class="txt-info" ng-if="result && result.total != 0 && !hadImport && $$productOn.tab != 'bathOnPerson'">成功导入 <span ng-bind="result.success + result.failure">600</span> 个产品(其中标准产品 <span ng-bind="result.success">200</span> 个,非标产品 <span ng-bind="result.failure">400</span> 个)<b class="success-hidden" ng-if="result.filter != 0">,下载 <a ng-click="downloadExcel()">导入失败产品</a></b></div>
+                        <div class="txt-info" ng-if="result && result.total != 0 && !hadImport">成功导入 <span ng-bind="result.success + result.failure">600</span> 个产品(其中标准产品 <span ng-bind="result.success">200</span> 个,非标产品 <span ng-bind="result.failure">400</span> 个)<b class="success-hidden" ng-if="result.filter != 0">,下载 <a ng-click="downloadExcel()">导入失败产品</a></b></div>
                         <div ng-show="$$productOn.tab == 'bathOn' && isPcbStore">
                             <table ng-table="relTableParams" class="public-tab table">
                                 <thead>