新增店铺
This commit is contained in:
@@ -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
|
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>
|
</sql>
|
||||||
|
|
||||||
<insert id="batchAddShop">
|
<insert id="batchAddShop" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||||
<foreach collection="shopInfoList" item="shop" separator=";">
|
insert into xfsg_shop_info(region_id, line_id, partner_id, shop_name, shop_code) values
|
||||||
insert into xfsg_shop_info(region_id, line_id, partner_id, shop_name, shop_code)
|
<foreach collection="shopInfoList" item="shop" separator=",">
|
||||||
values(#{shop.regionId}, #{shop.lineId}, #{shop.partnerId}, #{shop.shopName}, #{shop.shopCode})
|
(#{shop.regionId}, #{shop.lineId}, #{shop.partnerId}, #{shop.shopName}, #{shop.shopCode})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ public class ShopServiceImpl implements ShopService {
|
|||||||
addShopList.add(shopInfo);
|
addShopList.add(shopInfo);
|
||||||
}
|
}
|
||||||
shopInfoDAO.batchAddShop(addShopList);
|
shopInfoDAO.batchAddShop(addShopList);
|
||||||
List<ShopInfoDO> shopList = shopInfoDAO.getShopList(lineInfo.getId());
|
List<Long> shopIds = addShopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
|
||||||
List<Long> shopIds = shopList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
|
|
||||||
return shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds);
|
return shopStageInfoDAO.initShopStageInfo(lineInfo.getId(), shopIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,20 +118,30 @@ public class ShopServiceImpl implements ShopService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long addShop(AddShopRequest request) {
|
public Long addShop(AddShopRequest request) {
|
||||||
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(request.getLineId());
|
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(request.getLineId());
|
||||||
if(Objects.isNull(lineInfo)){
|
if(Objects.isNull(lineInfo)){
|
||||||
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
|
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
List<String> shopNameList = request.getShopNameList();
|
||||||
List<ShopInfoDO> shopList = shopInfoDAO.getShopList(request.getLineId());
|
List<ShopInfoDO> shopList = shopInfoDAO.getShopList(request.getLineId());
|
||||||
LineInfoDO updateLine = new LineInfoDO();
|
LineInfoDO updateLine = new LineInfoDO();
|
||||||
updateLine.setId(request.getLineId());
|
updateLine.setId(request.getLineId());
|
||||||
updateLine.setWantShopNum(shopList.size() + CommonConstants.ONE);
|
updateLine.setWantShopNum(shopList.size() + shopNameList.size());
|
||||||
lineInfoDAO.updateLineInfo(updateLine);
|
lineInfoDAO.updateLineInfo(updateLine);
|
||||||
ShopInfoDO addShop = new ShopInfoDO();
|
List<ShopInfoDO> addShopList = new ArrayList<>();
|
||||||
addShop.setLineId(request.getLineId());
|
for (String shopName : shopNameList) {
|
||||||
addShop.setPartnerId(lineInfo.getPartnerId());
|
ShopInfoDO addShop = new ShopInfoDO();
|
||||||
addShop.setShopName("店铺"+ NumberConverter.convertArabicToChinese(updateLine.getWantShopNum()));
|
addShop.setRegionId(lineInfo.getRegionId());
|
||||||
return shopInfoDAO.addShopInfo(addShop);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user