Browse Source

调整ERP上架的信息

yujia 8 years ago
parent
commit
d426d9463f

+ 2 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java

@@ -331,7 +331,7 @@ public class ProductController {
 	 * @return
 	 */
 	@RequestMapping(value = "/batch", method = RequestMethod.PUT)
-	public ResultMap batchPutOn() {
-		return productService.batchPutOn();
+	public ResultMap batchPutOn(Integer standard, String ids) {
+		return productService.batchPutOn(standard, ids);
 	}
 }

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

@@ -195,7 +195,9 @@ public interface ProductService {
     /**
      * 用户批量上架
      *
+     * @param standard 是否是标准
+     * @param ids 操作的主键
      * @return
      */
-    ResultMap batchPutOn();
+    ResultMap batchPutOn(Integer standard, String ids);
 }

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

@@ -7,6 +7,7 @@ import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.constant.IntegerConstant;
 import com.uas.platform.b2c.core.constant.ShortConstant;
+import com.uas.platform.b2c.core.constant.SplitChar;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.core.utils.NumberUtil;
@@ -52,6 +53,7 @@ import com.uas.platform.core.model.Type;
 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 org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -1332,7 +1334,16 @@ public class ProductServiceImpl implements ProductService {
      * @return
      */
     @Override
-    public ResultMap batchPutOn() {
+    public ResultMap batchPutOn(Integer standard, String ids) {
+        List<Long> prIdLong = null;
+        if (StringUtils.isEmpty(ids) && StringUtils.isEmpty(standard)) {
+            return new ResultMap(CodeType.PARAMETER_ERROR.code(), "没有选择需要操作的信息", null);
+        } else {
+            if (!StringUtils.isEmpty(ids)) {
+                Long[] idArray = (Long[]) ConvertUtils.convert(ids.split(SplitChar.COMMA), Long.class);
+                prIdLong = Arrays.asList(idArray);
+            }
+        }
         Long uu = SystemSession.getUser().getEnterprise().getUu();
         ResultMap registerAddress = enterpriseService.getCurrencyByRegisterAddress();
         String currency = null;
@@ -1356,9 +1367,18 @@ public class ProductServiceImpl implements ProductService {
         if (property == null) {
             return new ResultMap(CodeType.NOT_COMPLETE_INFO.code(), "请先设置上架参数", null);
         }
-        String sql = "select p.pr_id from products p left join product$private pp on pp.pr_id = p.pr_id where pp.pr_batchcount = 0 and p.pr_sourceapp = 'ERP' and p.pr_reserve <> 0 and p.pr_reserve is not null and pp.pr_b2cenabled = 1 and p.pr_enuu = (:enuu) and p.pr_id not in (select DISTINCT go_productid from trade$goods where  go_productid is not null);";
-        Map<String, Long> map = new HashMap<>();
-        map.put("enuu", uu);
+        String sql = null;
+        Map<String, Object> map = new HashMap<>();
+        if ((prIdLong != null) && (prIdLong.size() != 0)) {
+            sql = "select p.pr_id from products p left join product$private pp on pp.pr_id = p.pr_id where ifnull(pp.pr_batchcount, 0) = 0 and p.pr_sourceapp = 'ERP' and p.pr_reserve <> 0 and ifnull(pp.pr_b2cenabled, 0) = 1 and p.pr_id in (:ids) and p.pr_id not in (select DISTINCT go_productid from trade$goods where  go_productid is not null);";
+            map.put("ids", prIdLong);
+        } else {
+            // 暂时不会进入当前循环,速度比较低
+            sql = "select p.pr_id from products p left join product$private pp on pp.pr_id = p.pr_id where ifnull(pp.pr_batchcount, 0) = 0 and p.pr_sourceapp = 'ERP' and p.pr_reserve <> 0 and ifnull(pp.pr_b2cenabled,0) = 1 and if(p.pr_standard, 0) = (:standard) and p.pr_enuu = (:enuu) and p.pr_id not in (select DISTINCT go_productid from trade$goods where  go_productid is not null);";
+            map.put("enuu", uu);
+            map.put("standard", standard);
+        }
+
         List<Long> longList = namedParameterJdbcTemplate.queryForList(sql, map, Long.class);
          if (longList.size() == 0) {
             return new ResultMap(CodeType.OK.code(), "没有可上架的信息", null);

+ 10 - 2
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -2041,13 +2041,21 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			if (isFluctuateRateChange || isMinDeliveryChange || isMaxDeliveryChange) {
 				toaster.pop('warning', '提示', '批量上架配置信息被修改,请保存批量上架配置信息之后再上架');
                 return ;
-				// $scope.saveBatchPutOnProperty();
 			}
-			Material.batchPutOn(null, null, function (data) {
+			$scope.choosedIds = [];
+			$scope.getChoosedInfo();
+			if(!$scope.isChoosedAll && (!$scope.choosedIds || $scope.choosedIds.length == 0)) {
+				toaster.pop('warning', '提示','请选择要删除的信息');
+				return true;
+			}
+			var idStr = ($scope.choosedIds != null) ? $scope.choosedIds.join(',') : null;
+			var std = $scope.standard_tab == 'standard' ? 1 : 0;
+			Material.batchPutOn({'standard' : std, ids : idStr}, null, function (data) {
 				toaster.pop('success', '成功', data.message);
 			}, function (response) {
 				toaster.pop('error', '失败', response.data);
 			});
+
 		}
 
         /**