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.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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ public class BaseAreaEditDTO {
|
|||
@NotNull(message = "类别不能为空")
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 区域报价编码
|
||||
*/
|
||||
@NotBlank(message = "区域报价编码不能为空")
|
||||
private String areaQuoteCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ public class CustomerDTO {
|
|||
private List<CustomerAreaDTO> areaList;
|
||||
|
||||
/**
|
||||
* 是否报价对象
|
||||
* 是否报价主体
|
||||
*/
|
||||
@NotNull(message = "是否报价对象不能为空")
|
||||
@NotNull(message = "是否报价主体不能为空")
|
||||
private Boolean quotationUse=false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class QuotationAdminSearchRequest extends PageRequest{
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象
|
||||
* 报价主体
|
||||
*/
|
||||
private Long targetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ public class QuotationSearchVO {
|
|||
private String quotationCode;
|
||||
|
||||
/**
|
||||
* 报价对象
|
||||
* 报价主体
|
||||
*/
|
||||
private Integer targetId;
|
||||
|
||||
/**
|
||||
* 报价对象
|
||||
* 报价主体
|
||||
*/
|
||||
private String targetName;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class ShoppingSearchVO {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
||||
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||
*/
|
||||
private Integer targetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class DiscountConfigController extends ControllerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取所有报价对象
|
||||
* 获取所有报价主体
|
||||
*/
|
||||
@GetMapping("/applyFors")
|
||||
public ApiResult<List<DiscountApplyForVO>> getApplyFors() {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class RatioConfigController extends ControllerBase {
|
|||
private IAdminUserService adminUserService;
|
||||
|
||||
/**
|
||||
* 获取报价对象
|
||||
* 获取报价主体
|
||||
*/
|
||||
@GetMapping("/getTargetUsers")
|
||||
public ApiResult<TargetUserVO> getTargetUsers() {
|
||||
|
|
|
|||
|
|
@ -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())) {
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class QuotationCopyRequest {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象ID
|
||||
* 报价主体ID
|
||||
*/
|
||||
@NotNull
|
||||
private Integer targetId;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class ShoppingInitRequest {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象ID
|
||||
* 报价主体ID
|
||||
*/
|
||||
@NotNull
|
||||
private Integer targetId;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class ShoppingSaveRequest {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
||||
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||
*/
|
||||
@NotNull
|
||||
private Integer targetId;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class QuotationOrderInfoVO {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象
|
||||
* 报价主体
|
||||
*/
|
||||
private Integer targetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class RatioConfigSearchVO {
|
|||
private String modelNo;
|
||||
|
||||
/**
|
||||
* 报价对象
|
||||
* 报价主体
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class ShoppingCartVO {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
||||
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||
*/
|
||||
private Integer targetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -144,6 +144,11 @@ public class AdminUser implements Serializable {
|
|||
*/
|
||||
private String quotationCode;
|
||||
|
||||
/**
|
||||
* 区域id,多个用逗号分隔
|
||||
*/
|
||||
private String areaIds;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class QuotationShoppingCart implements Serializable {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象,代理商时为公司id,内部用户时为其用户id
|
||||
* 报价主体,代理商时为公司id,内部用户时为其用户id
|
||||
*/
|
||||
private Integer targetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class QuotationShoppingOrder implements Serializable {
|
|||
private String customerName;
|
||||
|
||||
/**
|
||||
* 报价对象
|
||||
* 报价主体
|
||||
*/
|
||||
private Integer targetId;
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class TBaseCustomer implements Serializable {
|
|||
private Integer delIs;
|
||||
|
||||
/**
|
||||
* 是否报价对象
|
||||
* 是否报价主体
|
||||
*/
|
||||
private Boolean quotationUse;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,6 @@ public interface ITBaseCustomerService extends IService<TBaseCustomer> {
|
|||
Collection<Integer> getAreaIds(List<Integer> companyIds);
|
||||
|
||||
List<TBaseCustomer> getForQuotation();
|
||||
|
||||
String getQuoteCode(List<Integer> companyIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue