Compare commits

...

8 Commits

Author SHA1 Message Date
曹鹏飞 0d79babfac feat(order): 优化购物车报价单号生成逻辑
- 在ITBaseAreaService和ITBaseCustomerService接口中新增获取报价码方法getQuoteCode
- TBaseAreaServiceImpl实现getQuoteCode,支持根据区域id集合获取报价码
- TBaseCustomerServiceImpl实现getQuoteCode,支持根据公司id列表获取对应区域报价码
- ShoppingController中使用getQuoteCode替换旧报价单号生成逻辑
- 购物单号前缀由“QO”改为“NFQ”,根据用户身份动态生成区域或公司报价码
- 引入Redis缓存报价单日期序号,避免单号冲突,提高性能
- 优化ShoppingCartPartVO金额乘以optionalRatio逻辑,防止负数金额错误乘算
2026-05-13 18:00:46 +08:00
曹鹏飞 88f1e8779e feat(adminUser): 支持直销人员区域信息及报价编码生成
- 在 AccountAddRequest 中新增 List<Integer> areaIds 字段以支持区域列表
- 在 AdminUser 实体添加 areaIds 字段,多个区域以逗号分隔保存
- AdminUserController 中设置区域信息,并根据 categoryId 生成唯一报价编码
- 在 AdminUserServiceImpl 中校验直销人员必须选择区域,否则抛出业务异常
- 新增代码逻辑实现区域信息持久化及报价编码生成流程
- 优化查询代码格式,保持一致的代码风格
2026-05-13 15:54:25 +08:00
曹鹏飞 50901bf40e fix(service): 修改代理公司特殊代码为"D"
- 将特殊代码由"A"更改为"D"
- 修复区域信息校验逻辑中的特殊代码定义
- 保证代理公司区域信息校验的正确性
2026-05-13 15:41:50 +08:00
曹鹏飞 dfa793fcff refactor(quotation): 将“报价对象”统一修改为“报价主体”
- 统一替换代码注释中的“报价对象”为“报价主体”
- 同步更新验证提示信息中的“报价对象”为“报价主体”
- 统一调整接口返回和请求参数描述为“报价主体”
- 确保相关实体类及请求VO中字段注释一致性
- 修改购物车和订单相关提示消息中的“报价对象”为“报价主体”
2026-05-13 14:35:14 +08:00
曹鹏飞 35bd3b4767 feat(dto): 添加区域报价编码字段注释
- 在 BaseAreaEditDTO 中新增 areaQuoteCode 字段
- 添加字段非空校验注解@NotBlank
- 补充字段的JavaDoc注释,说明其含义为区域报价编码
2026-05-13 11:44:00 +08:00
曹鹏飞 6acd9f8a52 feat(appUser): 优化代理商报价代码生成逻辑并支持Redis缓存
- 使用Redis缓存报价代码索引,提升报价代码生成性能
- 替换原有序列号生成服务,改用Redis自增策略生成报价代码
- 在编辑客户时,新增根据配置自动生成所属代理商报价代码功能
- 添加初始化APP用户报价代码接口,支持批量生成报价代码
- 修正代码格式及部分逻辑细节,提高代码可读性和维护性
- 在CustomerController中增加事务管理及日志记录功能
2026-05-13 11:34:29 +08:00
曹鹏飞 b8ca2a9905 feat(serial-number): 添加乐观锁支持及初始化报价代码接口
- 在AdminBaseSerialNumber实体中添加@Version注解实现乐观锁
- 在MybatisPlus配置中加入OptimisticLockerInnerInterceptor支持乐观锁插件
- 修正AdminBaseSerialNumberServiceImpl中序列号生成逻辑,避免逻辑遗漏
- TestController新增接口initAdminUserQuotationCode,批量初始化内部用户报价代码字段
- 新增日志记录生成的报价代码,确保数据初始化过程可追踪
- 引入相关服务依赖,完善测试控制器注入与调用逻辑
2026-05-13 10:07:34 +08:00
曹鹏飞 9cceef75bb fix(app): 统一修改提示信息为“请联系管理员为您开放权限”
- 将AppRatioAgentConfigController中所有涉及权限提示的消息由“请联系管理员为你设置”修改为“请联系管理员为您开放权限”
- PlanController中为setDefaultRatio接口添加@Min(1)参数校验,确保传入系数不小于1
- ShoppingController中修改权限相关提示信息,统一为“请联系管理员为您开放权限”
- 优化用户权限提示语句,提升用户体验和表述一致性
2026-05-13 09:01:03 +08:00
33 changed files with 269 additions and 69 deletions

View File

@ -18,10 +18,7 @@ import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.AdminUser;
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
import com.nflg.mobilebroken.repository.service.IAdminUserService;
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
import com.nflg.mobilebroken.repository.service.ITBasePositionService;
import com.nflg.mobilebroken.repository.service.*;
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
import com.nflg.mobilebroken.starter.service.EmailService;
import lombok.extern.slf4j.Slf4j;
@ -82,6 +79,9 @@ public class AdminUserController extends ControllerBase {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private IAdminBaseSerialNumberService serialNumberService;
/**
* 获取部门列表
* @return 部门列表
@ -161,11 +161,16 @@ public class AdminUserController extends ControllerBase {
.setGongFuHandler(request.isGongFuHandler())
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
.setCategoryId(request.getCategoryId())
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
.setUpdateBy(AdminUserUtil.getUserId())
.setUpdateTime(LocalDateTime.now());
if (!Objects.equals(user.getState(), UserState.ToBeActivated.getState()) && Objects.nonNull(request.getEnable())) {
user.setState(request.getEnable() ? UserState.Activated.getState() : UserState.Disabled.getState());
}
if (Objects.nonNull(request.getCategoryId()) && StrUtil.isBlank(user.getQuotationCode())) {
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
user.setQuotationCode(quotationCode);
}
adminUserService.updateById(user);
return ApiResult.success();
}

View File

@ -31,6 +31,8 @@ import com.nflg.mobilebroken.repository.service.IAppUserService;
import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.ttzero.excel.entity.ListSheet;
@ -40,6 +42,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@ -48,6 +51,7 @@ import java.util.stream.Collectors;
/**
* 客户管理
*/
@Slf4j
@RestController
@RequestMapping("/customer")
public class CustomerController extends ControllerBase {
@ -120,6 +124,7 @@ public class CustomerController extends ControllerBase {
* @param customerDTO
* @return
*/
@Transactional
@PostMapping("updateCompany")
@MethodInfoMark(value = "编辑", menuName = "客户管理")
@ApiMark(moduleName = "客户管理", apiName = "编辑")
@ -135,6 +140,23 @@ public class CustomerController extends ControllerBase {
//检查公司名称是否已存在
TBaseCustomer oldEnt = baseCustomerService.getById(customerDTO.getId());
VUtils.trueThrow(Objects.isNull(oldEnt)).throwMessage(STATE.PageError, customerDTO.getAgencyCompanyName() + "公司不存在");
if (customerDTO.getQuotationUse() && !oldEnt.getQuotationUse()) {
//该公司对应的代理商需要生成报价代码
List<AppUser> appUsers = appUserService.lambdaQuery()
.eq(AppUser::getType, 0)
.isNull(AppUser::getQuotationCode)
.apply("FIND_IN_SET({0}, companyId) > 0", customerDTO.getId())
.orderByAsc(AppUser::getId)
.list();
if (CollUtil.isNotEmpty(appUsers)) {
appUsers.forEach(appUser -> {
String quotationCode = appUserService.getAppUserQuotationCode(Arrays.stream(StrUtil.splitToInt(appUser.getCompanyId(), ",")).boxed().collect(Collectors.toList()));
log.info("生成报价代码【{}】:{}", appUser.getName(), quotationCode);
appUser.setQuotationCode(quotationCode);
});
appUserService.updateBatchById(appUsers);
}
}
BeanUtil.copyProperties(customerDTO, oldEnt);
oldEnt.setAreaCode(StrUtil.join(",", customerDTO.getAreaList().stream().map(CustomerAreaDTO::getAreaCode).collect(Collectors.toList())));
oldEnt.setAreaName(StrUtil.join(",", customerDTO.getAreaList().stream().map(CustomerAreaDTO::getAreaName).collect(Collectors.toList())));
@ -203,6 +225,7 @@ public class CustomerController extends ControllerBase {
EecExcelUtil.setResponseExcelHeader(response, "客户列表");
final ListSheet<CustomerExcelVO> listSheet = new ListSheet<CustomerExcelVO>() {
int i = 0;
@Override
protected List<CustomerExcelVO> more() {
List<TBaseCustomer> list = baseCustomerService.list();

View File

@ -25,6 +25,9 @@ public class BaseAreaEditDTO {
@NotNull(message = "类别不能为空")
private Long categoryId;
/**
* 区域报价编码
*/
@NotBlank(message = "区域报价编码不能为空")
private String areaQuoteCode;
}

View File

@ -89,8 +89,8 @@ public class CustomerDTO {
private List<CustomerAreaDTO> areaList;
/**
* 是否报价对象
* 是否报价主体
*/
@NotNull(message = "是否报价对象不能为空")
@NotNull(message = "是否报价主体不能为空")
private Boolean quotationUse=false;
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class AccountAddRequest {
@ -59,4 +60,9 @@ public class AccountAddRequest {
* 直销类别国内国外字典id
*/
private Long categoryId;
/**
* 区域id列表
*/
private List<Integer> areaIds;
}

View File

@ -33,7 +33,7 @@ public class QuotationAdminSearchRequest extends PageRequest{
private String customerName;
/**
* 报价对象
* 报价主体
*/
private Long targetId;

View File

@ -29,12 +29,12 @@ public class QuotationSearchVO {
private String quotationCode;
/**
* 报价对象
* 报价主体
*/
private Integer targetId;
/**
* 报价对象
* 报价主体
*/
private String targetName;

View File

@ -66,7 +66,7 @@ public class ShoppingSearchVO {
private String customerName;
/**
* 报价对象代理商时为公司id内部用户时为其用户id
* 报价主体代理商时为公司id内部用户时为其用户id
*/
private Integer targetId;

View File

@ -5,27 +5,24 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.ProductModel;
import com.nflg.mobilebroken.repository.entity.TBaseArea;
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
import com.nflg.mobilebroken.repository.service.IProductModelService;
import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
import com.nflg.mobilebroken.repository.entity.*;
import com.nflg.mobilebroken.repository.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.sql.Struct;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 测试
*/
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController extends ControllerBase {
@ -39,6 +36,18 @@ public class TestController extends ControllerBase {
@Resource
ITBaseAreaService areaService;
@Resource
private IAdminUserService adminUserService;
@Resource
private IAdminBaseSerialNumberService serialNumberService;
@Resource
private IAppUserService appUserService;
@Resource
private ITBaseCustomerService customerService;
/**
* 初始化机型表的BatchNumber字段数据
*/
@ -121,4 +130,57 @@ public class TestController extends ControllerBase {
return ApiResult.success();
}
/**
* 初始化内部用户报价代码字段数据
*/
@PostMapping("initAdminUserQuotationCode")
public ApiResult<Void> initAdminUserQuotationCode() {
List<AdminUser> adminUsers = adminUserService.lambdaQuery()
.isNull(AdminUser::getQuotationCode)
.orderByAsc(AdminUser::getId)
.list();
if (CollectionUtil.isNotEmpty(adminUsers)) {
adminUsers.forEach(adminUser -> {
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
log.info("生成报价代码【{}】:{}", adminUser.getUserName(), quotationCode);
adminUser.setQuotationCode(quotationCode);
});
adminUserService.updateBatchById(adminUsers);
return ApiResult.success();
}
return ApiResult.success();
}
/**
* 初始化APP用户报价代码字段数据
*/
@PostMapping("initAppUserQuotationCode")
public ApiResult<Void> initAppUserQuotationCode() {
Set<Integer> customers = customerService.getForQuotation()
.stream()
.map(TBaseCustomer::getId)
.collect(Collectors.toSet());
List<AppUser> appUsers = appUserService.lambdaQuery()
.eq(AppUser::getType, 0)
.isNull(AppUser::getQuotationCode)
.orderByAsc(AppUser::getId)
.list();
appUsers.removeIf(appUser -> customers.stream()
.noneMatch(customerId -> Arrays.stream(StrUtil.splitToInt(appUser.getCompanyId(), ","))
.boxed()
.collect(Collectors.toList())
.contains(customerId)
)
);
if (CollectionUtil.isNotEmpty(appUsers)) {
appUsers.forEach(appUser -> {
String quotationCode = appUserService.getAppUserQuotationCode(Arrays.stream(StrUtil.splitToInt(appUser.getCompanyId(), ",")).boxed().collect(Collectors.toList()));
log.info("生成报价代码【{}】:{}", appUser.getName(), quotationCode);
appUser.setQuotationCode(quotationCode);
});
appUserService.updateBatchById(appUsers);
return ApiResult.success();
}
return ApiResult.success();
}
}

View File

@ -140,7 +140,7 @@ public class DiscountConfigController extends ControllerBase {
}
/**
* 获取所有报价对象
* 获取所有报价主体
*/
@GetMapping("/applyFors")
public ApiResult<List<DiscountApplyForVO>> getApplyFors() {

View File

@ -64,7 +64,7 @@ public class RatioConfigController extends ControllerBase {
private IAdminUserService adminUserService;
/**
* 获取报价对象
* 获取报价主体
*/
@GetMapping("/getTargetUsers")
public ApiResult<TargetUserVO> getTargetUsers() {

View File

@ -94,7 +94,7 @@ public class AppRatioAgentConfigController extends ControllerBase {
*/
@PostMapping("config/search")
public ApiResult<PageData<Map<String, Object>>> search(@Valid @RequestBody ModelConfigSearchRequest request) {
VUtils.trueThrowBusinessError(!ratioAgentItemService.hasConfig(AppUserUtil.getUserId())).throwMessage("请联系管理员为你设置系数");
VUtils.trueThrowBusinessError(!ratioAgentItemService.hasConfig(AppUserUtil.getUserId())).throwMessage("请联系管理员为您开放权限");
QuotationModelRatioAgent ratioAgent = ratioAgentService.lambdaQuery()
.eq(QuotationModelRatioAgent::getStatus, 1)
.eq(QuotationModelRatioAgent::getCreateByType, 1)
@ -109,7 +109,7 @@ public class AppRatioAgentConfigController extends ControllerBase {
.list();
AppUser cuser = appUserService.getById(AppUserUtil.getUserId());
DictionaryItem category = appUserService.getCategory(cuser);
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为你设置区域类型");
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为您开放权限");
List<AppUser> users = appUserService.getChildren(cuser);
List<ModelPriceVO> prices = priceService.getAllModelPrice();
PageData<Map<String, Object>> mdatas = new PageData<>();
@ -235,7 +235,7 @@ public class AppRatioAgentConfigController extends ControllerBase {
}
/**
* 获取报价对象
* 获取报价主体
*/
@GetMapping("list/getUsers")
public ApiResult<List<SimpleUserVO>> getUsers() {
@ -247,10 +247,10 @@ public class AppRatioAgentConfigController extends ControllerBase {
*/
@PostMapping("list/search")
public ApiResult<PageData<RatioConfigSearchVO>> search(@Valid @RequestBody ModelRatioUserSearchRequest request) {
VUtils.trueThrowBusinessError(!ratioAgentItemService.hasConfig(AppUserUtil.getUserId())).throwMessage("请联系管理员为你设置系数");
VUtils.trueThrowBusinessError(!ratioAgentItemService.hasConfig(AppUserUtil.getUserId())).throwMessage("请联系管理员为您开放权限");
AppUser cuser = appUserService.getById(AppUserUtil.getUserId());
DictionaryItem category = appUserService.getCategory(cuser);
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为你设置区域类型");
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为您开放权限");
List<QuotationUserPlanModelItemDTO> plans = planModelItemService.getEffectivesForAgent();
List<QuotationModelRatioAgentItemDTO> items = ratioAgentItemService.getEffectiveByCreate(AppUserUtil.getUserId());
if (Objects.isNull(request.getUserId())) {

View File

@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.time.LocalDate;
@ -75,7 +76,7 @@ public class PlanController extends ControllerBase {
* 设置方案默认系数
*/
@PostMapping("/setDefaultRatio")
public ApiResult<Void> setDefaultRatio(@RequestParam BigDecimal ratio) {
public ApiResult<Void> setDefaultRatio(@RequestParam @Min(1) BigDecimal ratio) {
QuotationUserPlanDefault planDefault = planDefaultService.lambdaQuery()
.eq(QuotationUserPlanDefault::getCreateByType, AppUserUtil.isAgent() ? 1 : 0)
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())

View File

@ -28,6 +28,7 @@ import com.nflg.mobilebroken.repository.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -125,8 +126,14 @@ public class ShoppingController extends ControllerBase {
@Resource
private IDictionaryItemTranslateService dictionaryItemTranslateService;
@Resource
private ITBaseAreaService areaService;
@Resource
private RedisTemplate<String, Integer> redisTemplate;
/**
* 购物车-获取报价对象
* 购物车-获取报价主体
*/
@GetMapping("/cart/getTargets")
public ApiResult<List<SimpleUserVO>> getTargets() {
@ -156,7 +163,7 @@ public class ShoppingController extends ControllerBase {
@PostMapping("/cart/init")
public ApiResult<ShoppingCartVO> init(@Valid @RequestBody ShoppingInitRequest request) {
String qc = getQuotationCode();
VUtils.trueThrowBusinessError(StrUtil.isBlank(qc)).throwMessage("请联系管理员为你设置报价代码");
VUtils.trueThrowBusinessError(StrUtil.isBlank(qc)).throwMessage("请联系管理员为您开放权限");
Long categoryId = getCategoryId();
ProductModel model = productModelService.lambdaQuery().eq(ProductModel::getState, 1).eq(ProductModel::getNo, request.getModelNo()).one();
VUtils.trueThrowBusinessError(Objects.isNull(model)).throwMessage("未找到该机型");
@ -528,7 +535,7 @@ public class ShoppingController extends ControllerBase {
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getCustomerName).collect(Collectors.toSet()).size() > 1)
.throwMessage("客户名称不一致");
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getTargetId).collect(Collectors.toSet()).size() > 1)
.throwMessage("报价对象不一致");
.throwMessage("报价主体不一致");
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getCurrency).collect(Collectors.toSet()).size() > 1)
.throwMessage("币种不一致");
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getExchangeRate).collect(Collectors.toSet()).size() > 1)
@ -554,18 +561,7 @@ public class ShoppingController extends ControllerBase {
.setCartId(cart.getId()))
.collect(Collectors.toList())
);
QuotationShoppingOrder last = CollectionUtil.get(shoppingOrderService.lambdaQuery().orderByDesc(QuotationShoppingOrder::getId).list(), 0);
if (Objects.isNull(last)) {
order.setNo("QO" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "001");
} else {
String date = StrUtil.subWithLength(last.getNo(), 2, 8);
int index = Integer.parseInt(StrUtil.subSufByLength(last.getNo(), 3));
if (date.equals(DateTimeUtil.format(LocalDate.now(), "yyyyMMdd"))) {
order.setNo("QO" + date + StrUtil.padPre(String.valueOf(index + 1), 3, '0'));
} else {
order.setNo("QO" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "001");
}
}
order.setNo(genOrderNo());
shoppingOrderService.save(order);
shoppingCartService.lambdaUpdate()
.set(QuotationShoppingCart::getStatus, 1)
@ -575,6 +571,32 @@ public class ShoppingController extends ControllerBase {
return ApiResult.success(order.getId());
}
private String genOrderNo() {
VUtils.trueThrowBusinessError(AppUserUtil.isEndUser()).throwMessage("终端用户不能报价");
String orderNo = "NFQ";
if (AppUserUtil.isAgent()) {
AppUser appUser = appUserService.getById(AppUserUtil.getUserId());
orderNo += customerService.getQuoteCode(Arrays.stream(StrUtil.splitToInt(appUser.getCompanyId(), ",")).boxed().collect(Collectors.toList()));
} else {
AdminUser adminUser = adminUserService.getById(AppUserUtil.getUserId());
orderNo += areaService.getQuoteCode(Arrays.stream(StrUtil.splitToInt(adminUser.getAreaIds(), ",")).boxed().collect(Collectors.toList()));
}
orderNo += DateTimeUtil.format(LocalDate.now(), "yyyyMMdd");
String key = "quotation:order:no:" + orderNo;
Integer index = redisTemplate.opsForValue().get(key);
if (Objects.isNull(index)) {
QuotationShoppingOrder lastOrder = shoppingOrderService.lambdaQuery()
.likeRight(QuotationShoppingOrder::getNo, orderNo)
.orderByDesc(QuotationShoppingOrder::getNo)
.last("limit 1")
.one();
index = Objects.isNull(lastOrder) ? 0 : Integer.parseInt(lastOrder.getQuotationCode().replace(orderNo, ""));
}
index++;
redisTemplate.opsForValue().set(key, index);
return orderNo + String.format("%05d", index);
}
/**
* 报价单-查询报价单
*/
@ -923,14 +945,16 @@ public class ShoppingController extends ControllerBase {
private ShoppingCartPartVO convert(ModelConfigEffectiveDTO dto, BigDecimal optionalRatio) {
ShoppingCartPartVO vo = Convert.convert(ShoppingCartPartVO.class, dto);
if (vo.getAmount().compareTo(BigDecimal.ZERO) > 0) {
vo.setAmount(NumberUtil.multiply(vo.getAmount(), optionalRatio));
}
return vo;
}
private Long getCategoryId() {
if (AppUserUtil.isAgent()) {
DictionaryItem di = appUserService.getCategory(appUserService.getById(AppUserUtil.getUserId()));
VUtils.trueThrowBusinessError(Objects.isNull(di)).throwMessage("请联系管理员设置区域类别");
VUtils.trueThrowBusinessError(Objects.isNull(di)).throwMessage("请联系管理员为您开放权限");
return di.getId();
} else {
Long categoryId = adminUserService.getById(AppUserUtil.getUserId()).getCategoryId();

View File

@ -21,7 +21,7 @@ public class QuotationCopyRequest {
private String customerName;
/**
* 报价对象ID
* 报价主体ID
*/
@NotNull
private Integer targetId;

View File

@ -27,7 +27,7 @@ public class ShoppingInitRequest {
private String customerName;
/**
* 报价对象ID
* 报价主体ID
*/
@NotNull
private Integer targetId;

View File

@ -56,7 +56,7 @@ public class ShoppingSaveRequest {
private String customerName;
/**
* 报价对象代理商时为公司id内部用户时为其用户id
* 报价主体代理商时为公司id内部用户时为其用户id
*/
@NotNull
private Integer targetId;

View File

@ -23,7 +23,7 @@ public class QuotationOrderInfoVO {
private String customerName;
/**
* 报价对象
* 报价主体
*/
private Integer targetId;

View File

@ -25,7 +25,7 @@ public class RatioConfigSearchVO {
private String modelNo;
/**
* 报价对象
* 报价主体
*/
private String name;

View File

@ -56,7 +56,7 @@ public class ShoppingCartVO {
private String customerName;
/**
* 报价对象代理商时为公司id内部用户时为其用户id
* 报价主体代理商时为公司id内部用户时为其用户id
*/
private Integer targetId;

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.Version;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@ -45,6 +47,7 @@ public class AdminBaseSerialNumber implements Serializable {
/**
* 乐观锁版本号
*/
@Version
private Integer version;
/**

View File

@ -144,6 +144,11 @@ public class AdminUser implements Serializable {
*/
private String quotationCode;
/**
* 区域id多个用逗号分隔
*/
private String areaIds;
@Override
public boolean equals(Object o) {

View File

@ -62,7 +62,7 @@ public class QuotationShoppingCart implements Serializable {
private String customerName;
/**
* 报价对象代理商时为公司id内部用户时为其用户id
* 报价主体代理商时为公司id内部用户时为其用户id
*/
private Integer targetId;

View File

@ -37,7 +37,7 @@ public class QuotationShoppingOrder implements Serializable {
private String customerName;
/**
* 报价对象
* 报价主体
*/
private Integer targetId;

View File

@ -134,7 +134,7 @@ public class TBaseCustomer implements Serializable {
private Integer delIs;
/**
* 是否报价对象
* 是否报价主体
*/
private Boolean quotationUse;

View File

@ -8,6 +8,7 @@ import com.nflg.mobilebroken.repository.entity.TBaseArea;
import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.List;
/**
@ -32,4 +33,6 @@ public interface ITBaseAreaService extends IService<TBaseArea> {
void updateChildrenCategory(Integer id,Long categoryId);
void updateCustomerCategory(String areaCode, Long categoryId);
String getQuoteCode(Collection<Integer> ids);
}

View File

@ -36,4 +36,6 @@ public interface ITBaseCustomerService extends IService<TBaseCustomer> {
Collection<Integer> getAreaIds(List<Integer> companyIds);
List<TBaseCustomer> getForQuotation();
String getQuoteCode(List<Integer> companyIds);
}

View File

@ -1,5 +1,6 @@
package com.nflg.mobilebroken.repository.service.impl;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.repository.entity.AdminBaseSerialNumber;
import com.nflg.mobilebroken.repository.mapper.AdminBaseSerialNumberMapper;
import com.nflg.mobilebroken.repository.service.IAdminBaseSerialNumberService;
@ -16,7 +17,6 @@ import java.util.Objects;
* <p>
* 服务实现类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@ -34,7 +34,7 @@ public class AdminBaseSerialNumberServiceImpl extends ServiceImpl<AdminBaseSeria
public String generateSerialNumber(Integer businessType, String prefixNumber, String specialNumber,
boolean hasTimeStr, Integer serialLength) {
String currentDate = "";
String serialNo ;
String serialNo;
AdminBaseSerialNumber serialNumber = this.lambdaQuery()
.eq(AdminBaseSerialNumber::getBusinessType, businessType)
.one();
@ -59,6 +59,8 @@ public class AdminBaseSerialNumberServiceImpl extends ServiceImpl<AdminBaseSeria
if (serialNumber.getCurrentDateStr().equals(currentDate)) {
startSerial = serialNumber.getMaxSerial() + 1;
}
} else {
startSerial = serialNumber.getMaxSerial() + 1;
}
serialNumber.setSerialLength(serialLength);
serialNumber.setMaxSerial(startSerial);

View File

@ -97,6 +97,8 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
.exists()
)
.throwMessage("部门已存在负责人");
VUtils.trueThrowBusinessError(Objects.nonNull(request.getCategoryId()) && CollectionUtil.isEmpty(request.getAreaIds()))
.throwMessage("直销人员需要选择区域");
AdminUser user = lambdaQuery().eq(AdminUser::getLoginName, request.getLoginName()).one();
if (Objects.nonNull(user)) {
VUtils.trueThrowBusinessError(!user.getIsDel())
@ -113,11 +115,15 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
.setGongFuHandler(request.isGongFuHandler())
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
.setCategoryId(request.getCategoryId())
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
.setUpdateBy(AdminUserUtil.getUserId())
.setUpdateTime(LocalDateTime.now());
if (Objects.nonNull(request.getCategoryId()) && StrUtil.isBlank(user.getQuotationCode())) {
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
user.setQuotationCode(quotationCode);
}
updateById(user);
} else {
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
user = new AdminUser()
.setUserCode(request.getUserCode())
.setUserName(request.getUserName())
@ -132,9 +138,13 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
.setCategoryId(request.getCategoryId())
.setTitleId(request.getTitleId())
.setQuotationCode(quotationCode)
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
.setCreateBy(AdminUserUtil.getUserId())
.setCreateTime(LocalDateTime.now());
if (Objects.nonNull(request.getCategoryId())) {
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
user.setQuotationCode(quotationCode);
}
save(user);
}
departmentService.lambdaUpdate()

View File

@ -19,6 +19,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.*;
import com.nflg.mobilebroken.repository.mapper.AppUserMapper;
import com.nflg.mobilebroken.repository.service.*;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@ -80,7 +81,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
private IDictionaryItemService dictionaryItemService;
@Resource
private IAdminBaseSerialNumberService adminBaseSerialNumberService;
private RedisTemplate<String, Integer> redisTemplate;
@Override
public String getAppUserQuotationCode(List<Integer> companyId) {
@ -105,7 +106,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
.filter(StrUtil::isNotBlank)
.collect(Collectors.toSet());
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(uniqueAreaCodes)).throwMessage("存在未维护区域信息的代理公司,请先维护区域信息");
String specialCode = "";
String specialCode = "D";
List<TBaseArea> areas = adminAreaService.lambdaQuery()
.in(TBaseArea::getAreaCode, uniqueAreaCodes)
.list();
@ -117,7 +118,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
// 如果是只有一个公司或区域就返回区域报价代码
if (areas.size() == 1) {
VUtils.trueThrowBusinessError(StrUtil.isBlank(areas.get(0).getAreaQuoteCode())).throwMessage("区域报价代码没有维护,请先维护");
specialCode = areas.get(0).getAreaQuoteCode();
specialCode += areas.get(0).getAreaQuoteCode();
}
// 如果存在多个公司或区域需要查询上级
Set<Integer> parentIds = areas.stream()
@ -130,7 +131,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
// 如果只有一个上级就返回上级报价代码
if (parentAreas.size() == 1) {
VUtils.trueThrowBusinessError(StrUtil.isBlank(parentAreas.get(0).getAreaQuoteCode())).throwMessage("区域报价代码没有维护,请先维护");
specialCode = parentAreas.get(0).getAreaQuoteCode();
specialCode += parentAreas.get(0).getAreaQuoteCode();
} else {
// 多个上级区别处理合并相同上级的单独列出一个上级的
Map<Integer, Long> parentCountMap = areas.stream()
@ -168,9 +169,19 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
specialCode += "-" + baseArea.getAreaQuoteCode();
}
}
String code = adminBaseSerialNumberService.generateSerialNumber(1, "", specialCode, false, 6);
return code;
String key = "quotation:appUser:quotationCode:" + specialCode;
Integer index = redisTemplate.opsForValue().get(key);
if (Objects.isNull(index)) {
AppUser lastUser = lambdaQuery()
.likeRight(AppUser::getQuotationCode, specialCode)
.orderByDesc(AppUser::getQuotationCode)
.last("limit 1")
.one();
index = Objects.isNull(lastUser) ? 0 : Integer.parseInt(lastUser.getQuotationCode().replace(specialCode, ""));
}
index++;
redisTemplate.opsForValue().set(key, index);
return specialCode + String.format("%06d", index);
}
@ -531,8 +542,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
@Override
public List<AppUser> getEndUsers() {
return lambdaQuery()
.eq(AppUser::getIsDel,0)
.eq(AppUser::getType,1)
.eq(AppUser::getIsDel, 0)
.eq(AppUser::getType, 1)
.list();
}

View File

@ -10,7 +10,9 @@ import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
@ -51,4 +53,17 @@ public class TBaseAreaServiceImpl extends ServiceImpl<TBaseAreaMapper, TBaseArea
baseMapper.updateCustomerCategory(areaCode, categoryId);
}
@Override
public String getQuoteCode(Collection<Integer> ids) {
return lambdaQuery()
.select(TBaseArea::getAreaQuoteCode)
.in(TBaseArea::getId, ids)
.list()
.stream()
.map(TBaseArea::getAreaQuoteCode)
.collect(Collectors.toSet())
.iterator()
.next();
}
}

View File

@ -149,4 +149,27 @@ public class TBaseCustomerServiceImpl extends ServiceImpl<TBaseCustomerMapper, T
.eq(TBaseCustomer::getQuotationUse, true)
.list();
}
@Override
public String getQuoteCode(List<Integer> companyIds) {
Set<String> areaCodes = lambdaQuery()
.select(TBaseCustomer::getAreaCode)
.in(TBaseCustomer::getId, companyIds)
.list()
.stream()
.map(TBaseCustomer::getAreaCode)
.collect(Collectors.toSet());
List<TBaseArea> areas = areaService.lambdaQuery()
.in(TBaseArea::getAreaCode, areaCodes)
.list();
if (areas.size() == 1) {
return areas.get(0).getAreaQuoteCode();
}
TBaseArea area = areas.stream().filter(a -> a.getParentAreaRowId() == 0).findFirst().orElse(null);
if (Objects.nonNull(area)) {
return area.getAreaQuoteCode();
}
area = areaService.getById(areas.get(0).getParentAreaRowId());
return area.getAreaQuoteCode();
}
}

View File

@ -4,6 +4,7 @@ import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.nflg.mobilebroken.starter.handler.UTCLocalDateTimeTypeHandler;
@ -104,6 +105,7 @@ public class MysqlDataSourceConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}