Browse Source

ERP的物料 批量上架调整

yujia 8 years ago
parent
commit
a8fb7261c0

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

@@ -124,7 +124,7 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      * @return
      */
     @Query(value = "select p from Product p where p.enUU = :enuu and p.sourceApp = :sourceapp and (p.batchCount = 0 or p.batchCount is null) and (p.erpReserve is not null and p.erpReserve <> 0)")
-    List<Product> findByEnUUAndSourceAppNotPutOn(Long enuu, String sourceapp);
+    List<Product> findByEnUUAndSourceAppNotPutOn(@Param("enuu") Long enuu, @Param("sourceapp") String sourceapp);
 
     /**
      * 统计数量 通过企业uu,来源获取物料信息 并且未存在上架信息

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

@@ -18,7 +18,7 @@ public class UASBatchPutOnProperty implements Serializable{
 
     @Id
     @Column(name = "ubpp_id")
-    @GeneratedValue(strategy = GenerationType.SEQUENCE)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
 
     /**

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

@@ -17,7 +17,7 @@ public class UASBatchPutOnPropertyHistory implements Serializable {
 
     @Id
     @Column(name = "ubpph_id")
-    @GeneratedValue(strategy = GenerationType.SEQUENCE)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
 
     /**
@@ -53,7 +53,7 @@ public class UASBatchPutOnPropertyHistory implements Serializable {
     /**
      * 上架的企业
      */
-    @Column(name = "ubpp_enname")
+    @Column(name = "ubpph_enname")
     private String enName;
 
     public Long getId() {

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

@@ -1214,6 +1214,9 @@ public class ProductServiceImpl implements ProductService {
             storeid = storeIn.getUuid();
         }
         UASBatchPutOnProperty property = uasBatchPutOnPropertyService.get();
+        if (property == null) {
+            return new ResultMap(CodeType.NOT_COMPLETE_INFO.code(), "请先设置上架参数", null);
+        }
         // 暂时先不考虑数据过多的情况
 //        Integer count = productDao.findCountByEnUUAndSourceAppNotPutOn(uu, StringConstant.ERP);
 //        if (count > 1000) {
@@ -1241,9 +1244,9 @@ public class ProductServiceImpl implements ProductService {
         }
         if ((sourceAppNotPutOn.size() - result.size()) != 0) {
             if (!StringUtils.isEmpty(message)) {
-                message = " ,";
+                message = message +  " ,";
             }
-            message = "失败" + (sourceAppNotPutOn.size()-  result.size()) + "个";
+            message = "失败" + (sourceAppNotPutOn.size()-  result.size()) + "个, 失败原因:产品上架必填字段为空, 请完善";
         }
         return new ResultMap(CodeType.OK.code(), message);
     }
@@ -1288,31 +1291,42 @@ public class ProductServiceImpl implements ProductService {
         g.setMinDelivery(property.getMinDelivery());
         g.setProdNum(product.getProdNum());
         g.setTag(StringConstant.INIT_TAG);
-        g.setPackaging(detail.getPackaging() == null ? product.getPackaging(): detail.getPackaging());
+        g.setBreakUp(Boolean.FALSE);
+        g.setReserve(product.getErpReserve());
+
+        g.setPackaging((detail == null || detail.getPackaging() == null) ? product.getPackaging(): detail.getPackaging());
         if (g.getPackaging() == null) {
             g.setPackaging(StringConstant.DEFAULTPACKAGING);
         }
-        g.setProduceDate(detail.getProduceDate() == null ? product.getProduceDate() : detail.getProduceDate());
+
+
+        g.setProduceDate((detail == null || detail.getProduceDate() == null) ? product.getProduceDate() : detail.getProduceDate());
         if (g.getProduceDate() == null) {
             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
             String format = formatter.format(new Date());
             g.setProduceDate(format);
         }
-        g.setBreakUp(Boolean.FALSE);
-        g.setReserve(detail.getReserve());
-        g.setMinPackQty(detail.getMinPackQty() == null ? product.getMinPackQty() : detail.getMinPackQty());
-        g.setMinBuyQty(detail.getMinBuyQty());
-        if (g.getMinPackQty() == null && g.getMinBuyQty() == null) {
+
+
+        g.setMinPackQty((detail == null || detail.getMinPackQty() == null) ? product.getMinPackQty() : detail.getMinPackQty());
+        g.setMinBuyQty(detail != null ? detail.getMinBuyQty() : null);
+        int minPackQty = NumberUtil.compare(g.getMinPackQty(), DoubleConstant.zero);
+        int minBuyQty = NumberUtil.compare(g.getMinBuyQty(), DoubleConstant.zero);
+        if (minPackQty == 0 && minBuyQty == 0) {
             return new ResultMap(CodeType.NOT_COMPLETE_INFO, "上架必填信息缺失");
         } else {
-            if (g.getMinBuyQty() == null || g.getMinPackQty() == null) {
-                Double d = g.getMinBuyQty() == null ? g.getMinPackQty() : g.getMinBuyQty();
+            if (minPackQty == 0 || minBuyQty == 0) {
+                Double d = minBuyQty == 0 ? g.getMinPackQty() : g.getMinBuyQty();
                 g.setMinBuyQty(d);
                 g.setMinPackQty(d);
             }
-            double div = NumberUtil.div(g.getMinBuyQty(), g.getMinPackQty());
-            if (NumberUtil.compare(div, DoubleConstant.zero) != 0) {
-                g.setMinBuyQty(NumberUtil.sub(g.getMinBuyQty(), div));
+            double remainder = g.getMinBuyQty() % g.getMinPackQty();
+            if (NumberUtil.compare(remainder, DoubleConstant.zero) != 0) {
+                g.setMinBuyQty(NumberUtil.sub(g.getMinBuyQty(), remainder));
+            }
+            int k = NumberUtil.compare(g.getMinBuyQty(), g.getMinPackQty());
+            if (k < 0) {
+                g.setMinBuyQty(g.getMinPackQty());
             }
         }
         double price = NumberUtil.mul(detail.getPrice(), property.getFluctuateRate());

+ 10 - 0
src/main/webapp/resources/js/common/query/UASBatchPutOnProperty.js

@@ -0,0 +1,10 @@
+define([ 'ngResource'], function() {
+    angular.module('UASBatchPutOnPropertyModule', [ 'ngResource']).factory('UASBatchPutOnPropertyServices', ['$resource' , function($resource) {
+        return $resource('UASBatchPutOnProperty', {}, {
+            save: {
+                url : 'UASBatchPutOnProperty/save',
+                method : 'POST'
+            }
+        });
+    }]);
+});

+ 5 - 0
src/main/webapp/resources/js/common/query/material.js

@@ -76,6 +76,11 @@ define([ 'ngResource' ], function() {
             updateInfoAfterChoose : {
                 url: 'trade/products/update/goods',
                 method: 'POST'
+            },
+            //批量上架信息
+            batchPutOn: {
+                url: 'trade/products/batch',
+                method: 'PUT'
             }
         });
     }]);

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

@@ -1,4 +1,4 @@
-define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'common/query/brand', 'common/query/kind', 'common/query/component', 'common/query/goods','common/query/rate', 'common/query/cart', 'common/query/order', 'common/query/address', 'common/query/invoice', 'common/query/property', 'common/query/kindAdvice', 'common/query/propertyAdvice', 'common/query/return' , 'common/query/change', 'common/query/logistics', 'ui.router', 'ui-bootstrap', 'ui-form', 'ui-jquery', 'angular-toaster', 'ngDraggable', 'angular-sanitize', 'ngTable', 'dynamicInput', 'jquery-imagezoom', 'file-upload', 'file-upload-shim', 'common/query/urlencryption' , 'common/query/purchase', 'common/query/vendor', 'common/query/goods', 'common/query/bankTransfer', 'common/query/enterprise', 'common/query/bill', 'common/query/receipt', 'common/query/collection', 'common/query/express', 'common/query/bankInfo','common/query/charge', 'common/query/statistics', 'common/query/currency', 'jquery-chart', 'common/query/responseLogistics', 'common/query/goodsPrice', 'common/query/address' , 'common/query/search', 'common/query/urlencryption', 'common/query/releaseProInfo', 'common/query/makerDemand', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/logistics', 'common/query/storeInfo', 'common/query/recommendation', 'common/query/user', 'common/query/logisticsPort', 'common/query/cms', 'common/query/material', 'common/query/storeCms', 'common/query/productImport', 'common/query/stockInOut', 'common/module/store_recommend_product', 'common/module/chat_web_module', 'common/query/standardPutOnAdmin', 'common/query/storeViolations', 'common/query/internalMessage', 'common/query/installments','common/query/product'], function(angularAMD) {
+define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'common/query/brand', 'common/query/kind', 'common/query/component', 'common/query/goods','common/query/rate', 'common/query/cart', 'common/query/order', 'common/query/address', 'common/query/invoice', 'common/query/property', 'common/query/kindAdvice', 'common/query/propertyAdvice', 'common/query/return' , 'common/query/change', 'common/query/logistics', 'ui.router', 'ui-bootstrap', 'ui-form', 'ui-jquery', 'angular-toaster', 'ngDraggable', 'angular-sanitize', 'ngTable', 'dynamicInput', 'jquery-imagezoom', 'file-upload', 'file-upload-shim', 'common/query/urlencryption' , 'common/query/purchase', 'common/query/vendor', 'common/query/goods', 'common/query/bankTransfer', 'common/query/enterprise', 'common/query/bill', 'common/query/receipt', 'common/query/collection', 'common/query/express', 'common/query/bankInfo','common/query/charge', 'common/query/statistics', 'common/query/currency', 'jquery-chart', 'common/query/responseLogistics', 'common/query/goodsPrice', 'common/query/address' , 'common/query/search', 'common/query/urlencryption', 'common/query/releaseProInfo', 'common/query/makerDemand', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/logistics', 'common/query/storeInfo', 'common/query/recommendation', 'common/query/user', 'common/query/logisticsPort', 'common/query/cms', 'common/query/material', 'common/query/storeCms', 'common/query/productImport', 'common/query/stockInOut', 'common/module/store_recommend_product', 'common/module/chat_web_module', 'common/query/standardPutOnAdmin', 'common/query/storeViolations', 'common/query/internalMessage', 'common/query/installments', 'common/query/product', ,'common/query/UASBatchPutOnProperty'], function(angularAMD) {
 	'use strict';
 	/**
 	 * 自定义Array对象的属性last 方法
@@ -8,7 +8,7 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
 		return this.length > 0 ? this[this.length - 1] : null;
 	};
 
-	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ui.form', 'ui.jquery', 'toaster', 'ngDraggable', 'tool.directives', 'ngSanitize', 'common.query.kind', 'common.services', 'brandServices', 'componentServices', 'goodsServices',  'rateServices','cartServices', 'orderServices', 'addressServices', 'invoiceServices', 'common.query.propertyAdvice', 'propertyServices', 'returnServices' , 'changeServices',  'logisticsServices', 'common.query.kindAdvice', 'ngTable', 'ngDynamicInput', 'common.directives', 'angularFileUpload', 'urlencryptionServices', 'purchaseServices', 'vendorServices', 'goodsServices', 'bankTransfer', 'common.query.enterprise', 'billServices', 'receiptServices', 'collection', 'expressServices', 'bankInfo','Charge', 'statisticsServices', 'currencyService', 'responseLogisticsService', 'PriceServices', 'addressServices', 'searchService', 'urlencryptionServices', 'ReleaseProductByBatchService', 'makerDemand', 'afterSaleService', 'messageBoardServices', 'logisticsServices', 'table.directives', 'storeInfoServices', 'recommendation', 'common.query.user', 'logisticsPortService', 'cmsService', 'materialServices', 'StoreCmsServices', 'productImportModule', 'stockInOutModule', 'StoreCmsModule', 'WebChatModule', 'StandardPutOnAdminModule', 'StoreViolationsServices', 'internalMessageServices', 'common.query.product', 'ui.tour', 'installmentServices']);
+	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ui.form', 'ui.jquery', 'toaster', 'ngDraggable', 'tool.directives', 'ngSanitize', 'common.query.kind', 'common.services', 'brandServices', 'componentServices', 'goodsServices',  'rateServices','cartServices', 'orderServices', 'addressServices', 'invoiceServices', 'common.query.propertyAdvice', 'propertyServices', 'returnServices' , 'changeServices',  'logisticsServices', 'common.query.kindAdvice', 'ngTable', 'ngDynamicInput', 'common.directives', 'angularFileUpload', 'urlencryptionServices', 'purchaseServices', 'vendorServices', 'goodsServices', 'bankTransfer', 'common.query.enterprise', 'billServices', 'receiptServices', 'collection', 'expressServices', 'bankInfo','Charge', 'statisticsServices', 'currencyService', 'responseLogisticsService', 'PriceServices', 'addressServices', 'searchService', 'urlencryptionServices', 'ReleaseProductByBatchService', 'makerDemand', 'afterSaleService', 'messageBoardServices', 'logisticsServices', 'table.directives', 'storeInfoServices', 'recommendation', 'common.query.user', 'logisticsPortService', 'cmsService', 'materialServices', 'StoreCmsServices', 'productImportModule', 'stockInOutModule', 'StoreCmsModule', 'WebChatModule', 'StandardPutOnAdminModule', 'StoreViolationsServices', 'internalMessageServices', 'common.query.product', 'ui.tour', 'installmentServices', 'UASBatchPutOnPropertyModule']);
 	//初始化,启动时载入app
 	app.init = function() {
 		angularAMD.bootstrap(app);

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

@@ -1,6 +1,6 @@
 define([ 'app/app', 'jquery-uploadify' ], function(app) {
 	'use strict';
-	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', 'DistributionRule', 'prodRepositoryService', 'AuthenticationService', 'StoreInfo', 'ProductServiceQuery', 'StoreCms', 'ByteCountService', 'Goods', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI, DistributionRule, prodRepositoryService, AuthenticationService, StoreInfo, ProductServiceQuery, StoreCms, ByteCountService, Goods) {
+	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', '$location', '$stateParams', 'Search', '$modal', 'ComponentActiveAPI', 'BrandSubmit', 'BrandActiveAPI', 'DistributionRule', 'prodRepositoryService', 'AuthenticationService', 'StoreInfo', 'ProductServiceQuery', 'StoreCms', 'ByteCountService', 'Goods', 'UASBatchPutOnPropertyServices', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, $location, $stateParams, Search, $modal, ComponentActiveAPI, BrandSubmit, BrandActiveAPI, DistributionRule, prodRepositoryService, AuthenticationService, StoreInfo, ProductServiceQuery, StoreCms, ByteCountService, Goods, UASBatchPutOnPropertyServices) {
 		$rootScope.active = 'vendor_material';
 		document.title = '卖家产品库-优软商城';
 		$scope.tab = 'material';
@@ -17,6 +17,10 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 
 		$scope.$$nonProduct.enterSaveButton = false;
 
+		$scope.$$nonProduct.enterBatchPutOnPropertySaveButton = false;
+
+		$scope.uasBatchPutOnProperty = {editFluctuateRate : 1, editMaxDelivery : 1, editMinDelivery : 1};
+
 		$scope.salePrice = 0;
 
 		$scope.setSalePrice = function (price) {
@@ -1918,6 +1922,110 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			return str;
 		};
 
+		/***
+		 * 验证交期是否正确
+		 *
+		 * @param min
+		 * @param max
+		 */
+		$scope.uasBatchChangeDeliver = function(min, max, isMax) {
+			if ($scope.$$nonProduct.enterBatchPutOnPropertySaveButton) {
+				return ;
+			}
+			var day;
+			day = isMax ? max : min;
+			if (typeof day == 'undefined') {
+				return ;
+			} else {
+				if ($scope.isInt.test(day)) {
+					if (Number(day) < 1 || Number(day) > 31) {
+						toaster.pop('warning', '提示', '交期必须是1-31的整数');
+						return ;
+					}
+				} else {
+					toaster.pop('warning', '提示', '交期必须是1-31的整数');
+					return ;
+				}
+			}
+
+			if ($scope.isInt.test(min) && $scope.isInt.test(max)) {
+				if (max < min) {
+					toaster.pop('warning', '提示', '最小交期不能大于最大交期');
+				}
+			}
+		};
+
+		/**
+		 * 鼠标移入保存的按钮
+		 */
+		$scope.enterBatchPutOnPropertySaveButton = function () {
+			$scope.$$nonProduct.enterBatchPutOnPropertySaveButton = true;
+		}
+
+		/**
+		 * 鼠标移出保存按钮
+		 */
+		$scope.leaveBatchPutOnPropertySaveButton = function () {
+			$scope.$$nonProduct.enterBatchPutOnPropertySaveButton = false;
+		}
+
+		/**
+		 * 验证配置的信息
+		 */
+		$scope.validateBatchPutOnProperty = function() {
+			if (!$scope.uasBatchPutOnProperty.editFluctuateRate || Number($scope.uasBatchPutOnProperty.editFluctuateRate) < 1 || Number($scope.uasBatchPutOnProperty.editFluctuateRate) > 200) {
+				toaster.pop('warning', '提示', '浮动率必须介于1-200');
+				return false;
+			}
+			if (!$scope.uasBatchPutOnProperty.editMinDelivery || !$scope.uasBatchPutOnProperty.editMaxDelivery) {
+				toaster.pop('warning', '提示', '交期必须是1-31的整数');
+				return false;
+			}
+			if (Number($scope.uasBatchPutOnProperty.editMinDelivery) > Number($scope.uasBatchPutOnProperty.editMaxDelivery)) {
+				toaster.pop('warning', '提示', '最小交期不能大于最大交期');
+				return false;
+			}
+
+			return true;
+		}
+
+		/**
+		 * 批量保存配置信息
+		 */
+		$scope.saveBatchPutOnProperty = function() {
+			var isPass = $scope.validateBatchPutOnProperty();
+			if (!isPass) {
+				return ;
+			}
+			$scope.uasBatchPutOnProperty.fluctuateRate = $scope.uasBatchPutOnProperty.editFluctuateRate / 100;
+			$scope.uasBatchPutOnProperty.minDelivery = $scope.uasBatchPutOnProperty.editMinDelivery;
+			$scope.uasBatchPutOnProperty.maxDelivery = $scope.uasBatchPutOnProperty.editMaxDelivery;
+			UASBatchPutOnPropertyServices.save(null, $scope.uasBatchPutOnProperty, function (data) {
+				if (data.code == 1) {
+					$scope.uasBatchPutOnProperty = data.data;
+					$scope.uasBatchPutOnProperty.editFluctuateRate =  $scope.uasBatchPutOnProperty.fluctuateRate * 100;
+					$scope.uasBatchPutOnProperty.editMinDelivery = $scope.uasBatchPutOnProperty.minDelivery;
+					$scope.uasBatchPutOnProperty.editMaxDelivery = $scope.uasBatchPutOnProperty.maxDelivery;
+					toaster.pop('success', '成功', "保存成功");
+				} else {
+					toaster.pop('error', '失败', data.message);
+				}
+			}, function (response) {
+				toaster.pop('error', '失败', response.data);
+			});
+		};
+
+		/**
+		 * 批量上架信息
+		 */
+		$scope.batchPutOn = function () {
+			Material.batchPutOn(null, null, function (data) {
+				toaster.pop('success', '成功', data.message);
+			}, function (response) {
+				toaster.pop('error', '失败', response.data);
+			});
+		}
+
         /**
          * 编辑包装方式的信息
          * @param goods

+ 4 - 4
src/main/webapp/resources/view/vendor/forstore/erp/vendor_material_erp.html

@@ -1606,8 +1606,8 @@
 							<span>全选</span>
 						</label>
 						<div class="fr">
-							<span class="com-btn-level1 com-btn-submit">上架</span>
-							<span class="com-btn-level1 com-btn-submit">保存</span>
+							<span class="com-btn-level1 com-btn-submit" ng-click="batchPutOn()">上架</span>
+							<span class="com-btn-level1 com-btn-submit" ng-mouseenter="enterBatchPutOnPropertySaveButton()" ng-mouseleave="leaveBatchPutOnPropertySaveButton()" ng-click="saveBatchPutOnProperty()">保存</span>
 							<span class="com-btn-level1 com-btn-red">删除</span>
 							<span class="com-btn-level1 com-btn-cancel">取消</span>
 						</div>
@@ -1615,7 +1615,7 @@
 					<div class="operate-content">
 						<div class="batch-sale">
 							<p><span class="batch-price-title">批量设置销售价:</span><em>0</em><span class="batch-progress"><i style="left: {{salePrice ? salePrice > 200 ? '100%' : salePrice / 2 + '%' : 0}}"></i></span><em>200</em></p>
-							<div><span>销售价 = 近一个月的平均销售价 X </span><input type="number" ng-model="salePrice" ng-change="onSalePriceChange()"> %
+							<div><span>销售价 = 近一个月的平均销售价 X </span><input type="number" ng-model="uasBatchPutOnProperty.editFluctuateRate" ng-change="onSalePriceChange()"> %
 								<span class="com-btn-level2 com-btn-submit" ng-click="setSalePrice(100)">100%</span>
 								<span class="com-btn-level2 com-btn-submit" ng-click="setSalePrice(120)">120%</span>
 								<span class="com-btn-level2 com-btn-submit" ng-click="setSalePrice(130)">130%</span>
@@ -1624,7 +1624,7 @@
 						</div>
 						<div class="batch-date">
 							<p>批量设置交期:</p>
-							<div><span>交期(天)= </span><input type="number"> - <input type="number"></div>
+							<div><span>交期(天)= </span><input type="number" ng-model="uasBatchPutOnProperty.editMinDelivery" ng-blur="uasBatchChangeDeliver(uasBatchPutOnProperty.editMinDelivery, uasBatchPutOnProperty.editMaxDelivery, false)"> - <input type="number" ng-model="uasBatchPutOnProperty.editMaxDelivery" ng-blur="uasBatchChangeDeliver(uasBatchPutOnProperty.editMinDelivery, uasBatchPutOnProperty.editMaxDelivery, true)"></div>
 						</div>
 					</div>
 				</div>