Compare commits

..

No commits in common. "0d79babfac929630a26b9036c03791c58da6a509" and "a97e80f85791e1a5c00f009ad52c0091597e7a05" have entirely different histories.

33 changed files with 69 additions and 269 deletions

View File

@ -18,7 +18,10 @@ 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.*;
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.starter.annotation.MethodInfoMark;
import com.nflg.mobilebroken.starter.service.EmailService;
import lombok.extern.slf4j.Slf4j;
@ -79,9 +82,6 @@ public class AdminUserController extends ControllerBase {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private IAdminBaseSerialNumberService serialNumberService;
/**
* 获取部门列表
* @return 部门列表
@ -161,16 +161,11 @@ 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,8 +31,6 @@ 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;
@ -42,7 +40,6 @@ 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;
@ -51,7 +48,6 @@ import java.util.stream.Collectors;
/**
* 客户管理
*/
@Slf4j
@RestController
@RequestMapping("/customer")
public class CustomerController extends ControllerBase {
@ -124,7 +120,6 @@ public class CustomerController extends ControllerBase {
* @param customerDTO
* @return
*/
@Transactional
@PostMapping("updateCompany")
@MethodInfoMark(value = "编辑", menuName = "客户管理")
@ApiMark(moduleName = "客户管理", apiName = "编辑")
@ -140,23 +135,6 @@ 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())));
@ -225,7 +203,6 @@ 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,9 +25,6 @@ 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,7 +6,6 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class AccountAddRequest {
@ -60,9 +59,4 @@ 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,24 +5,27 @@ 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.*;
import com.nflg.mobilebroken.repository.service.*;
import lombok.extern.slf4j.Slf4j;
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 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.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 测试
*/
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController extends ControllerBase {
@ -36,18 +39,6 @@ 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字段数据
*/
@ -130,57 +121,4 @@ 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,7 +20,6 @@ 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;
@ -76,7 +75,7 @@ public class PlanController extends ControllerBase {
* 设置方案默认系数
*/
@PostMapping("/setDefaultRatio")
public ApiResult<Void> setDefaultRatio(@RequestParam @Min(1) BigDecimal ratio) {
public ApiResult<Void> setDefaultRatio(@RequestParam BigDecimal ratio) {
QuotationUserPlanDefault planDefault = planDefaultService.lambdaQuery()
.eq(QuotationUserPlanDefault::getCreateByType, AppUserUtil.isAgent() ? 1 : 0)
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())

View File

@ -28,7 +28,6 @@ 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;
@ -126,14 +125,8 @@ 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() {
@ -163,7 +156,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("未找到该机型");
@ -535,7 +528,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)
@ -561,7 +554,18 @@ public class ShoppingController extends ControllerBase {
.setCartId(cart.getId()))
.collect(Collectors.toList())
);
order.setNo(genOrderNo());
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");
}
}
shoppingOrderService.save(order);
shoppingCartService.lambdaUpdate()
.set(QuotationShoppingCart::getStatus, 1)
@ -571,32 +575,6 @@ 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);
}
/**
* 报价单-查询报价单
*/
@ -945,16 +923,14 @@ 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,8 +4,6 @@ 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;
@ -47,7 +45,6 @@ public class AdminBaseSerialNumber implements Serializable {
/**
* 乐观锁版本号
*/
@Version
private Integer version;
/**

View File

@ -144,11 +144,6 @@ 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,7 +8,6 @@ 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;
/**
@ -33,6 +32,4 @@ 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,6 +36,4 @@ public interface ITBaseCustomerService extends IService<TBaseCustomer> {
Collection<Integer> getAreaIds(List<Integer> companyIds);
List<TBaseCustomer> getForQuotation();
String getQuoteCode(List<Integer> companyIds);
}

View File

@ -1,6 +1,5 @@
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;
@ -17,6 +16,7 @@ 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,8 +59,6 @@ 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,8 +97,6 @@ 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())
@ -115,15 +113,11 @@ 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())
@ -138,13 +132,9 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
.setCategoryId(request.getCategoryId())
.setTitleId(request.getTitleId())
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
.setQuotationCode(quotationCode)
.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,7 +19,6 @@ 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;
@ -81,7 +80,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
private IDictionaryItemService dictionaryItemService;
@Resource
private RedisTemplate<String, Integer> redisTemplate;
private IAdminBaseSerialNumberService adminBaseSerialNumberService;
@Override
public String getAppUserQuotationCode(List<Integer> companyId) {
@ -106,7 +105,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
.filter(StrUtil::isNotBlank)
.collect(Collectors.toSet());
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(uniqueAreaCodes)).throwMessage("存在未维护区域信息的代理公司,请先维护区域信息");
String specialCode = "D";
String specialCode = "";
List<TBaseArea> areas = adminAreaService.lambdaQuery()
.in(TBaseArea::getAreaCode, uniqueAreaCodes)
.list();
@ -118,7 +117,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()
@ -131,7 +130,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()
@ -169,19 +168,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
specialCode += "-" + baseArea.getAreaQuoteCode();
}
}
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);
String code = adminBaseSerialNumberService.generateSerialNumber(1, "", specialCode, false, 6);
return code;
}
@ -542,8 +531,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,9 +10,7 @@ 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>
@ -53,17 +51,4 @@ 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,27 +149,4 @@ 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,7 +4,6 @@ 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;
@ -105,7 +104,6 @@ public class MysqlDataSourceConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}