新增店铺

This commit is contained in:
zhangchenbiao
2024-04-24 14:26:39 +08:00
parent e2cf2ae528
commit 15feb2d9a5
2 changed files with 21 additions and 12 deletions

View File

@@ -25,10 +25,10 @@
id, region_id, line_id, partner_id, point_id, shop_name, shop_code, store_num, shop_manager_user_id, supervisor_user_id, plan_open_time, cur_progress, shop_type, shop_stage, deleted, create_time, update_time
</sql>
<insert id="batchAddShop">
<foreach collection="shopInfoList" item="shop" separator=";">
insert into xfsg_shop_info(region_id, line_id, partner_id, shop_name, shop_code)
values(#{shop.regionId}, #{shop.lineId}, #{shop.partnerId}, #{shop.shopName}, #{shop.shopCode})
<insert id="batchAddShop" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into xfsg_shop_info(region_id, line_id, partner_id, shop_name, shop_code) values
<foreach collection="shopInfoList" item="shop" separator=",">
(#{shop.regionId}, #{shop.lineId}, #{shop.partnerId}, #{shop.shopName}, #{shop.shopCode})
</foreach>
</insert>

View File

@@ -64,8 +64,7 @@ public class ShopServiceImpl implements ShopService {
addShopList.add(shopInfo);
}
shopInfoDAO.batchAddShop(addShopList);
List<ShopInfoDO> shopList = shopInfoDAO.getShopList(lineInfo.getId());
List<Long> shopIds = shopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
List<Long> shopIds = addShopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
return shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds);
}
@@ -119,20 +118,30 @@ public class ShopServiceImpl implements ShopService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long addShop(AddShopRequest request) {
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(request.getLineId());
if(Objects.isNull(lineInfo)){
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
}
List<String> shopNameList = request.getShopNameList();
List<ShopInfoDO> shopList = shopInfoDAO.getShopList(request.getLineId());
LineInfoDO updateLine = new LineInfoDO();
updateLine.setId(request.getLineId());
updateLine.setWantShopNum(shopList.size() + CommonConstants.ONE);
updateLine.setWantShopNum(shopList.size() + shopNameList.size());
lineInfoDAO.updateLineInfo(updateLine);
ShopInfoDO addShop = new ShopInfoDO();
addShop.setLineId(request.getLineId());
addShop.setPartnerId(lineInfo.getPartnerId());
addShop.setShopName("店铺"+ NumberConverter.convertArabicToChinese(updateLine.getWantShopNum()));
return shopInfoDAO.addShopInfo(addShop);
List<ShopInfoDO> addShopList = new ArrayList<>();
for (String shopName : shopNameList) {
ShopInfoDO addShop = new ShopInfoDO();
addShop.setRegionId(lineInfo.getRegionId());
addShop.setLineId(request.getLineId());
addShop.setPartnerId(lineInfo.getPartnerId());
addShop.setShopName(shopName);
addShopList.add(addShop);
}
shopInfoDAO.batchAddShop(addShopList);
List<Long> shopIds = addShopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds);
return 1L;
}
}