소스 검색

呵呵商品迁移

Aslee 3 년 전
부모
커밋
c855facbf2

+ 2 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java

@@ -52,4 +52,6 @@ public interface CmHeheProductDao extends CrudDao<CmHeheProduct> {
     void addActivityProduct(@Param("productId") Integer productId, @Param("activityId") Integer activityId);
 
     void addFloorProduct(@Param("productId") String productId, @Param("floorId") String floorId);
+
+    void updateProductId(@Param("heheProductId") Integer heheProductId, @Param("newProductId") Integer newProductId);
 }

+ 2 - 0
src/main/java/com/caimei/modules/product/dao/ProductNewDao.java

@@ -61,4 +61,6 @@ public interface ProductNewDao extends CrudDao<Product> {
     List<SplitCode> findSplitCode(Integer shopID);
 
     String findSplitCodeByProduct(Integer productID);
+
+    Integer getShopIdByName(String shopName);
 }

+ 57 - 4
src/main/java/com/caimei/modules/product/service/ProductNewService.java

@@ -3,14 +3,16 @@ package com.caimei.modules.product.service;
 
 import com.caimei.dfs.image.beens.ImageUploadInfo;
 import com.caimei.modules.common.utils.UploadUtils;
+import com.caimei.modules.hehe.dao.CmHeheProductDao;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.caimei.modules.product.dao.CmPromotionDao;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.dao.ProductNewDao;
-import com.caimei.modules.product.entity.CmPromotion;
-import com.caimei.modules.product.entity.Product;
-import com.caimei.modules.product.entity.ProductParameters;
-import com.caimei.modules.product.entity.ProductStatusRecord;
+import com.caimei.modules.product.entity.*;
 import com.caimei.modules.sys.utils.UploadImageUtils;
+import com.caimei.modules.user.dao.NewCmShopDao;
 import com.caimei.po.ProductImage;
+import com.caimei.po.ProductLadderPrice;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
@@ -40,7 +42,13 @@ public class ProductNewService extends CrudService<ProductNewDao, Product> {
     @Autowired
     ProductNewDao productNewDao;
     @Autowired
+    ProductDao productDao;
+    @Autowired
     private CmPromotionDao cmPromotionDao;
+    @Autowired
+    private CmHeheProductDao cmHeheProductDao;
+    @Autowired
+    private ProductService productService;
 
     @Override
     public Product get(String id) {
@@ -264,4 +272,49 @@ public class ProductNewService extends CrudService<ProductNewDao, Product> {
         }
         return recordList;
     }
+
+    public void moveHeheProducts() {
+        List<CmHeheProduct> heheProductList = cmHeheProductDao.findList(new CmHeheProduct());
+        heheProductList.forEach(heheProduct->{
+            Integer heheProductId = Integer.parseInt(heheProduct.getId());
+            // 采美商品id
+            Integer productId = heheProduct.getProductId();
+            // 查询商品
+            Product product = productNewDao.get(productId.toString());
+            Integer shopId = productNewDao.getShopIdByName("采美奥泰特殊供应商");
+            if (null != shopId) {
+                product.setId(null);
+                product.setShopID(shopId);
+                // 置为冻结状态
+                product.setValidFlag("10");
+                // 添加商品到奥泰特殊供应商下
+                productDao.insert(product);
+                Integer newProductId = product.getProductID();
+                // 查询商品详情信息
+                ProductDetailInfo productDetailInfo = productService.getProductDetailInfo(productId);
+                productDetailInfo.setProductID(newProductId);
+                productDao.insertProductDetailInfo(productDetailInfo);
+                // 查询阶梯列表
+                List<ProductLadderPrice> ladderPriceList = productService.findLadderPrice(productId);
+                ladderPriceList.forEach(ladder->{
+                    ladder.setProductId(newProductId);
+                    productDao.insertLadderPrice(ladder);
+                });
+                // 查询商品图片
+                List<ProductImage> imageList = productNewDao.getImageList(productId);
+                imageList.forEach(image->{
+                    image.setProductID(newProductId);
+                    productNewDao.insertProductImage(image);
+                });
+                // 查询相关参数
+                List<ProductParameters> productParams = getProductParams(productId);
+                productParams.forEach(productParam->{
+                    productParam.setProductId(newProductId);
+                    productNewDao.insertParameters(productParam);
+                });
+                // 将呵呵商品关联到新商品上
+                cmHeheProductDao.updateProductId(heheProductId, newProductId);
+            }
+        });
+    }
 }

+ 10 - 0
src/main/java/com/caimei/modules/product/web/ProductNewController.java

@@ -1077,5 +1077,15 @@ public class ProductNewController extends BaseController {
         model.addAttribute("productId", productId);
         return "modules/product-new/statusRemarksList";
     }
+
+    /**
+     * 迁移呵呵对应的采美商品到采美奥泰特殊供应商中,并将呵呵商品关联到迁移后的商品
+     */
+    @RequestMapping("/hehe/move")
+    @ResponseBody
+    public String moveHeheProducts(){
+        productNewService.moveHeheProducts();
+        return "success";
+    }
 }
 

+ 4 - 1
src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml

@@ -217,5 +217,8 @@
 	<update id="deleteActivityProduct">
 		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}
 	</update>
-	
+	<update id="updateProductId">
+		update cm_hehe_product set productId = #{newProductId} where id = #{heheProductId}
+	</update>
+
 </mapper>

+ 4 - 2
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -395,7 +395,8 @@
 			trainingType,
 			trainingFee,
 			productDescribe,
-			splitCode
+			splitCode,
+			productDetail
 		) VALUES (
 					 #{brandID},
 					 #{bigTypeID},
@@ -468,7 +469,8 @@
 					 #{trainingType},
 					 #{trainingFee},
 		          	 #{productDescribe},
-					 #{splitCode}
+					 #{splitCode},
+					 #{productDetail}
 						 )
 	</insert>
 

+ 6 - 1
src/main/resources/mappings/modules/product/ProductNewMapper.xml

@@ -85,6 +85,8 @@
         a.trainingMethod as "trainingMethod",
         a.trainingType as "trainingType",
         a.trainingFee as "trainingFee",
+        a.splitCode as "splitCode",
+        a.productDescribe as "productDescribe",
         cshd.secondHandType as "secondHandType",
         cshd.instrumentType as "instrumentType",
         cshd.sold as "sold",
@@ -125,7 +127,7 @@
     </select>
 
     <select id="getProductParams" resultType="com.caimei.modules.product.entity.ProductParameters">
-        select *from cm_product_related_parameters where productId =  #{productId}  and delFlag = 0 LIMIT 50
+        select * from cm_product_related_parameters where productId =  #{productId}  and delFlag = 0 LIMIT 50
     </select>
 
     <select id="findList" resultType="Product">
@@ -754,6 +756,9 @@
     <select id="findSplitCodeByProduct" resultType="java.lang.String">
         select splitCode from product where productID = #{productID}
     </select>
+    <select id="getShopIdByName" resultType="java.lang.Integer">
+        select shopID from shop where name like concat('%',#{shopName},'%')
+    </select>
 
 </mapper>