Переглянути джерело

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

wangcz 7 роки тому
батько
коміт
c5fb5daf68

+ 6 - 1
src/main/java/com/uas/platform/b2c/core/constant/ReleaseStatus.java

@@ -73,7 +73,12 @@ public enum ReleaseStatus {
 	/**
 	 * {@code 115  产品库已存在}
 	 */
-	had_exists(115, "产品库已存在");
+	had_exists(115, "产品库已存在"),
+
+	/**
+	 * {@code 116  个人物料库已存在}
+	 */
+	personal_had_exists(116, "个人物料库已存在");
 
 	/**
 	 * @param value

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

@@ -37,9 +37,11 @@ public interface ReleaseProductByBatchDao
      *
 	 * @param relbatchid 批号
 	 * @param releaseCode 匹配状态(不等于)
+     * @param publisherUu 发布者UU
 	 * @return List<ReleaseProductByBatch>
 	 */
-	List<ReleaseProductByBatch> findByRelbatchidAndReleaseCodeNot(String relbatchid, Integer releaseCode);
+    @Query("select r from ReleaseProductByBatch r where r.publisherUu =:publisherUu and r.relbatchid =:relbatchid and r.releaseCode not in :releaseCode")
+    List<ReleaseProductByBatch> findByRelbatchidAndReleaseCodeNot(@Param("publisherUu") Long publisherUu, @Param("relbatchid") String relbatchid, @Param("releaseCode") List<Integer> releaseCode);
 
 	@Query("select r from ReleaseProductByBatch r where r.publisherUu =:publisherUu and r.relbatchid =:relbatchid and r.releaseCode in :failCodes")
 	List<ReleaseProductByBatch> findByPublisherUuAndRelbatchidAndFailCode(@Param("publisherUu") Long publisherUu, @Param("relbatchid") String relbatchid, @Param("failCodes") List<Integer> failCodes);
@@ -129,4 +131,13 @@ public interface ReleaseProductByBatchDao
      */
     @Procedure(procedureName = "PRODUCT_RELEASE_BATCH_PUBLISH")
     String callPublishByBatch(Long enuu, String enterName, String batchid);
+
+    /**
+     * 批量上架个人物料验证数据信息是否重复
+     * @param batch 本批次代码
+     * @param enuu 公司enuu
+     * @param useruu 个人UU
+     */
+    @Procedure(procedureName = "PRODUCT_RELEASE_PERSON_EXIST_VALID")
+    void callReleasePersonExistValidProcedure(String batch, Long enuu, Long useruu);
 }

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

@@ -406,7 +406,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 	}
 
-
 	/**
 	 * 调用存储过程
 	 * @param enUU 企业的enUU

+ 1 - 5
src/main/java/com/uas/platform/b2c/trade/order/controller/PurchaseProductController.java

@@ -3,7 +3,6 @@ package com.uas.platform.b2c.trade.order.controller;
 import com.uas.platform.b2c.common.base.model.FileUpload;
 import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.core.support.view.JxlsExcelView;
-import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
 import com.uas.platform.b2c.trade.order.service.PurchaseProductService;
 import com.uas.platform.b2c.trade.order.support.AjaxUtil;
 import com.uas.platform.b2c.trade.support.ResultMap;
@@ -43,9 +42,6 @@ public class PurchaseProductController {
     @Autowired
     private PurchaseProductService purchaseProductService;
 
-    @Autowired
-    private ReleaseProductByBatchService releaseProductByBatchService;
-
     /**
      * 下载Excel批量上传个人物料模板
      *
@@ -115,7 +111,7 @@ public class PurchaseProductController {
         if (loading == null || !Boolean.valueOf(loading.toString())) {
             session.setAttribute("load-error-ing", true);
         }
-        modelAndView.addObject("data", releaseProductByBatchService.findFailureReleaseProductByBatch(batch));
+        modelAndView.addObject("data", purchaseProductService.findFailureReleaseProductByBatch(batch));
         String url = "classpath:jxls-tpl/trade/releaseByBatchError-person";
         modelAndView.setView(new JxlsExcelView(url, "导出失败的个人物料-优软商城"));
         LOGGER.log("买家物料", "以Excel形式导出失败的个人物料");

+ 11 - 0
src/main/java/com/uas/platform/b2c/trade/order/service/PurchaseProductService.java

@@ -1,8 +1,11 @@
 package com.uas.platform.b2c.trade.order.service;
 
+import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import org.apache.poi.ss.usermodel.Workbook;
 
+import java.util.List;
+
 /**
  * 买家中心物料相关
  *
@@ -20,4 +23,12 @@ public interface PurchaseProductService {
      * @see ResultMap
      */
     ResultMap releasePersonalProductByExcel(Workbook workbook, Integer ignoreImport);
+
+    /**
+     * 通过批号查询导入失败的数据
+     *
+     * @param batch 批号
+     * @return List<ReleaseProductByBatch>
+     */
+    List<ReleaseProductByBatch> findFailureReleaseProductByBatch(String batch);
 }

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

@@ -29,6 +29,7 @@ import org.springframework.ui.ModelMap;
 import org.springframework.util.StringUtils;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -69,6 +70,12 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
      */
     private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(PurchaseProductServiceImpl.class);
 
+    /**
+     * 不需要传入的状态码
+     */
+    private final static List<Integer> failCode = Arrays.asList(ReleaseStatus.lack_info.value(),
+            ReleaseStatus.personal_had_exists.value());
+
     /**
      * 通过excel批量导入个人物料
      *
@@ -84,6 +91,10 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         if (sheet.getRow(0) == null) {
             return ResultMap.error(new IllegalOperatorException("表格模板不正确!请重新下载最新模板"));
         }
+        int headNum = sheet.getRow(0).getPhysicalNumberOfCells();
+        if (headNum != UploadConstant.TOTAL_COLUMN_PERSON && headNum != UploadConstant.MAX_TOTAL_COLUMN_PERSON) {
+            return ResultMap.error(new IllegalOperatorException("表格模板不正确!请重新下载最新模板"));
+        }
         int rowNum = SheetUtil.getSheetLastNum(sheet, UploadConstant.MAX_TOTAL_COLUMN);
         // 表头占用行数
         int minExcelNumber = 2;
@@ -134,13 +145,16 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             Long enUU = SystemSession.getUser().getEnterprise().getUu();
             // 验证数据信息是否重复
             releaseProductByBatchDao.callReleaseExistValidProcedure(batch, enUU);
+            // 验证数是否存在个人物料库
+            Long userUU = SystemSession.getUser().getUserUU();
+            releaseProductByBatchDao.callReleasePersonExistValidProcedure(batch, enUU, userUU);
             ModelMap modelMap = new ModelMap();
             // 处理上传数据
             assignmentProductInfo(enUU, modelMap, batch);
             // 验证成功后进行绑定处理
             Integer assignNumber = 0;
             // 去重后的数据
-            List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCodeNot(batch, ReleaseStatus.lack_info.value());
+            List<ReleaseProductByBatch> uniqueBatchList = releaseProductByBatchDao.findByRelbatchidAndReleaseCodeNot(userUU, batch, failCode);
             if (!CollectionUtils.isEmpty(uniqueBatchList)) {
                 assignNumber = assignBatch(uniqueBatchList);
             }
@@ -153,6 +167,17 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
         return ResultMap.success();
     }
 
+    /**
+     * 通过批号查询导入失败的数据
+     *
+     * @param batch 批号
+     * @return List<ReleaseProductByBatch>
+     */
+    @Override
+    public List<ReleaseProductByBatch> findFailureReleaseProductByBatch(String batch) {
+        return releaseProductByBatchDao.findByPublisherUuAndRelbatchidAndFailCode(SystemSession.getUser().getUserUU(), batch, failCode);
+    }
+
     /**
      * 初始化赋值
      *
@@ -272,7 +297,7 @@ public class PurchaseProductServiceImpl implements PurchaseProductService {
             params.put("data", data);
             HttpUtil.Response res = null;
             try {
-                res = HttpUtil.sendPostRequest(productServiceIp + "/productuser/coverToUserByIds", params);
+                res = HttpUtil.sendPostRequest("http://10.1.51.24" + "/productuser/coverToUserByIds", params);
                 return Integer.valueOf(res.getResponseText());
             } catch (Exception e) {
                 String resultCode = null != res ? String.valueOf(res.getStatusCode()) : "access error";

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

@@ -508,7 +508,7 @@ define([ 'app/app' ], function(app) {
             intervalId= setInterval(function () {
                 getDownLoadStatus();
             }, 500);
-        }else {
+        } else {
             if(!$scope.result || !$scope.result.batch) {
                 toaster.pop('info', '提示', '您没有上传信息');
             }else if(!$scope.result.filter) {

+ 12 - 4
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -3768,7 +3768,7 @@ define(['app/app', 'jquery-uploadify'], function(app) {
     }
     $scope.productUpOff = {}
     // 编辑上下架
-    $scope.dateArea = 'formMe';
+    // $scope.dateArea = 'formMe';
     var _item = null
     $scope.editProductUpOff = function(commodity, index) {
       if (commodity.erpReserve === '' ||  commodity.erpReserve === 0 || !commodity.erpReserve) {
@@ -3810,6 +3810,9 @@ define(['app/app', 'jquery-uploadify'], function(app) {
       // $scope.productUpOff.dateArea = $scope.productUpOff.goods.selfSale === 1 ? 'formMe' : 'autoMonth' // 自营还是销售
       commodity.dateArea = $scope.productUpOff.goods.selfSale === 1 ? 'formMe' : 'autoMonth' // 自营还是销售
       if (!$scope.productUpOff.goods.storeid) {
+        $scope.productUpOff.goods.selfSale = 0
+        commodity.dateArea = 'autoMonth'
+      } else {
         $scope.productUpOff.goods.selfSale = 1
         commodity.dateArea = 'formMe'
       }
@@ -3855,13 +3858,18 @@ define(['app/app', 'jquery-uploadify'], function(app) {
       }
     }
     // 选择寄售还是自营
-    $scope.productChangeSelfType = function(num, _type) {
+    $scope.productChangeSelfType = function(num, _type, obj) {
+      if ((!$scope.storeInfo.uuid || $scope.storeInfo.uuid === '33069557578d44e69bd91ad12d28a8d4') && _type === 'formMe'){
+        toaster.pop('warning','提示','您还未开店铺,不能选择自营')
+        obj.dateArea = 'autoMonth'
+        return
+      }
       // $scope.productUpOff.goods.selfSale = num
       // $scope.productUpOff.goods.selfSale = num
       $scope.productUpOff.goods.dateArea = _type
-      // $scope.material.dateArea = _type
+
     }
-    // 上下架保存按钮
+    // 编辑上下架保存按钮
     $scope.productSave = function() {
       $scope.productUpOff.EditMinBuyQty = false
       if (!$scope.productUpOff.goods.minBuyQty || $scope.productUpOff.goods.minBuyQty === 0) {

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

@@ -616,21 +616,13 @@
                                 <a href="javascript:void(0)" ng-click="upload()" ng-disabled="!batch.myFiles[0]" class="blue-bg" style="margin-left: 18px;">确认上传</a>
                             </div>
                             <!--批量删除操作-->
-                           <!-- <div class="check fr">
-                                <a  ng-click="">批量操作</a>
-                                <span class="check-btn">
-                                    <label class="check-active">
-                                        <input type="checkbox" id="AllChoose"/>
-                                        <label for="AllChoose"></label>
-                                        <span>全选</span>
-                                    </label>
-                                    <a href="#">删除</a>
-                                    <a href="#">取消</a>
-                                    <a href="#">确定</a>
-                                </span>
-                            </div>-->
                         </div>
-                        <div class="txt-info" ng-if="result && result.total != 0 && !hadImport">成功导入 <span ng-bind="result.success + result.failure">600</span> 个产品(其中标准产品 <span ng-bind="result.success">200</span> 个,非标产品 <span ng-bind="result.failure">400</span> 个)<b class="success-hidden" ng-if="result.filter != 0">,下载 <a ng-click="downloadExcel()">导入失败产品</a></b></div>
+                        <div class="txt-info" ng-if="result && result.total != 0 && !hadImport">
+                            成功导入 <span ng-bind="result.assignSuccess">600</span> 个产品
+                            <!--(其中标准产品
+                            <span ng-bind="result.success">200</span> 个,非标产品
+                            <span ng-bind="result.failure">400</span> 个)-->
+                            <b class="success-hidden" ng-if="result.assignFailure != 0">,下载 <a ng-click="downloadExcel()">导入失败产品</a></b></div>
                         <div ng-show="$$productOn.tab == 'bathOn' && isPcbStore">
                             <table ng-table="relTableParams" class="public-tab table">
                                 <thead>

+ 2 - 2
src/main/webapp/resources/view/vendor/forstore/vendor_material.html

@@ -1432,12 +1432,12 @@
 														<div class="name pull-left">销售方式:</div>
 														<div class="pull-left">
 															<label class="com-check-radio">
-																<input type="radio" id="{{'autoMonth' + $index}}" ng-click="productChangeSelfType(1, 'formMe')" name="date" ng-checked="material.dateArea === 'formMe'">
+																<input type="radio" id="{{'autoMonth' + $index}}" ng-click="productChangeSelfType(1, 'formMe', material)" name="date" ng-model="material.dateArea" value="formMe">
 																<label style="vertical-align: top" for="{{'autoMonth' + $index}}"></label>
 																自营
 															</label>
 															<label class="com-check-radio">
-																<input type="radio" id="{{'autoMonth_' + $index}}" ng-click="productChangeSelfType(2, 'autoMonth')" name="date" ng-checked="material.dateArea === 'autoMonth'">
+																<input type="radio" id="{{'autoMonth_' + $index}}" ng-click="productChangeSelfType(2, 'autoMonth', material)" name="date"   ng-model="material.dateArea" value="autoMonth">
 																<label style="vertical-align: top" for="{{'autoMonth_' + $index}}"></label>
 																寄售
 															</label>