Compare commits
8 Commits
a97e80f857
...
0d79babfac
| Author | SHA1 | Date |
|---|---|---|
|
|
0d79babfac | |
|
|
88f1e8779e | |
|
|
50901bf40e | |
|
|
dfa793fcff | |
|
|
35bd3b4767 | |
|
|
6acd9f8a52 | |
|
|
b8ca2a9905 | |
|
|
9cceef75bb |
|
|
@ -18,10 +18,7 @@ import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
import com.nflg.mobilebroken.repository.service.*;
|
||||||
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.annotation.MethodInfoMark;
|
||||||
import com.nflg.mobilebroken.starter.service.EmailService;
|
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -82,6 +79,9 @@ public class AdminUserController extends ControllerBase {
|
||||||
@Resource
|
@Resource
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAdminBaseSerialNumberService serialNumberService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
* @return 部门列表
|
* @return 部门列表
|
||||||
|
|
@ -161,11 +161,16 @@ public class AdminUserController extends ControllerBase {
|
||||||
.setGongFuHandler(request.isGongFuHandler())
|
.setGongFuHandler(request.isGongFuHandler())
|
||||||
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
|
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
|
||||||
.setCategoryId(request.getCategoryId())
|
.setCategoryId(request.getCategoryId())
|
||||||
|
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
|
||||||
.setUpdateBy(AdminUserUtil.getUserId())
|
.setUpdateBy(AdminUserUtil.getUserId())
|
||||||
.setUpdateTime(LocalDateTime.now());
|
.setUpdateTime(LocalDateTime.now());
|
||||||
if (!Objects.equals(user.getState(), UserState.ToBeActivated.getState()) && Objects.nonNull(request.getEnable())) {
|
if (!Objects.equals(user.getState(), UserState.ToBeActivated.getState()) && Objects.nonNull(request.getEnable())) {
|
||||||
user.setState(request.getEnable() ? UserState.Activated.getState() : UserState.Disabled.getState());
|
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);
|
adminUserService.updateById(user);
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ import com.nflg.mobilebroken.repository.service.IAppUserService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
|
import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
import com.nflg.mobilebroken.repository.service.ITBaseCustomerService;
|
||||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
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.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.ttzero.excel.entity.ListSheet;
|
import org.ttzero.excel.entity.ListSheet;
|
||||||
|
|
@ -40,6 +42,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -48,6 +51,7 @@ import java.util.stream.Collectors;
|
||||||
/**
|
/**
|
||||||
* 客户管理
|
* 客户管理
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/customer")
|
@RequestMapping("/customer")
|
||||||
public class CustomerController extends ControllerBase {
|
public class CustomerController extends ControllerBase {
|
||||||
|
|
@ -120,6 +124,7 @@ public class CustomerController extends ControllerBase {
|
||||||
* @param customerDTO
|
* @param customerDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@PostMapping("updateCompany")
|
@PostMapping("updateCompany")
|
||||||
@MethodInfoMark(value = "编辑", menuName = "客户管理")
|
@MethodInfoMark(value = "编辑", menuName = "客户管理")
|
||||||
@ApiMark(moduleName = "客户管理", apiName = "编辑")
|
@ApiMark(moduleName = "客户管理", apiName = "编辑")
|
||||||
|
|
@ -135,6 +140,23 @@ public class CustomerController extends ControllerBase {
|
||||||
//检查公司名称是否已存在
|
//检查公司名称是否已存在
|
||||||
TBaseCustomer oldEnt = baseCustomerService.getById(customerDTO.getId());
|
TBaseCustomer oldEnt = baseCustomerService.getById(customerDTO.getId());
|
||||||
VUtils.trueThrow(Objects.isNull(oldEnt)).throwMessage(STATE.PageError, customerDTO.getAgencyCompanyName() + "公司不存在");
|
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);
|
BeanUtil.copyProperties(customerDTO, oldEnt);
|
||||||
oldEnt.setAreaCode(StrUtil.join(",", customerDTO.getAreaList().stream().map(CustomerAreaDTO::getAreaCode).collect(Collectors.toList())));
|
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())));
|
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, "客户列表");
|
EecExcelUtil.setResponseExcelHeader(response, "客户列表");
|
||||||
final ListSheet<CustomerExcelVO> listSheet = new ListSheet<CustomerExcelVO>() {
|
final ListSheet<CustomerExcelVO> listSheet = new ListSheet<CustomerExcelVO>() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CustomerExcelVO> more() {
|
protected List<CustomerExcelVO> more() {
|
||||||
List<TBaseCustomer> list = baseCustomerService.list();
|
List<TBaseCustomer> list = baseCustomerService.list();
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ public class BaseAreaEditDTO {
|
||||||
@NotNull(message = "类别不能为空")
|
@NotNull(message = "类别不能为空")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域报价编码
|
||||||
|
*/
|
||||||
@NotBlank(message = "区域报价编码不能为空")
|
@NotBlank(message = "区域报价编码不能为空")
|
||||||
private String areaQuoteCode;
|
private String areaQuoteCode;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,8 @@ public class CustomerDTO {
|
||||||
private List<CustomerAreaDTO> areaList;
|
private List<CustomerAreaDTO> areaList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否报价对象
|
* 是否报价主体
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "是否报价对象不能为空")
|
@NotNull(message = "是否报价主体不能为空")
|
||||||
private Boolean quotationUse=false;
|
private Boolean quotationUse=false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class AccountAddRequest {
|
public class AccountAddRequest {
|
||||||
|
|
@ -59,4 +60,9 @@ public class AccountAddRequest {
|
||||||
* 直销类别(国内、国外),字典id
|
* 直销类别(国内、国外),字典id
|
||||||
*/
|
*/
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域id列表
|
||||||
|
*/
|
||||||
|
private List<Integer> areaIds;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class QuotationAdminSearchRequest extends PageRequest{
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象
|
* 报价主体
|
||||||
*/
|
*/
|
||||||
private Long targetId;
|
private Long targetId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ public class QuotationSearchVO {
|
||||||
private String quotationCode;
|
private String quotationCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象
|
* 报价主体
|
||||||
*/
|
*/
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象
|
* 报价主体
|
||||||
*/
|
*/
|
||||||
private String targetName;
|
private String targetName;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class ShoppingSearchVO {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||||
*/
|
*/
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,27 +5,24 @@ import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.ProductModel;
|
import com.nflg.mobilebroken.repository.entity.*;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseArea;
|
import com.nflg.mobilebroken.repository.service.*;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.sql.Struct;
|
import java.sql.Struct;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试
|
* 测试
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test")
|
@RequestMapping("/test")
|
||||||
public class TestController extends ControllerBase {
|
public class TestController extends ControllerBase {
|
||||||
|
|
@ -39,6 +36,18 @@ public class TestController extends ControllerBase {
|
||||||
@Resource
|
@Resource
|
||||||
ITBaseAreaService areaService;
|
ITBaseAreaService areaService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAdminUserService adminUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAdminBaseSerialNumberService serialNumberService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAppUserService appUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITBaseCustomerService customerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化机型表的BatchNumber字段数据
|
* 初始化机型表的BatchNumber字段数据
|
||||||
*/
|
*/
|
||||||
|
|
@ -121,4 +130,57 @@ public class TestController extends ControllerBase {
|
||||||
return ApiResult.success();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ public class DiscountConfigController extends ControllerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有报价对象
|
* 获取所有报价主体
|
||||||
*/
|
*/
|
||||||
@GetMapping("/applyFors")
|
@GetMapping("/applyFors")
|
||||||
public ApiResult<List<DiscountApplyForVO>> getApplyFors() {
|
public ApiResult<List<DiscountApplyForVO>> getApplyFors() {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class RatioConfigController extends ControllerBase {
|
||||||
private IAdminUserService adminUserService;
|
private IAdminUserService adminUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取报价对象
|
* 获取报价主体
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getTargetUsers")
|
@GetMapping("/getTargetUsers")
|
||||||
public ApiResult<TargetUserVO> getTargetUsers() {
|
public ApiResult<TargetUserVO> getTargetUsers() {
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class AppRatioAgentConfigController extends ControllerBase {
|
||||||
*/
|
*/
|
||||||
@PostMapping("config/search")
|
@PostMapping("config/search")
|
||||||
public ApiResult<PageData<Map<String, Object>>> search(@Valid @RequestBody ModelConfigSearchRequest request) {
|
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()
|
QuotationModelRatioAgent ratioAgent = ratioAgentService.lambdaQuery()
|
||||||
.eq(QuotationModelRatioAgent::getStatus, 1)
|
.eq(QuotationModelRatioAgent::getStatus, 1)
|
||||||
.eq(QuotationModelRatioAgent::getCreateByType, 1)
|
.eq(QuotationModelRatioAgent::getCreateByType, 1)
|
||||||
|
|
@ -109,7 +109,7 @@ public class AppRatioAgentConfigController extends ControllerBase {
|
||||||
.list();
|
.list();
|
||||||
AppUser cuser = appUserService.getById(AppUserUtil.getUserId());
|
AppUser cuser = appUserService.getById(AppUserUtil.getUserId());
|
||||||
DictionaryItem category = appUserService.getCategory(cuser);
|
DictionaryItem category = appUserService.getCategory(cuser);
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为你设置区域类型");
|
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为您开放权限");
|
||||||
List<AppUser> users = appUserService.getChildren(cuser);
|
List<AppUser> users = appUserService.getChildren(cuser);
|
||||||
List<ModelPriceVO> prices = priceService.getAllModelPrice();
|
List<ModelPriceVO> prices = priceService.getAllModelPrice();
|
||||||
PageData<Map<String, Object>> mdatas = new PageData<>();
|
PageData<Map<String, Object>> mdatas = new PageData<>();
|
||||||
|
|
@ -235,7 +235,7 @@ public class AppRatioAgentConfigController extends ControllerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取报价对象
|
* 获取报价主体
|
||||||
*/
|
*/
|
||||||
@GetMapping("list/getUsers")
|
@GetMapping("list/getUsers")
|
||||||
public ApiResult<List<SimpleUserVO>> getUsers() {
|
public ApiResult<List<SimpleUserVO>> getUsers() {
|
||||||
|
|
@ -247,10 +247,10 @@ public class AppRatioAgentConfigController extends ControllerBase {
|
||||||
*/
|
*/
|
||||||
@PostMapping("list/search")
|
@PostMapping("list/search")
|
||||||
public ApiResult<PageData<RatioConfigSearchVO>> search(@Valid @RequestBody ModelRatioUserSearchRequest request) {
|
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());
|
AppUser cuser = appUserService.getById(AppUserUtil.getUserId());
|
||||||
DictionaryItem category = appUserService.getCategory(cuser);
|
DictionaryItem category = appUserService.getCategory(cuser);
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为你设置区域类型");
|
VUtils.trueThrowBusinessError(Objects.isNull(category)).throwMessage("请联系管理员为您开放权限");
|
||||||
List<QuotationUserPlanModelItemDTO> plans = planModelItemService.getEffectivesForAgent();
|
List<QuotationUserPlanModelItemDTO> plans = planModelItemService.getEffectivesForAgent();
|
||||||
List<QuotationModelRatioAgentItemDTO> items = ratioAgentItemService.getEffectiveByCreate(AppUserUtil.getUserId());
|
List<QuotationModelRatioAgentItemDTO> items = ratioAgentItemService.getEffectiveByCreate(AppUserUtil.getUserId());
|
||||||
if (Objects.isNull(request.getUserId())) {
|
if (Objects.isNull(request.getUserId())) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
@ -75,7 +76,7 @@ public class PlanController extends ControllerBase {
|
||||||
* 设置方案默认系数
|
* 设置方案默认系数
|
||||||
*/
|
*/
|
||||||
@PostMapping("/setDefaultRatio")
|
@PostMapping("/setDefaultRatio")
|
||||||
public ApiResult<Void> setDefaultRatio(@RequestParam BigDecimal ratio) {
|
public ApiResult<Void> setDefaultRatio(@RequestParam @Min(1) BigDecimal ratio) {
|
||||||
QuotationUserPlanDefault planDefault = planDefaultService.lambdaQuery()
|
QuotationUserPlanDefault planDefault = planDefaultService.lambdaQuery()
|
||||||
.eq(QuotationUserPlanDefault::getCreateByType, AppUserUtil.isAgent() ? 1 : 0)
|
.eq(QuotationUserPlanDefault::getCreateByType, AppUserUtil.isAgent() ? 1 : 0)
|
||||||
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())
|
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import com.nflg.mobilebroken.repository.service.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
|
@ -125,8 +126,14 @@ public class ShoppingController extends ControllerBase {
|
||||||
@Resource
|
@Resource
|
||||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITBaseAreaService areaService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate<String, Integer> redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 购物车-获取报价对象
|
* 购物车-获取报价主体
|
||||||
*/
|
*/
|
||||||
@GetMapping("/cart/getTargets")
|
@GetMapping("/cart/getTargets")
|
||||||
public ApiResult<List<SimpleUserVO>> getTargets() {
|
public ApiResult<List<SimpleUserVO>> getTargets() {
|
||||||
|
|
@ -156,7 +163,7 @@ public class ShoppingController extends ControllerBase {
|
||||||
@PostMapping("/cart/init")
|
@PostMapping("/cart/init")
|
||||||
public ApiResult<ShoppingCartVO> init(@Valid @RequestBody ShoppingInitRequest request) {
|
public ApiResult<ShoppingCartVO> init(@Valid @RequestBody ShoppingInitRequest request) {
|
||||||
String qc = getQuotationCode();
|
String qc = getQuotationCode();
|
||||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(qc)).throwMessage("请联系管理员为你设置报价代码");
|
VUtils.trueThrowBusinessError(StrUtil.isBlank(qc)).throwMessage("请联系管理员为您开放权限");
|
||||||
Long categoryId = getCategoryId();
|
Long categoryId = getCategoryId();
|
||||||
ProductModel model = productModelService.lambdaQuery().eq(ProductModel::getState, 1).eq(ProductModel::getNo, request.getModelNo()).one();
|
ProductModel model = productModelService.lambdaQuery().eq(ProductModel::getState, 1).eq(ProductModel::getNo, request.getModelNo()).one();
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(model)).throwMessage("未找到该机型");
|
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)
|
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getCustomerName).collect(Collectors.toSet()).size() > 1)
|
||||||
.throwMessage("客户名称不一致");
|
.throwMessage("客户名称不一致");
|
||||||
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getTargetId).collect(Collectors.toSet()).size() > 1)
|
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)
|
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getCurrency).collect(Collectors.toSet()).size() > 1)
|
||||||
.throwMessage("币种不一致");
|
.throwMessage("币种不一致");
|
||||||
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getExchangeRate).collect(Collectors.toSet()).size() > 1)
|
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getExchangeRate).collect(Collectors.toSet()).size() > 1)
|
||||||
|
|
@ -554,18 +561,7 @@ public class ShoppingController extends ControllerBase {
|
||||||
.setCartId(cart.getId()))
|
.setCartId(cart.getId()))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
QuotationShoppingOrder last = CollectionUtil.get(shoppingOrderService.lambdaQuery().orderByDesc(QuotationShoppingOrder::getId).list(), 0);
|
order.setNo(genOrderNo());
|
||||||
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);
|
shoppingOrderService.save(order);
|
||||||
shoppingCartService.lambdaUpdate()
|
shoppingCartService.lambdaUpdate()
|
||||||
.set(QuotationShoppingCart::getStatus, 1)
|
.set(QuotationShoppingCart::getStatus, 1)
|
||||||
|
|
@ -575,6 +571,32 @@ public class ShoppingController extends ControllerBase {
|
||||||
return ApiResult.success(order.getId());
|
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) {
|
private ShoppingCartPartVO convert(ModelConfigEffectiveDTO dto, BigDecimal optionalRatio) {
|
||||||
ShoppingCartPartVO vo = Convert.convert(ShoppingCartPartVO.class, dto);
|
ShoppingCartPartVO vo = Convert.convert(ShoppingCartPartVO.class, dto);
|
||||||
vo.setAmount(NumberUtil.multiply(vo.getAmount(), optionalRatio));
|
if (vo.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
vo.setAmount(NumberUtil.multiply(vo.getAmount(), optionalRatio));
|
||||||
|
}
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getCategoryId() {
|
private Long getCategoryId() {
|
||||||
if (AppUserUtil.isAgent()) {
|
if (AppUserUtil.isAgent()) {
|
||||||
DictionaryItem di = appUserService.getCategory(appUserService.getById(AppUserUtil.getUserId()));
|
DictionaryItem di = appUserService.getCategory(appUserService.getById(AppUserUtil.getUserId()));
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(di)).throwMessage("请联系管理员设置区域类别");
|
VUtils.trueThrowBusinessError(Objects.isNull(di)).throwMessage("请联系管理员为您开放权限");
|
||||||
return di.getId();
|
return di.getId();
|
||||||
} else {
|
} else {
|
||||||
Long categoryId = adminUserService.getById(AppUserUtil.getUserId()).getCategoryId();
|
Long categoryId = adminUserService.getById(AppUserUtil.getUserId()).getCategoryId();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class QuotationCopyRequest {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象ID
|
* 报价主体ID
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class ShoppingInitRequest {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象ID
|
* 报价主体ID
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class ShoppingSaveRequest {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class QuotationOrderInfoVO {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象
|
* 报价主体
|
||||||
*/
|
*/
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class RatioConfigSearchVO {
|
||||||
private String modelNo;
|
private String modelNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象
|
* 报价主体
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class ShoppingCartVO {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||||
*/
|
*/
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.Version;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
@ -45,6 +47,7 @@ public class AdminBaseSerialNumber implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 乐观锁版本号
|
* 乐观锁版本号
|
||||||
*/
|
*/
|
||||||
|
@Version
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,11 @@ public class AdminUser implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String quotationCode;
|
private String quotationCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域id,多个用逗号分隔
|
||||||
|
*/
|
||||||
|
private String areaIds;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class QuotationShoppingCart implements Serializable {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||||
*/
|
*/
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class QuotationShoppingOrder implements Serializable {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价对象
|
* 报价主体
|
||||||
*/
|
*/
|
||||||
private Integer targetId;
|
private Integer targetId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ public class TBaseCustomer implements Serializable {
|
||||||
private Integer delIs;
|
private Integer delIs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否报价对象
|
* 是否报价主体
|
||||||
*/
|
*/
|
||||||
private Boolean quotationUse;
|
private Boolean quotationUse;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.nflg.mobilebroken.repository.entity.TBaseArea;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,4 +33,6 @@ public interface ITBaseAreaService extends IService<TBaseArea> {
|
||||||
void updateChildrenCategory(Integer id,Long categoryId);
|
void updateChildrenCategory(Integer id,Long categoryId);
|
||||||
|
|
||||||
void updateCustomerCategory(String areaCode, Long categoryId);
|
void updateCustomerCategory(String areaCode, Long categoryId);
|
||||||
|
|
||||||
|
String getQuoteCode(Collection<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,6 @@ public interface ITBaseCustomerService extends IService<TBaseCustomer> {
|
||||||
Collection<Integer> getAreaIds(List<Integer> companyIds);
|
Collection<Integer> getAreaIds(List<Integer> companyIds);
|
||||||
|
|
||||||
List<TBaseCustomer> getForQuotation();
|
List<TBaseCustomer> getForQuotation();
|
||||||
|
|
||||||
|
String getQuoteCode(List<Integer> companyIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
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.entity.AdminBaseSerialNumber;
|
||||||
import com.nflg.mobilebroken.repository.mapper.AdminBaseSerialNumberMapper;
|
import com.nflg.mobilebroken.repository.mapper.AdminBaseSerialNumberMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.IAdminBaseSerialNumberService;
|
import com.nflg.mobilebroken.repository.service.IAdminBaseSerialNumberService;
|
||||||
|
|
@ -14,9 +15,8 @@ import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* @author 代码生成器生成
|
* @author 代码生成器生成
|
||||||
* @since 2026
|
* @since 2026
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,7 +34,7 @@ public class AdminBaseSerialNumberServiceImpl extends ServiceImpl<AdminBaseSeria
|
||||||
public String generateSerialNumber(Integer businessType, String prefixNumber, String specialNumber,
|
public String generateSerialNumber(Integer businessType, String prefixNumber, String specialNumber,
|
||||||
boolean hasTimeStr, Integer serialLength) {
|
boolean hasTimeStr, Integer serialLength) {
|
||||||
String currentDate = "";
|
String currentDate = "";
|
||||||
String serialNo ;
|
String serialNo;
|
||||||
AdminBaseSerialNumber serialNumber = this.lambdaQuery()
|
AdminBaseSerialNumber serialNumber = this.lambdaQuery()
|
||||||
.eq(AdminBaseSerialNumber::getBusinessType, businessType)
|
.eq(AdminBaseSerialNumber::getBusinessType, businessType)
|
||||||
.one();
|
.one();
|
||||||
|
|
@ -59,6 +59,8 @@ public class AdminBaseSerialNumberServiceImpl extends ServiceImpl<AdminBaseSeria
|
||||||
if (serialNumber.getCurrentDateStr().equals(currentDate)) {
|
if (serialNumber.getCurrentDateStr().equals(currentDate)) {
|
||||||
startSerial = serialNumber.getMaxSerial() + 1;
|
startSerial = serialNumber.getMaxSerial() + 1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
startSerial = serialNumber.getMaxSerial() + 1;
|
||||||
}
|
}
|
||||||
serialNumber.setSerialLength(serialLength);
|
serialNumber.setSerialLength(serialLength);
|
||||||
serialNumber.setMaxSerial(startSerial);
|
serialNumber.setMaxSerial(startSerial);
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||||
.exists()
|
.exists()
|
||||||
)
|
)
|
||||||
.throwMessage("部门已存在负责人");
|
.throwMessage("部门已存在负责人");
|
||||||
|
VUtils.trueThrowBusinessError(Objects.nonNull(request.getCategoryId()) && CollectionUtil.isEmpty(request.getAreaIds()))
|
||||||
|
.throwMessage("直销人员需要选择区域");
|
||||||
AdminUser user = lambdaQuery().eq(AdminUser::getLoginName, request.getLoginName()).one();
|
AdminUser user = lambdaQuery().eq(AdminUser::getLoginName, request.getLoginName()).one();
|
||||||
if (Objects.nonNull(user)) {
|
if (Objects.nonNull(user)) {
|
||||||
VUtils.trueThrowBusinessError(!user.getIsDel())
|
VUtils.trueThrowBusinessError(!user.getIsDel())
|
||||||
|
|
@ -113,11 +115,15 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||||
.setGongFuHandler(request.isGongFuHandler())
|
.setGongFuHandler(request.isGongFuHandler())
|
||||||
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
|
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
|
||||||
.setCategoryId(request.getCategoryId())
|
.setCategoryId(request.getCategoryId())
|
||||||
|
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
|
||||||
.setUpdateBy(AdminUserUtil.getUserId())
|
.setUpdateBy(AdminUserUtil.getUserId())
|
||||||
.setUpdateTime(LocalDateTime.now());
|
.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);
|
updateById(user);
|
||||||
} else {
|
} else {
|
||||||
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
|
|
||||||
user = new AdminUser()
|
user = new AdminUser()
|
||||||
.setUserCode(request.getUserCode())
|
.setUserCode(request.getUserCode())
|
||||||
.setUserName(request.getUserName())
|
.setUserName(request.getUserName())
|
||||||
|
|
@ -132,9 +138,13 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||||
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
|
.setGongfu(StrUtil.contains(request.getProductLine(), Constant.MOBILE_BROKEN))
|
||||||
.setCategoryId(request.getCategoryId())
|
.setCategoryId(request.getCategoryId())
|
||||||
.setTitleId(request.getTitleId())
|
.setTitleId(request.getTitleId())
|
||||||
.setQuotationCode(quotationCode)
|
.setAreaIds(StrUtil.join(",", request.getAreaIds()))
|
||||||
.setCreateBy(AdminUserUtil.getUserId())
|
.setCreateBy(AdminUserUtil.getUserId())
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
|
if (Objects.nonNull(request.getCategoryId())) {
|
||||||
|
String quotationCode = serialNumberService.generateSerialNumber(0, "NF", "", false, 6);
|
||||||
|
user.setQuotationCode(quotationCode);
|
||||||
|
}
|
||||||
save(user);
|
save(user);
|
||||||
}
|
}
|
||||||
departmentService.lambdaUpdate()
|
departmentService.lambdaUpdate()
|
||||||
|
|
@ -186,8 +196,8 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<DictionaryItem> categories = CollectionUtil.isEmpty(categoryIds) ? Collections.emptyList() : dictionaryItemService.lambdaQuery()
|
List<DictionaryItem> categories = CollectionUtil.isEmpty(categoryIds) ? Collections.emptyList() : dictionaryItemService.lambdaQuery()
|
||||||
.in(DictionaryItem::getId, categoryIds)
|
.in(DictionaryItem::getId, categoryIds)
|
||||||
.list();
|
.list();
|
||||||
pageData.setItems(page.getRecords().stream().map(u -> {
|
pageData.setItems(page.getRecords().stream().map(u -> {
|
||||||
AdminUser userCreate = users.stream()
|
AdminUser userCreate = users.stream()
|
||||||
.filter(it -> Objects.equals(it.getId(), u.getCreateBy()))
|
.filter(it -> Objects.equals(it.getId(), u.getCreateBy()))
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.*;
|
import com.nflg.mobilebroken.repository.entity.*;
|
||||||
import com.nflg.mobilebroken.repository.mapper.AppUserMapper;
|
import com.nflg.mobilebroken.repository.mapper.AppUserMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.*;
|
import com.nflg.mobilebroken.repository.service.*;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
@ -80,7 +81,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
private IDictionaryItemService dictionaryItemService;
|
private IDictionaryItemService dictionaryItemService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IAdminBaseSerialNumberService adminBaseSerialNumberService;
|
private RedisTemplate<String, Integer> redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAppUserQuotationCode(List<Integer> companyId) {
|
public String getAppUserQuotationCode(List<Integer> companyId) {
|
||||||
|
|
@ -105,7 +106,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.filter(StrUtil::isNotBlank)
|
.filter(StrUtil::isNotBlank)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(uniqueAreaCodes)).throwMessage("存在未维护区域信息的代理公司,请先维护区域信息");
|
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(uniqueAreaCodes)).throwMessage("存在未维护区域信息的代理公司,请先维护区域信息");
|
||||||
String specialCode = "";
|
String specialCode = "D";
|
||||||
List<TBaseArea> areas = adminAreaService.lambdaQuery()
|
List<TBaseArea> areas = adminAreaService.lambdaQuery()
|
||||||
.in(TBaseArea::getAreaCode, uniqueAreaCodes)
|
.in(TBaseArea::getAreaCode, uniqueAreaCodes)
|
||||||
.list();
|
.list();
|
||||||
|
|
@ -117,7 +118,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
// 如果是只有一个公司或区域,就返回区域报价代码
|
// 如果是只有一个公司或区域,就返回区域报价代码
|
||||||
if (areas.size() == 1) {
|
if (areas.size() == 1) {
|
||||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(areas.get(0).getAreaQuoteCode())).throwMessage("区域报价代码没有维护,请先维护");
|
VUtils.trueThrowBusinessError(StrUtil.isBlank(areas.get(0).getAreaQuoteCode())).throwMessage("区域报价代码没有维护,请先维护");
|
||||||
specialCode = areas.get(0).getAreaQuoteCode();
|
specialCode += areas.get(0).getAreaQuoteCode();
|
||||||
}
|
}
|
||||||
// 如果存在多个公司或区域,需要查询上级
|
// 如果存在多个公司或区域,需要查询上级
|
||||||
Set<Integer> parentIds = areas.stream()
|
Set<Integer> parentIds = areas.stream()
|
||||||
|
|
@ -130,7 +131,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
// 如果只有一个上级,就返回上级报价代码
|
// 如果只有一个上级,就返回上级报价代码
|
||||||
if (parentAreas.size() == 1) {
|
if (parentAreas.size() == 1) {
|
||||||
VUtils.trueThrowBusinessError(StrUtil.isBlank(parentAreas.get(0).getAreaQuoteCode())).throwMessage("区域报价代码没有维护,请先维护");
|
VUtils.trueThrowBusinessError(StrUtil.isBlank(parentAreas.get(0).getAreaQuoteCode())).throwMessage("区域报价代码没有维护,请先维护");
|
||||||
specialCode = parentAreas.get(0).getAreaQuoteCode();
|
specialCode += parentAreas.get(0).getAreaQuoteCode();
|
||||||
} else {
|
} else {
|
||||||
// 多个上级,区别处理,合并相同上级的,单独列出一个上级的
|
// 多个上级,区别处理,合并相同上级的,单独列出一个上级的
|
||||||
Map<Integer, Long> parentCountMap = areas.stream()
|
Map<Integer, Long> parentCountMap = areas.stream()
|
||||||
|
|
@ -168,9 +169,19 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
specialCode += "-" + baseArea.getAreaQuoteCode();
|
specialCode += "-" + baseArea.getAreaQuoteCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
String key = "quotation:appUser:quotationCode:" + specialCode;
|
||||||
String code = adminBaseSerialNumberService.generateSerialNumber(1, "", specialCode, false, 6);
|
Integer index = redisTemplate.opsForValue().get(key);
|
||||||
return code;
|
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
|
@Override
|
||||||
public List<AppUser> getEndUsers() {
|
public List<AppUser> getEndUsers() {
|
||||||
return lambdaQuery()
|
return lambdaQuery()
|
||||||
.eq(AppUser::getIsDel,0)
|
.eq(AppUser::getIsDel, 0)
|
||||||
.eq(AppUser::getType,1)
|
.eq(AppUser::getType, 1)
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -51,4 +53,17 @@ public class TBaseAreaServiceImpl extends ServiceImpl<TBaseAreaMapper, TBaseArea
|
||||||
baseMapper.updateCustomerCategory(areaCode, categoryId);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,4 +149,27 @@ public class TBaseCustomerServiceImpl extends ServiceImpl<TBaseCustomerMapper, T
|
||||||
.eq(TBaseCustomer::getQuotationUse, true)
|
.eq(TBaseCustomer::getQuotationUse, true)
|
||||||
.list();
|
.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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.baomidou.mybatisplus.annotation.DbType;
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
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.plugins.inner.PaginationInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||||
import com.nflg.mobilebroken.starter.handler.UTCLocalDateTimeTypeHandler;
|
import com.nflg.mobilebroken.starter.handler.UTCLocalDateTimeTypeHandler;
|
||||||
|
|
@ -104,6 +105,7 @@ public class MysqlDataSourceConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
return interceptor;
|
return interceptor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue