فهرست منبع

修改商品,删除商品删除赠品购物车

yfh 1 ماه پیش
والد
کامیت
4450c48a8b

+ 1 - 0
fs-framework/src/main/java/com/fs/framework/config/SecurityConfig.java

@@ -144,6 +144,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/course/userVideo/videoTranscode").anonymous()
                 .antMatchers("/erp/call/**").anonymous()
+                .antMatchers("/store/express/expressNotify").anonymous()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 8 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCartScrmMapper.java

@@ -94,6 +94,13 @@ public interface FsStoreCartScrmMapper
             "</if>" +
             "</script>"})*/
     Integer selectFsStoreCartCount(@Param("maps") FsStoreCartCountParam param);
-    @Select("select c.*,p.cate_id,p.product_name,p.image as product_image,p.temp_id,p.product_type,v.price,v.sku as product_attr_name,v.image as product_attr_image,v.stock,v.cost,v.integral,v.weight,v.volume,v.bar_code,v.group_bar_code,v.brokerage,v.brokerage_two,v.brokerage_three from fs_store_cart_scrm c left join fs_store_product_scrm p on p.product_id=c.product_id left join fs_store_product_attr_value_scrm v on v.id=c.product_attr_value_id where c.is_gift = 1 AND user_id = #{userId}")
+    @Select("select c.*,p.cate_id,p.product_name,p.image as product_image,p.temp_id,p.product_type,v.price,v.sku as product_attr_name,v.image as product_attr_image,v.stock,v.cost,v.integral,v.weight,v.volume,v.bar_code,v.group_bar_code,v.brokerage,v.brokerage_two,v.brokerage_three from fs_store_cart_scrm c left join fs_store_product_scrm p on p.product_id=c.product_id left join fs_store_product_attr_value_scrm v on v.id=c.product_attr_value_id where c.is_gift = 1 AND user_id = #{userId} and v.price is not null")
     List<FsStoreCartQueryVO> selectFsStoreGiftCartList(@Param("userId") Long userId);
+
+    /**
+     * 删除赠品
+     *
+     * @param id
+     */
+    void deleteFsStoreCartByProDuctValueId(@Param("productAttrValueId") Long productAttrValueId);
 }

+ 4 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -2301,6 +2301,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 //计算总价
                 for(FsStoreCartQueryVO vo:giftCarts){
                     logger.info("错误信息:userId = {},FsStoreCartQueryVO ={}",userId,vo);
+                    if (ObjectUtil.isEmpty(vo.getPrice())){
+                        continue;
+                    }
                     money=money.add(vo.getPrice().multiply(new BigDecimal(vo.getCartNum().toString())));
                 }
 //                redisCache.setCacheObject("orderGiftCarts:"+createOrderKey, giftCarts, 24, TimeUnit.HOURS);
@@ -2912,7 +2915,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     }
 
     @Override
-    public ExpressResultDTO updateDeliveryItem(ExpressNotifyDTO notifyDTO) {
+        public ExpressResultDTO updateDeliveryItem(ExpressNotifyDTO notifyDTO) {
         String data = URLDecoder.decode(notifyDTO.getRequestData(), Charset.forName("UTF-8"));
         //ExpressInfoDTO
         logger.info("快递跟踪回调: {}", data);

+ 22 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -20,6 +20,7 @@ import com.fs.company.cache.ICompanyCacheService;
 import com.fs.erp.domain.ErpGoods;
 import com.fs.erp.service.IErpGoodsService;
 import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.FsStoreProductAttrValue;
 import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsStoreProductExcelVO;
@@ -38,6 +39,7 @@ import com.fs.hisStore.service.IFsStoreProductAttrValueScrmService;
 import com.fs.hisStore.vo.*;
 import com.fs.statis.dto.ProductAuditDTO;
 import com.fs.store.vo.FsStoreProductScrmQueryVO;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -63,7 +65,8 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
     @Autowired
     private FsStoreProductAttrScrmMapper fsStoreProductAttrMapper;
-
+    @Autowired
+    private FsStoreCartScrmMapper fsStoreCartScrmMapper;
 
     @Autowired
     private IFsStoreProductAttrValueScrmService attrValueService;
@@ -158,10 +161,22 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
      * @param productIds 需要删除的商品ID
      * @return 结果
      */
+    
     @Override
     public int deleteFsStoreProductByIds(Long[] productIds)
     {
         storeAuditLogUtil.addBatchAuditArray(productIds, "", "");
+        for (Long productId : productIds) {
+            //查出商品属性所有ID;
+            List<FsStoreProductAttrValueScrm> attrValues = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(productId);
+            if (CollectionUtils.isNotEmpty(attrValues)){
+                attrValues.forEach(e->{
+                    fsStoreCartScrmMapper.deleteFsStoreCartByProDuctValueId(e.getId());
+                });
+            }
+            fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByProductId(productId);
+        }
+
         return fsStoreProductMapper.deleteFsStoreProductByIds(productIds);
     }
 
@@ -319,7 +334,7 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
     public R addOrEdit(FsStoreProductAddEditParam param) {
         ProductAttrCountDto countDto=computedProductCount(param.getValues());
 
-        if(param.getProductId()>0){
+        if(ObjectUtil.isNotEmpty(param.getProductId())&&param.getProductId()>0){
             FsStoreProductScrm product=new FsStoreProductScrm();
             BeanUtils.copyProperties(param,product);
             product.setPrice(countDto.getMinPrice());
@@ -377,6 +392,11 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         //清空values
         //查出商品属性所有ID;
         List<FsStoreProductAttrValueScrm> attrValues=fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(productId);
+        if (CollectionUtils.isNotEmpty(attrValues)){
+            attrValues.forEach(e->{
+                fsStoreCartScrmMapper.deleteFsStoreCartByProDuctValueId(e.getId());
+            });
+        }
         fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByProductId(productId);
         //写入attr
         for(ProductArrtDTO vo:items){

+ 5 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreCartScrmMapper.xml

@@ -119,4 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+
+    <delete id="deleteFsStoreCartByProDuctValueId" >
+        delete from fs_store_cart_scrm where is_gift =1 and product_attr_value_id = #{productAttrValueId}
+    </delete>
+
 </mapper>