Browse Source

后台产品管理调整

hulh 8 years ago
parent
commit
7ec811cf6d

+ 3 - 3
src/main/java/com/uas/platform/b2c/external/erp/commodity/service/impl/ProductDetailERPServiceImpl.java

@@ -115,7 +115,7 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                             if (!CollectionUtils.isEmpty(goods)) {
                                 for (Goods good : goods) {
                                     if (Double.compare(subtractDecimal.doubleValue(), good.getReserve()) == 0) {// 差值等于此批次数量,直接下架此批次
-                                        goodsService.offShelfGoodsByProvider(good.getBatchCode());
+                                        goodsService.offShelfGoodsByProvider(good.getBatchCode(), null);
                                         break;
                                     }
 
@@ -126,7 +126,7 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                                         loggerInfo.info(SystemSession.getUser().getEnterprise().getEnName() + "更新库存: " + products.get(0).getProdNum() + ",self is" + good.getSelfSale());
                                         // 如果调整后的库存小于最小起订量直接下架
                                         if (good.getReserve() < good.getMinBuyQty()) {
-                                            goodsService.offShelfGoodsByProvider(good.getBatchCode());
+                                            goodsService.offShelfGoodsByProvider(good.getBatchCode(), null);
                                         } else {
                                             goodsService.updateGoods(nowGood, good);
                                             goodsService.updateComponentTradeInfos(nowGood.getUuid());
@@ -135,7 +135,7 @@ public class ProductDetailERPServiceImpl implements ProductDetailERPService {
                                     }
 
                                     if (Double.compare(subtractDecimal.doubleValue(), good.getReserve()) > 0) {// 差值大于此批次数量,下架次批次,并继续下一批次调整
-                                        goodsService.offShelfGoodsByProvider(good.getBatchCode());
+                                        goodsService.offShelfGoodsByProvider(good.getBatchCode(), null);
                                         subtractDecimal = subtractDecimal.subtract(BigDecimal.valueOf(good.getReserve()));
                                     }
                                 }

+ 111 - 8
src/main/webapp/resources/js/admin/controllers/product/productManageCtrl.js

@@ -49,7 +49,7 @@ define(['app/app'], function(app) {
             angular.forEach($scope.goodsList, function (list) {
                 list.isChoosed = $scope.isChooseAll;
             })
-        }
+        };
 
         // 检查是否全选
         var checkChoosedAll = function () {
@@ -67,10 +67,28 @@ define(['app/app'], function(app) {
             checkChoosedAll();
         };
 
+        //获取选中之后的信息
+        var getChooseBatch = function () {
+            $scope.choosedBatch = [];
+            angular.forEach($scope.goodsList, function (goods) {
+                if (goods.isChoosed) {
+                    $scope.choosedBatch.push(goods.batchCode);
+                }
+            });
+        };
+
+        $scope.batchDown = function () {
+            getChooseBatch();
+            if (!$scope.choosedBatch || $scope.choosedBatch.length == 0) {
+                toaster.pop("info", "您尚未选中任何产品");
+                return ;
+            }
+            $scope.soldOutProduct($scope.choosedBatch);
+        };
+
         var initKindDataInfo = function () {
             Commodity.getAllKindInfo({}, function (data) {
                 $scope.kindInfo = data;
-                console.log(data)
             })
         };
         initKindDataInfo();
@@ -228,14 +246,15 @@ define(['app/app'], function(app) {
 
             })
         };
+
         // 下架事件
-        $scope.soldOutProduct = function (data) {
+        $scope.soldOutProduct = function (batchArray) {
             var modalInstance = $modal.open({
                 templateUrl: 'static/view/admin/modal/manage/ManageSoldOut.html',
                 controller: 'soleOutCtrl',
                 resolve: {
-                    account: function () {
-                        return angular.copy(data);
+                    batchArray: function () {
+                        return angular.copy(batchArray);
                     }
                 }
             });
@@ -326,6 +345,26 @@ define(['app/app'], function(app) {
             $scope.errorType = type;
         };
 
+        var countLength = function (string) {
+            return string.replace(/[^\x00-\xff]/g, '**').length;
+        };
+
+        var cutOutString = function (str, length) {
+            for (var i = 1; i <= str.length; i++) {
+                if (countLength(str.substr(0, i)) > length){
+                    str = str.substr(0, i-1);
+                    break;
+                }
+            }
+            return str;
+        };
+
+        $scope.inputMessage = function () {
+            if ($scope.otherMessage) {
+                $scope.otherMessage = cutOutString($scope.otherMessage, 30);
+            }
+        };
+
         $scope.ensureAudit = function (pass) {
             if (!pass) {
                 if (!$scope.errorType) {
@@ -333,7 +372,7 @@ define(['app/app'], function(app) {
                     return;
                 }
                 if ($scope.errorType == 5) {
-                    if (!$scope.otherMessage || $scope.otherMessage.length == 0) {
+                    if (!$scope.otherMessage || countLength($scope.otherMessage) < 2) {
                         toaster.pop("info", "原因至少要填写2个字");
                         return;
                     }
@@ -386,10 +425,74 @@ define(['app/app'], function(app) {
             $modalInstance.dismiss();
         }
     }]);
-    app.register.controller('soleOutCtrl', ['$scope', 'account', '$modalInstance', function($scope, account, $modalInstance) {
+
+    app.register.controller('soleOutCtrl', ['$scope', 'batchArray', 'Goods', 'toaster', '$modalInstance', function($scope, batchArray, Goods, toaster, $modalInstance) {
+        $scope.errorMsg = '';
+        $scope.otherMessage = '';
+        $scope.errorArray = ['价格异常', '图片违规', '基本信息有误', '短缺货'];
+
+        var countLength = function (string) {
+            return string.replace(/[^\x00-\xff]/g, '**').length;
+        };
+
+        var cutOutString = function (str, length) {
+            for (var i = 1; i <= str.length; i++) {
+                if (countLength(str.substr(0, i)) > length){
+                    str = str.substr(0, i-1);
+                    break;
+                }
+            }
+            return str;
+        };
+
+        $scope.inputMessage = function () {
+            if ($scope.otherMessage) {
+                $scope.otherMessage = cutOutString($scope.otherMessage, 30);
+            }
+        };
+
         $scope.cancel = function () {
             $modalInstance.dismiss();
-        }
+        };
+
+        $scope.changeType = function (type) {
+            $scope.errorType = type;
+        };
+
+        $scope.ensureDown = function () {
+            if (!$scope.errorType) {
+                toaster.pop("info", "您尚未选择下架原因");
+                return;
+            }
+            if ($scope.errorType == 5) {
+                if (!$scope.otherMessage || countLength($scope.otherMessage) < 2) {
+                    toaster.pop("info", "原因至少要填写2个字");
+                    return;
+                }
+            }
+            if ($scope.errorType == 5) {
+                $scope.errorMsg = $scope.otherMessage;
+            } else {
+                $scope.errorMsg = $scope.errorArray[$scope.errorType - 1];
+            }
+
+            if (!$scope.errorMsg || $scope.errorMsg.length == 0) {
+                toaster.pop("info", "您尚未选择下架原因");
+                return;
+            }
+            var batchs = batchArray.join(",");
+            Goods.offShelfGoodsByProvider({batchCodes:batchs, downMsg:$scope.errorMsg}, {}, function(map){
+                if (map.success) {
+                    toaster.pop('success', '下架成功');
+                    $scope.batchStatus = false;
+                } else {
+                    toaster.pop('error', map.message);
+                }
+            }, function() {
+                toaster.pop('error', '下架失败');
+            });
+        };
+
     }]);
     app.register.controller('showContrastImgCtrl', ['$scope', 'img', '$modalInstance', function ($scope, img, $modalInstance) {
         $scope.showImgs = img;

+ 7 - 7
src/main/webapp/resources/view/admin/modal/manage/ManageSoldOut.html

@@ -15,29 +15,29 @@
                 <form class="form-inline" name="myForm">
                     <div class="checkbox">
                         <label class="control-label">
-                            <input type="radio" name="soldOut">价格异常
+                            <input type="radio" name="soldOut" ng-model="errorType" ng-checked="errorType==1" ng-click="changeType(1)">价格异常
                         </label>
                     </div>
                     <div class="checkbox">
                         <label class="control-label">
-                            <input type="radio" name="soldOut">图片违规
+                            <input type="radio" name="soldOut" ng-model="errorType" ng-checked="errorType==2" ng-click="changeType(2)">图片违规
                         </label>
                     </div>
                     <div class="checkbox">
                         <label class="control-label">
-                            <input type="radio" name="soldOut">基本信息有误
+                            <input type="radio" name="soldOut" ng-model="errorType" ng-checked="errorType==3" ng-click="changeType(3)">基本信息有误
                         </label>
                     </div>
                     <br/>
                     <div class="checkbox">
                         <label class="control-label">
-                            <input type="radio" name="soldOut">断缺货&nbsp;&nbsp;&nbsp;
+                            <input type="radio" name="soldOut" ng-model="errorType" ng-checked="errorType==4" ng-click="changeType(4)">断缺货&nbsp;&nbsp;&nbsp;
                         </label>
                     </div>
                     <div class="checkbox">
                         <label class="control-label">
-                            <input type="radio" name="soldOut">其它
-                            <input type="text">
+                            <input type="radio" name="soldOut" ng-model="errorType" ng-checked="errorType==5" ng-click="changeType(5)">其它
+                            <input type="text" ng-show="errorType==5" ng-model="otherMessage" ng-change="inputMessage()">
                         </label>
                     </div>
                 </form>
@@ -46,7 +46,7 @@
     </div>
     <div class="form-btn">
         <button class="btn" ng-click="cancel()" value="close">取消</button>
-        <button class="btn" type="submit" ng-click="ensureAddAccount()" value="success">确定</button>
+        <button class="btn" type="submit" ng-click="ensureDown()" value="success">确定</button>
     </div>
 </div>
 <style>

+ 1 - 1
src/main/webapp/resources/view/admin/modal/manage/manageAudit.html

@@ -37,7 +37,7 @@
                     <div class="checkbox">
                         <label class="control-label">
                             <input type="radio" name="soldOut" ng-model="errorType" ng-checked="errorType==5" ng-click="changeType(5)">其它
-                            <input type="text" ng-if="errorType==5" ng-model="otherMessage">{{errorType}}
+                            <input type="text" ng-show="errorType==5" ng-model="otherMessage" ng-change="inputMessage()">
                         </label>
                     </div>
                 </form>

+ 2 - 2
src/main/webapp/resources/view/admin/product/productManage.html

@@ -134,7 +134,7 @@
                 </div>
             </div>
             <div class="form-bottom">
-                <button>批量下架</button>
+                <button ng-click="batchDown">批量下架</button>
                 <button ng-click="moreInfo()">更多信息</button>
                 <label>
                     <input type="checkbox">合并相同产品
@@ -187,7 +187,7 @@
                        <a ng-if="list.audited == 0" ng-click="auditProduct(list)">审核</a>
                        <br/>
                        <a ng-click="journalProduct()" style="margin-left:-1px;">日志</a>
-                       <a ng-click="soldOutProduct()">下架</a>
+                       <a ng-click="soldOutProduct(list.batchCode)">下架</a>
                    </td>
                    <td ng-if="titleInShow['商家ID']">
                        <span ng-bind="list.enUU || '-'">商家ID</span>