Browse Source

个人产品库 初步搭建3 -还差展示模块的视图逻辑

wangdy 8 years ago
parent
commit
385c3f8143

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

@@ -154,6 +154,18 @@ public class ReleaseProductByBatchController {
         return releaseProductByBatchService.publishByBatch(batch);
     }
 
+    /**
+     * 通过batch批量导入个人产品库
+     *
+     * @param batch the batch 发布的批次号
+     * @return string
+     */
+    @RequestMapping(value = "/batchRelease/person", method = RequestMethod.POST)
+    public String batchReleasePerson(String batch) {
+        logger.log("批量上架模块", "批量导入个人产品库:" + batch + "的内容");
+        return releaseProductByBatchService.publishByBatchPerson(batch);
+    }
+
     /**
      * 通过发布者的UU查询所有的产品的信息
      *

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/ReleaseProductByBatchService.java

@@ -66,6 +66,14 @@ public interface ReleaseProductByBatchService {
      */
     public String publishByBatch(String batch);
 
+    /**
+     * 批量批量导入个人产品库
+     *
+     * @param batch the batch
+     * @return string
+     */
+    public String publishByBatchPerson(String batch);
+
 
     /**
      * 创建时间 :2016年12月22日 上午11:33:28

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

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.prod.commodity.service.impl;
 
 import com.uas.platform.b2c.common.account.model.Enterprise;
+import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.service.EnterpriseService;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.core.config.SysConf;
@@ -984,4 +985,26 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		return StringUtilB2C.getStr(num);
 	}
 
+	@Override
+	public String publishByBatchPerson(String batch) {
+		User user = SystemSession.getUser();
+		Enterprise enterprise = SystemSession.getUser().getEnterprise();
+		final Object[] obj = new Object[]{enterprise.getUu(), user.getUserUU(), enterprise.getEnName(), batch};
+		String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @useruu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_PRODUCT_PERSON_V1(@enuu, @useruu, @enName, @batch)";
+		final String updateSql = String.format(sql, obj);
+		jdbcTemplate.execute(new StatementCallback<String>() {
+
+			@Override
+			public String doInStatement(Statement stmt) throws SQLException, DataAccessException {
+				stmt.executeQuery(updateSql);
+				ResultSet rs = stmt.getResultSet();
+				if (null != rs) {
+					rs.next();
+					return rs.getString(1);
+				}
+				return "0";
+			}
+		});
+		return null;
+	}
 }

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

@@ -17,6 +17,11 @@ define([ 'ngResource' ], function() {
 				url: 'release/product/batchRelease',
 				method: 'POST',
 			},
+            // 批量上架个人产品
+            batchReleasePerson: {
+                url: 'release/product/batchRelease/person',
+                method: 'POST',
+            },
 			// 获取批量上架的分页信息
 			getPageBatchRelease: {
 				url: 'release/product/batch/page',

+ 35 - 4
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_upload_ctrl.js

@@ -245,6 +245,9 @@ define([ 'app/app' ], function(app) {
 				$scope.pageParams.totalPages = 0;
 				toaster.pop('error', response.data || response);
 			});
+			if ($rootScope.$$productOn.tab === 'bathOnPerson') {
+                publicPersonProduct();
+			}
 		};
 
 		// 下载模板
@@ -267,10 +270,6 @@ define([ 'app/app' ], function(app) {
 
 		//批量发布
 		$scope.publish = function(event) {
-			if ( $rootScope.$$productOn.tab === 'bathOnPerson'){
-				alert('ffff');
-				return;
-			}
 			if ($scope.pageParams.totalElements > 0) {
 				ReleaseProductByBatch.batchRelease({batch : $scope.result.batch}, null, function(data) {
 					if ($scope.needShowTip){
@@ -308,6 +307,38 @@ define([ 'app/app' ], function(app) {
 			}
 		};
 
+		function publicPersonProduct() {
+			ReleaseProductByBatch.batchReleasePerson({batch : $scope.result.batch}, null, function(data) {
+                    if ($scope.needShowTip){
+                        $scope.relTableParams.page(1);
+                        $scope.relTableParams.reload();
+                        $scope.result.success = 0;//设置成0,让前端用户不能点击
+                        $modal.open({
+                            animation : true,
+                            templateUrl : 'static/view/common/modal/product_upload_modal.html',
+                            controller : 'rule_tip_ctrl',
+                            resolve : {
+                                type : function() {
+                                    return 'upload';
+                                },
+                                tipModal : function() {
+                                    return true;
+                                }
+                            }
+                        });
+                        return ;
+                    }
+                    // toaster.pop("success", "提示", "发布成功 :" + data.data + "条");
+                    toaster.pop("success", "提示", "发布成功");
+                    $scope.relTableParams.page(1);
+                    $scope.relTableParams.reload();
+                    $scope.result.success = 0;//设置成0,让前端用户不能点击
+                    $scope.hadImport = true; //上架后隐藏提示语
+                }, function(res) {
+                    toaster.pop("error", "发布失败", res.data);
+			});
+        }
+
 		//下载未匹配成功的数据
 		$scope.downloadExcel = function(){
 			if($scope.result && $scope.result.batch && $scope.result.filter) {

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

@@ -406,7 +406,7 @@
                             </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>
-                        <table ng-table="relTableParams" class="public-tab table">
+                        <table ng-table="relTableParams" class="public-tab table" ng-if="$$productOn.tab == 'bathOn'">
                             <thead>
                                 <tr>
                                     <th width="60">序号</th>
@@ -485,7 +485,7 @@
                             </tbody>
                         </table>
                         <div style="margin-top: -40px;" ng-if="$$productOn.tab == 'bathOn'">3、如核对信息无误之后,点击确认发布</div>
-                        <a class="blue-bg publish" href="javascript:void(0)" ng-click="publish($event)" ng-disabled="!pageParams.totalElements" ><span ng-if="$$productOn.tab == 'bathOn'">确认上架</span><span ng-if="$$productOn.tab == 'bathOnPerson'">提交</span></a>
+                        <a class="blue-bg publish" href="javascript:void(0)" ng-click="publish($event)" ng-disabled="!pageParams.totalElements" ng-show="$$productOn.tab == 'bathOn'"><span>确认上架</span></a>
                     </div>
                 </div>
                 <!--<div class="load_next">-->