同步数据和菜单相关问题解决

This commit is contained in:
liyj 2025-06-27 14:53:09 +08:00
parent da24e3dfd2
commit 4947025a25
9 changed files with 55 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.api.StateCode;
import com.suisung.mall.common.modules.product.*;
import com.suisung.mall.common.utils.StringUtils;
import com.suisung.mall.shop.product.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -119,6 +120,9 @@ public class ShopProductInfoController {
List<ShopProductAssistIndex> assistIndexList = assistIndexService.find(indexQueryWrapper);
HashMap<String, Object> map = new HashMap<>();
if(StringUtils.isEmpty(shopProductInfo.getProduct_spec())){
shopProductInfo.setProduct_spec("[]");
}
map.put("shop_product_info", shopProductInfo);
map.put("shop_product_image", shopProductImages);
map.put("shop_product_detail", shopProductDetail);

View File

@ -9,6 +9,7 @@ import com.suisung.mall.common.pojo.dto.EduCourseDetailDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
@ -31,4 +32,5 @@ public interface ShopProductItemMapper extends BaseMapper<ShopProductItem> {
int lockSkuStock(@Param("item_id") Long itemId, @Param("cart_quantity") int cart_quantity);
void updateBatchByProductId(List<ShopProductItem> list,Integer itemEnable);
}

View File

@ -79,4 +79,10 @@ public interface ShopProductItemService extends IBaseService<ShopProductItem> {
void clearProductItemIdByStore(Integer store_id);
/**
* 更加产品名称更新状态
* @param shopProductItemList
* @return
*/
void batchUpdateByCondition(List<ShopProductItem> shopProductItemList);
}

View File

@ -5379,6 +5379,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
shopProductIndexList.get(i).setSubsite_id(0);
shopProductIndexList.get(i).setProduct_number(base.getProduct_number());
base.setProduct_market_price(base.getProduct_unit_price());
shopProductInfoList.get(i).setProduct_spec("[]");
if(CollUtil.isNotEmpty(shopProductIndexList)){
newShopProductIndexList.add(shopProductIndexList.get(i));
}

View File

@ -2288,6 +2288,10 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
}
}
// 通过product_id 批量更新
@Override
public void batchUpdateByCondition(List<ShopProductItem> shopProductItemList) {
shopProductItemMapper.updateBatchByProductId(shopProductItemList,shopProductItemList.get(0).getItem_enable());
}
}

View File

@ -12,6 +12,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.suisung.mall.common.api.StateCode;
import com.suisung.mall.common.modules.product.ShopProductBase;
import com.suisung.mall.common.modules.product.ShopProductImage;
import com.suisung.mall.common.modules.product.ShopProductIndex;
import com.suisung.mall.common.modules.product.ShopProductItem;
import com.suisung.mall.common.modules.sync.ImageMappingDto;
import com.suisung.mall.common.utils.StringUtils;
@ -19,6 +20,7 @@ import com.suisung.mall.shop.product.mapper.ShopProductImageMapper;
import com.suisung.mall.shop.product.service.ShopProductBaseService;
import com.suisung.mall.shop.product.service.ShopProductImageService;
import com.suisung.mall.shop.product.service.ShopProductIndexService;
import com.suisung.mall.shop.product.service.ShopProductItemService;
import com.suisung.mall.shop.sixun.utils.CommonUtil;
import com.suisung.mall.shop.sync.mapper.ShopImageMappingTempMapper;
@ -54,6 +56,9 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
@Autowired
private ShopProductBaseService shopProductBaseService;
@Autowired
private ShopProductIndexService shopProductIndexService;
@Value("${project.static_domain}")
private String staticDomain;
@ -146,6 +151,7 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
List<ShopProductBase> shopProductBaseList=new ArrayList<>();
List<ShopProductItem> shopProductItemList=new ArrayList<>();
List<ShopProductImage> shopProductImageList=new ArrayList<>();
List<ShopProductIndex> shopProductIndexList=new ArrayList<>();
for (ImageMappingDto imageMappingDto:imageMappingDtos){
String mergedImageUrl=imageMappingDto.getMergedImageUrl();
if(StringUtils.isEmpty(mergedImageUrl)){
@ -162,15 +168,22 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
}else {
shopProductImage.setItem_image_other(imageMappingDto.addDomainPrefix(staticDomain,mergedImageUrl));
}
String thumb=imageMappingDto.addDomainPrefix(staticDomain,imageMappingDto.getThumb());
shopProductImage.setProduct_id(imageMappingDto.getProductId());
shopProductImage.setProduct_image_id(imageMappingDto.getProductImageId());
shopProductImage.setItem_image_default(imageMappingDto.addDomainPrefix(staticDomain,imageMappingDto.getThumb()));
shopProductImage.setItem_image_default(thumb);
shopProductImageList.add(shopProductImage);
shopProductBase.setProduct_id(imageMappingDto.getProductId());
shopProductBase.setProduct_image(thumb);
shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL);
shopProductBaseList.add(shopProductBase);
shopProductItem.setProduct_id(imageMappingDto.getProductId());
shopProductItem.setItem_enable(StateCode.PRODUCT_STATE_NORMAL);
shopProductItemList.add(shopProductItem);
ShopProductIndex shopProductIndex=new ShopProductIndex();
shopProductIndex.setProduct_id(imageMappingDto.getProductId());
shopProductIndex.setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL);
shopProductIndexList.add(shopProductIndex);
}
if(CollectionUtil.isNotEmpty(shopProductImageList)){
shopProductImageService.updateBatchById(shopProductImageList);
@ -179,7 +192,10 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
shopProductBaseService.updateBatchById(shopProductBaseList);
}
if(CollectionUtil.isNotEmpty(shopProductItemList)){
shopProductItemService.updateBatchById(shopProductItemList);
shopProductItemService.batchUpdateByCondition(shopProductItemList);
}
if(CollectionUtil.isNotEmpty(shopProductIndexList)){
shopProductIndexService.updateBatchById(shopProductIndexList);
}
}

View File

@ -218,4 +218,14 @@
where f.product_id = #{product_id}
</select>
<update id="updateBatchByProductId">
UPDATE shop_product_item
SET item_enable= #{itemEnable}
WHERE product_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.product_id}
</foreach>
</update>
</mapper>

View File

@ -1,20 +1,20 @@
INSERT INTO admin_base_menu (menu_parent_id,menu_rel,menu_name,menu_url,menu_path,menu_component,menu_close,menu_label,menu_order,menu_enable,menu_class,menu_icon,menu_bubble,menu_url_path,menu_url_mdu,menu_url_ctl,menu_url_met,menu_url_parem,menu_time,menu_type,menu_note,menu_func,menu_role,menu_hidden) VALUES
(320,'pageTab','分类管理','','category','@/views/base/product/category',0,'CategoryManagement',50,1,'','','','/admin/shop/shop-base-product-category/list','','Base_ProductCategory','index','','2024-07-12 21:33:44',1,'<div class="chat-group">
(8021,'pageTab','分类管理','','category','@/views/base/product/category',0,'CategoryManagement',50,1,'','','','/admin/shop/shop-base-product-category/list','','Base_ProductCategory','index','','2024-07-12 21:33:44',1,'<div class="chat-group">
<strong></strong>
<a><span class="user-status is-online"></span><em></em></a>
<a><span class="user-status is-online"></span><em></em></a>
</div>','',2,0),
(320,'pageTab','品牌管理','','brand','@/views/base/product/brand/index.vue',0,'BrandManagement',51,1,'','','','/admin/shop/shop-base-product-brand/list','','Base_ProductBrand','index','','2024-07-12 21:33:44',1,'<div class="chat-group">
(8021,'pageTab','品牌管理','','brand','@/views/base/product/brand/index.vue',0,'BrandManagement',51,1,'','','','/admin/shop/shop-base-product-brand/list','','Base_ProductBrand','index','','2024-07-12 21:33:44',1,'<div class="chat-group">
<strong></strong>
<a><span class="user-status is-online"></span><em></em></a>
<a><span class="user-status is-online"></span><em></em></a>
<a><span class="user-status is-online"></span><em></em></a>
</div>','',2,0),
(320,'pageTab','类型管理','','type','@/views/base/product/type/index.vue',0,'Vab3204',52,1,'','','','/admin/shop/shop-base-product-type/list','','Base_ProductType','index','','2024-07-12 21:33:44',1,'<div class="chat-group">
(8021,'pageTab','类型管理','','type','@/views/base/product/type/index.vue',0,'Vab3204',52,1,'','','','/admin/shop/shop-base-product-type/list','','Base_ProductType','index','','2024-07-12 21:33:44',1,'<div class="chat-group">
<strong></strong>
<a><span class="user-status is-online"></span><em>便</em></a>
</div>','',2,0),
(320,'pageTab','规格管理','','spec','@/views/base/product/spec/index.vue',0,'CpecManagement',53,1,'','','','m','','Base_ProductSpec','index','','2025-06-12 17:19:46',1,'<div class="chat-group">
(8021,'pageTab','规格管理','','spec','@/views/base/product/spec/index.vue',0,'CpecManagement',53,1,'','','','m','','Base_ProductSpec','index','','2025-06-12 17:19:46',1,'<div class="chat-group">
<strong></strong>
<a><span class="user-status is-online"></span><em></em></a>
<a><span class="user-status is-online"></span><em></em></a>

View File

@ -0,0 +1,5 @@
INSERT INTO `admin_base_protocol` (`ctl`, `met`, `db`, `rights_id`, `log`, `path`) VALUES ('/admin/shop/shop-sync-productMapper/syncShopImages', 'index', 'master', '', '0', '/admin/shop/shop-sync-productMapper/syncShopImages');
update admin_base_menu set menu_parent_id ='8021' where menu_url_path in('/admin/shop/shop-base-product-category/list','/admin/shop/shop-base-product-brand/list','/admin/shop/shop-base-product-type/list','/admin/shop/shop-base-product-spec/list') and menu_role='2';
update shop_product_image set item_image_default='1' where product_from ='1005' and item_image_default !='1';