Browse Source

Merge branch 'dev-mysql' into feature_release-tomysql

hulh 8 years ago
parent
commit
43e4a2300e

+ 3 - 0
src/main/java/com/uas/platform/b2c/common/account/controller/SecurityController.java

@@ -228,6 +228,9 @@ public class SecurityController {
 					request.setAttribute("sso_cookie_maxage", maxage);
 				}
 				SSOHelper.setSSOCookie(request, response, tk, true);
+				response.setHeader("P3P","CP='IDCDSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT'");
+
+				response.setHeader("P3P","CP=\"CURaADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSPCOR\"");
 				User user = getUserByToken(tk);
 				if (user != null) {
 					if (!user.getUserPwd().equals(FlexJsonUtils.fromJson(tk.getData(), com.uas.account.entity.User.class).getPassword())){

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

@@ -90,6 +90,17 @@ public class ProductController {
 		return productService.getAllProductsByPerson(info, keyword, type);
 	}
 
+	/**
+	 * 根据ids绑定至个人产品库
+	 * @param ids
+	 * @param isAll 是否将该企业下的所有添加至个人下
+	 */
+	@RequestMapping(value = "/person", method = RequestMethod.POST)
+	ResultMap setAllProductsByPerson(@RequestBody String ids, Integer isAll, Integer isStardand) {
+		productService.setAllProductsByProductIds(ids,isAll,isStardand);
+		return ResultMap.success("success");
+	}
+
     /**
      * 批量导出产品表
      *

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

@@ -137,8 +137,9 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
      * @param standard 是否是标准的信息
      * @return 返回所属该公司的产品信息
      */
-    @Query(value = "select p from Product p where p.enUU = :enuu and p.standard = :standard")
-    List<Product> findProductByEnuuAndStandard(@Param("enuu") Long enuu, @Param("standard") Integer standard);
+    @Query(value = "select p from products p left join product$private pp on pp.pr_id = p.pr_id where " +
+            "p.pr_enuu=:enuu and p.pr_pcmpcode is not null and p.pr_pbranden is not null and p.pr_standard = :standard and pp.pr_b2cenabled = :enabled", nativeQuery = true)
+    List<Product> findProductByEnuuAndStandardAndEnabled(@Param("enuu") Long enuu, @Param("standard") Integer standard, @Param("enabled") Integer enabled);
 
 
     /**
@@ -168,4 +169,13 @@ public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaReposi
     @Query(value = "select p from Product p where id in :idList")
     List<Product> findProductInId(@Param("idList") List<Long> idList);
 
+    /**
+     * 根据enuu查询所有的prids
+     * @param enuu
+     * @return
+     */
+    @Query(value = "select p.id from Product p where p.enUU = :enuu and p.standard = :standard")
+    List<Long> findPridsByEnuuAndStardand(@Param("enuu") Long enuu, @Param("standard") Integer standard);
+
+
 }

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

@@ -17,7 +17,7 @@ public interface V_ProductPersonDao extends JpaRepository<V_ProductPerson, V_Pro
      * @param standard the standard 标准状态
      * @return count by enuu and status
      */
-    @Query(value = "select count(1) from v$person$product where pr_enuu =:enuu and user_uu = :userUU and pr_standard =:standard and pr_b2cenabled =:enabled", nativeQuery = true)
+    @Query(value = "select count(1) from v$person$product where pr_enuu =:enuu and pr_pcmpcode is not null and pr_pbranden is not null and user_uu = :userUU and pr_standard =:standard and pr_b2cenabled =:enabled", nativeQuery = true)
     Integer getCountByEnuuAndUserUUAndStatusAndEnabled(@Param("enuu") Long enuu, @Param("userUU") Long userUU, @Param("standard") Short standard, @Param("enabled") Integer enabled);
 
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -36,6 +36,13 @@ public interface ProductService {
      */
     Page<V_ProductPerson> getAllProductsByPerson(PageInfo page, String keyword, String type);
 
+    /**
+     * 绑定至个人产品库
+     * @return all products
+     */
+    boolean setAllProductsByProductIds(String ids, Integer isAll, Integer isStardand);
+
+
     /**
      * 下载产品资料
      *

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

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.commodity.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.advertise.ad.service.RecommendProductService;
@@ -43,6 +44,7 @@ import com.uas.platform.b2c.trade.order.status.OrderStatus;
 import com.uas.platform.b2c.trade.presale.dao.CartDao;
 import com.uas.platform.b2c.trade.presale.dao.GoodsBrowsingHistoryDao;
 import com.uas.platform.b2c.trade.presale.model.Cart;
+import com.uas.platform.b2c.trade.presale.model.Collection;
 import com.uas.platform.b2c.trade.presale.model.GoodsBrowsingHistory;
 import com.uas.platform.b2c.trade.presale.service.CartService;
 import com.uas.platform.b2c.trade.support.CodeType;
@@ -266,6 +268,8 @@ public class ProductServiceImpl implements ProductService {
     public Page<V_ProductPerson> getAllProductsByPerson(final PageInfo page, String keyword, String type) {
         page.expression(PredicateUtils.eq("enUU", SystemSession.getUser().getEnterprise().getUu(), true));
         page.expression(PredicateUtils.eq("ppUserUU", SystemSession.getUser().getUserUU(), true));
+        page.expression(PredicateUtils.isNotNull("pcmpcode"));
+        page.expression(PredicateUtils.isNotNull("pbranden"));
         if (StringUtils.isEmpty(type)) {
             type = "nStandard";
         }
@@ -325,6 +329,31 @@ public class ProductServiceImpl implements ProductService {
         return new PageImpl<V_ProductPerson>(productList, page, productPage.getTotalElements());
     }
 
+    @Override
+    public boolean setAllProductsByProductIds(String ids, Integer isAll, Integer isStardand) {
+        List<Long> prIds;
+        try {
+            prIds = JSON.parseArray(ids,Long.class);
+        } catch (RuntimeException e){prIds = new ArrayList<>();}
+        Long useruu = SystemSession.getUser().getUserUU();
+        if (isAll != null && isAll.equals(IntegerConstant.YES_SHORT)) {
+            prIds = productDao.findPridsByEnuuAndStardand(SystemSession.getUser().getEnterprise().getUu(), isStardand);
+        }
+        if (!CollectionUtils.isEmpty(prIds)) {
+            for (Long prId : prIds) {
+                List<ProductPerson> p = productPersonDao.findByProductIdAndUserUU(prId,useruu);
+                if (CollectionUtils.isEmpty(p)) {
+                    ProductPerson productPerson = new ProductPerson();
+                    productPerson.setUserUU(useruu);
+                    productPerson.setProductId(prId);
+                    productPerson.setTime(new Date(System.currentTimeMillis()));
+                    productPersonDao.save(productPerson);
+                }
+            }
+        }
+        return true;
+    }
+
     @Override
     public List<Goods> getProductsGoods(String type, String keyword) {
         final PageInfo page = new PageInfo();
@@ -474,7 +503,7 @@ public class ProductServiceImpl implements ProductService {
         } else {
             standard = IntegerConstant.NO_SHORT;
         }
-        List<Product> products = productDao.findProductByEnuuAndStandard(uu, standard);
+        List<Product> products = productDao.findProductByEnuuAndStandardAndEnabled(uu, standard, IntegerConstant.YES_SHORT);
         Set<String> uuids = new HashSet<>();
         for (Product product : products) {
             if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {

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

@@ -1218,6 +1218,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
                 product.setpBrandUuid(releaseProductByBatch.getBranduuid());
                 product.setStandard(releaseProductByBatch.getComponentUuId() == null ? (short)0 : (short)1);
                 product.setCmpUuid(releaseProductByBatch.getComponentUuId());
+                product.setCreateTime(new Date(System.currentTimeMillis()));
                 if (isAPerson) {
                     product.setSpec(releaseProductByBatch.getPackaging());
                 }

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/order/dao/PurchaseDao.java

@@ -36,7 +36,7 @@ public interface PurchaseDao extends JpaSpecificationExecutor<Purchase>, JpaRepo
 	 */
 	@Query(nativeQuery = true, value=" select o.* from trade$purchase o " +
 			" left join b2c$rate$buyer v " +
-			" on o.or_id = v.order_id left join trade$order t on o.or_id = t.or_orderid where locate('405',t.or_statushistory)>0  and v.id is null;")
+			" on o.or_orderid = v.order_id left join trade$order t on o.or_orderid = t.or_id where locate('405',t.or_statushistory)>0  and v.id is null;")
 	List<Purchase> findByNotRate();
 
 	/**

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

@@ -22,6 +22,11 @@ define([ 'ngResource' ], function() {
                 url: 'trade/products/:ids',
                 method: 'DELETE'
             },
+            // 绑定个人物料
+            setAllProductsByPerson: {
+                url: 'trade/products/person',
+                method: 'POST'
+            },
             // 删除所有非标的信息
             deleteUnstandardAll: {
                 url: 'trade/products/unstandard',

+ 37 - 0
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -897,6 +897,43 @@ define([ 'app/app', 'jquery-uploadify' ], function(app) {
 			}
 		};
 
+        // 一键添加到个人产品库
+        $scope.setAllInPerson = function () {
+            if ($scope.chooseAllPage) {
+                if ('standard' == $scope.standard_tab) {
+                	$scope.setPrArg = {isAll : 1, isStardand : 1};
+				} else {
+                    $scope.setPrArg = {isAll : 1, isStardand : 0};
+				}
+                Material.setAllProductsByPerson( $scope.setPrArg ,{}, function (data) {
+                    if (data.success) {
+                        toaster.pop("info", "绑定成功!");
+                        loadData();
+                    } else {
+                        toaster.pop("info", data.message);
+                    }
+                }, function (error) {
+                    toaster.pop("error", "绑定失败!")
+                });
+            } else {
+                $scope.getChoosedInfo();
+                if (!$scope.choosedIds || $scope.choosedIds.length == 0) {
+                    toaster.pop("info", "您尚未选中任何产品");
+                    return ;
+                }
+                Material.setAllProductsByPerson({},$scope.choosedIds,function (data) {
+                    if (data.success) {
+                        toaster.pop("info", "绑定成功!");
+                        loadData();
+                    } else {
+                        toaster.pop("error", data.message);
+                    }
+                }, function (error) {
+                    toaster.pop("error", "绑定失败!")
+                })
+            }
+        };
+
 		function downloadByJs(url, keyword, type) {
 			var form = $("<form>");   //定义一个form表单
 			form.attr('style', 'display:none');   //在form表单中添加查询参数

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

@@ -177,7 +177,7 @@
 		margin-bottom: 16px;
 	}
 	.search-check .search{
-		width: 550px;
+		width: 532px;
 		margin-left: 150px;
 	}
 	.search-check .search .form-control{
@@ -1578,6 +1578,7 @@
 					<!--<a ng-click="download()">批量导出</a>-->
 				</div>
 				<div class="check fr">
+					<div class="operate-btn" ng-click="setAllInPerson()"><span>加入我的产品库</span></div>
 					<div class="operate-btn" ng-show="standard_tab == 'unstandard'" ng-click="matchAll()"><span ng-show="standard_tab == 'unstandard'">匹配</span></div>
 					<div class="operate-btn more-operate">
 						<span>更多操作</span>

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

@@ -1525,12 +1525,11 @@
 					<a ng-show="!isBatch" ng-click="enterBatch()"><span ng-show="!isBatch">批量操作</span></a>
 					<span class="check-btn" ng-show="isBatch">
 						<label class="check-active">
-							<input type="checkbox"  ng-click="chooseAll()" ng-checked="isChoosedAll" id="AllChoose"/>
+							<input type="checkbox"  ng-click="chooseAll()" ng-checked="isChoosedAll" ng-disabled="currenctMaterial.length == 0" id="AllChoose"/>
 							<label for="AllChoose"></label>
 							<span>全选</span>
 						</label>
-						<a
-								ng-click="deleteBatch()" name="delete-material">删除</a>
+						<a ng-click="deleteBatch()" name="delete-material">删除</a>
 						<a ng-click="exitBatch()">取消</a>
 					</span>
 				</div>