选址阶段

This commit is contained in:
zhangchenbiao
2024-04-10 17:24:37 +08:00
parent 0eb33e8d4b
commit fa18c4c476
6 changed files with 86 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package com.cool.store.utils;
/**
* @author zhangchenbiao
* @FileName: NumberConverter
* @Description:
* @date 2024-04-10 17:07
*/
public class NumberConverter {
private static final char[] CN_NUMBERS = {'零', '一', '二', '三', '四', '五', '六', '七', '八', '九'};
private static final char[] CN_UNITS = {'个', '十', '百', '千', '万'};
public static String convertArabicToChinese(int number) {
String result = "";
// 将数字转换为字符串
String numStr = String.valueOf(number);
int len = numStr.length();
boolean lastIsZero = false;
for (int i = 0; i < len; i++) {
int n = numStr.charAt(i) - '0'; // 转换为数字
if (n != 0 || (!lastIsZero && i != len - 1)) {
result += CN_NUMBERS[n]; // 转换为中文数字
if (i != len - 1) {
// 不是最后一位数字,需要添加单位
result += CN_UNITS[(len - 1 - i)];
}
} else {
lastIsZero = true;
}
}
return result;
}
}

View File

@@ -1,10 +1,13 @@
package com.cool.store.dao;
import com.cool.store.entity.LineInfoDO;
import com.cool.store.entity.ShopInfoDO;
import com.cool.store.mapper.ShopInfoMapper;
import com.cool.store.utils.NumberConverter;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -20,6 +23,26 @@ public class ShopInfoDAO {
@Resource
private ShopInfoMapper shopInfoMapper;
/**
* 初始化店铺
* @param lineInfo
* @return
*/
public Integer initShop(LineInfoDO lineInfo){
Integer wantShopNum = lineInfo.getWantShopNum();
List<ShopInfoDO> shopList = new ArrayList<>();
for (int i = 0; i < wantShopNum; i++) {
ShopInfoDO shopInfo = new ShopInfoDO();
shopInfo.setRegionId(lineInfo.getRegionId());
shopInfo.setLineId(lineInfo.getId());
shopInfo.setPartnerId(lineInfo.getPartnerId());
shopInfo.setShopName("店铺" + NumberConverter.convertArabicToChinese(i + 1));
shopList.add(shopInfo);
}
return shopInfoMapper.batchAddShop(shopList);
}
/**
* 获取门店信息
* @param shopId

View File

@@ -8,6 +8,14 @@ import java.util.List;
public interface ShopInfoMapper extends Mapper<ShopInfoDO> {
/**
* 批量新增
* @param shopInfoList
* @return
*/
Integer batchAddShop(@Param("shopInfoList") List<ShopInfoDO> shopInfoList);
/**
* 获取加盟商的店铺列表
* @param lineId

View File

@@ -25,6 +25,13 @@
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})
</foreach>
</insert>
<select id="getShopList" resultMap="BaseResultMap">
select <include refid="allColumn"/> from xfsg_shop_info where line_id = #{lineId} and deleted= '0'
</select>

View File

@@ -71,6 +71,8 @@ public class LineInterviewServiceImpl extends LineFlowService implements LineInt
private TransferLogService transferLogService;
@Resource
private HyPartnerUserChannelDAO hyPartnerUserChannelDAO;
@Resource
private ShopInfoDAO shopInfoDAO;
@Override
public List<AppointmentTimeVO> getAppointmentTime(Long lineId, Integer interviewType, LocalDate appointmentDate) {
@@ -412,7 +414,7 @@ public class LineInterviewServiceImpl extends LineFlowService implements LineInt
updateLine.setDevelopmentManager(developmentManager);
lineInfoDAO.updateLineInfo(updateLine);
//初始化店铺
shopInfoDAO.initShop(lineInfo);
}
return lineInterviewDAO.updateInterviewInfo(updateInterviewInfo) > 0;
}

View File

@@ -26,6 +26,10 @@ public class PCTestController {
@Resource
private CommonService commonService;
@Resource
private LineInfoDAO lineInfoDAO;
@Resource
private ShopInfoDAO shopInfoDAO;
@GetMapping("/sendMessage")
@@ -33,4 +37,11 @@ public class PCTestController {
commonService.sendMessage(Arrays.asList("123836131931284423"), 1L, MessageEnum.MESSAGE_1, "张三", "浙江-杭州");
return ResponseResult.success(Boolean.FALSE);
}
@GetMapping("/initShop")
public ResponseResult<Boolean> initShop(@RequestParam("lineId")Long lineId){
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(lineId);
shopInfoDAO.initShop(lineInfo);
return ResponseResult.success(Boolean.FALSE);
}
}