|
|
@@ -35,7 +35,6 @@ import static com.yami.shop.common.util.HttpUtil.post;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
-@Transactional(readOnly = true)
|
|
|
public class HBFrontCategoryService implements IHBFrontCategoryService {
|
|
|
private final FrontCategoryMapper frontCategoryMapper;
|
|
|
private final ShopCategoryMapper shopCategoryMapper;
|
|
|
@@ -80,22 +79,20 @@ public class HBFrontCategoryService implements IHBFrontCategoryService {
|
|
|
.eq(FrontCategory::getIsDelete, 0));
|
|
|
if (frontCategory1 == null) {
|
|
|
frontCategoryMapper.insert(frontCategory);
|
|
|
+
|
|
|
+ //添加门店分类
|
|
|
+ addShopCategory(frontCategory, 1L, 5104238L);
|
|
|
} else {
|
|
|
frontCategory.setId(frontCategory1.getId());
|
|
|
frontCategoryMapper.updateById(frontCategory);
|
|
|
-
|
|
|
- //修改门店分类里面对应的
|
|
|
- List<ShopCategory> shopCategory = shopCategoryMapper.selectList(new LambdaQueryWrapper<ShopCategory>().eq(ShopCategory::getCode, frontCategory.getCode())
|
|
|
- .eq(ShopCategory::getIsDelete, 0));
|
|
|
+ List<ShopCategory> shopCategory = shopCategoryMapper.selectList(new LambdaQueryWrapper<ShopCategory>()
|
|
|
+ .eq(ShopCategory::getCode, frontCategory.getCode())
|
|
|
+ .eq(ShopCategory::getIsDelete, 0));
|
|
|
for (ShopCategory shopCategory1 : shopCategory) {
|
|
|
shopCategory1.setName(frontCategory.getName());
|
|
|
shopCategoryMapper.updateById(shopCategory1);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
- // 3. 保存门店信息
|
|
|
-// frontCategoryMapper.insert(frontCategory);
|
|
|
}
|
|
|
log.info("前台分类成功");
|
|
|
// 4. 构建响应
|
|
|
@@ -106,6 +103,70 @@ public class HBFrontCategoryService implements IHBFrontCategoryService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加门店分类
|
|
|
+ *
|
|
|
+ * @param frontCategory 前台分类
|
|
|
+ * @param shopId 门店id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ //添加事务
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void addShopCategory(FrontCategory frontCategory, Long shopId, Long hbShopId) {
|
|
|
+ ShopCategory shopCategoryByCode = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
+ .eq(ShopCategory::getCode, frontCategory.getCode())
|
|
|
+ .eq(ShopCategory::getShopId, shopId)
|
|
|
+ .eq(ShopCategory::getIsDelete, 0));
|
|
|
+
|
|
|
+ if (shopCategoryByCode != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ShopCategory shopCategory = new ShopCategory();
|
|
|
+ shopCategory.setCode(frontCategory.getCode());
|
|
|
+ shopCategory.setName(frontCategory.getName());
|
|
|
+ if (frontCategory.getParentCode() == null || frontCategory.getParentCode().equals("0")) {
|
|
|
+ shopCategory.setPid(0L);
|
|
|
+ shopCategory.setParentCode("0");
|
|
|
+ } else {
|
|
|
+ ShopCategory shopCategoryByCode1 = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
|
|
|
+ .eq(ShopCategory::getCode, frontCategory.getParentCode())
|
|
|
+ .eq(ShopCategory::getShopId, shopId)
|
|
|
+ .eq(ShopCategory::getIsDelete, 0));
|
|
|
+ if (shopCategoryByCode1 == null) {
|
|
|
+ //不存在父类目添加
|
|
|
+ FrontCategory frontCategoryParent = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
|
|
|
+ .eq(FrontCategory::getCode, frontCategory.getParentCode())
|
|
|
+ .eq(FrontCategory::getIsDelete, 0));
|
|
|
+ addShopCategory(frontCategoryParent, shopId, hbShopId);
|
|
|
+ }
|
|
|
+ shopCategory.setPid(shopCategoryByCode1.getId());
|
|
|
+ shopCategory.setParentCode(shopCategoryByCode1.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ shopCategory.setShopId(shopId);
|
|
|
+ shopCategory.setHbShopId(String.valueOf(hbShopId));
|
|
|
+ shopCategory.setLabel(frontCategory.getLabel());
|
|
|
+ shopCategory.setIcon(frontCategory.getIcon());
|
|
|
+ shopCategory.setPic(frontCategory.getPic());
|
|
|
+ shopCategory.setLevel(frontCategory.getLevel());
|
|
|
+ shopCategory.setIsDelete(0);
|
|
|
+ shopCategory.setOperateUser("admin");
|
|
|
+ shopCategory.setNum(frontCategory.getNum());
|
|
|
+ shopCategory.setIsLeaves(frontCategory.getIsLeaves());
|
|
|
+
|
|
|
+ shopCategoryMapper.insert(shopCategory);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sync(Long shopId, Long hbShopId) {
|
|
|
+ List<FrontCategory> frontCategoryList = frontCategoryMapper.selectList(new LambdaQueryWrapper<FrontCategory>()
|
|
|
+ .eq(FrontCategory::getIsDelete, 0));
|
|
|
+ for (FrontCategory frontCategory : frontCategoryList) {
|
|
|
+ addShopCategory(frontCategory, shopId, hbShopId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public String selectHBFrontCategory(List<String> resultList) {
|
|
|
HBBaseReq<Object> build = HBBaseReq.create();
|
|
|
build.setAppId(hbSignUtil.getAppId());
|