Browse Source

Merge branch 'release-201827-wangcz' into dev

suntg 7 years ago
parent
commit
b40721ceff
100 changed files with 1396 additions and 501 deletions
  1. 109 0
      src/main/java/com/uas/platform/b2c/common/lottery/controller/LotteryController.java
  2. 18 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/ActivityItemService.java
  3. 19 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/LotteryService.java
  4. 19 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/PrizeService.java
  5. 19 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/UserInfoService.java
  6. 30 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/WinningHistoryService.java
  7. 53 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/impl/ActivityItemServiceImpl.java
  8. 55 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/impl/LotteryServiceImpl.java
  9. 54 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/impl/PrizeServiceImpl.java
  10. 53 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/impl/UserInfoServiceImpl.java
  11. 79 0
      src/main/java/com/uas/platform/b2c/common/lottery/service/impl/WinningHistoryServiceImpl.java
  12. 1 1
      src/main/java/com/uas/platform/b2c/common/message/service/InternalMessageService.java
  13. 14 0
      src/main/java/com/uas/platform/b2c/core/config/SysConf.java
  14. 0 30
      src/main/java/com/uas/platform/b2c/core/support/log/TradeBufferedLogger.java
  15. 25 0
      src/main/java/com/uas/platform/b2c/external/erp/order/api/OrderController.java
  16. 2 2
      src/main/java/com/uas/platform/b2c/external/erp/order/api/PurchaseController.java
  17. 13 12
      src/main/java/com/uas/platform/b2c/external/erp/order/service/impl/InvoiceNotifyServiceImpl.java
  18. 3 3
      src/main/java/com/uas/platform/b2c/fa/payment/controller/BankInfoController.java
  19. 13 2
      src/main/java/com/uas/platform/b2c/fa/payment/dao/BankInfoDao.java
  20. 2 4
      src/main/java/com/uas/platform/b2c/fa/payment/service/BankInfoService.java
  21. 5 5
      src/main/java/com/uas/platform/b2c/fa/payment/service/impl/BankInfoServiceImpl.java
  22. 2 4
      src/main/java/com/uas/platform/b2c/logistics/controller/InvoiceController.java
  23. 10 0
      src/main/java/com/uas/platform/b2c/logistics/dao/InvoiceDao.java
  24. 19 0
      src/main/java/com/uas/platform/b2c/logistics/dao/InvoiceDetailDao.java
  25. 0 1
      src/main/java/com/uas/platform/b2c/logistics/service/InvoiceFPurchaseDetailService.java
  26. 8 5
      src/main/java/com/uas/platform/b2c/logistics/service/InvoiceService.java
  27. 0 3
      src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFOrderDetailServiceImpl.java
  28. 0 7
      src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFPurchaseDetailServiceImpl.java
  29. 31 4
      src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceServiceImpl.java
  30. 25 20
      src/main/java/com/uas/platform/b2c/prod/commodity/constant/ModifyConstant.java
  31. 1 1
      src/main/java/com/uas/platform/b2c/prod/commodity/controller/ReleaseProductByBatchController.java
  32. 8 0
      src/main/java/com/uas/platform/b2c/prod/commodity/dao/GoodsDao.java
  33. 2 2
      src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductDao.java
  34. 0 1
      src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductPrivateDao.java
  35. 34 2
      src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java
  36. 1 3
      src/main/java/com/uas/platform/b2c/prod/commodity/model/InOutboundDetail.java
  37. 11 17
      src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java
  38. 7 0
      src/main/java/com/uas/platform/b2c/prod/commodity/service/GoodsService.java
  39. 4 2
      src/main/java/com/uas/platform/b2c/prod/commodity/service/InOutboundDetailService.java
  40. 1 2
      src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java
  41. 35 5
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/CommodityInOutboundServiceImpl.java
  42. 25 17
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java
  43. 27 6
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/InOutboundDetailServiceImpl.java
  44. 81 117
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java
  45. 186 129
      src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java
  46. 2 2
      src/main/java/com/uas/platform/b2c/prod/store/facade/impl/StoreApplyFacadeImpl.java
  47. 14 0
      src/main/java/com/uas/platform/b2c/prod/store/model/StoreApply.java
  48. 2 3
      src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java
  49. 3 4
      src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreInServiceImpl.java
  50. 0 25
      src/main/java/com/uas/platform/b2c/trade/order/controller/OrderController.java
  51. 2 4
      src/main/java/com/uas/platform/b2c/trade/order/controller/PurchaseController.java
  52. 5 5
      src/main/java/com/uas/platform/b2c/trade/order/model/OrderIndex.java
  53. 5 5
      src/main/java/com/uas/platform/b2c/trade/order/model/OrderIndexDetail.java
  54. 9 0
      src/main/java/com/uas/platform/b2c/trade/order/service/OrderService.java
  55. 11 2
      src/main/java/com/uas/platform/b2c/trade/order/service/PurchaseService.java
  56. 68 7
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java
  57. 24 15
      src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java
  58. 14 0
      src/main/java/com/uas/platform/b2c/trade/seek/controller/SeekPurchaseBomController.java
  59. 9 0
      src/main/java/com/uas/platform/b2c/trade/seek/service/SeekPurchaseBomService.java
  60. 107 20
      src/main/java/com/uas/platform/b2c/trade/seek/service/impl/SeekPurchaseBomServiceImpl.java
  61. 3 0
      src/main/resources/dev/sys.properties
  62. BIN
      src/main/resources/jxls-tpl/trade/products-error.xls
  63. BIN
      src/main/resources/jxls-tpl/trade/products.xls
  64. BIN
      src/main/resources/jxls-tpl/trade/releaseByBatch-rmb.xls
  65. BIN
      src/main/resources/jxls-tpl/trade/releaseByBatchError-rmb.xls
  66. BIN
      src/main/resources/jxls-tpl/trade/releasebyBatch-usd.xls
  67. 4 1
      src/main/resources/prod/sys.properties
  68. 4 1
      src/main/resources/test/sys.properties
  69. 1 0
      src/main/webapp/WEB-INF/spring/webmvc.xml
  70. 4 0
      src/main/webapp/WEB-INF/views/normal/adminWithNav.html
  71. 1 0
      src/main/webapp/WEB-INF/views/normal/user_center.html
  72. BIN
      src/main/webapp/resources/img/all/default.png
  73. BIN
      src/main/webapp/resources/img/all/empty-cart.png
  74. BIN
      src/main/webapp/resources/img/all/qrcode_mall.png
  75. BIN
      src/main/webapp/resources/img/all/u.png
  76. BIN
      src/main/webapp/resources/img/common/mall-logo.png
  77. BIN
      src/main/webapp/resources/img/common/uas-mall.png
  78. BIN
      src/main/webapp/resources/img/common/uas_mall.png
  79. BIN
      src/main/webapp/resources/img/example/tip_logo.png
  80. BIN
      src/main/webapp/resources/img/help/brand.png
  81. BIN
      src/main/webapp/resources/img/help/buy-search.png
  82. BIN
      src/main/webapp/resources/img/help/kind.png
  83. BIN
      src/main/webapp/resources/img/help/market.png
  84. BIN
      src/main/webapp/resources/img/help/orderinfo.png
  85. BIN
      src/main/webapp/resources/img/help/register.png
  86. BIN
      src/main/webapp/resources/img/help/search.png
  87. BIN
      src/main/webapp/resources/img/help/search1.png
  88. BIN
      src/main/webapp/resources/img/help/search2.png
  89. BIN
      src/main/webapp/resources/img/help/search3.png
  90. BIN
      src/main/webapp/resources/img/help/seller-apply-brand.png
  91. BIN
      src/main/webapp/resources/img/help/seller-apply-component.png
  92. BIN
      src/main/webapp/resources/img/help/seller-apply-componentInfo.png
  93. BIN
      src/main/webapp/resources/img/help/seller-batch-publish.png
  94. BIN
      src/main/webapp/resources/img/help/sign.png
  95. BIN
      src/main/webapp/resources/img/logo/squirrel_logo_weixin.jpg
  96. BIN
      src/main/webapp/resources/img/logo/uas_mall.png
  97. BIN
      src/main/webapp/resources/img/logo/uas_mall_hor.png
  98. BIN
      src/main/webapp/resources/img/mobile/client-icon-32.png
  99. BIN
      src/main/webapp/resources/img/mobile/yrsc_weixin.jpg
  100. BIN
      src/main/webapp/resources/img/store/common/default.png

+ 109 - 0
src/main/java/com/uas/platform/b2c/common/lottery/controller/LotteryController.java

@@ -0,0 +1,109 @@
+package com.uas.platform.b2c.common.lottery.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.lottery.service.ActivityItemService;
+import com.uas.platform.b2c.common.lottery.service.LotteryService;
+import com.uas.platform.b2c.common.lottery.service.PrizeService;
+import com.uas.platform.b2c.common.lottery.service.UserInfoService;
+import com.uas.platform.b2c.common.lottery.service.WinningHistoryService;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 推广抽奖活动接口
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 10:25 wangyc
+ */
+@RestController
+@RequestMapping(value = "/lottery")
+public class LotteryController {
+
+    private final UserInfoService userInfoService;
+
+    private final ActivityItemService activityItemService;
+
+    private final PrizeService prizeService;
+
+    private final WinningHistoryService winningHistoryService;
+
+    private final LotteryService lotteryService;
+
+    @Autowired
+    public LotteryController(UserInfoService userInfoService, ActivityItemService activityItemService, PrizeService prizeService, WinningHistoryService winningHistoryService, LotteryService lotteryService) {
+        this.userInfoService = userInfoService;
+        this.activityItemService = activityItemService;
+        this.prizeService = prizeService;
+        this.winningHistoryService = winningHistoryService;
+        this.lotteryService = lotteryService;
+    }
+
+    /**
+     * 获取单个用户信息
+     * @param activityCode 活动编号
+     * @return
+     */
+    @RequestMapping(value = "/userInfo", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap findUserInfo(String activityCode) {
+        return userInfoService.findUserInfo(activityCode);
+    }
+
+    /**
+     * 获取当前等级信息、下一等级信息
+     * @param activityCode 活动编号
+     * @return
+     */
+    @RequestMapping(value = "/user/activityItems", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap getActivityItems(String activityCode) {
+        return activityItemService.getActivityItems(activityCode);
+    }
+
+    /**
+     * 获取当前等级奖品
+     * @param activityCode 活动编号
+     * @param itemCode 等级编号
+     * @return
+     */
+    @RequestMapping(value = "/user/prizes", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap getPrizesByUser(String activityCode, String itemCode) {
+        return prizeService.getPrizesByUser(activityCode, itemCode);
+    }
+
+    /**
+     * 获取获奖记录
+     * @param activityCode 活动编号
+     * @param size 条数
+     * @return
+     */
+    @RequestMapping(value = "/user/winninghistories", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap getWinningHistories(String activityCode, Integer size) {
+        return winningHistoryService.getWinningHistories(activityCode, size);
+    }
+
+    /**
+     * 分页获取个人中奖记录
+     * @param activityCode 活动编码
+     * @param pageParams 分页参数
+     * @return
+     */
+    @RequestMapping(value = "/user/winninghistories/one", method = RequestMethod.GET, produces = "application/json")
+    public JSONObject getWinningHistoriesByUser(String activityCode, PageParams pageParams) {
+        return winningHistoryService.getWinningHistoriesByUser(activityCode, pageParams);
+    }
+
+    /**
+     * 用户抽奖
+     * @param activityCode 活动编号
+     * @param itemCode 等级编号
+     * @return
+     */
+    @RequestMapping(value = "/user/draw", method = RequestMethod.GET, produces = "application/json")
+    public ResultMap drawLottery(String activityCode, String itemCode) {
+        return lotteryService.drawLottery(activityCode, itemCode);
+    }
+}

+ 18 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/ActivityItemService.java

@@ -0,0 +1,18 @@
+package com.uas.platform.b2c.common.lottery.service;
+
+import com.uas.platform.b2c.trade.support.ResultMap;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 14:47 wangyc
+ */
+public interface ActivityItemService {
+
+    /**
+     * 获取当前等级信息、下一等级信息
+     * @param activityCode 活动编号
+     * @return
+     */
+    ResultMap getActivityItems(String activityCode);
+}

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/LotteryService.java

@@ -0,0 +1,19 @@
+package com.uas.platform.b2c.common.lottery.service;
+
+import com.uas.platform.b2c.trade.support.ResultMap;
+
+/**
+ * Created by wangyc on 2018/9/13.
+ *
+ * @version 2018/9/13 17:14 wangyc
+ */
+public interface LotteryService {
+
+    /**
+     * 用户抽奖
+     * @param activityCode 活动编号
+     * @param itemCode 等级编号
+     * @return
+     */
+    ResultMap drawLottery(String activityCode, String itemCode);
+}

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/PrizeService.java

@@ -0,0 +1,19 @@
+package com.uas.platform.b2c.common.lottery.service;
+
+import com.uas.platform.b2c.trade.support.ResultMap;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 17:34 wangyc
+ */
+public interface PrizeService {
+
+    /**
+     * 获取当前等级奖品
+     * @param activityCode 活动编号
+     * @param itemCode 等级编号
+     * @return
+     */
+    ResultMap getPrizesByUser(String activityCode, String itemCode);
+}

+ 19 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/UserInfoService.java

@@ -0,0 +1,19 @@
+package com.uas.platform.b2c.common.lottery.service;
+
+import com.uas.platform.b2c.trade.support.ResultMap;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 10:28 wangyc
+ */
+public interface UserInfoService {
+
+    /**
+     * 获取单个用户信息
+     * @param activityCode 活动编号
+     * @return
+     */
+    ResultMap findUserInfo(String activityCode);
+
+}

+ 30 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/WinningHistoryService.java

@@ -0,0 +1,30 @@
+package com.uas.platform.b2c.common.lottery.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import org.springframework.data.domain.Page;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 18:45 wangyc
+ */
+public interface WinningHistoryService {
+
+    /**
+     * 获取获奖记录
+     * @param activityCode 活动编号
+     * @param size 条数
+     * @return
+     */
+    ResultMap getWinningHistories(String activityCode, Integer size);
+
+    /**
+     * 分页获取个人中奖记录
+     * @param activityCode 活动编码
+     * @param pageParams 分页参数
+     * @return
+     */
+    JSONObject getWinningHistoriesByUser(String activityCode, PageParams pageParams);
+}

+ 53 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/ActivityItemServiceImpl.java

@@ -0,0 +1,53 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.platform.b2c.common.lottery.service.ActivityItemService;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.HttpUtil.Response;
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 14:47 wangyc
+ */
+@Service
+public class ActivityItemServiceImpl implements ActivityItemService {
+
+    // 获取单个用户等级信息路径
+    private static final String GET_ITEMS_USER_URL = "/activityItem/user";
+
+    private final SysConf sysConf;
+
+    @Autowired
+    public ActivityItemServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap getActivityItems(String activityCode) {
+        if (StringUtils.isEmpty(activityCode)) {
+            return new ResultMap(CodeType.PARAMETER_ERROR, "活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("useruu", SystemSession.getUser().getUserUU());
+        params.put("enuu", SystemSession.getUser().getEnterprise() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+        params.put("activityCode", activityCode);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_ITEMS_USER_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            return new ResultMap(CodeType.ERROR_STATE, "获取等级信息错误,请重试");
+        }
+    }
+}

+ 55 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/LotteryServiceImpl.java

@@ -0,0 +1,55 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.lottery.service.LotteryService;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.HttpUtil.Response;
+import com.uas.ps.core.page.exception.IllegalOperatorException;
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+/**
+ * Created by wangyc on 2018/9/13.
+ *
+ * @version 2018/9/13 17:15 wangyc
+ */
+@Service
+public class LotteryServiceImpl implements LotteryService {
+
+    private final SysConf sysConf;
+
+    private static final String DRAW_PERSONAL_URL = "/lottery/draw";
+
+    @Autowired
+    public LotteryServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap drawLottery(String activityCode, String itemCode) {
+        if (StringUtils.isEmpty(activityCode)) {
+            throw new IllegalOperatorException("活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("activityCode", activityCode);
+        params.put("itemCode", itemCode);
+        params.put("useruu", SystemSession.getUser().getUserUU());
+        params.put("enuu", SystemSession.getUser().getEnterprise() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+
+        try {
+            Response response = HttpUtil
+                .sendGetRequest(sysConf.getLottery() + DRAW_PERSONAL_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            throw new IllegalOperatorException("获取中奖信息错误,请重试");
+        }
+    }
+}

+ 54 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/PrizeServiceImpl.java

@@ -0,0 +1,54 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.platform.b2c.common.lottery.service.PrizeService;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.HttpUtil.Response;
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 17:36 wangyc
+ */
+@Service
+public class PrizeServiceImpl implements PrizeService {
+
+    private final SysConf sysConf;
+
+    // 获取当前等级奖品路径
+    private static final String GET_PRIZES_USER_URL = "/prizes/user";
+
+    @Autowired
+    public PrizeServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap getPrizesByUser(String activityCode, String itemCode) {
+        if (StringUtils.isEmpty(activityCode)) {
+            return new ResultMap(CodeType.PARAMETER_ERROR, "活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("useruu", SystemSession.getUser().getUserUU());
+        params.put("enuu", SystemSession.getUser().getEnterprise() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+        params.put("activityCode", activityCode);
+        params.put("itemCode", StringUtils.isEmpty(itemCode) ? "" : itemCode);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_PRIZES_USER_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            return new ResultMap(CodeType.ERROR_STATE, "获取奖品信息错误,请重试");
+        }
+    }
+}

+ 53 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/UserInfoServiceImpl.java

@@ -0,0 +1,53 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.platform.b2c.common.lottery.service.UserInfoService;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.HttpUtil.Response;
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 10:30 wangyc
+ */
+@Service
+public class UserInfoServiceImpl implements UserInfoService {
+
+    // 获取单个用户信息路径
+    private static final String GET_USER_URL = "/users/user";
+
+    private final SysConf sysConf;
+
+    @Autowired
+    public UserInfoServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap findUserInfo(String activityCode) {
+        if (StringUtils.isEmpty(activityCode)) {
+            return new ResultMap(CodeType.PARAMETER_ERROR, "活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("useruu", SystemSession.getUser().getUserUU());
+        params.put("enuu", SystemSession.getUser().getEnterprise() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+        params.put("activityCode", activityCode);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_USER_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            return new ResultMap(CodeType.ERROR_STATE, "获取用户信息错误,请重试");
+        }
+    }
+}

+ 79 - 0
src/main/java/com/uas/platform/b2c/common/lottery/service/impl/WinningHistoryServiceImpl.java

@@ -0,0 +1,79 @@
+package com.uas.platform.b2c.common.lottery.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.lottery.service.WinningHistoryService;
+import com.uas.platform.b2c.common.search.util.PageParams;
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.trade.support.CodeType;
+import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.HttpUtil.Response;
+import com.uas.ps.core.page.exception.IllegalOperatorException;
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+/**
+ * Created by wangyc on 2018/9/12.
+ *
+ * @version 2018/9/12 18:48 wangyc
+ */
+@Service
+public class WinningHistoryServiceImpl implements WinningHistoryService {
+
+    private final SysConf sysConf;
+
+    // 获取最近中奖记录路径
+    private static final String GET_WINNING_HOSTORIES_TOP_URL = "/winninghistorys/top";
+
+    // 获取个人中奖记录路径
+    private static final String GET_WINNING_HOSTORIES_PERSONAL_URL = "/winninghistorys/user";
+
+    @Autowired
+    public WinningHistoryServiceImpl(SysConf sysConf) {
+        this.sysConf = sysConf;
+    }
+
+    @Override
+    public ResultMap getWinningHistories(String activityCode, Integer size) {
+        if (StringUtils.isEmpty(activityCode)) {
+            return new ResultMap(CodeType.PARAMETER_ERROR, "活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("activityCode", activityCode);
+        params.put("size", size == null ? 20 : size);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_WINNING_HOSTORIES_TOP_URL, params);
+            return JSON.parseObject(response.getResponseText(), ResultMap.class);
+        } catch (Exception e) {
+            return new ResultMap(CodeType.ERROR_STATE, "获取中奖信息错误,请重试");
+        }
+    }
+
+    @Override
+    public JSONObject getWinningHistoriesByUser(String activityCode, PageParams pageParams) {
+        if (StringUtils.isEmpty(activityCode)) {
+            throw new IllegalOperatorException("活动信息不完全,请确认活动信息");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("activityCode", activityCode);
+        params.put("useruu", SystemSession.getUser().getUserUU());
+        params.put("enuu", SystemSession.getUser().getEnterprise() == null ? 0 : SystemSession.getUser().getEnterprise().getUu());
+        params.put("pageParams", pageParams);
+
+        try {
+            Response response = HttpUtil.sendGetRequest(sysConf.getLottery() + GET_WINNING_HOSTORIES_PERSONAL_URL, params);
+            return JSON.parseObject(response.getResponseText(), JSONObject.class);
+        } catch (Exception e) {
+            throw new IllegalOperatorException("获取中奖信息错误,请重试");
+        }
+    }
+}

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/message/service/InternalMessageService.java

@@ -25,7 +25,7 @@ public interface InternalMessageService {
      * @param status 状态
      * @return 消息数量
      */
-    Integer getCount(Long recuu, Long recEnuu, String recType, String status);
+    Integer  getCount(Long recuu, Long recEnuu, String recType, String status);
 
     /**
      * 分页获取消息 (用户)

+ 14 - 0
src/main/java/com/uas/platform/b2c/core/config/SysConf.java

@@ -175,6 +175,12 @@ public class SysConf {
 	@Value(("#{sys.profile}"))
 	private String profile;
 
+	/**
+	 * 推广抽奖活动地址
+	 */
+	@Value(("#{sys.lottery}"))
+	private String lottery;
+
 	/**
 	 * 物料id
 	 */
@@ -394,6 +400,14 @@ public class SysConf {
 		return this;
 	}
 
+	public String getLottery() {
+		return lottery;
+	}
+
+	public void setLottery(String lottery) {
+		this.lottery = lottery;
+	}
+
 	public String getProductServiceIp() {
 		return productServiceIp;
 	}

+ 0 - 30
src/main/java/com/uas/platform/b2c/core/support/log/TradeBufferedLogger.java

@@ -4,8 +4,6 @@ import com.uas.platform.b2c.common.account.model.TradeLog;
 import com.uas.platform.b2c.common.account.service.TradeLogService;
 import com.uas.platform.b2c.core.utils.ContextUtils;
 import com.uas.platform.b2c.core.utils.PathUtils;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrder;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.Purchase;
 import com.uas.platform.core.exception.IllegalOperatorException;
@@ -63,32 +61,4 @@ public class TradeBufferedLogger extends BufferedLogger<TradeLog> {
 		log(purchase.getClass().getSimpleName(), purchase.getPurchaseid(), voucherOperation, changeLog);
 	}
 
-	/**
-	 * 记录交易流程卖家出货单操作日志
-	 *
-	 * @param invoice				状态变更的卖家出货单的实例
-	 * @param voucherOperation		单据操作
-	 * @param changeLog				操作具体日志记录
-	 */
-	public void log(InvoiceFPurchase invoice, TradeLog.VoucherOperation voucherOperation, String changeLog) {
-		if (invoice == null) {
-			throw new IllegalOperatorException("卖家出货单数据已失效");
-		}
-		log(invoice.getClass().getSimpleName(), invoice.getInvoiceid(), voucherOperation, changeLog);
-	}
-
-	/**
-	 * 记录交易流程平台出货单操作日志
-	 *
-	 * @param invoice				状态变更的平台出货单的实例
-	 * @param voucherOperation		单据操作
-	 * @param changeLog				操作具体日志记录
-	 */
-	public void log(InvoiceFOrder invoice, TradeLog.VoucherOperation voucherOperation, String changeLog) {
-		if (invoice == null) {
-			throw new IllegalOperatorException("平台出货单数据已失效");
-		}
-		log(invoice.getClass().getSimpleName(), invoice.getInvoiceid(), voucherOperation, changeLog);
-	}
-
 }

+ 25 - 0
src/main/java/com/uas/platform/b2c/external/erp/order/api/OrderController.java

@@ -441,4 +441,29 @@ public class OrderController {
 		return orderService.findUserVenderByCode(orderid);
 	}
 
+	/**
+	 * 统计个人的订单金额(只包含520-405)
+	 * @param useruu 个人uu
+	 * @param enuu 企业uu
+	 * @param starttime 开始时间
+	 * @param endtime 结束时间
+	 * @return  ResultMap
+	 */
+	@RequestMapping(value = "/trading/volume/personal", method = RequestMethod.GET)
+	public ResultMap statisticsPersonTradingVolume(Long useruu, Long enuu, Long starttime, Long endtime) {
+		return orderService.statisticsPersonTradingVolume(useruu, enuu, starttime, endtime);
+	}
+
+	/**
+	 * 统计企业的订单金额总计 (只包含520-405)
+	 * @param enuu
+	 * @param starttime
+	 * @param endtime
+	 * @return ResultMap
+	 */
+	@RequestMapping(value = "/trading/volume", method = RequestMethod.GET)
+	public ResultMap statisticsEnterpriseTradingVolume(Long enuu, Long starttime, Long endtime) {
+		return orderService.statisticsEnterpriseTradingVolume(enuu, starttime, endtime);
+	}
+
 }

+ 2 - 2
src/main/java/com/uas/platform/b2c/external/erp/order/api/PurchaseController.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
+import com.uas.platform.b2c.logistics.model.Invoice;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.Purchase;
 import com.uas.platform.b2c.trade.order.service.PurchaseService;
@@ -206,7 +206,7 @@ public class PurchaseController {
      * @return invoice f purchase
      */
     @RequestMapping(value = "/{invoiceid}/ensurereceipt", method = RequestMethod.PUT)
-	public InvoiceFPurchase ensureReceipt(@PathVariable String invoiceid) {
+	public Invoice ensureReceipt(@PathVariable String invoiceid) {
 		return purchaseService.ensuerAcceptInvoise(invoiceid);
 	}
 

+ 13 - 12
src/main/java/com/uas/platform/b2c/external/erp/order/service/impl/InvoiceNotifyServiceImpl.java

@@ -4,9 +4,10 @@ import com.uas.api.b2c_erp.buyer.model.AcceptNotify;
 import com.uas.api.b2c_erp.buyer.model.AcceptNotifyDetail;
 import com.uas.api.b2c_erp.buyer.service.InvoiceNotifyService;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.logistics.dao.InvoiceDao;
 import com.uas.platform.b2c.logistics.dao.InvoiceFOrderDao;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrder;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
+import com.uas.platform.b2c.logistics.model.Invoice;
+import com.uas.platform.b2c.logistics.model.InvoiceDetail;
 import com.uas.platform.core.model.Status;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,30 +21,30 @@ import java.util.List;
 public class InvoiceNotifyServiceImpl implements InvoiceNotifyService {
 
 	@Autowired
-	private InvoiceFOrderDao inForDao;
+	private InvoiceDao inForDao;
 
 	@Override
 	public List<AcceptNotify> getAllInvoiceNoitify() {
 		List<AcceptNotify> acceptNotifys = new ArrayList<AcceptNotify>();
 		// 获取平台发货单
-		List<InvoiceFOrder> fOrders = inForDao.findByBuyerenuuAndSendstatusAndUasPurcidNotNull(SystemSession.getUser().getEnterprise()
+		List<Invoice> fOrders = inForDao.findByBuyerenuuAndSendstatusAndUasPurcidNotNull(SystemSession.getUser().getEnterprise()
 				.getUu(), Status.NOT_UPLOAD.value());
 		if (!CollectionUtils.isEmpty(fOrders)) {
-			for (InvoiceFOrder fOrder : fOrders) {
+			for (Invoice fOrder : fOrders) {
 				AcceptNotify acceptNotify = new AcceptNotify();
 				acceptNotify.setCreateTime(new Date());
 				acceptNotify.setId(fOrder.getId());
 				// 这里记录的是平台的订单号
-				acceptNotify.setPurchaseId(fOrder.getOrid());
+				acceptNotify.setPurchaseId(fOrder.getOrderId());
 				double qtys = 0D;
 				List<AcceptNotifyDetail> notifyDetails = new ArrayList<AcceptNotifyDetail>();
-				for (InvoiceFOrderDetail detail : fOrder.getInvoiceFOrderDetails()) {
+				for (InvoiceDetail detail : fOrder.getInvoiceDetails()) {
 					AcceptNotifyDetail notifyDetail = new AcceptNotifyDetail();
 					notifyDetail.setBatchcode(detail.getBatchCode());
-					notifyDetail.setQty(detail.getNumber());
-					notifyDetail.setPrice(detail.getTaxunitprice());
+					notifyDetail.setQty(detail.getQty());
+					notifyDetail.setPrice(detail.getTaxUnitprice());
 					notifyDetails.add(notifyDetail);
-					qtys = qtys + detail.getNumber();
+					qtys = qtys + detail.getQty();
 				}
 				acceptNotify.setNotifyDetail(notifyDetails);
 				acceptNotify.setQty(qtys);
@@ -57,7 +58,7 @@ public class InvoiceNotifyServiceImpl implements InvoiceNotifyService {
 	@Override
 	public void backSuccess(long[] ids) {
 		for (long id : ids) {
-			InvoiceFOrder fOrder = inForDao.findOne(id);
+			Invoice fOrder = inForDao.findOne(id);
 			fOrder.setSendstatus(Status.DOWNLOADED.value());
 			inForDao.save(fOrder);
 		}
@@ -66,7 +67,7 @@ public class InvoiceNotifyServiceImpl implements InvoiceNotifyService {
 	@Override
 	public void agreeInvoice(long[] ids) {
 		for (long id : ids) {
-			InvoiceFOrder fOrder = inForDao.findOne(id);
+			Invoice fOrder = inForDao.findOne(id);
 			// 安全性验证一下
 			if (fOrder.getSendstatus() == Status.DOWNLOADED.value()) {
 				fOrder.setStatusReceived(SystemSession.getUser().getUserUU());

+ 3 - 3
src/main/java/com/uas/platform/b2c/fa/payment/controller/BankInfoController.java

@@ -271,11 +271,11 @@ public class BankInfoController {
 	/**
 	 * 根据银行账号返回账户数
 	 * @param number 银行账号
-	 * @param type   类型,卖家、买家、平台
+	 * @param accountType   类型,卖家、买家、平台
 	 * @return
 	 */
 	@RequestMapping(value = "/number/count", method = RequestMethod.GET)
-	public ResultMap getCountByNumber(Integer type, String number){
-		return bankInfoService.getCountByNumber(type, number);
+	public ResultMap getCountByNumber(String accountType, String number){
+		return bankInfoService.getCountByNumber(accountType, number);
 	}
 }

+ 13 - 2
src/main/java/com/uas/platform/b2c/fa/payment/dao/BankInfoDao.java

@@ -125,8 +125,19 @@ public interface BankInfoDao extends CrudRepository<BankInfo, Long>, JpaSpecific
 	 * @param number
 	 * @return
 	 */
-	@Query("select count(b) from BankInfo b where b.enuu=:enuu and b.dissociative=:dissociative and b.status=:status and b.number=:number")
-	int getSupCountByNumberAndDissociative(@Param("enuu") Long enuu, @Param("dissociative") Integer dissociative, @Param("status") Integer status, @Param("number") String number);
+	@Query("select count(b) from BankInfo b where b.enuu=:enuu and b.dissociative=:dissociative and b.status=:status and b.number=:number and b.accountType =:accountType")
+	int getSupCountByNumberAndDissociative(@Param("enuu") Long enuu, @Param("dissociative") Integer dissociative, @Param("status") Integer status, @Param("number") String number, @Param("accountType") String accountType);
+
+	/**
+	 * 根据银行账号查询个人账号下的账户个数
+	 * @param useruu
+	 * @param dissociative
+	 * @param status
+	 * @param number
+	 * @return
+	 */
+	@Query("select count(b) from BankInfo b where b.enuu=:enuu and b.dissociative=:dissociative and b.status=:status and b.number=:number and b.accountType =:accountType")
+	int getBuyCountByNumberAndDissociative(@Param("enuu") Long useruu, @Param("dissociative") Integer dissociative, @Param("status") Integer status, @Param("number") String number, @Param("accountType") String accountType);
 
 	/**
 	 * 银行账户返回企业账户数

+ 2 - 4
src/main/java/com/uas/platform/b2c/fa/payment/service/BankInfoService.java

@@ -4,8 +4,6 @@ import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.fa.payment.model.BankInfo;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageParams;
-import com.uas.platform.core.model.Status;
-import com.uas.platform.core.model.Type;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
@@ -125,11 +123,11 @@ public interface BankInfoService {
 	/**
 	 * 根据银行账号返回账户数
 	 *
-	 * @param type
+	 * @param accountType
 	 * @param number
 	 * @return
 	 */
-	ResultMap getCountByNumber(Integer type, String number);
+	ResultMap getCountByNumber(String accountType, String number);
 
 	/**
 	 * 获取

+ 5 - 5
src/main/java/com/uas/platform/b2c/fa/payment/service/impl/BankInfoServiceImpl.java

@@ -359,8 +359,8 @@ public class BankInfoServiceImpl implements BankInfoService {
 	}
 
 	@Override
-	public ResultMap getCountByNumber(Integer type, String number) {
-		if (type != Type.MALL.value() && type != Type.BUYER.value() && type != Type.SUP.value()){
+	public ResultMap getCountByNumber(String accountType, String number) {
+		if (!AccountType.PAY_TYPE.equals(accountType)  && !AccountType.RECEIVE_TYPE.equals(accountType)){
 			return new ResultMap(CodeType.ERROR_STATE, "类型不存在,确认要查找账户的类型");
 		}
 		if (StringUtils.isEmpty(number)) {
@@ -368,10 +368,10 @@ public class BankInfoServiceImpl implements BankInfoService {
 		}
 		Integer count = null;
 		User user = SystemSession.getUser();
-		if (user.getEnterprise() != null) {
-			count = bankInfoDao.getSupCountByNumberAndDissociative(user.getEnterprise().getUu(), Type.ENTERPRISING.value(), Status.ALLOW.value(), number);
+		if (user.getEnterprise() == null) {
+			count = bankInfoDao.getBuyCountByNumberAndDissociative(user.getUserUU(), Type.PERSONAL.value(), Status.ALLOW.value(), number, accountType);
 		}else {
-			count = bankInfoDao.getBuyerCountByNumberAndDissociative(user.getUserUU(), Type.PERSONAL.value(), Status.ALLOW.value(), number);
+			count = bankInfoDao.getSupCountByNumberAndDissociative(user.getEnterprise().getUu(), Type.ENTERPRISING.value(), Status.ALLOW.value(), number, accountType);
 		}
 		return ResultMap.success(count);
 	}

+ 2 - 4
src/main/java/com/uas/platform/b2c/logistics/controller/InvoiceController.java

@@ -7,8 +7,6 @@ import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.logistics.model.Invoice;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrder;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
 import com.uas.platform.b2c.logistics.service.InvoiceFOrderService;
 import com.uas.platform.b2c.logistics.service.InvoiceFPurchaseService;
 import com.uas.platform.b2c.logistics.service.InvoiceService;
@@ -386,7 +384,7 @@ public class InvoiceController {
 	 * @return ResultMap
 	 */
 	@RequestMapping(value = "/enterprise/inbound", method = RequestMethod.GET)
-    public Page<Invoice> getEnterpriseInboundInvoice(PageParams pageParams) {
-		return invoiceService.getEnterpriseInboundInvoice(pageParams);
+    public Page<Invoice> getEnterpriseInboundInvoice(PageParams pageParams, String keyword) {
+		return invoiceService.getEnterpriseInboundInvoice(pageParams, keyword);
 	}
 }

+ 10 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/InvoiceDao.java

@@ -49,4 +49,14 @@ public interface InvoiceDao extends JpaSpecificationExecutor<Invoice>, JpaReposi
 	 */
 	@Query(value = "select count(1) from Invoice ifo where ifo.invoiceid in (:invoiceids) and ifo.status = 404 and ifo.piclass = :piclass")
 	Integer countInBoundInvoice(@Param("invoiceids") List<String> invoiceids, @Param("piclass") Integer piclass);
+
+
+	/**
+	 * 根据买家UU和状态查询平台发货单
+	 *
+	 * @param buyerenuu  the buyerenuu 买家enuu
+	 * @param sendstatus the sendstatus 状态
+	 * @return list 返回InvoiceFOrder列表
+	 */
+	List<Invoice> findByBuyerenuuAndSendstatusAndUasPurcidNotNull(Long buyerenuu, Integer sendstatus);
 }

+ 19 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/InvoiceDetailDao.java

@@ -0,0 +1,19 @@
+package com.uas.platform.b2c.logistics.dao;
+
+import com.uas.platform.b2c.logistics.model.InvoiceDetail;
+import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface InvoiceDetailDao extends JpaSpecificationExecutor<InvoiceDetail>, JpaRepository<InvoiceDetail, Long> {
+
+    /**
+     * 根据采购单明细获取InvoiceFPurchaseDetail对象
+     *
+     * @param pudetailid the pudetailid 采购单明细id
+     * @return InvoiceFPurchaseDetail 返回InvoiceFPurchaseDetail对象
+     */
+    InvoiceDetail findByPurchaseDetailId(Long pudetailid);
+}

+ 0 - 1
src/main/java/com/uas/platform/b2c/logistics/service/InvoiceFPurchaseDetailService.java

@@ -1,6 +1,5 @@
 package com.uas.platform.b2c.logistics.service;
 
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
 
 /**
  * The interface InvoiceFPurchaseDetail service.

+ 8 - 5
src/main/java/com/uas/platform/b2c/logistics/service/InvoiceService.java

@@ -2,16 +2,12 @@ package com.uas.platform.b2c.logistics.service;
 
 import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.logistics.model.Invoice;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrder;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.Purchase;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import org.springframework.data.domain.Page;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 
 import javax.management.OperationsException;
 import java.util.List;
@@ -25,6 +21,13 @@ public interface InvoiceService {
 
     ResultMap convert();
 
+    /**
+     * 批量发货单
+     * @param invoice
+     * @return
+     */
+    Invoice save(Invoice invoice);
+
     /**
      * 根据订单生成平台出货单及其明细信息,并保存出货单和修改订单状态信息
      * Created by huxz 2017-1-13 15:39:40
@@ -212,5 +215,5 @@ public interface InvoiceService {
      * 获取买家的待收货出库单
      * @return Page<Invoice>
      */
-    Page<Invoice> getEnterpriseInboundInvoice(PageParams pageParams);
+    Page<Invoice> getEnterpriseInboundInvoice(PageParams pageParams, String keyword);
 }

+ 0 - 3
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceFOrderDetailServiceImpl.java

@@ -1,10 +1,7 @@
 package com.uas.platform.b2c.logistics.service.impl;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.uas.platform.b2c.logistics.dao.InvoiceFOrderDetailDao;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
 import com.uas.platform.b2c.logistics.service.InvoiceFOrderDetailService;
 
 @Service

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

@@ -1,13 +1,6 @@
 package com.uas.platform.b2c.logistics.service.impl;
 
-import com.uas.platform.b2c.core.support.SystemSession;
-import com.uas.platform.b2c.core.utils.NumberUtil;
-import com.uas.platform.b2c.logistics.dao.InvoiceFPurchaseDetailDao;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
 import com.uas.platform.b2c.logistics.service.InvoiceFPurchaseDetailService;
-import com.uas.platform.core.model.Status;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service

+ 31 - 4
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceServiceImpl.java

@@ -3,7 +3,6 @@ package com.uas.platform.b2c.logistics.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
 import com.uas.platform.b2c.common.account.model.Enterprise;
-import com.uas.platform.b2c.common.account.model.TradeLog;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.model.UserBaseInfo;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
@@ -41,12 +40,13 @@ import com.uas.platform.b2c.trade.order.model.PurchaseDetail;
 import com.uas.platform.b2c.trade.order.service.OrderService;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
-import com.uas.platform.b2c.trade.util.TradeLogUtil;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.EncodingRulesConstant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.Status;
+import com.uas.platform.core.persistence.criteria.CriterionExpression;
+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.uas.platform.core.util.serializer.FlexJsonUtils;
@@ -144,6 +144,21 @@ public class InvoiceServiceImpl implements InvoiceService {
         return ResultMap.success(invoices1.size());
     }
 
+    /**
+     * 批量发货单
+     *
+     * @param invoice
+     * @return
+     */
+    @Override
+    public Invoice save(Invoice invoice) {
+        if (invoice != null) {
+            return null;
+        } else {
+            return invoiceDao.save(invoice);
+        }
+    }
+
     @Override
     public Invoice sendInvoiceFOrder(String inid) {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
@@ -638,6 +653,9 @@ public class InvoiceServiceImpl implements InvoiceService {
             if (invoice == null) {
                 throw new IllegalOperatorException("没有传入有效的订单信息");
             }
+            if (invoice.getStatus().intValue() != Status.INBOUND.value()) {
+                return ResultMap.success("");
+            }
             User user = SystemSession.getUser();
             Long useruu = null;
             if (user == null) {
@@ -856,7 +874,7 @@ public class InvoiceServiceImpl implements InvoiceService {
         if(NumberUtil.compare(purchase.getQty(), purchase.getShipQty()) < 1) {
             Set<PurchaseDetail> purchaseDetails = purchase.getPurchaseDetails();
             for (PurchaseDetail purchaseDetail : purchaseDetails) {
-                if (Status.TOBESHIPPED.value() == purchaseDetail.getStatus()) {
+                if (Status.TOBESHIPPED.value() == purchaseDetail.getStatus() || Status.CONFIRMED.value() == purchaseDetail.getStatus()) {
                     purchaseDetail.setStatusInBound(userUU);
                 }
             }
@@ -1203,7 +1221,7 @@ public class InvoiceServiceImpl implements InvoiceService {
     }
 
     @Override
-    public Page<Invoice> getEnterpriseInboundInvoice(PageParams pageParams) {
+    public Page<Invoice> getEnterpriseInboundInvoice(PageParams pageParams, String keyword) {
         final PageInfo info = new PageInfo(pageParams);
         User user = SystemSession.getUser();
         Enterprise enterprise = user.getEnterprise();
@@ -1213,6 +1231,15 @@ public class InvoiceServiceImpl implements InvoiceService {
         } else {
             info.filter("buyerenuu", user.getEnterprise().getUu());
         }
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(keyword)) {
+            CriterionExpression[] expressions = new CriterionExpression[2];
+            expressions[0] = PredicateUtils.like("invoiceid", keyword, true);
+            expressions[1] = PredicateUtils.like("sellername", keyword, true);
+
+            LogicalExpression logicalExpression = PredicateUtils.or(expressions);
+            info.expression(logicalExpression);
+        }
+        info.filter("status", com.uas.platform.b2c.core.constant.Status.INBOUND.value());
         return invoiceDao.findAll(new Specification<Invoice>() {
             @Override
             public Predicate toPredicate(Root<Invoice> root, CriteriaQuery<?> query, CriteriaBuilder cb) {

+ 25 - 20
src/main/java/com/uas/platform/b2c/prod/commodity/constant/ModifyConstant.java

@@ -18,17 +18,17 @@ public class ModifyConstant {
     /**
      * 导入最大行数
      */
-    public static final int EXCEL_MAX_ROW = 2000;
+    public static final int EXCEL_MAX_ROW = 2002;
 
     /**
      * The constant TOTAL_ROW.
      */
-    public static final int TOTAL_COLUMN = 22;
+    public static final int TOTAL_COLUMN = 21;
 
     /**
      * The constant MAX_TOTAL_COLUMN.
      */
-    public static final int MAX_TOTAL_COLUMN = 23;
+    public static final int MAX_TOTAL_COLUMN = 22;
 
     /**
      * 产品编码
@@ -38,17 +38,17 @@ public class ModifyConstant {
     /**
      * The constant PRODUCT_KIND.
      */
-    public static final int PRODUCT_KIND = 1;
+    public static final int PRODUCT_KIND = 2;
 
     /**
      * The constant PRODUCT_CODE.
      */
-    public static final int PRODUCT_CODE = 2;
+    public static final int PRODUCT_CODE = 3;
 
     /**
      * The constant PRODUCT_BRAND.
      */
-    public static final int PRODUCT_BRAND = 3;
+    public static final int PRODUCT_BRAND = 1;
 
     /**
      * The constant PRODUCT_BRAND.
@@ -63,67 +63,72 @@ public class ModifyConstant {
     /**
      * The constant PACKAGE_METHOD.
      */
-    public static final int PACKAGE_METHOD = 6;
+    public static final int PACKAGE_METHOD = 5;
 
     /**
      * The constant MIN_DELIVERY.
      */
-    public static final int MIN_DELIVERY = 7;
+    public static final int MIN_DELIVERY = 6;
 
     /**
      * The constant MAX_DELIVERY.
      */
-    public static final int MAX_DELIVERY = 8;
+    public static final int MAX_DELIVERY = 7;
 
     /**
      * The constant BREAK_UP.
      */
-    public static final int BREAK_UP = 9;
+    public static final int BREAK_UP = 8;
 
     /**
      * The constant PACKAGE_NUMBER.
      */
-    public static final int PACKAGE_NUMBER = 10;
+    public static final int PACKAGE_NUMBER = 9;
 
     /**
      * 最小起订量
      */
-    public static final int BUY_MIN_QTY = 11;
+    public static final int BUY_MIN_QTY = 10;
 
     /**
      * 分段价格开始
      */
-    public static final int PRICE_FIRST = 12;
+    public static final int PRICE_FIRST = 11;
 
     /**
      * 第二个分段
      */
-    public static final int QTY_SECOND_START = 13;
+    public static final int QTY_SECOND_START = 12;
 
     /**
      * 第二个分段
      */
-    public static final int PRICE_SECOND = 14;
+    public static final int PRICE_SECOND = 13;
 
     /**
      * 第三个分段
      */
-    public static final int QTY_THIRD_START = 15;
+    public static final int QTY_THIRD_START = 14;
 
     /**
      * 第三个分段
      */
-    public static final int PRICE_THIRD = 16;
+    public static final int PRICE_THIRD = 15;
 
     /**
      * The constant SALE_METHOD.
      */
-    public static final int SALE_METHOD = 17;
+    public static final int SALE_METHOD = 16;
 
     /**
      * The constant RESERVE_NUMBER.
      */
-    public static final int RESERVE_NUMBER = 18;
+    public static final int RESERVE_NUMBER = 17;
+
+    /**
+     * 成本单价
+     */
+    public static final int COST_PRICE = 18;
 
     /**
      * The constant CUSTOM_LABEL.
@@ -133,7 +138,7 @@ public class ModifyConstant {
     /**
      * The constant SALE_STATUS.
      */
-    public static final int SALE_STATUS = 20;
+    public static final int SALE_STATUS = 19;
 
     /**
      * The constant MATCH_STATUS.

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ReleaseProductByBatchController.java

@@ -249,7 +249,7 @@ public class ReleaseProductByBatchController {
      * 通过excel批量导入PCB商品发布(大量)
      * @param uploadItem 上传内容
      * @param currency 币别
-     * @param repeatImport 重复导入
+     * @param ignoreImport 重复导入
      * @return
      */
     @RequestMapping(value = "/release/excel/pcb", method = RequestMethod.POST)

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/dao/GoodsDao.java

@@ -43,6 +43,14 @@ public interface GoodsDao extends JpaSpecificationExecutor<Goods>, JpaRepository
      */
     Goods findByBatchCode(String batchCode);
 
+    /**
+     * 批量获取在售产品信息
+     * @param batchCodes
+     * @return
+     */
+    @Query(value = "select g from Goods g where g.batchCode in (:batchCodes)")
+    List<Goods> findByBatchCodes(@Param("batchCodes") List<String> batchCodes);
+
     /**
      * 根据UUID和状态查找对应的货物信息
      *

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

@@ -8,7 +8,6 @@ import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -147,7 +146,8 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      * @param uuid 器件的uuid
      * @return  List<Product>
      */
-    List<Product> findByCmpUuId(String uuid);
+    @Query(value = "select p from Product p where p.cmpUuId = :uuid")
+    List<Product> findByCmpUuId(@Param("uuid") String uuid);
 
     /**
      * 通过企业uu,标准器件uuid,来源获取物料信息

+ 0 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/dao/ProductPrivateDao.java

@@ -12,7 +12,6 @@ public interface ProductPrivateDao  extends JpaRepository<ProductPrivate, Long>,
 
     public List<ProductPrivate> findByPrId(Long prId);
 
-
     /**
      * 根据物料的id 获取私有信息
      *

+ 34 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -541,6 +541,12 @@ public class Goods implements Serializable {
 	@Column(name = "go_autopublish", columnDefinition = "TINYINT(1)")
 	private Boolean autoPublish;
 
+	/**
+	 * 成本单价
+	 */
+	@Transient
+	private Double costPrice;
+
 	@Transient
 	private ProductAttachSubmit productAttachSubmit;
 
@@ -722,6 +728,9 @@ public class Goods implements Serializable {
 	}
 
 	public void setStatus() {
+		if (this.autoPublish == null) {
+			this.autoPublish = Boolean.TRUE;
+		}
 		if (this.autoPublish) {
 			if (StringUtils.isEmpty(this.packaging) || (this.minBuyQty == null) || (this.minPackQty == null) || (this.b2cMinDelivery == null) || (this.b2cMaxDelivery == null) || StringUtils.isEmpty(this.qtyPrice)) {
 				//做未上架处理
@@ -1692,6 +1701,10 @@ public class Goods implements Serializable {
 		g.setPackaging(product.getPackaging());
 		g.setUuid(product.getCmpUuId());
         g.setSpec(product.getSpec());
+        g.setReserve(product.getErpReserve());
+        g.setMinPackQty(product.getMinPackQty());
+        g.setPackaging(product.getPackaging());
+		g.setCostPrice(product.getPrice());
 		return g;
 	}
 
@@ -1727,8 +1740,11 @@ public class Goods implements Serializable {
 	 * 根据最小起订量 调整分段信息
 	 */
 	public void adjustFragmentPrice() {
-		if (!StringUtils.isEmpty(this.minBuyQty) && org.apache.commons.lang.StringUtils.isNotEmpty(this.qtyPrice)) {
-			List<GoodsQtyPrice> array = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
+		List<GoodsQtyPrice> array = new ArrayList<>();
+		if (org.apache.commons.lang.StringUtils.isNotEmpty(this.qtyPrice)) {
+			array = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
+		}
+		if (!StringUtils.isEmpty(this.minBuyQty) && CollectionUtils.isNotEmpty(array)) {
 			GoodsQtyPrice price = array.get(0);
 			if (NumberUtil.compare(price.getStart(), this.minBuyQty) > 0) {
 				price.setStart(this.minBuyQty);
@@ -1825,6 +1841,8 @@ public class Goods implements Serializable {
 		if (this.autoPublish == null) {
 			this.autoPublish = Boolean.TRUE;
 		}
+		setMinBuyQtyByMinPackQty(this.minBuyQty);
+		adjustFragmentPrice();
 		this.setStatus();
 		return this;
 	}
@@ -1910,6 +1928,9 @@ public class Goods implements Serializable {
 			this.breakUp = releaseProductByBatch.getBreakUp();
 			this.perQty = releaseProductByBatch.getBreakUp() ? 1 : releaseProductByBatch.getMinPackage();
 		}
+		if (IntegerConstant.NO_INT == ignoreImport || StringUtils.isEmpty(this.reserve)) {
+			this.reserve = releaseProductByBatch.getReserve();
+		}
 		this.batchid = releaseProductByBatch.getRelbatchid();
 		this.storeid = releaseProductByBatch.getStoreid();
 		this.storeName = releaseProductByBatch.getStoreName();
@@ -1917,6 +1938,8 @@ public class Goods implements Serializable {
 		if (this.autoPublish == null) {
 			this.autoPublish = Boolean.TRUE;
 		}
+		setMinBuyQtyByMinPackQty(this.minBuyQty);
+		adjustFragmentPrice();
 		this.setStatus();
 
 		return this;
@@ -1947,4 +1970,13 @@ public class Goods implements Serializable {
 			}
 		}
 	}
+
+	public Double getCostPrice() {
+		return costPrice;
+	}
+
+	public Goods setCostPrice(Double costPrice) {
+		this.costPrice = costPrice;
+		return this;
+	}
 }

+ 1 - 3
src/main/java/com/uas/platform/b2c/prod/commodity/model/InOutboundDetail.java

@@ -3,8 +3,6 @@ package com.uas.platform.b2c.prod.commodity.model;
 import com.alibaba.fastjson.annotation.JSONField;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.uas.platform.b2c.logistics.model.InvoiceDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
 import com.uas.platform.b2c.trade.order.model.PurchaseDetail;
 
 import javax.persistence.*;
@@ -286,7 +284,7 @@ public class InOutboundDetail implements Serializable {
         this.cmpuuid = detail.getUuid();
         this.spec = detail.getSpec();
         this.qty = detail.getQty();
-        this.price = detail.getPrice();
+        this.price = detail.getTaxUnitprice();
         this.productId = detail.getProductid();
         this.sourceid = detail.getId();
         this.currency = detail.getCurrency();

+ 11 - 17
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -593,21 +593,18 @@ public class ReleaseProductByBatch implements Serializable {
 		ReleaseProductByBatch that = (ReleaseProductByBatch) o;
 
 		if (!brandNameEn.equals(that.brandNameEn)) return false;
-		if (!code.equals(that.code)) return false;
-		if (!minBuyQtyStr.equals(that.minBuyQtyStr)) return false;
-		if (!productDate.equals(that.productDate)) return false;
-		if (!minPackageStr.equals(that.minPackageStr)) return false;
-		if (!packaging.equals(that.packaging)) return false;
-		if (!selfMaxDeliveryStr.equals(that.selfMaxDeliveryStr)) return false;
+//		if (!code.equals(that.code)) return false;
+//		if (!minBuyQtyStr.equals(that.minBuyQtyStr)) return false;
+//		if (!productDate.equals(that.productDate)) return false;
+//		if (!minPackageStr.equals(that.minPackageStr)) return false;
+//		if (!packaging.equals(that.packaging)) return false;
+//		if (!selfMaxDeliveryStr.equals(that.selfMaxDeliveryStr)) return false;
 //		if (!selfMinDeliveryStr.equals(that.selfMinDeliveryStr)) return false;
 //		return GoodsUtil.compareWithQtyPrice(prices, that.getPrices(), that.getCurrency());
-		return selfMinDeliveryStr.equals(that.selfMinDeliveryStr);
+		return code.equals(that.code);
 	}
 
 	public void setBatchCodeByExcel(Object value) {
-		if (StringUtils.isEmpty(value)) {
-			addErrmsg(ErrorInfoConstant.BATCH_EMPTY.getInfo());
-		}
 		setBatchCode(StringUtilB2C.getStr(value).trim());
 	}
 
@@ -704,7 +701,7 @@ public class ReleaseProductByBatch implements Serializable {
 	public void setReserveByExcel(Object value) {
 		setReserveStr(StringUtilB2C.getStr(value));
 		if (StringUtils.isEmpty(value) || !RegexConstant.isNumber(value.toString())) {
-			setReserve(DoubleConstant.zero);
+			addErrmsg(ErrorInfoConstant.RESERVE_NUMBER_INFO.getInfo());
 		} else {
 			Double reserve = Double.valueOf(value.toString());
 			if (reserve % 1 != 0) {
@@ -1485,20 +1482,17 @@ public class ReleaseProductByBatch implements Serializable {
 
 	public Goods releaseProductByBatchConvertToGoods(ReleaseProductByBatch releaseProductByBatch) {
 		Goods goods = new Goods();
-		goods.setBrandNameCn(releaseProductByBatch.getBrandNameEn());
+		goods.setBrandNameEn(releaseProductByBatch.getBrandNameEn());
 		goods.setCurrencyName(releaseProductByBatch.getCurrency());
 		goods.setCode(releaseProductByBatch.getCode());
 		goods.setCreatedDate(new Date());
 		goods.setUpdateDate(new Date());
 		goods.setMinDelivery(releaseProductByBatch.getSelfMinDelivery());
 		goods.setMaxDelivery(releaseProductByBatch.getSelfMaxDelivery());
-//		goods.setSelfDeliveryDemMaxTime(releaseProductByBatch.getDeliveryDemMaxTime());
-//		goods.setSelfDeliveryDemMinTime(releaseProductByBatch.getDeliveryDemMinTime());
-//		goods.setSelfDeliveryHKMaxTime(releaseProductByBatch.getDeliveryHKMaxTime());
-//		goods.setSelfDeliveryHKMinTime(releaseProductByBatch.getDeliveryHKMinTime());
 		goods.setProduceDate(releaseProductByBatch.getProductDate());
 		goods.setPublisherUU(releaseProductByBatch.getPublisherUu());
 		goods.setPublisherName(releaseProductByBatch.getPublisherName());
+		goods.setPublishPhone(releaseProductByBatch.getPublisherTel());
 		goods.setMinBuyQty(releaseProductByBatch.getMinBuyQty());
 		goods.setMinPackQty(releaseProductByBatch.getMinPackage());
 		goods.setUuid(releaseProductByBatch.getComponentUuId());
@@ -1508,12 +1502,12 @@ public class ReleaseProductByBatch implements Serializable {
 		goods.setRmbTaxRate(releaseProductByBatch.getRmbTaxRate());
 		goods.setUsdTaxRate(releaseProductByBatch.getUsdTaxRate());
 		goods.setReserve(releaseProductByBatch.getReserve());
-		goods.setPublishPhone(releaseProductByBatch.getPublisherTel());
 		goods.setReturnInWeek(releaseProductByBatch.getReturnInWeek());
 		goods.setShipArea(releaseProductByBatch.getShipArea());
 		goods.setSampleQty(releaseProductByBatch.getSampleqty());
 		goods.setKindNameCn(releaseProductByBatch.getKindName());
 		goods.setImg(releaseProductByBatch.getImg());
+		goods.setProductid(releaseProductByBatch.getProductid());
 		return goods;
 	}
 

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/GoodsService.java

@@ -65,6 +65,13 @@ public interface GoodsService {
      */
     Goods findGoodsByBatchCode(String code);
 
+    /**
+     * 在售产品批次号
+     * @param batchCodes 批次号
+     * @return List<Goods>
+     */
+    List<Goods> findGoodsByBatchCodes(List<String> batchCodes);
+
     /**
      * 根据uuid查找简单货物信息
      *

+ 4 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/InOutboundDetailService.java

@@ -1,11 +1,10 @@
 package com.uas.platform.b2c.prod.commodity.service;
 
 import com.uas.platform.b2c.logistics.model.InvoiceDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
 import com.uas.platform.b2c.prod.commodity.model.InOutboundDetail;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -26,4 +25,7 @@ public interface InOutboundDetailService {
      * @return
      */
     Set<InOutboundDetail> produceInOutboundDetailByInvoiceDetail(Set<InvoiceDetail> details);
+
+
+    Map<String, Set<InOutboundDetail>> initInOutboundDetailByQty (Set<InOutboundDetail> newInOutboundDetail);
 }

+ 1 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -341,9 +341,8 @@ public interface ProductService {
      * @param reList 临时表的id
      * @param ignoreImport 1表示忽略导入,0代表覆盖导入
      * @param newInOutboundDetail 出入库明细
-     * @param inOutMap 出入库的map
      */
-    void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail, Map<String, Set<InOutboundDetail>> inOutMap);
+    void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail);
 
 
     /**

+ 35 - 5
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/CommodityInOutboundServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.commodity.service.impl;
 
+import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.NumberUtil;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
@@ -30,6 +31,7 @@ import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
@@ -178,27 +180,47 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
                 }
                 prids.add(inOutboundDetail.getProductId());
             }
+            User user = SystemSession.getUser();
             String inOutboundId = createNumberService.generateOrderNumber(com.uas.platform.b2c.core.constant.EncodingRulesConstant.INOUTBOUND_NUM, "trade$commodity_in_outbound", 8);
             CommodityInOutbound inOutbound = new CommodityInOutbound(type);
             inOutbound.setInOutId(inOutboundId);
             Short i = 1;
             Set<InOutboundDetail> set = new HashSet<>();
+            Set<Product> productSet = new HashSet<>();
             if (CollectionUtils.isNotEmpty(prids)) {
                 List<Product> products = productService.findByProductId(prids);
                 for (InOutboundDetail inOutboundDetail : detaiList) {
                     for (Product product : products) {
+                        if (user.getEnterprise().getUu().longValue() != product.getEnUU().longValue()) {
+                            throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"不属于本公司,不能做出入库");
+                        }
                         if (inOutboundDetail.getProductId().longValue() == product.getId().longValue()) {
                             if (InOutBoundType.INBOUND.equals(type) || InOutBoundType.OTHER_INBOUND.equals(type) || InOutBoundType.PURCHASE_INBOUND.equals(type)) {
+                                //只有入库会影响成本单价
+                                Double totalQty = 0.0d;
+                                Double price = 0.0d;
+                                if (NumberUtil.compare(product.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) > 0) {
+                                    price = NumberUtil.add(price, NumberUtil.mul(product.getErpReserve(), product.getPrice()));
+                                    totalQty = NumberUtil.add(totalQty, product.getErpReserve());
+                                }
+                                if (NumberUtil.compare(inOutboundDetail.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(inOutboundDetail.getQty(), DoubleConstant.zero) > 0) {
+                                    price = NumberUtil.add(price, NumberUtil.mul(inOutboundDetail.getPrice(),inOutboundDetail.getQty()));
+                                    totalQty = NumberUtil.add(totalQty, inOutboundDetail.getQty());
+                                }
+                                if (NumberUtil.compare(totalQty, DoubleConstant.zero) > 0) {
+                                    product.setPrice(NumberUtil.div(price, totalQty));
+                                }
                                 product.setErpReserve(NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty()));
+                                productSet.add(product);
                             } else {
                                 //出库
                                 if (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) == 0) {
-                                    break;
-                                } else if (NumberUtil.compare(product.getErpReserve(), inOutboundDetail.getQty()) > 0) {
+                                    throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"的物料为0,不能做出库");
+                                } else if (NumberUtil.compare(product.getErpReserve(), inOutboundDetail.getQty()) > -1) {
                                     product.setErpReserve(NumberUtil.sub(product.getErpReserve(), inOutboundDetail.getQty()));
+                                    productSet.add(product);
                                 } else {
-                                    inOutboundDetail.setQty(product.getErpReserve());
-                                    product.setErpReserve(DoubleConstant.zero);
+                                    throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"的物料库存数为"+product.getErpReserve() + "出库数是:"+inOutboundDetail.getQty()+"不能做出库");
                                 }
 
                             }
@@ -227,7 +249,14 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
             //重新计算成本价、在售产品的库存信息需要更新
             List<Long> pridList = new ArrayList<>();
             pridList.addAll(prids);
-            productService.updateProductsByInBound(pridList);
+            List<Product> productList = new ArrayList<>();
+            productList.addAll(productSet);
+            if (CollectionUtils.isNotEmpty(productList)) {
+                productService.save(productList);
+            }
+            if (CollectionUtils.isNotEmpty(pridList)) {
+                productService.updateProductsByInBound(pridList);
+            }
             return ResultMap.success(commodityInOutbound);
         }
     }
@@ -247,6 +276,7 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
         final PageInfo info = new PageInfo(params);
         Long enuu = SystemSession.getUser().getEnterprise().getUu();
         info.filter("enuu", enuu);
+        info.sorting("createTime", Sort.Direction.DESC);
         if (fromDate != null) {
             info.expression(PredicateUtils.gte("createTime", new Date(fromDate), false));
         }

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

@@ -376,7 +376,26 @@ public class GoodsServiceImpl implements GoodsService {
 
     @Override
     public Goods findGoodsByBatchCode(String code) {
-        return goodsDao.findByBatchCode(code);
+        if (StringUtils.isEmpty(code)) {
+            return null;
+        } else {
+            return goodsDao.findByBatchCode(code);
+        }
+    }
+
+    /**
+     * 在售产品批次号
+     *
+     * @param batchCodes 批次号
+     * @return List<Goods>
+     */
+    @Override
+    public List<Goods> findGoodsByBatchCodes(List<String> batchCodes) {
+        if (CollectionUtils.isEmpty(batchCodes)) {
+            return new ArrayList<>();
+        } else {
+            return goodsDao.findByBatchCodes(batchCodes);
+        }
     }
 
     @Override
@@ -597,10 +616,9 @@ public class GoodsServiceImpl implements GoodsService {
         goods.setReserve(goods);
         if (NumberUtil.compare(goods.getMinPackQty(), DoubleConstant.zero) < 1) {
             goods.setMinPackQty(DoubleConstant.minReserve);
-            goods.setMinBuyQty();
         }
+        goods.setMinBuyQty();
         goods.setPerQty();
-        goods.setStatus();
         // 设置货到香港,货到大陆的延长时间
         if (goods.getMinDelivery() != null || goods.getMaxDelivery() != null) {
             setB2CDelayTime(goods);
@@ -612,6 +630,7 @@ public class GoodsServiceImpl implements GoodsService {
         goods.setWithOutTaxUSDPrice();
         // 计算本批最小价格
         goods.setMaxAndMinPrice();
+        goods.setStatus();
     }
 
 
@@ -4011,20 +4030,9 @@ public class GoodsServiceImpl implements GoodsService {
                 goods.setMinPackQty(product.getMinPackQty());
                 goods.setPackaging(product.getPackaging());
                 goods.setMinBuyQty();
-                if (goods.getAutoPublish() == null) {
-                    goods.setAutoPublish(Boolean.TRUE);
-                }
-                if (goods.getAutoPublish()) {
-                    if (StringUtils.isEmpty(goods.getPackaging()) || StringUtils.isEmpty(goods.getProduceDate()) || (goods.getMinBuyQty() == null) || (goods.getMinPackQty() == null) || (goods.getB2cMaxDelivery() == null) || (goods.getB2cMinDelivery() == null) || StringUtils.isEmpty(goods.getQtyPrice())) {
-                        //做未上架处理
-                        goods.setStatus(Status.NO_SHELVE.value());
-                    } else {
-                        //如果信息填写全,默认上架
-                        goods.setStatus((NumberUtil.compare(goods.getReserve(), goods.getMinBuyQty()) > -1) ? Status.AVAILABLE.value() : Status.UNAVAILABLE.value());
-                    }
-                } else {
-                    goods.setStatus(Status.NO_SHELVE.value());
-                }
+                goods.setPerQty();
+                goods.adjustFragmentPrice();
+                goods.setStatus();
                 GoodsHistory history = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Update.getPhrase(), false);
                 list.add(history);
             }

+ 27 - 6
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/InOutboundDetailServiceImpl.java

@@ -1,19 +1,17 @@
 package com.uas.platform.b2c.prod.commodity.service.impl;
 
+import com.uas.platform.b2c.core.utils.NumberUtil;
 import com.uas.platform.b2c.logistics.model.InvoiceDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
+import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.model.InOutboundDetail;
 import com.uas.platform.b2c.prod.commodity.dao.InOutboundDetailDao;
 import com.uas.platform.b2c.prod.commodity.service.InOutboundDetailService;
+import com.uas.platform.b2c.prod.commodity.type.InOutBoundType;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * description
@@ -66,4 +64,27 @@ public class InOutboundDetailServiceImpl implements InOutboundDetailService {
         }
         return inOutBoundset;
     }
+
+    public Map<String, Set<InOutboundDetail>> initInOutboundDetailByQty (Set<InOutboundDetail> newInOutboundDetail) {
+        Map<String, Set<InOutboundDetail>> inOutMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
+            Set<InOutboundDetail> inBoundDetail = new HashSet<>();
+            Set<InOutboundDetail> outBoundDetail = new HashSet<>();
+            for (InOutboundDetail detail1 : newInOutboundDetail) {
+                if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) < 0) {
+                    detail1.setQty(Math.abs(detail1.getQty()));
+                    outBoundDetail.add(detail1);
+                } else if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) > 0) {
+                    inBoundDetail.add(detail1);
+                }
+            }
+            if (CollectionUtils.isNotEmpty(inBoundDetail)) {
+                inOutMap.put(InOutBoundType.OTHER_INBOUND, inBoundDetail);
+            }
+            if (CollectionUtils.isNotEmpty(outBoundDetail)) {
+                inOutMap.put(InOutBoundType.OTHER_OUTBOUND, outBoundDetail);
+            }
+        }
+        return inOutMap;
+    }
 }

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

@@ -24,7 +24,6 @@ import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
 import com.uas.platform.b2c.prod.commodity.dao.*;
 import com.uas.platform.b2c.prod.commodity.model.*;
 import com.uas.platform.b2c.prod.commodity.service.*;
-import com.uas.platform.b2c.prod.commodity.type.InOutBoundType;
 import com.uas.platform.b2c.prod.commodity.type.ProductConstant;
 import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
@@ -52,6 +51,7 @@ import com.uas.platform.b2c.trade.presale.model.GoodsBrowsingHistory;
 import com.uas.platform.b2c.trade.presale.service.CartService;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
+import com.uas.platform.b2c.trade.util.BoundedExecutor;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
@@ -92,6 +92,8 @@ import java.sql.Statement;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * Created by wangyc on 2017/5/26.
@@ -209,6 +211,11 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private UserDao userDao;
 
+    /**
+     * 控制任务提交速度的线程池
+     */
+    private final BoundedExecutor executor;
+
     @Autowired
     private SearchService searchService;
 
@@ -221,12 +228,18 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private ProductPrivateService productPrivateService;
 
-    @Autowired
-    private CommonDao commonDao;
+    private final CommonDao commonDao;
 
     @Autowired
     private InOutboundDetailService inOutboundDetailService;
 
+    @Autowired
+    public ProductServiceImpl(CommonDao commonDao) {
+        this.commonDao = commonDao;
+        ExecutorService executorService = Executors.newCachedThreadPool();
+        executor = new BoundedExecutor(executorService, 1600);
+    }
+
     private ConcurrentHashMap<String, Field> sortFields = new ConcurrentHashMap<String, Field>();
 
     @Override
@@ -490,7 +503,8 @@ public class ProductServiceImpl implements ProductService {
         for (V_ProductPrivate product : productList) {
             List<Goods> goodsList = goodsDao.findByProductIdOrderByGoodsId(product.getId());
             if (!CollectionUtils.isEmpty(goodsList)) {
-                resultList.addAll(goodsList);
+                //目前现在一颗物料只能存在一个在售产品,目前取id最大的在售产品信息
+                resultList.add(goodsList.get(0));
             } else {
                 Goods g = Goods.productConvertGoods(product);
                 resultList.add(g);
@@ -1762,7 +1776,7 @@ public class ProductServiceImpl implements ProductService {
                 } else {
                     persistProduct.setSpec((String) specResultMap.getData());
                 }
-                if (productPrivate.getStandard() == IntegerConstant.NO_SHORT) {
+                if (productPrivate.getStandard() == IntegerConstant.NO_SHORT || StringUtils.isEmpty(productPrivate.getCmpUuId())) {
                     Component component = findBybrNameAndcmpCode(productPrivate.getPbranden(), productPrivate.getPcmpcode());
                     if (component != null) {
                         //更新物料信息
@@ -1973,11 +1987,8 @@ public class ProductServiceImpl implements ProductService {
                 productPrivate.setAttach(component.getAttach());
                 productPrivateDao.save(productPrivate);
             } else {
-                ProductPrivate productPrivate = new ProductPrivate();
+                ProductPrivate productPrivate = new ProductPrivate(product.getId());
                 productPrivate.setAttach(component.getAttach());
-                productPrivate.setPrId(product.getId());
-                productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
-                productPrivate.setBatchCount(IntegerConstant.NO_SHORT);
                 productPrivateDao.save(productPrivate);
             }
         }
@@ -1999,39 +2010,59 @@ public class ProductServiceImpl implements ProductService {
             return new ResultMap(CodeType.OK, "");
         } else {
             if ((!StringUtils.isEmpty(component.getSpec())) || (!StringUtils.isEmpty(component.getAttach()))) {
-                List<Product> productList = productDao.findByCmpUuId(component.getUuid());
-                List<ProductPrivate> productPrivatelist = new ArrayList<>();
-                List<Product> list = new ArrayList<>();
-                for (Product product : productList) {
-                    if (!StringUtils.isEmpty(component.getAttach())) {
-                        List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(product.getId());
-                        if (CollectionUtils.isNotEmpty(productPrivates)) {
-                            ProductPrivate productPrivate = productPrivates.get(0);
-                            productPrivate.setAttach(component.getAttach());
-                            productPrivatelist.add(productPrivate);
-                        } else {
-                            ProductPrivate productPrivate = new ProductPrivate();
-                            productPrivate.setAttach(component.getAttach());
-                            productPrivate.setPrId(product.getId());
-                            productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
-                            productPrivate.setBatchCount(IntegerConstant.NO_SHORT);
-                            productPrivatelist.add(productPrivate);
-                        }
-                    }
 
-                    if (StringUtils.isEmpty(product.getSpec()) && !StringUtils.isEmpty(component.getSpec())) {
-                        product.setSpec(component.getSpec());
-                        list.add(product);
+                final Runnable runnable = new Runnable() {
+                    @Override
+                    public void run() {
+                        List<Product> productList = productDao.findByCmpUuId(component.getUuid());
+                        List<Product> list = new ArrayList<>();
+                        List<Long> ids = new ArrayList<>();
+                        for (Product product : productList) {
+                            if (!StringUtils.isEmpty(component.getAttach())) {
+                                ids.add(product.getId());
+                            }
+                            if (StringUtils.isEmpty(product.getSpec()) && !StringUtils.isEmpty(component.getSpec())) {
+                                product.setSpec(component.getSpec());
+                                list.add(product);
+                            }
+                        }
+                        if (CollectionUtils.isNotEmpty(ids)) {
+                            List<ProductPrivate> productPrivates = productPrivateDao.findByPrIds(ids);
+                            boolean isExist = false;
+                            List<ProductPrivate> productPrivatelist = new ArrayList<>();
+                            for (Long id : ids) {
+                                isExist = false;
+                                for (ProductPrivate productPrivate : productPrivates) {
+                                    if (id.longValue() == productPrivate.getPrId().longValue()) {
+                                        productPrivate.setAttach(component.getAttach());
+                                        productPrivatelist.add(productPrivate);
+                                        isExist = true;
+                                        break;
+                                    }
+                                }
+                                if (!isExist) {
+                                    ProductPrivate productPrivate = new ProductPrivate(id);
+                                    productPrivate.setAttach(component.getAttach());
+                                    productPrivatelist.add(productPrivate);
+                                }
+                            }
+                            if (CollectionUtils.isNotEmpty(productPrivatelist)) {
+                                productPrivateDao.save(productPrivatelist);
+                            }
+                        }
+                        if (CollectionUtils.isNotEmpty(list)) {
+                            productDao.save(list);
+                        }
+                        goodsService.updateGoodsByComponent(component);
                     }
+                };
+                try {
+                    executor.submitTask(runnable);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
                 }
-                if (CollectionUtils.isNotEmpty(productPrivatelist)) {
-                    productPrivateDao.save(productPrivatelist);
-                }
-                if (CollectionUtils.isNotEmpty(list)) {
-                    productDao.save(list);
-                }
 
-                goodsService.updateGoodsByComponent(component);
+
                 return ResultMap.success("");
             } else {
                 return ResultMap.success("");
@@ -2159,7 +2190,7 @@ public class ProductServiceImpl implements ProductService {
                             ps.setObject(11, t.getB2cBranden());
                             ps.setObject(12, t.getBrandId());
                             ps.setObject(13, t.getBranduuid());
-                            ps.setObject(14, (t.getComponentUuId() == null ? 0 : 1));
+                            ps.setObject(14, (StringUtilB2C.isEmpty(t.getComponentUuId()) ? 0 : 1));
                             ps.setObject(15, new Date(System.currentTimeMillis()));
                             ps.setObject(16, t.getSpec());
                             ps.setObject(17, t.getKindName());
@@ -2188,9 +2219,9 @@ public class ProductServiceImpl implements ProductService {
         if (fromDate == null || toDate == null) {
             //统计所有的未审核的品牌信息
             Map<String, Integer> map = new HashedMap();
-            Integer productAmout = jdbcTemplate.queryForInt("select count(1) from products p left join product$private pp on p.pr_id = pp.pr_id  where pp.pr_b2cenabled = 1;");
+            Integer productAmout = jdbcTemplate.queryForInt("select count(1) from products p join product$private pp on p.pr_id = pp.pr_id  where pp.pr_b2cenabled = 1;");
             map.put("productAmout", productAmout);
-            Integer productUserAmout = jdbcTemplate.queryForInt("select count(DISTINCT pr_enuu) from products p left join product$private pp on p.pr_id = pp.pr_id  where pp.pr_b2cenabled = 1;");
+            Integer productUserAmout = jdbcTemplate.queryForInt("select count(DISTINCT pr_enuu) from products p join product$private pp on p.pr_id = pp.pr_id  where pp.pr_b2cenabled = 1;");
             map.put("productUserAmout", productUserAmout);
             return ResultMap.success(map);
         } else {
@@ -2198,9 +2229,9 @@ public class ProductServiceImpl implements ProductService {
             Date toT = new Date(toDate);
             SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             Map<String, Integer> map = new HashedMap();
-            Integer productAmout = jdbcTemplate.queryForInt("select count(1) from products p left join product$private pp on p.pr_id = pp.pr_id  where pr_create_time < '" + dateFormat.format(toT) + "' and pr_create_time > '" + dateFormat.format(fromT) + "' and pp.pr_b2cenabled = 1;");
+            Integer productAmout = jdbcTemplate.queryForInt("select count(1) from products p join product$private pp on p.pr_id = pp.pr_id  where pr_create_time < '" + dateFormat.format(toT) + "' and pr_create_time > '" + dateFormat.format(fromT) + "' and pp.pr_b2cenabled = 1;");
             map.put("productAmout", productAmout);
-            Integer productUserAmout = jdbcTemplate.queryForInt("select count(DISTINCT pr_enuu) from products p left join product$private pp on p.pr_id = pp.pr_id  where pr_create_time < '" + dateFormat.format(toT) + "' and pr_create_time > '" + dateFormat.format(fromT) + "' and pp.pr_b2cenabled = 1;");
+            Integer productUserAmout = jdbcTemplate.queryForInt("select count(DISTINCT pr_enuu) from products p join product$private pp on p.pr_id = pp.pr_id  where pr_create_time < '" + dateFormat.format(toT) + "' and pr_create_time > '" + dateFormat.format(fromT) + "' and pp.pr_b2cenabled = 1;");
             map.put("productUserAmout", productUserAmout);
             return ResultMap.success(map);
         }
@@ -2213,10 +2244,9 @@ public class ProductServiceImpl implements ProductService {
      * @param reList       临时表的id
      * @param ignoreImport 1表示忽略导入,0代表覆盖导入
      * @param newInOutboundDetail 需要确定的出入库
-     * @param inOutMap 出入库的map
      */
     @Override
-    public void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail, Map<String, Set<InOutboundDetail>> inOutMap) {
+    public void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail) {
         if (CollectionUtils.isEmpty(prIds) || CollectionUtils.isEmpty(reList)) {
             return ;
         }
@@ -2229,7 +2259,7 @@ public class ProductServiceImpl implements ProductService {
                         !productByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
                     continue;
                 }
-                if ((productByBatch.getId() != null) &&(productByBatch.getId().longValue() == product.getId().longValue()) ) {
+                if ((productByBatch.getProductid() != null) &&(productByBatch.getProductid().longValue() == product.getId().longValue()) ) {
                     // ignoreImport 1表示忽略导入,0代表覆盖导入
                     if (StringUtils.isEmpty(product.getPackaging()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
                         product.setPackaging(productByBatch.getPackaging());
@@ -2244,7 +2274,7 @@ public class ProductServiceImpl implements ProductService {
                     if (StringUtils.isEmpty(product.getSpec()) || (ignoreImport == IntegerConstant.NO_SHORT)) {
                         product.setSpec(productByBatch.getSpec());
                     }
-                    if ((ignoreImport == IntegerConstant.NO_SHORT) || (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) == 0)) {
+                    if ((ignoreImport == IntegerConstant.NO_SHORT) || (NumberUtil.compare(product.getErpReserve(), productByBatch.getReserve()) != 0)) {
                         Double qty = NumberUtil.sub(productByBatch.getReserve(), product.getErpReserve());
                         if (NumberUtil.compare(qty, DoubleConstant.zero) != 0) {
                             //做出入库记录
@@ -2260,24 +2290,6 @@ public class ProductServiceImpl implements ProductService {
             }
         }
         productDao.save(freshProducts);
-        if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
-            Set<InOutboundDetail> inBoundDetail = new HashSet<>();
-            Set<InOutboundDetail> outBoundDetail = new HashSet<>();
-            for (InOutboundDetail detail1 : newInOutboundDetail) {
-                if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) < 0) {
-                    detail1.setQty(Math.abs(detail1.getQty()));
-                    outBoundDetail.add(detail1);
-                } else if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) > 0) {
-                    inBoundDetail.add(detail1);
-                }
-            }
-            if (CollectionUtils.isNotEmpty(inBoundDetail)) {
-                inOutMap.put(InOutBoundType.OTHER_INBOUND, inBoundDetail);
-            }
-            if (CollectionUtils.isNotEmpty(outBoundDetail)) {
-                inOutMap.put(InOutBoundType.OTHER_OUTBOUND, outBoundDetail);
-            }
-        }
     }
 
 
@@ -2292,62 +2304,13 @@ public class ProductServiceImpl implements ProductService {
             return;
         } else {
             List<Product> products = productDao.findProductInId(prids);
-            Set<Long> idSet = new HashSet<>();
-            idSet.addAll(prids);
-            List<InOutboundDetail> inOutboundDetails = inOutboundDetailService.findByProductId(idSet);
-            Map<Long, List<Double>> map = new HashMap<>();
-            Double qtyContainPrice = 0.0d;
-            Double qty = 0.0d;
-            Double totalPrice = 0.0d;
-            List<Double> doubleList = null;
-            for (InOutboundDetail inOutboundDetail : inOutboundDetails) {
-                doubleList = map.get(inOutboundDetail.getProductId());
-                qtyContainPrice = 0.0d; qty = 0.0d; totalPrice = 0.0d;
-                if (doubleList == null) {
-                    doubleList = new ArrayList<>();
-                    doubleList.add(qtyContainPrice);
-                    doubleList.add(qty);
-                    doubleList.add(totalPrice);
-                } else {
-                    qtyContainPrice = doubleList.get(0);
-                    qty = doubleList.get(1);
-                    totalPrice = doubleList.get(2);
-                }
-                if (InOutBoundType.INBOUND.equals(inOutboundDetail.getCommodityInOutbound().getType())) {
-                    qty = NumberUtil.add(qty, inOutboundDetail.getQty());
-                    if (inOutboundDetail.getPrice() != null) {
-                        qtyContainPrice = NumberUtil.add(qtyContainPrice, inOutboundDetail.getQty());
-                        totalPrice = NumberUtil.add(totalPrice, NumberUtil.mul(inOutboundDetail.getPrice(), inOutboundDetail.getQty()));
-                    }
-                } else {
-                    qty = NumberUtil.sub(qty, inOutboundDetail.getQty());
-                }
-                doubleList.set(0, qtyContainPrice);
-                doubleList.set(1, qty);
-                doubleList.set(2, totalPrice);
-                map.put(inOutboundDetail.getProductId(), doubleList);
-            }
-
-            for (Product product : products) {
-                List<Double> list = map.get(product.getId());
-                if (CollectionUtils.isNotEmpty(list)) {
-                    qty = list.get(1);
-                    if (NumberUtil.compare(qty, DoubleConstant.zero) < 1) {
-                        product.setErpReserve(DoubleConstant.zero);
-                    } else {
-                        product.setErpReserve(qty);
-                    }
-                    double price = NumberUtil.div(list.get(2), list.get(0));
-                    product.setPrice(price);
-                }
-            }
-
             List<Goods> goodsList = goodsService.findByProductids(prids);
             for (Product product : products) {
                 for (Goods goods : goodsList) {
                     if (goods.getProductid().longValue() == product.getId().longValue()) {
                         goods.setReserve(product.getErpReserve());
                         goods.setStatus();
+                        break;
                     }
                 }
             }
@@ -2387,8 +2350,9 @@ public class ProductServiceImpl implements ProductService {
             for (Integer id : list) {
                 prids.add(Long.valueOf(id));
             }
-            List<Product> products = productDao.findProductInId(prids);
-            return products;
+            if (CollectionUtils.isNotEmpty(prids)) {
+                return productDao.findProductInId(prids);
+            }
         }
         return new ArrayList<>();
     }

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

@@ -142,6 +142,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	@Autowired
 	private CommodityInOutboundService commodityInOutboundService;
 
+	@Autowired
+	private InOutboundDetailService inOutboundDetailService;
+
+
 	private final Logger logger = Logger.getLogger(getClass());
 
 	/**
@@ -257,8 +261,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 						releaseProductByBatch.setReleaseCode(ReleaseStatus.lack_info.value());
 						releaseProductByBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
 					}
-					// 简单验证数据,防止空行保存的情况(品牌、类目、型号)
-					if (blankNum != 3) {
+					// 简单验证数据,防止空行保存的情况(品牌、类目、型号、庫存信息)
+					if (blankNum != 4) {
 						total++;
 						releaseProductByBatchs.add(releaseProductByBatch);
 					}
@@ -297,7 +301,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                 success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
             }
 		}
-		if (!isAPerson) {
+		if (!isAPerson && !isPcb) {
 			String publish = publishByBatch(batch, isPcb, ignoreImport);
 			modelMap.put("publish", publish);
 		}
@@ -425,9 +429,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			Object skuObj = readWorkBookCell(row.getCell(ModifyConstant.SKU_CODE), Cell.CELL_TYPE_STRING,
 					r, ModifyConstant.SKU_CODE);
 			aBatch.setBatchCodeByExcel(skuObj);
-			if (!validateBatchCode(aBatch.getBatchCode(), aBatch)) {
-				aBatch.addErrmsg(ErrorInfoConstant.BATCH_ERROR.getInfo());
-			}
 
 			Object sellObj = readWorkBookCell(row.getCell(ModifyConstant.SALE_METHOD), Cell.CELL_TYPE_STRING,
 					r, ModifyConstant.SALE_METHOD);
@@ -454,21 +455,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
 			} else {
 				// 导入成功的需要判断自定义标签是否重复
-				if (CollectionUtils.isNotEmpty(batchList) && aBatch.getTag() != null) {
-					if (validateTagInfo(aBatch, batchList)) {
-						aBatch.setTag(null);
-					}
-				}
+//				if (CollectionUtils.isNotEmpty(batchList) && aBatch.getTag() != null) {
+//					if (validateTagInfo(aBatch, batchList)) {
+//						aBatch.setTag(null);
+//					}
+//				}
 				validateRepeatInExcel(batchList, aBatch, true);
 			}
 			batchList.add(aBatch);
 			total++;
 		}
+		int success = goodsFillDataToExcelAndUpdate(batchList);
 		Long userUU = SystemSession.getUser().getUserUU();
-		Long enUU = SystemSession.getUser().getEnterprise().getUu();
-		resetRepeatData(batchList, true, false);
-		setDefaultTag(batchList);
-		int success = modifyGoodsByBatch(batchList);
+//		Long enUU = SystemSession.getUser().getEnterprise().getUu();
+//		resetRepeatData(batchList, true, false);
+//		setDefaultTag(batchList);
 		commonDao.save(batchList, ReleaseProductByBatch.class);
 		Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
 		modelMap.put("total", total);
@@ -479,6 +480,77 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		return modelMap;
 	}
 
+	/**
+	 * 根据批次号设置需要被修改的信息
+	 * @param batchList
+	 */
+	private Integer goodsFillDataToExcelAndUpdate(List<ReleaseProductByBatch> batchList) {
+		int result = 0;
+		if (CollectionUtils.isEmpty(batchList)) {
+			return result;
+		}
+		List<String> batchCodes = new ArrayList<>();
+		for (ReleaseProductByBatch aBatch : batchList) {
+			if (!StringUtilB2C.isEmpty(aBatch.getBatchCode())) {
+				batchCodes.add(aBatch.getBatchCode());
+			}
+		}
+
+		List<Goods> goodses = new ArrayList<>();
+		if (CollectionUtils.isNotEmpty(batchCodes)) {
+			goodses = goodsService.findGoodsByBatchCodes(batchCodes);
+		}
+		Goods newGoods = null;
+		List<GoodsHistory> goodsHistoryList = new ArrayList<>();
+		for (ReleaseProductByBatch aBatch : batchList) {
+			newGoods = null;
+			for (Goods goods : goodses) {
+				if (goods.getBatchCode().equals(aBatch.getBatchCode())) {
+					aBatch.setB2cBranden(goods.getBrandNameEn());
+					aBatch.setBrandNameEn(goods.getBrandNameEn());
+					aBatch.setKindName(goods.getKindNameCn());
+					aBatch.setB2cCode(goods.getCode());
+					aBatch.setCode(goods.getCode());
+					aBatch.setCurrency(goods.getCurrencyName());
+					if (goods.getUuid() == null) {
+						aBatch.setReleaseCode(ReleaseStatus.failure.value());
+						aBatch.setReleaseStatus(ReleaseStatus.failure.getPhrase());
+					}
+					fillInGoods(goods, aBatch);
+					newGoods = goods;
+					break;
+				}
+			}
+			if (newGoods == null) {
+				newGoods = new Goods();
+				TradeDeliveryDelayTime delayTime = getDelayTime(aBatch);
+				newGoods.setGoodsByReleaseProductByBatch(aBatch, delayTime);
+				goodsHistoryList.add(goodsHistoryService.converTGoodsHist(newGoods, GoodsHistory.OperateType.Publish.getPhrase(), false));
+			}
+			ResultMap resultMap = goodsService.updateGoods(newGoods);
+			if (resultMap.isSuccess()) {
+				Goods goods1 = (Goods) resultMap.getData();
+				if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
+					ResultMap offMap = goodsService.offShelfGoodsByProvider(newGoods.getBatchCode(), null, false);
+					if (offMap.isSuccess()) {
+						result++;
+					} else {
+						aBatch.setErrmsg(offMap.getMessage());
+						aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
+						aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
+					}
+				} else {
+					result++;
+				}
+			} else {
+				aBatch.setErrmsg(resultMap.getMessage());
+				aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
+				aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
+			}
+		}
+		return result;
+	}
+
 	/**
 	 * 给自定义标签为空的batch设置默认自定义标签
 	 * @param batchList
@@ -622,21 +694,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				rowNum, ModifyConstant.PRODUCT_SPEC);
 		aProduct.setSpec(StringUtilB2C.getStr(specValue));
 
-		Cell productCell = row.getCell(ModifyConstant.PRODUCE_DATE);
-		if (productCell != null && productCell.getCellType() == 0) {
-			if (HSSFDateUtil.isCellDateFormatted(productCell)) {
-				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-				String productStr = sdf.format(productCell.getDateCellValue());
-				aProduct.setProductDateByExcel(productStr);
-			} else {
-				aProduct.setProductDateByExcel(readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
-						rowNum, ModifyConstant.PRODUCE_DATE));
-			}
-		} else {
-			Object produceValue = readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
-					rowNum, ModifyConstant.PRODUCE_DATE);
-			aProduct.setProductDateByExcel(produceValue);
-		}
+//		Cell productCell = row.getCell(ModifyConstant.PRODUCE_DATE);
+//		if (productCell != null && productCell.getCellType() == 0) {
+//			if (HSSFDateUtil.isCellDateFormatted(productCell)) {
+//				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//				String productStr = sdf.format(productCell.getDateCellValue());
+//				aProduct.setProductDateByExcel(productStr);
+//			} else {
+//				aProduct.setProductDateByExcel(readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
+//						rowNum, ModifyConstant.PRODUCE_DATE));
+//			}
+//		} else {
+//			Object produceValue = readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
+//					rowNum, ModifyConstant.PRODUCE_DATE);
+//			aProduct.setProductDateByExcel(produceValue);
+//		}
 
 		Object packageMethodValue = readWorkBookCell(row.getCell(ModifyConstant.PACKAGE_METHOD), Cell.CELL_TYPE_STRING,
 				rowNum, ModifyConstant.PACKAGE_METHOD);
@@ -677,52 +749,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
             aProduct.setReserveByExcel(reserveValue);
         }
 
-		Object statusValue = readWorkBookCell(row.getCell(ModifyConstant.SALE_STATUS), Cell.CELL_TYPE_STRING,
-				rowNum, ModifyConstant.SALE_STATUS);
+		Object statusValue = readWorkBookCell(row.getCell(ModifyConstant.COST_PRICE), Cell.CELL_TYPE_STRING,
+				rowNum, ModifyConstant.COST_PRICE);
         if (!StringUtils.isEmpty(statusValue)) {
-            aProduct.setStatusByExcel(statusValue);
+            aProduct.setCostPriceByExcel(statusValue);
         }
 
-		Object tagValue = readWorkBookCell(row.getCell(ModifyConstant.CUSTOM_LABEL), Cell.CELL_TYPE_STRING,
-				rowNum, ModifyConstant.CUSTOM_LABEL);
-        if (!StringUtils.isEmpty(tagValue)) {
-            aProduct.setTagByExcel(tagValue.toString().trim());
-        }
-		// 自定义标签不为null,则检查是否重复
-		if (aProduct.getCode() != null && aProduct.getBrandNameEn() != null && aProduct.getTag() != null) {
-			resetTag(aProduct);
-		}
-	}
-
-	/**
-	 * 验证批次号是否正确,并为该公司下的goods
-	 * @param batchCode
-	 * @param aBatch
-	 * @return
-	 */
-	private boolean validateBatchCode(String batchCode, ReleaseProductByBatch aBatch) {
-		if (StringUtils.isEmpty(batchCode)) {
-			return false;
-		}
-		Goods goods = goodsDao.findByBatchCode(batchCode);
-		if (goods == null) {
-			return false;
-		}
-		aBatch.setB2cBranden(goods.getBrandNameEn());
-		aBatch.setBrandNameEn(goods.getBrandNameEn());
-		aBatch.setKindName(goods.getKindNameCn());
-		aBatch.setB2cCode(goods.getCode());
-		aBatch.setCode(goods.getCode());
-		aBatch.setCurrency(goods.getCurrencyName());
-		if (goods.getUuid() == null) {
-			aBatch.setReleaseCode(ReleaseStatus.failure.value());
-			aBatch.setReleaseStatus(ReleaseStatus.failure.getPhrase());
-		}
-		Long enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
-		if (goods.getEnUU() != null) {
-			return goods.getEnUU().equals(enuu);
-		}
-		return goods.getEnUU() == null && enuu == null;
+//		Object tagValue = readWorkBookCell(row.getCell(ModifyConstant.CUSTOM_LABEL), Cell.CELL_TYPE_STRING,
+//				rowNum, ModifyConstant.CUSTOM_LABEL);
+//        if (!StringUtils.isEmpty(tagValue)) {
+//            aProduct.setTagByExcel(tagValue.toString().trim());
+//        }
+//		// 自定义标签不为null,则检查是否重复
+//		if (aProduct.getCode() != null && aProduct.getBrandNameEn() != null && aProduct.getTag() != null) {
+//			resetTag(aProduct);
+//		}
 	}
 
 	private void validateModifyExcel(Row headerRow) {
@@ -746,19 +787,22 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			return ;
 		for (ReleaseProductByBatch each : batchList) {
 			if (StringUtils.isEmpty(each.getErrmsg()) && each.equals(aBatch)) {
-				if (!isImport) {
-					aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
-					aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
-					aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
-					break;
-				} else {
-					if (GoodsUtil.compareWithQtyPrice(each.getPrices(), aBatch.getPrices(), each.getCurrency())) {
-						aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
-						aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
-						aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
-						break;
-					}
-				}
+				aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+				aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+				aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+//				if (!isImport) {
+//					aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+//					aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+//					aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+//					break;
+//				} else {
+//					if (GoodsUtil.compareWithQtyPrice(each.getPrices(), aBatch.getPrices(), each.getCurrency())) {
+//						aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
+//						aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
+//						aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
+//						break;
+//					}
+//				}
 			}
 		}
 	}
@@ -934,7 +978,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			aProduct.setUsdTaxRate(0d);
 		} else {
 			aProduct.setCurrency("RMB");
-			aProduct.setRmbTaxRate(0.17d);
+			aProduct.setRmbTaxRate(0.16d);
 		}
 	}
 
@@ -1174,6 +1218,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			Object reserveValue = readWorkBookCell(row.getCell(UploadConstant.RESERVE_NUMBER), Cell.CELL_TYPE_STRING,
 					rowNum, UploadConstant.RESERVE_NUMBER);
 			aProduct.setReserveByExcel(reserveValue);
+			if (StringUtils.isEmpty(reserveValue)) {
+				result += 1;
+			}
 
 			Object costPrice = readWorkBookCell(row.getCell(UploadConstant.COST_PRICE), Cell.CELL_TYPE_STRING,
 					rowNum, UploadConstant.COST_PRICE);
@@ -1305,19 +1352,19 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 		aProduct.setFragmentPrice(StringUtilB2C.getStr(firstValue), 0);
 		if (StringUtils.isEmpty(firstValue)) {
-			aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
+			//aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
 		} else {
 			if (RegexConstant.isNumber(firstValue.toString())) {
 				Double cellPrice = Double.valueOf(firstValue.toString());
 				if (validatePrice(cellPrice)) {
-					GoodsQtyPrice qtyPrice = getOneQtyPrice(aProduct.getMinBuyQty(), DoubleConstant.maxMinPackageQty,
+					GoodsQtyPrice qtyPrice = getOneQtyPrice(aProduct.getMinBuyQty(), DoubleConstant.maxReserve,
 							cellPrice, aProduct.getRmbTaxRate(), aProduct.getCurrency());
 					qtyPriceList.add(qtyPrice);
 				} else {
 					aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
 				}
 			} else {
-				aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
+				//aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
 			}
 
 		}
@@ -1366,7 +1413,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		if (start == null || lastEnd == null) {
 			return false;
 		}
-		return start.compareTo(lastEnd) > 0 && start.compareTo(DoubleConstant.maxMinPackageQty) <= 0;
+		return start.compareTo(lastEnd) > 0 && start.compareTo(DoubleConstant.maxReserve) <= 0;
 	}
 
 	/**
@@ -1395,7 +1442,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				Double price = Double.valueOf(priceValue.toString());
 				Double start = Double.valueOf(startValue.toString());
 				if (validatePrice(price) && validateStartNumber(start, aProduct.getMinBuyQty())) {
-					GoodsQtyPrice qtyPrice = getOneQtyPrice(Double.valueOf(startValue.toString()), DoubleConstant.maxMinPackageQty,
+					GoodsQtyPrice qtyPrice = getOneQtyPrice(Double.valueOf(startValue.toString()), DoubleConstant.maxReserve,
 							price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
 					qtyPriceList.add(qtyPrice);
 					qtyPriceList.get(0).setEnd(Double.valueOf(startValue.toString()) - 1);
@@ -1436,7 +1483,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				Double start = Double.valueOf(startValue.toString());
 				Double lastEnd = qtyPriceList.get(qtyPriceList.size() - 1).getStart();
 				if (validatePrice(price) && validateStartNumber(start, lastEnd)) {
-					GoodsQtyPrice qtyPrice = getOneQtyPrice(start, DoubleConstant.maxMinPackageQty,
+					GoodsQtyPrice qtyPrice = getOneQtyPrice(start, DoubleConstant.maxReserve,
 							price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
 					qtyPriceList.get(qtyPriceList.size() - 1).setEnd(start - 1);
 					qtyPriceList.add(qtyPrice);
@@ -1773,8 +1820,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
         if (StringUtils.isEmpty(batch)) {
             return "0";
         }
-		List<ReleaseProductByBatch> releaseProductByBatchList =
-				releaseProductByBatchDao.findByRelbatchid(batch);
+		List<ReleaseProductByBatch> releaseProductByBatchList = releaseProductByBatchDao.findByRelbatchid(batch);
 		if (CollectionUtils.isEmpty(releaseProductByBatchList)) {
 			return String.valueOf(IntegerConstant.NO_SHORT);
 		}
@@ -1810,28 +1856,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		if (CollectionUtils.isNotEmpty(list)) {
 			List<Goods> goodses = new ArrayList<>();
 			Goods goods = null;
-			TradeDeliveryDelayTime delayTime = null;
-			ReleaseProductByBatch releaseProductByBatch1 = list.get(0);
-			if (releaseProductByBatch1.getStoreid().equals(SysConf.getStoreid())) {
-				// 增加交货延长期限
-				List<TradeDeliveryDelayTime> tradeDeliveryDelayTime = tradeDeliveryDelayTimeService.getTradeDeliveryDelayTime();
-				if (releaseProductByBatch1.getCurrency().equals(StringConstant.RMB)) {
-					for (TradeDeliveryDelayTime deliveryDelayTime : tradeDeliveryDelayTime) {
-						if (deliveryDelayTime.getType() == IntegerConstant.DOMESTIC_DELAY) {
-							delayTime = deliveryDelayTime;
-						}
-					}
-				} else {
-					for (TradeDeliveryDelayTime deliveryDelayTime : tradeDeliveryDelayTime) {
-						if (deliveryDelayTime.getType() == IntegerConstant.ABROAD_DELAY) {
-							delayTime = deliveryDelayTime;
-						}
-					}
-				}
-				if (delayTime == null) {
-					throw new IllegalOperatorException("平台未设置供应商延长时间,请联系管理员");
-				}
-			}
+			TradeDeliveryDelayTime delayTime = getDelayTime(list.get(0));
 			List<Goods> goodlist = null;
 			if (CollectionUtils.isNotEmpty(idSet)) {
 				List<Long> prids = new ArrayList<>();
@@ -1841,6 +1866,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			List<ReleaseProductByBatch> insertGoods = new ArrayList<>();
 			Set<Long> prids = new HashSet<>();
 			List<Goods> updateGoods = new ArrayList<>();
+			List<GoodsHistory> goodsHistoryList = new ArrayList<>();
 			for (ReleaseProductByBatch releaseProductByBatch : list) {
 				if (releaseProductByBatch.getReleaseCode().intValue() == ReleaseStatus.success.value() || releaseProductByBatch.getReleaseCode().intValue() == ReleaseStatus.failure.value()) {
                     Boolean isExist = false;
@@ -1852,6 +1878,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                                 isExist = true;
 								prids.add(releaseProductByBatch.getProductid());
                                 goods1.updateGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime, ignoreImport);
+								goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods1, GoodsHistory.OperateType.Update.getPhrase(), false));
 								updateGoods.add(goods1);
                                 break;
 							}
@@ -1866,6 +1893,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				for (ReleaseProductByBatch releaseProductByBatch : insertGoods) {
 					goods = new Goods();
 					goods.setGoodsByReleaseProductByBatch(releaseProductByBatch, delayTime);
+					goodsHistoryList.add(goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false));
 					goodses.add(goods);
 				}
 			}
@@ -1875,12 +1903,40 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			if (CollectionUtils.isNotEmpty(updateGoods)) {
                 goodsDao.save(updateGoods);
             }
+            if (CollectionUtils.isNotEmpty(goodsHistoryList)) {
+				goodsHistoryService.save(goodsHistoryList);
+			}
 			return (goodses.size() + updateGoods.size());
 		} else {
 			return 0;
 		}
 	}
 
+	public TradeDeliveryDelayTime getDelayTime(ReleaseProductByBatch releaseProductByBatch) {
+		TradeDeliveryDelayTime delayTime = null;
+		if (releaseProductByBatch.getStoreid().equals(SysConf.getStoreid())) {
+			// 增加交货延长期限
+			List<TradeDeliveryDelayTime> tradeDeliveryDelayTime = tradeDeliveryDelayTimeService.getTradeDeliveryDelayTime();
+			if (releaseProductByBatch.getCurrency().equals(StringConstant.RMB)) {
+				for (TradeDeliveryDelayTime deliveryDelayTime : tradeDeliveryDelayTime) {
+					if (deliveryDelayTime.getType() == IntegerConstant.DOMESTIC_DELAY) {
+						delayTime = deliveryDelayTime;
+					}
+				}
+			} else {
+				for (TradeDeliveryDelayTime deliveryDelayTime : tradeDeliveryDelayTime) {
+					if (deliveryDelayTime.getType() == IntegerConstant.ABROAD_DELAY) {
+						delayTime = deliveryDelayTime;
+					}
+				}
+			}
+			if (delayTime == null) {
+				throw new IllegalOperatorException("平台未设置供应商延长时间,请联系管理员");
+			}
+		}
+		return delayTime;
+	}
+
 	/**
 	 * 批量保存pcb的信息
 	 * @param idSet id
@@ -1964,6 +2020,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                     proNums.add(prodNum);
                     productsfromRelease.add(releaseProductByBatch);
 				} else {
+					prodNum = releaseProductByBatch.getCode();
 					//对于已经存在于物料库的信息,如果规格信息已存在,则做更新
 					prIds.add(releaseProductByBatch.getProductid());
 				}
@@ -2009,9 +2066,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
             commonDao.save(productPrivates, ProductPrivate.class);
 		}
 		//将本次临时表中的数据更新到物料表中
-        if (CollectionUtils.isNotEmpty(updateProducts)) {
-			Map<String, Set<InOutboundDetail>> inOutMap = new HashedMap();
-            productService.updateProductsByReleaseProductByBatch(prIds, releaseProductByBatchList, ignoreImport, newInOutboundDetail, inOutMap);
+		productService.updateProductsByReleaseProductByBatch(prIds, releaseProductByBatchList, ignoreImport, newInOutboundDetail);
+		if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
+			Map<String, Set<InOutboundDetail>> inOutMap = inOutboundDetailService.initInOutboundDetailByQty(newInOutboundDetail);
 			Set<String> stringSet = inOutMap.keySet();
 			for (String type : stringSet) {
 				CommodityInOutbound commodityInOutbound = commodityInOutboundService.produceCommodityInOutbound(inOutMap.get(type), type);
@@ -2088,15 +2145,15 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 			public void run() {
 
 				//创建历史库存
-				List<Goods> goodses1 = goodsService.findByBatchId(batchid);
-				List<GoodsHistory> list = new ArrayList<>();
-				for (Goods goods : goodses1) {
-					GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
-					list.add(goodsHistory);
-				}
-				if (CollectionUtils.isNotEmpty(list)) {
-					goodsHistoryService.save(list);
-				}
+//				List<Goods> goodses1 = goodsService.findByBatchId(batchid);
+//				List<GoodsHistory> list = new ArrayList<>();
+//				for (Goods goods : goodses1) {
+//					GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
+//					list.add(goodsHistory);
+//				}
+//				if (CollectionUtils.isNotEmpty(list)) {
+//					goodsHistoryService.save(list);
+//				}
 				//创建物料的私有信息
 				productPrivateService.newProductPrivateIfNotExist(productIds);
 

+ 2 - 2
src/main/java/com/uas/platform/b2c/prod/store/facade/impl/StoreApplyFacadeImpl.java

@@ -44,8 +44,6 @@ public class StoreApplyFacadeImpl implements StoreApplyFacade {
 	@Override
 	public ResultMap handlerApply(String uuid, StoreApply.ApplyStatus status, StoreApply apply) {
 		// 通过uuid找到店铺申请信息
-		Date date = new Date();
-		StoreApply storeApply = storeApplyService.findByUuid(uuid);
 		User user = SystemSession.getUser();
 		if (user == null || user.getEnterprise() == null) {
 			return new ResultMap(CodeType.NOT_PERMIT, "请进行用户登录操作");
@@ -60,6 +58,7 @@ public class StoreApplyFacadeImpl implements StoreApplyFacade {
 		if (apply == null) {
 			return new ResultMap(CodeType.NO_INFO, "店铺申请信息不能为空");
 		}
+		StoreApply storeApply = storeApplyService.findByUuid(uuid);
 		// 检测资质信息
 		if (StoreApply.ApplyStatus.PASS == status) {
 			// TODO 检测企业信息以及品牌信息
@@ -102,6 +101,7 @@ public class StoreApplyFacadeImpl implements StoreApplyFacade {
 			}
 			storeApply.setReason(apply.getReason());
 		}
+		Date date = new Date();
 		// 保存审核时的审核人信息和是否通过状态
 		storeApply.setAuthPerson(user.getUserName());
 		storeApply.setAuthTime(date);

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/store/model/StoreApply.java

@@ -41,6 +41,12 @@ public class StoreApply {
 	@Column(name = "apply_useruu")
 	private Long userUU;
 
+	/**
+	 * 主营产品
+	 */
+	@Column(name = "apply_description", length = 1000)
+	private String applyDescription;
+
 	/**
 	 * 申请人姓名
 	 */
@@ -181,6 +187,14 @@ public class StoreApply {
 	public StoreApply() {
 	}
 
+	public String getApplyDescription() {
+		return applyDescription;
+	}
+
+	public void setApplyDescription(String applyDescription) {
+		this.applyDescription = applyDescription;
+	}
+
 	public String getStoreUuid() {
 		return storeUuid;
 	}

+ 2 - 3
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java

@@ -28,7 +28,6 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
-import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -103,12 +102,12 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 		}
 		// 检测是否存在待处理开铺申请
 		StoreApply existApply = storeApplyDao.findByEnUUAndStatus(user.getEnterprise().getUu(), StoreApply.ApplyStatus.PREPARE);
-		if(existApply != null) {
+		if (existApply != null) {
 			return new ResultMap(CodeType.SAVED, "AUTH_PREPARE");
 		}
 		// 检测是否存在待处理开铺申请
 		existApply = storeApplyDao.findByEnUUAndStatus(user.getEnterprise().getUu(), StoreApply.ApplyStatus.PASS);
-		if(existApply != null) {
+		if (existApply != null) {
 			return new ResultMap(CodeType.SAVED, "AUTH_PASS");
 		}
 

+ 3 - 4
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreInServiceImpl.java

@@ -126,9 +126,6 @@ public class StoreInServiceImpl implements StoreInService {
 		if (storeApply == null || storeApply.getEnUU() == null) {
 			return null;
 		}
-
-		StoreIn store;
-		Date date = new Date();
 		StoreIn existStore = storeDao.findByStoreName(storeApply.getStoreName());
 		if (existStore != null) {
 			throw new IllegalStatusException("店铺信息已经存在");
@@ -137,7 +134,8 @@ public class StoreInServiceImpl implements StoreInService {
 		if (existStore != null) {
 			throw new IllegalStatusException("店铺英文缩写已经存在");
 		}
-		store = new StoreIn();
+		StoreIn store = new StoreIn();
+		Date date = new Date();
 		if (StringUtils.isEmpty(storeApply.getStoreUuid())) {
 			store.setUuid(UuidUtils.generatedUuid());
 		} else {
@@ -151,6 +149,7 @@ public class StoreInServiceImpl implements StoreInService {
 		store.setType(storeApply.getType());
 		store.setCreateTime(date);
 		store.setUpdateTime(date);
+		store.setDescription(storeApply.getApplyDescription());
 
 		store.setEnUU(storeApply.getEnUU());
 		store.setEnterprise(storeApply.getEnterprise());

+ 0 - 25
src/main/java/com/uas/platform/b2c/trade/order/controller/OrderController.java

@@ -984,29 +984,4 @@ public class OrderController {
 	public ResultMap findInvoiceByIdAndInvoiceId(Long id, String invoiceid) {
 		return orderService.findInvoiceByIdAndInvoiceId(id, invoiceid);
 	}
-
-	/**
-	 * 统计个人的订单金额(只包含520-405)
-	 * @param useruu 个人uu
-	 * @param enuu 企业uu
-	 * @param starttime 开始时间
-	 * @param endtime 结束时间
-	 * @return  ResultMap
-	 */
-	@RequestMapping(value = "/trading/volume/personal", method = RequestMethod.GET)
-	public ResultMap statisticsPersonTradingVolume(Long useruu, Long enuu, Long starttime, Long endtime) {
-		return orderService.statisticsPersonTradingVolume(useruu, enuu, starttime, endtime);
-	}
-
-	/**
-	 * 统计企业的订单金额总计 (只包含520-405)
-	 * @param enuu
-	 * @param starttime
-	 * @param endtime
-	 * @return ResultMap
-	 */
-	@RequestMapping(value = "/trading/volume", method = RequestMethod.GET)
-	public ResultMap statisticsEnterpriseTradingVolume(Long enuu, Long starttime, Long endtime) {
-		return orderService.statisticsEnterpriseTradingVolume(enuu, starttime, endtime);
-	}
 }

+ 2 - 4
src/main/java/com/uas/platform/b2c/trade/order/controller/PurchaseController.java

@@ -8,15 +8,13 @@ import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
-import com.uas.platform.b2c.logistics.model.Logistics;
+import com.uas.platform.b2c.logistics.model.Invoice;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.Purchase;
 import com.uas.platform.b2c.trade.order.model.PurchaseModifyingHistory;
 import com.uas.platform.b2c.trade.order.service.PurchaseDetailService;
 import com.uas.platform.b2c.trade.order.service.PurchaseService;
-import com.uas.platform.b2c.trade.presale.model.ValidTime;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
@@ -238,7 +236,7 @@ public class PurchaseController {
 	 * @return the invoice f purchase
 	 */
 	@RequestMapping(value = "/{invoiceid}/ensurereceipt", method = RequestMethod.PUT)
-	public InvoiceFPurchase ensureReceipt(@PathVariable String invoiceid) {
+	public Invoice ensureReceipt(@PathVariable String invoiceid) {
 		assert logger != null;
 		logger.log("采购单管理", "平台确认收货,出货单id: " + invoiceid);
 		return purchaseService.ensuerAcceptInvoise(invoiceid);

+ 5 - 5
src/main/java/com/uas/platform/b2c/trade/order/model/OrderIndex.java

@@ -2,7 +2,7 @@ package com.uas.platform.b2c.trade.order.model;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrder;
+import com.uas.platform.b2c.logistics.model.Invoice;
 import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
 import com.uas.platform.core.model.EncodingRulesConstant;
 import com.uas.platform.core.model.Status;
@@ -1130,21 +1130,21 @@ public class OrderIndex extends Document implements Serializable {
 	 * @param createNumberService the create number service
 	 * @return the invoice f order
 	 */
-	public InvoiceFOrder convertInvoiceFOrder(CreateNumberService createNumberService) {
+	public Invoice convertInvoiceFOrder(CreateNumberService createNumberService) {
 		String invoiceid = EncodingRulesConstant.INVOICE_FROMORDER.replace("_TIMESTAP_NUMBER",
 				createNumberService.getTimeNumber("trade$invoice_fmor", 8));
 		Date date = new Date();
-		InvoiceFOrder inFor = new InvoiceFOrder();
+		Invoice inFor = new Invoice();
 		inFor.setInvoiceid(invoiceid);
 		// 给属性赋值
-		inFor.setCreattime(date);
+		inFor.setCreatetime(date);
 		inFor.setBuyeruu(this.getBuyeruu());
 		inFor.setBuyerenuu(this.getBuyerenuu());
 		inFor.setPrice(this.getPrice());
 		// TODO 这里需要考虑确认总价的(默认和总价相等 打折等其他逻辑待考虑)
 		inFor.setEnsurePrice(this.ensurePrice);
 		inFor.setJsonSpAddress(this.getJsonAddress());
-		inFor.setOrid(this.getId());
+		inFor.setOrderId(this.getId());
 		inFor.setSourceid(this.orderid);
 		inFor.setProofingid(this.proofingid);
 		return inFor;

+ 5 - 5
src/main/java/com/uas/platform/b2c/trade/order/model/OrderIndexDetail.java

@@ -1,6 +1,6 @@
 package com.uas.platform.b2c.trade.order.model;
 
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
+import com.uas.platform.b2c.logistics.model.InvoiceDetail;
 import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
 import com.uas.platform.core.model.EncodingRulesConstant;
 import com.uas.platform.core.persistence.StatusColumn;
@@ -473,8 +473,8 @@ public class OrderIndexDetail {
 	 * @param createNumberService the create number service
 	 * @return the invoice f order detail
 	 */
-	public InvoiceFOrderDetail convertInvoiceFOrderDetail(CreateNumberService createNumberService) {
-		InvoiceFOrderDetail inForD = new InvoiceFOrderDetail();
+	public InvoiceDetail convertInvoiceFOrderDetail(CreateNumberService createNumberService) {
+		InvoiceDetail inForD = new InvoiceDetail();
 		String detailid = EncodingRulesConstant.INVOICE_DETAIL_FROMORDER.replace("_TIMESTAP_NUMBER",
 				createNumberService.getTimeNumber("trade$invoice_fmor_dt", 9));
 		inForD.setDetailid(detailid);
@@ -483,12 +483,12 @@ public class OrderIndexDetail {
 		inForD.setCmpCode(this.cmpCode);
 		inForD.setImg(this.img);
 		inForD.setUnitprice(this.getUnitprice());
-		inForD.setNumber(this.getNumber());
+		inForD.setQty(this.getNumber());
 		inForD.setPrice(this.getPrice());
 		// TODO 这里需要考虑确认总价的(默认和总价相等 打折等其他逻辑待考虑)
 		inForD.setEnsurePrice(this.ensurePrice);
 		inForD.setStatus(this.getStatus());
-		inForD.setOrdetailid(this.getId());
+		inForD.setOrderDetailId(this.getId());
 		return inForD;
 	}
 

+ 9 - 0
src/main/java/com/uas/platform/b2c/trade/order/service/OrderService.java

@@ -688,4 +688,13 @@ public interface OrderService {
 	 * @return ResultMap
 	 */
 	ResultMap statisticsEnterpriseTradingVolume(Long enuu, Long starttime, Long endtime);
+
+
+	/**
+	 * 根据订单号和订单主键获取订单
+	 * @param id
+	 * @param orderid
+	 * @return
+	 */
+	Order getOrderByOrderIdOrId(Long id, String orderid);
 }

+ 11 - 2
src/main/java/com/uas/platform/b2c/trade/order/service/PurchaseService.java

@@ -1,7 +1,7 @@
 package com.uas.platform.b2c.trade.order.service;
 
 import com.alibaba.fastjson.JSONArray;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchase;
+import com.uas.platform.b2c.logistics.model.Invoice;
 import com.uas.platform.b2c.logistics.model.Logistics;
 import com.uas.platform.b2c.trade.order.model.Order;
 import com.uas.platform.b2c.trade.order.model.OrderDetail;
@@ -113,7 +113,7 @@ public interface PurchaseService {
 	 * @param invoiceid the invoiceid
 	 * @return invoice f purchase
 	 */
-	InvoiceFPurchase ensuerAcceptInvoise(String invoiceid);
+	Invoice ensuerAcceptInvoise(String invoiceid);
 
 	/**
 	 * 平台批量确定收货
@@ -423,4 +423,13 @@ public interface PurchaseService {
 	String release(String purchaseId, String reason);
 
 	Logistics modifyPurchaseLogistics(Long id);
+
+
+	/**
+	 * 根据订单号和订单主键获取订单
+	 * @param id
+	 * @param purchaseid
+	 * @return
+	 */
+	Purchase getPurchaseByPurchaseidOrId(Long id, String purchaseid);
 }

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

@@ -10,6 +10,11 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.TradeLog;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.base.service.SendMessageService;
+import com.uas.platform.b2c.common.message.model.MessageModel;
+import com.uas.platform.b2c.common.message.type.ConsumerApp;
+import com.uas.platform.b2c.common.message.type.ConsumerType;
+import com.uas.platform.b2c.common.message.type.SMSType;
+import com.uas.platform.b2c.common.psmessage.service.MessageService;
 import com.uas.platform.b2c.common.search.rpc.service.OrderSearchService;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.ShortConstant;
@@ -34,11 +39,8 @@ import com.uas.platform.b2c.fa.settlement.model.ExchangeRate;
 import com.uas.platform.b2c.fa.settlement.service.BillSubmitService;
 import com.uas.platform.b2c.fa.settlement.service.ExchangeRateService;
 import com.uas.platform.b2c.logistics.dao.AddressDao;
-import com.uas.platform.b2c.logistics.dao.InvoiceFOrderDao;
-import com.uas.platform.b2c.logistics.dao.InvoiceFPurchaseDao;
 import com.uas.platform.b2c.logistics.dao.PickUpAddressDao;
 import com.uas.platform.b2c.logistics.model.*;
-import com.uas.platform.b2c.logistics.service.InvoiceFPurchaseService;
 import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
 import com.uas.platform.b2c.logistics.service.InvoiceService;
@@ -50,7 +52,6 @@ import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
 import com.uas.platform.b2c.prod.commodity.service.GoodsHistoryService;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
-import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.b2c.prod.product.component.modal.Component;
 import com.uas.platform.b2c.prod.product.component.service.ComponentService;
 import com.uas.platform.b2c.prod.store.dao.StoreInDao;
@@ -61,6 +62,7 @@ import com.uas.platform.b2c.trade.deprecated.model.UserInfoForOrder;
 import com.uas.platform.b2c.trade.inquiry.dao.TradeChargeDao;
 import com.uas.platform.b2c.trade.inquiry.model.TradeCharge;
 import com.uas.platform.b2c.trade.order.StringConstant.Currency;
+import com.uas.platform.b2c.trade.order.StringConstant.StringFormat;
 import com.uas.platform.b2c.trade.order.dao.OrderDao;
 import com.uas.platform.b2c.trade.order.dao.OrderDetailDao;
 import com.uas.platform.b2c.trade.order.dao.OrderIndexDetailDao;
@@ -201,6 +203,9 @@ public class OrderServiceImpl implements OrderService {
     @Autowired
     private SeekPurchaseService seekPurchaseService;
 
+    @Autowired
+    private MessageService messageService;
+
     @Autowired
     private MessageNotifyPersonalManagementService messageNotifyPersonalManagementService;
 
@@ -1723,10 +1728,26 @@ public class OrderServiceImpl implements OrderService {
     @Transactional
     @Override
     public ResultMap ensureOrderAccept(Long id, String invoiceId) {
+        if (id == null && StringUtils.isEmpty(invoiceId)) {
+            throw new IllegalOperatorException("传入的订单信息和出货单信息都为空");
+        }
+        Order order = null;
         if (id == null) {
-            return new ResultMap(CodeType.NO_INFO, "订单信息缺失");
+            Invoice invoice = invoiceService.getInvoice(invoiceId);
+            if (invoice == null){
+                throw new IllegalOperatorException("找不到指定的出货单信息");
+            }
+            order = getOrderByOrderIdOrId(invoice.getOrderId(), invoice.getOrid());
+            if (order == null) {
+                Purchase purchase = purchaseService.getPurchaseByPurchaseidOrId(invoice.getPurchaseid(), invoice.getPuid());
+                if (purchase == null){
+                    throw new IllegalOperatorException("找不到销售单信息");
+                }
+                order = getOrderByOrderIdOrId(null, purchase.getOrderid());
+            }
+        } else {
+            order = orderDao.findOne(id);
         }
-        Order order = orderDao.findOne(id);
         if (order == null) {
             return new ResultMap(CodeType.NO_INFO, "订单信息错误,找不到对应订单信息");
         }
@@ -1743,7 +1764,7 @@ public class OrderServiceImpl implements OrderService {
                 invoiceSignReceive(order, inid);
             }
         }
-        if (NumberUtil.compare(order.getQty(), order.getShipQty()) > 0) {
+        if (NumberUtil.compare(order.getQty(), order.getSignReceiveQty()) > 0) {
             return ResultMap.success(null);
         }
         //如果已经全部发货 (order.getQty() < order.getShipQty())
@@ -3512,6 +3533,16 @@ public class OrderServiceImpl implements OrderService {
         return ResultMap.success(orderTotal);
     }
 
+    @Override
+    public Order getOrderByOrderIdOrId(Long id, String orderid) {
+        if (id != null){
+            return orderDao.findOne(id);
+        }
+        if (org.apache.commons.lang.StringUtils.isNotEmpty(orderid)) {
+            return orderDao.findByOrderid(orderid);
+        }
+        return null;
+    }
 
     /**
      * 统计订单的总金额
@@ -3558,4 +3589,34 @@ public class OrderServiceImpl implements OrderService {
             return ResultMap.success(invoice);
         }
     }
+
+    /**
+     * 用户确认付款,通知管理后台确认收款
+     *
+     * @param order 确认付款的订单
+     * @return
+     */
+    @Override
+    public void sendConfirmPaidMessage(Order order) {
+        if (order == null || StringUtils.isEmpty(order.getOrderid())) {
+            return ;
+        }
+        List<MessageNotifyPersonalManagement> notifyPersonalManagements = messageNotifyPersonalManagementService.findNotifyPersonalEnuuAndType(sysConf.getEnUU(), com.uas.platform.b2c.trade.order.type.MessageType.CONFIRM_PAID.getType());
+        if (org.apache.commons.collections.CollectionUtils.isNotEmpty(notifyPersonalManagements)) {
+            ArrayList<MessageModel> list = new ArrayList<>();
+            for (MessageNotifyPersonalManagement management : notifyPersonalManagements) {
+                Long notifyPersonalUseruu = management.getNotifyPersonalUseruu();
+                if (notifyPersonalUseruu != null) {
+                    MessageModel model = messageService.initMessage(String.format(StringFormat.CONFIRMPAID, order.getOrderid()), com.uas.platform.b2c.trade.order.type.MessageType.CONFIRM_PAID.getType(), notifyPersonalUseruu, sysConf.getEnUU(), ConsumerType.SINGLE, ConsumerApp.MALL, SMSType.DONT_SEND, "");
+                    if (model != null) {
+                        list.add(model);
+                    }
+                }
+            }
+
+            if (org.apache.commons.collections.CollectionUtils.isNotEmpty(list)) {
+                messageService.sendMessage(list);
+            }
+        }
+    }
 }

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

@@ -106,8 +106,6 @@ public class PurchaseServiceImpl implements PurchaseService {
 	@Autowired
 	private OrderDao orderDao;
 	@Autowired
-	private InvoiceFPurchaseDao invoiceFPurchaseDao;
-	@Autowired
 	private EnterpriseDao enterpriseDao;
 	// 这个只是为了粗暴拿到地址
 	@Autowired
@@ -117,8 +115,6 @@ public class PurchaseServiceImpl implements PurchaseService {
 	@Autowired
 	private BillInfoDao billInfoDao;
 	@Autowired
-	private InvoiceFPurchaseDetailDao invoiceFPurchaseDetailDao;
-	@Autowired
 	private ReceiptDetailDao receiptDetailDao;
 	@Autowired
 	private ReceiptDao receiptDao;
@@ -152,6 +148,8 @@ public class PurchaseServiceImpl implements PurchaseService {
 	private InstallmentService installmentService;
 	@Autowired
 	private BillSubmitService billSubmitService;
+	@Autowired
+	private InvoiceDetailDao invoiceDetailDao;
 
 	@Override
 	public Purchase save(Purchase purchase) {
@@ -526,22 +524,22 @@ public class PurchaseServiceImpl implements PurchaseService {
 		if (invoiceids != null) {
 			String[] inids = invoiceids.split(SplitChar.COMMA);
 			for (String invoiceid : inids) {
-				InvoiceFPurchase invoiceFp = invoiceFPurchaseDao.findByInvoiceid(invoiceid);
+				Invoice invoiceFp = invoiceService.getInvoice(invoiceid);
 				if (invoiceFp.getStatus() != Status.INBOUND.value()) {
 					throw new IllegalAccessError("出货单不为待收货状态,不能确认收货");
 				}
 				Long uu = SystemSession.getUser().getUserUU();
-				Purchase purchase = purchaseDao.findOne(invoiceFp.getPuid());
+				Purchase purchase = purchaseDao.findOne(invoiceFp.getPurchaseid());
 				purchase = StatusChangeUtil.updatePurchaseStatus(purchase, Status.INBOUND, Status.RECEIVED);
 				purchaseDao.save(purchase);
 				// 1、生成入库单
 				receiptService.createPreceipts(invoiceFp);
 				// 2、改写订单状态
-				orderService.setShipped(invoiceFp.getPuid());
+				orderService.setShipped(invoiceFp.getPurchaseid());
 				// 3、改写卖方出货单状态 (首先改成出货单已出货,再判断是否为现货,现货在直接保存为待收款)
 				invoiceFp.setStatusReceived(uu);
-				invoiceFPurchaseDao.save(invoiceFp);
-				invoiceService.setToReceiveMoney(invoiceFp.getPuid());
+				invoiceService.save(invoiceFp);
+				invoiceService.setToReceiveMoney(invoiceFp.getPurchaseid());
 			}
 			return "success";
 		}
@@ -550,14 +548,14 @@ public class PurchaseServiceImpl implements PurchaseService {
 
 	@Transactional
 	@Override
-	public InvoiceFPurchase ensuerAcceptInvoise(String invoiceid) {
-		InvoiceFPurchase invoiceFp = invoiceFPurchaseDao.findByInvoiceid(invoiceid);
+	public Invoice ensuerAcceptInvoise(String invoiceid) {
+		Invoice invoiceFp = invoiceService.getInvoice(invoiceid);
 		if (invoiceFp.getStatus().intValue() != Status.INBOUND.value()) {
 			throw new IllegalAccessError("出货单不为待收货状态,不能确认收货");
 		}
 		Long uu = SystemSession.getUser().getUserUU();
 		boolean allReceived = true;
-		Purchase purchase = purchaseDao.findOne(invoiceFp.getPuid());
+		Purchase purchase = purchaseDao.findOne(invoiceFp.getPurchaseid());
 		Set<PurchaseDetail> purchaseDetails = purchase.getPurchaseDetails();
 		for (PurchaseDetail purchaseDetail : purchaseDetails) {
 			if (purchaseDetail.getStatus().intValue() == Status.INBOUND.value() && (NumberUtil.compare(purchaseDetail.getShipQty(), purchaseDetail.getNumber()) == 0)) {
@@ -592,10 +590,10 @@ public class PurchaseServiceImpl implements PurchaseService {
 		}
 		// 3、改写卖方出货单状态 (首先改成出货单已出货,再判断是否为现货,现货在直接保存为待收款)
 		invoiceFp.setStatusReceived(uu);
-		for (InvoiceFPurchaseDetail invoiceF : invoiceFp.getInvoiceFPurchaseDetails()) {
+		for (InvoiceDetail invoiceF : invoiceFp.getInvoiceDetails()) {
 			invoiceF.setStatus(Status.RECEIVED.value());
 		}
-		InvoiceFPurchase thisinvoiceFp = invoiceFPurchaseDao.save(invoiceFp);
+		Invoice thisinvoiceFp = invoiceService.save(invoiceFp);
 		return thisinvoiceFp;
 	}
 
@@ -1020,7 +1018,7 @@ public class PurchaseServiceImpl implements PurchaseService {
 	 */
 // 传入已经修改为已收票状态的明细id
 	public void changeReceiptToReceivedBill(Long purchaseDetailId) {
-		InvoiceFPurchaseDetail invoiceFPurchaseDetail = invoiceFPurchaseDetailDao.findInvoiceFPurchaseDetailByPudetailid(purchaseDetailId);
+		InvoiceDetail invoiceFPurchaseDetail = invoiceDetailDao.findByPurchaseDetailId(purchaseDetailId);
 		List<ReceiptDetail> receiptDetails = receiptDetailDao.findReceiptDetailBySourceid(invoiceFPurchaseDetail.getDetailid());
 		if (receiptDetails == null || receiptDetails.size() == 0) {
 			System.out.println("出货单的明细对应不到入库单的明细行,出库单的明细行是:" + invoiceFPurchaseDetail.getDetailid());
@@ -1734,4 +1732,15 @@ public class PurchaseServiceImpl implements PurchaseService {
 	public Logistics modifyPurchaseLogistics(Long id) {
 		return null;
 	}
+
+	@Override
+	public Purchase getPurchaseByPurchaseidOrId(Long id, String purchaseid) {
+		if (id != null){
+			return purchaseDao.findOne(id);
+		}
+		if (org.apache.commons.lang.StringUtils.isNotEmpty(purchaseid)) {
+			return purchaseDao.findByPurchaseid(purchaseid);
+		}
+		return null;
+	}
 }

+ 14 - 0
src/main/java/com/uas/platform/b2c/trade/seek/controller/SeekPurchaseBomController.java

@@ -29,6 +29,7 @@ import org.springframework.web.servlet.ModelAndView;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -275,4 +276,17 @@ public class SeekPurchaseBomController {
         logger.log("求购", "部分发布bom求购,detailIds: " + detailIds);
         return seekPurchaseBomService.confirmBomSelectedItems(detailIds, inquiryServiceInnerUrl, endTime, count);
     }
+
+    /**
+     * 保存新增物料
+     * @param newProducts
+     * @return
+     */
+    @RequestMapping(value = "/bom/detail/add", method = RequestMethod.POST)
+    public ModelMap saveBomProducts(@RequestBody List<SeekPurchaseByBatch> newProducts){
+        ModelMap map = seekPurchaseBomService.saveNewProducts(newProducts);
+        logger.log("求购", "保存新增物料, newProducts:{}" + newProducts);
+        return  map;
+
+    }
 }

+ 9 - 0
src/main/java/com/uas/platform/b2c/trade/seek/service/SeekPurchaseBomService.java

@@ -6,6 +6,8 @@ import com.uas.platform.b2c.trade.seek.model.SeekPurchaseBomList;
 import com.uas.platform.b2c.trade.seek.model.SeekPurchaseByBatch;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
+
+import java.util.List;
 import java.util.Map;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.data.domain.Page;
@@ -137,4 +139,11 @@ public interface SeekPurchaseBomService {
      * @return
      */
     SeekPurchaseBom findOneWithoutDetail(Long bomId);
+
+    /**
+     * 保存新增物料
+     * @param newProducts
+     * @return
+     */
+    ModelMap saveNewProducts(List<SeekPurchaseByBatch> newProducts);
 }

+ 107 - 20
src/main/java/com/uas/platform/b2c/trade/seek/service/impl/SeekPurchaseBomServiceImpl.java

@@ -6,6 +6,8 @@ import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.utils.StringUtilB2C;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
+import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
+import com.uas.platform.b2c.prod.commodity.model.Product;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
 import com.uas.platform.b2c.prod.product.brand.modal.Brand;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
@@ -98,6 +100,9 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
     @Autowired
     private SearcherService searcherService;
 
+    @Autowired
+    private ProductDao productDao;
+
     private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
 
     /**
@@ -116,11 +121,11 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
     public final int CODENUM = 2;
     // 品牌
     public final int BRANDNUM = 0;
-//    // 截止日期
+    //    // 截止日期
 //    public final int DEADLINENUM = 4;
     // 采购数量
     public final int AMOUNTNUM = 4;
-//    public static final int CURRENCYNUM = 6;
+    //    public static final int CURRENCYNUM = 6;
 //    public static final int UNITPRICENUM = 7;
 //    public static final int ENCAPSULATIONNUM = 8;
 //    public static final int PRODUCEDATENUM = 9;
@@ -132,6 +137,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 导入bom
+     *
      * @param workbook
      * @param bomName
      * @return
@@ -200,6 +206,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 校验第二行是否为商城示例
+     *
      * @param row
      * @return
      */
@@ -218,6 +225,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 验证是否为商城模板
+     *
      * @param headerRow
      * @return
      */
@@ -255,6 +263,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 将列信息注入到求购临时实体中
+     *
      * @param row
      * @param seekPurchaseByBatch
      * @param rowNum
@@ -404,13 +413,14 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 判断输入是否合法
+     *
      * @param code
      * @return
      */
     private String match(String code) {
         List<String> filterList = Arrays.asList("空", "没", "无", "—", "-", "null", "#N/A");
         for (String s : filterList) {
-            if (s.equals(code)){
+            if (s.equals(code)) {
                 return null;
             }
         }
@@ -419,6 +429,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 读取excel
+     *
      * @return
      */
     private Object readWorkBookCell(Cell cell, int cellType, int r, int n) {
@@ -426,7 +437,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         try {
             if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                 switch (cellType) {
-                    case Cell.CELL_TYPE_STRING :
+                    case Cell.CELL_TYPE_STRING:
                         cell.setCellType(HSSFCell.CELL_TYPE_STRING);
                         String str = cell.getStringCellValue().trim();
                         if (str.indexOf("\u00A0") > 0) {
@@ -435,7 +446,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
                         str = StringUtilB2C.replaceTabAndLineBreak(str);
                         obj = str.trim();
                         break;
-                    case Cell.CELL_TYPE_NUMERIC :
+                    case Cell.CELL_TYPE_NUMERIC:
                         cell.setCellType(Cell.CELL_TYPE_NUMERIC);
                         obj = cell.getNumericCellValue();
                         if (obj != null) {
@@ -445,7 +456,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
                             }
                         }
                         break;
-                    default :
+                    default:
                         if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                             String productTime = cell.getStringCellValue();
                             Pattern p = Pattern.compile("\\s*|\t|\r|\n");
@@ -475,7 +486,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         }
         Page<SeekPurchaseByBatch> pageSeeks = seekPurchaseByBatchDao.findAll(new Specification<SeekPurchaseByBatch>() {
             public Predicate toPredicate(Root<SeekPurchaseByBatch> root, CriteriaQuery<?> query,
-                    CriteriaBuilder builder) {
+                                         CriteriaBuilder builder) {
                 query.where(pageInfo.getPredicates(root, query, builder));
                 return null;
             }
@@ -509,6 +520,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 根据型号和品牌类目匹配
+     *
      * @param brand
      * @param code
      * @return
@@ -562,7 +574,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         pageInfo.sorting("releaseDate", Direction.DESC);
         Page<SeekPurchaseBomList> pageSeeks = seekPurchaseBomListDao.findAll(new Specification<SeekPurchaseBomList>() {
             public Predicate toPredicate(Root<SeekPurchaseBomList> root, CriteriaQuery<?> query,
-                    CriteriaBuilder builder) {
+                                         CriteriaBuilder builder) {
                 query.where(pageInfo.getPredicates(root, query, builder));
                 return null;
             }
@@ -625,7 +637,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
     public Page<SeekPurchaseBom> findAllByPageInfo(final PageInfo pageInfo, String keyword) {
         Sort sort = new Sort(Sort.Direction.DESC, "id");
         pageInfo.setSort(sort);
-        pageInfo.setOffset((pageInfo.getPageNumber() -1 ) * pageInfo.getPageSize());
+        pageInfo.setOffset((pageInfo.getPageNumber() - 1) * pageInfo.getPageSize());
         if (!StringUtils.isEmpty(keyword)) {
             pageInfo.expression(PredicateUtils.like("name", keyword, false));
         }
@@ -673,15 +685,38 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
             return map;
         }
         try {
+            Date now = new Date();
+            List<Product> products = new ArrayList<>();
+            Integer newAmount = 0;
             List<SeekPurchaseByBatch> seekPurchaseByBatches = bom.getSeekPurchaseByBatchs();
             if (!CollectionUtils.isEmpty(seekPurchaseByBatches)) {
                 for (SeekPurchaseByBatch batch : seekPurchaseByBatches) {
+                    if (null == batch.getId()) {
+                        newAmount++;
+                    }
                     if (null == batch.getAmount()) {
                         batch.setAmount(1d);
                     }
+                    batch.setReleaseDate(now);
+                    Product product = new Product();
+                    if (CollectionUtils.isEmpty(productDao.findProductByPcmpcodeAndPbrandenAndEnUU(batch.getCode(), batch.getBrand(), SystemSession.getUser().getEnterprise().getUu()))){
+                        product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
+                        product.setUserUU(SystemSession.getUser().getUserUU());
+                        product.setProdNum(System.currentTimeMillis() + StringUtilB2C.getRandomNumber(5));
+                        product.setBrand(batch.getBrand());
+                        product.setCmpCode(batch.getCode());
+                        product.setPbranden(batch.getBrand());
+                        product.setPcmpcode(batch.getCode());
+                        product.setSpec(batch.getSpec());
+                        product.setProdName(batch.getKind());
+                        product.setKind(batch.getKind());
+                        products.add(product);
+                    }
                 }
                 seekPurchaseByBatchDao.save(seekPurchaseByBatches);
+                productDao.save(products);
             }
+            bom.setAmount(bom.getAmount() + newAmount);
             seekPurchaseBomDao.save(bom);
             map.put("success", true);
         } catch (Exception e) {
@@ -758,10 +793,10 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
     /**
      * 部分发布,bom明细非全选时
      *
-     * @param detailIds              detail id串   1,2,3,4...
-     * @param endTime 截止时间  时间戳
-     * @param count 采购套数
-     * @param url 询价服务地址
+     * @param detailIds detail id串   1,2,3,4...
+     * @param endTime   截止时间  时间戳
+     * @param count     采购套数
+     * @param url       询价服务地址
      * @return 处理结果
      */
     @Override
@@ -795,10 +830,11 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     /**
      * 发布bom询价
-     * @param url  询价服务url
-     * @param seekPurchaseByBatchList  bom明细List
-     * @param endTime 截止时间  时间戳
-     * @param count 采购套数
+     *
+     * @param url                     询价服务url
+     * @param seekPurchaseByBatchList bom明细List
+     * @param endTime                 截止时间  时间戳
+     * @param count                   采购套数
      * @return 处理结果
      */
     private ResultMap publishBomInquiry(String url, List<SeekPurchaseByBatch> seekPurchaseByBatchList, SeekPurchaseBom seekPurchaseBom, Long endTime, Integer count) {
@@ -858,10 +894,10 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         inquiry.setInquiryItems(inquiryItems);
         String res = "";
         try {
-            res = HttpUtil.doPost(url + "/inquiry/buyer/save",  FlexJsonUtils.toJsonDeep(inquiry));
-            logger.log("bom求购确认发布成功",user.getUserUU() + ",参数:" + FlexJsonUtils.toJsonDeep(inquiry));
+            res = HttpUtil.doPost(url + "/inquiry/buyer/save", FlexJsonUtils.toJsonDeep(inquiry));
+            logger.log("bom求购确认发布成功", user.getUserUU() + ",参数:" + FlexJsonUtils.toJsonDeep(inquiry));
         } catch (Exception e) {
-            logger.log("bom求购确认发布报错",user.getUserUU() + ",错误:" + e.getMessage() + "参数:" + FlexJsonUtils.toJsonDeep(inquiry));
+            logger.log("bom求购确认发布报错", user.getUserUU() + ",错误:" + e.getMessage() + "参数:" + FlexJsonUtils.toJsonDeep(inquiry));
             e.printStackTrace();
             throw new IllegalOperatorException("发布失败");
         }
@@ -870,4 +906,55 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         return ResultMap.success(result);
     }
 
+    @Override
+    public ModelMap saveNewProducts(List<SeekPurchaseByBatch> newProducts) {
+        ModelMap map = new ModelMap();
+        try {
+            List<Product> products = new ArrayList<>();
+            //判断传入参数是否为空
+            if (CollectionUtils.isEmpty(newProducts)) {
+                map.put("success", false);
+                map.put("message", "参数为空");
+            }
+            //获取传入参数第一个Bomid,为判断新增物料是否为同一个Bom清单里的
+            Long bomId = newProducts.get(0).getBomId();
+            for (SeekPurchaseByBatch newProduct : newProducts) {
+                if (newProduct.getBomId() == null && !Objects.equals(newProduct.getBomId(), bomId)) {
+                    map.put("success", false);
+                    map.put("message", "没有找到Bom清单id或者bomId不一致");
+                    return map;
+                }
+                Date now = new Date();
+                newProduct.setReleaseDate(now);
+                //如果该物料在物料表中不存在,则将新增物料添加到物料表中
+                Product product = new Product();
+                if (CollectionUtils.isEmpty(productDao.findProductByPcmpcodeAndPbrandenAndEnUU(newProduct.getCode(), newProduct.getBrand(), SystemSession.getUser().getEnterprise().getUu()))){
+                    product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
+                    product.setUserUU(SystemSession.getUser().getUserUU());
+                    product.setProdNum(System.currentTimeMillis() + StringUtilB2C.getRandomNumber(5));
+                    product.setBrand(newProduct.getBrand());
+                    product.setCmpCode(newProduct.getCode());
+                    product.setPbranden(newProduct.getBrand());
+                    product.setPcmpcode(newProduct.getCode());
+                    product.setSpec(newProduct.getSpec());
+                    product.setProdName(newProduct.getKind());
+                    product.setKind(newProduct.getKind());
+                    products.add(product);
+                }
+            }
+            seekPurchaseByBatchDao.save(newProducts);
+            SeekPurchaseBom bom = seekPurchaseBomDao.findOne(bomId);
+            //bom清单中数量按照传入条数增加
+            bom.setAmount(bom.getAmount() + newProducts.size());
+            seekPurchaseBomDao.save(bom);
+            if (!CollectionUtils.isEmpty(products)) {
+                productDao.save(products);
+            }
+            map.put("success", true);
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("message", e.getMessage());
+        }
+        return map;
+    }
 }

+ 3 - 0
src/main/resources/dev/sys.properties

@@ -55,3 +55,6 @@ messageServiceUrl=http://192.168.253.12:24000/message/
 #b2b
 b2b=http://218.17.158.219/b2b_test
 b2bDomain=218.17.158.219:9000/b2b_test
+
+#lottery
+lottery=http://192.168.253.3:26789/

BIN
src/main/resources/jxls-tpl/trade/products-error.xls


BIN
src/main/resources/jxls-tpl/trade/products.xls


BIN
src/main/resources/jxls-tpl/trade/releaseByBatch-rmb.xls


BIN
src/main/resources/jxls-tpl/trade/releaseByBatchError-rmb.xls


BIN
src/main/resources/jxls-tpl/trade/releasebyBatch-usd.xls


+ 4 - 1
src/main/resources/prod/sys.properties

@@ -57,4 +57,7 @@ messageServiceUrl=http://api-message.ubtob.com/
 #b2b
 b2b=http://uas.ubtob.com
 b2bDomain=uas.ubtob.com
-b2bInner=http://10.10.100.103:8080
+b2bInner=http://10.10.100.103:8080
+
+#lottery
+lottery=http://192.168.253.3:26789

+ 4 - 1
src/main/resources/test/sys.properties

@@ -55,4 +55,7 @@ messageServiceUrl=http://192.168.253.12:24000/message/
 
 #b2b
 b2b=http://218.17.158.219/b2b_test
-b2bDomain=218.17.158.219:9000/b2b_test
+b2bDomain=218.17.158.219:9000/b2b_test
+
+#lottery
+lottery=http://192.168.253.3:26789/

+ 1 - 0
src/main/webapp/WEB-INF/spring/webmvc.xml

@@ -105,6 +105,7 @@
 			<mvc:exclude-mapping path="/store/**" />
 			<mvc:exclude-mapping path="/providers/**" />
 			<mvc:exclude-mapping path="/api/**" />
+			<mvc:exclude-mapping path="/api/trade/trading/**" />
 			<mvc:exclude-mapping path="/search/**" />
 			<mvc:exclude-mapping path="/commonSearch/**" />
 			<mvc:exclude-mapping path="/help" />

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

@@ -138,6 +138,10 @@
 
 
 			<li class="nav-header">审批</li>
+			<li class="nav-node"><a href="/vendor#/brand/apply"><i
+					class="fa fa-bullhorn"></i><span> 品牌申请</span></a></li>
+			<li class="nav-node"><a href="/vendor#/component/apply"><i
+					class="fa fa-bullhorn"></i><span> 器件申请</span></a></li>
 			<li class="nav-node"><a href="#audit/brand"><i
 					class="fa fa-bullhorn"></i><span> 品牌</span></a></li>
 			<li class="nav-node"><a href="#supplierSubmitList"><i

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

@@ -15,6 +15,7 @@
 <link rel="stylesheet" href="static/lib/iconfont/css/iconfont.css" />
 <link rel="stylesheet" href="static/lib/jquery/themes/uploadify/uploadify.css" />
 <link rel="stylesheet" href="static/lib/angular/toaster.css" />
+	<link rel="stylesheet" href="static/css/vendor/sell.css" />
 <link rel="stylesheet" href="static/css/common.css" />
 <!--<link rel="stylesheet" href="static/css/usercenter.css" />-->
 <link rel="stylesheet" href="static/css/user/base.css" />

BIN
src/main/webapp/resources/img/all/default.png


BIN
src/main/webapp/resources/img/all/empty-cart.png


BIN
src/main/webapp/resources/img/all/qrcode_mall.png


BIN
src/main/webapp/resources/img/all/u.png


BIN
src/main/webapp/resources/img/common/mall-logo.png


BIN
src/main/webapp/resources/img/common/uas-mall.png


BIN
src/main/webapp/resources/img/common/uas_mall.png


BIN
src/main/webapp/resources/img/example/tip_logo.png


BIN
src/main/webapp/resources/img/help/brand.png


BIN
src/main/webapp/resources/img/help/buy-search.png


BIN
src/main/webapp/resources/img/help/kind.png


BIN
src/main/webapp/resources/img/help/market.png


BIN
src/main/webapp/resources/img/help/orderinfo.png


BIN
src/main/webapp/resources/img/help/register.png


BIN
src/main/webapp/resources/img/help/search.png


BIN
src/main/webapp/resources/img/help/search1.png


BIN
src/main/webapp/resources/img/help/search2.png


BIN
src/main/webapp/resources/img/help/search3.png


BIN
src/main/webapp/resources/img/help/seller-apply-brand.png


BIN
src/main/webapp/resources/img/help/seller-apply-component.png


BIN
src/main/webapp/resources/img/help/seller-apply-componentInfo.png


BIN
src/main/webapp/resources/img/help/seller-batch-publish.png


BIN
src/main/webapp/resources/img/help/sign.png


BIN
src/main/webapp/resources/img/logo/squirrel_logo_weixin.jpg


BIN
src/main/webapp/resources/img/logo/uas_mall.png


BIN
src/main/webapp/resources/img/logo/uas_mall_hor.png


BIN
src/main/webapp/resources/img/mobile/client-icon-32.png


BIN
src/main/webapp/resources/img/mobile/yrsc_weixin.jpg


BIN
src/main/webapp/resources/img/store/common/default.png


Some files were not shown because too many files changed in this diff