feat(quotation): 实现机型折扣配置功能

- 新增折扣申请对象 VO 类用于存储折扣应用信息
- 在折扣配置控制器中添加获取机型价格接口和导出导入功能
- 更新动态表头显示折扣价标签为具体区域名称
- 重构保存方法使用 JsonNode 处理折扣数据并支持批量操作
- 添加对折扣对象数组的验证和处理逻辑
- 集成客户信息到折扣配置列表显示申请对象详情
- 实现 Excel 导入导出功能支持折扣数据批量处理
- 优化区域管理中的分类更新逻辑并添加事务支持
- 客户管理中增强区域类别一致性校验机制
This commit is contained in:
曹鹏飞 2026-03-13 15:59:11 +08:00
parent cfac015497
commit cb920721ef
24 changed files with 578 additions and 77 deletions

View File

@ -19,6 +19,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.TBaseArea;
import com.nflg.mobilebroken.repository.service.ITBaseAreaService;
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -48,7 +49,6 @@ public class BaseAreaController extends ControllerBase {
*/
@PostMapping("getList")
public ApiResult<PageData<TBaseAreaVO>> getList(@RequestBody BaseAreaQuery query) {
//
return adminBaseAreaService.getList(query);
}
@ -73,7 +73,6 @@ public class BaseAreaController extends ControllerBase {
@MethodInfoMark(value = "新增", menuName = "区域管理")
@ApiMark(moduleName = "区域管理", apiName = "新增")
public ApiResult<Boolean> add(@Valid @RequestBody BaseAreaEditDTO baseAreaEditDTO) {
List<TBaseArea> checkCode = baseAreaService.lambdaQuery().eq(TBaseArea::getAreaName, baseAreaEditDTO.getAreaName()).list();
VUtils.trueThrowBusinessError(CollUtil.isNotEmpty(checkCode)).throwMessage("区域名称已存在");
Integer count = baseAreaService.getCount() + 1;
@ -86,6 +85,7 @@ public class BaseAreaController extends ControllerBase {
// ent.setDataModifyUserName(AdminUserUtil.getUserName());
// ent.setDataModifyTime(LocalDateTime.now());
ent.setAreaCode(UniqueSequenceGenerator.generateCode(Constant.AreaCodePrefix));
ent.setCategoryId(baseAreaEditDTO.getCategoryId());
ent.setAreaQuoteCode(baseAreaEditDTO.getAreaQuoteCode());
baseAreaService.save(ent);
return ApiResult.success(true);
@ -96,6 +96,7 @@ public class BaseAreaController extends ControllerBase {
* @param baseAreaEditDTO
* @return
*/
@Transactional
@PostMapping("update")
@MethodInfoMark(value = "编辑", menuName = "区域管理")
@ApiMark(moduleName = "区域管理", apiName = "编辑")
@ -103,6 +104,12 @@ public class BaseAreaController extends ControllerBase {
VUtils.trueThrow(baseAreaEditDTO.getId() <= 0).throwMessage(STATE.ParamErr, "编辑时ID参数不能为空");
TBaseArea oldEnt = baseAreaService.getById(baseAreaEditDTO.getId());
VUtils.trueThrowBusinessError(Objects.isNull(oldEnt)).throwMessage("区域不存在");
if (!Objects.equals(oldEnt.getCategoryId(), baseAreaEditDTO.getCategoryId())){
//设置下级区域的区域类别
baseAreaService.updateChildrenCategory(oldEnt.getId(), baseAreaEditDTO.getCategoryId());
//设置公司区域类别
baseAreaService.updateCustomerCategory(oldEnt.getAreaCode(), baseAreaEditDTO.getCategoryId());
}
oldEnt.setParentAreaRowId(baseAreaEditDTO.getParentAreaRowId());
oldEnt.setAreaName(baseAreaEditDTO.getAreaName());
oldEnt.setDataModifyUserNo(AdminUserUtil.getUserNo());
@ -112,7 +119,6 @@ public class BaseAreaController extends ControllerBase {
oldEnt.setAreaQuoteCode(baseAreaEditDTO.getAreaQuoteCode());
baseAreaService.updateById(oldEnt);
return ApiResult.success(true);
}
/**

View File

@ -64,42 +64,40 @@ public class CustomerController extends ControllerBase {
@Resource
ITBaseAreaService areaService;
@PostMapping("getList")
@ApiMark(moduleName = "客户管理", apiName = "获取客户列表")
public ApiResult<PageData<TBaseCustomerListVO>> getList(@RequestBody CustomerQuery query){
Page<TBaseCustomer> result = baseCustomerService.getList(new Page<>(query.getPage(),query.getPageSize()), query);
List<TBaseCustomerListVO> resultData=Convert.toList(TBaseCustomerListVO.class, result.getRecords());
resultData.forEach(u->{
if(StrUtil.isNotBlank(u.getAreaCode())){
public ApiResult<PageData<TBaseCustomerListVO>> getList(@RequestBody CustomerQuery query) {
Page<TBaseCustomer> result = baseCustomerService.getList(new Page<>(query.getPage(), query.getPageSize()), query);
List<TBaseCustomerListVO> resultData = Convert.toList(TBaseCustomerListVO.class, result.getRecords());
resultData.forEach(u -> {
if (StrUtil.isNotBlank(u.getAreaCode())) {
List<TBaseArea> areaList = areaService.lambdaQuery().in(TBaseArea::getAreaCode, StrUtil.split(u.getAreaCode(), ",")).list();
u.setAreaList(Convert.toList(CustomerAreaDTO.class, areaList));
}
});
return ApiResult.success(resultData,query,result.getTotal());
return ApiResult.success(resultData, query, result.getTotal());
}
/**
* 新增
* @param customerDTO
* @return
*/
@PostMapping("add")
@MethodInfoMark(value = "新增" ,menuName = "客户管理")
@MethodInfoMark(value = "新增", menuName = "客户管理")
@ApiMark(moduleName = "客户管理", apiName = "新增")
public ApiResult<Boolean> add(@Valid @RequestBody CustomerDTO customerDTO) {
VUtils.trueThrow(CollUtil.isEmpty(customerDTO.getAreaList())).throwMessage(STATE.ParamErr,"公司区域不能为空");
Set<Long> categoryIds =areaService.lambdaQuery()
VUtils.trueThrow(CollUtil.isEmpty(customerDTO.getAreaList())).throwMessage(STATE.ParamErr, "公司区域不能为空");
Set<Long> categoryIds = areaService.lambdaQuery()
.in(TBaseArea::getId, customerDTO.getAreaList().stream().map(CustomerAreaDTO::getId).collect(Collectors.toList()))
.list()
.stream()
.map(TBaseArea::getCategoryId)
.collect(Collectors.toSet());
VUtils.trueThrowBusinessError(categoryIds.size()>1).throwMessage("区域类别不一致");
VUtils.trueThrowBusinessError(categoryIds.size() > 1).throwMessage("区域类别不一致");
//检查公司名称是否已存在
List<TBaseCustomer> existCompany = baseCustomerService.lambdaQuery().eq(TBaseCustomer::getAgencyCompanyName, customerDTO.getAgencyCompanyName()).list();
VUtils.trueThrow(CollUtil.isNotEmpty(existCompany)).throwMessage(STATE.PageError,customerDTO.getAgencyCompanyName()+"公司名称已存在");
VUtils.trueThrow(CollUtil.isNotEmpty(existCompany)).throwMessage(STATE.PageError, customerDTO.getAgencyCompanyName() + "公司名称已存在");
TBaseCustomer ent = Convert.convert(TBaseCustomer.class, customerDTO);
ent.setId(null);
ent.setAgencyCompanyCode(UniqueSequenceGenerator.generateCode(Constant.CustomerCodePrefix));
@ -123,23 +121,23 @@ public class CustomerController extends ControllerBase {
* @return
*/
@PostMapping("updateCompany")
@MethodInfoMark(value = "编辑" ,menuName = "客户管理")
@MethodInfoMark(value = "编辑", menuName = "客户管理")
@ApiMark(moduleName = "客户管理", apiName = "编辑")
public ApiResult<Boolean> updateCompany(@Valid @RequestBody CustomerDTO customerDTO) {
VUtils.trueThrow(CollUtil.isEmpty(customerDTO.getAreaList())).throwMessage(STATE.ParamErr,"公司区域不能为空");
Set<Long> categoryIds =areaService.lambdaQuery()
VUtils.trueThrow(CollUtil.isEmpty(customerDTO.getAreaList())).throwMessage(STATE.ParamErr, "公司区域不能为空");
Set<Long> categoryIds = areaService.lambdaQuery()
.in(TBaseArea::getId, customerDTO.getAreaList().stream().map(CustomerAreaDTO::getId).collect(Collectors.toList()))
.list()
.stream()
.map(TBaseArea::getCategoryId)
.collect(Collectors.toSet());
VUtils.trueThrowBusinessError(categoryIds.size()>1).throwMessage("区域类别不一致");
VUtils.trueThrowBusinessError(categoryIds.size() > 1).throwMessage("区域类别不一致");
//检查公司名称是否已存在
TBaseCustomer oldEnt = baseCustomerService.getById(customerDTO.getId());
VUtils.trueThrow(Objects.isNull(oldEnt)).throwMessage(STATE.PageError,customerDTO.getAgencyCompanyName()+"公司不存在");
BeanUtil.copyProperties(customerDTO,oldEnt);
oldEnt.setAreaCode(StrUtil.join(",", customerDTO.getAreaList().stream().map(u->u.getAreaCode()).collect(Collectors.toList())));
oldEnt.setAreaName(StrUtil.join(",", customerDTO.getAreaList().stream().map(u->u.getAreaName()).collect(Collectors.toList())));
VUtils.trueThrow(Objects.isNull(oldEnt)).throwMessage(STATE.PageError, customerDTO.getAgencyCompanyName() + "公司不存在");
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())));
oldEnt.setDataModifyUserNo(AdminUserUtil.getUserNo());
oldEnt.setDataModifyUserName(AdminUserUtil.getUserName());
oldEnt.setDataModifyTime(LocalDateTime.now());
@ -155,20 +153,18 @@ public class CustomerController extends ControllerBase {
* @return
*/
@PostMapping("del")
@MethodInfoMark(value = "删除" ,menuName = "客户管理")
@MethodInfoMark(value = "删除", menuName = "客户管理")
@ApiMark(moduleName = "客户管理", apiName = "删除")
public ApiResult<Boolean> del(@RequestBody List<Integer> ids){
VUtils.trueThrow(CollUtil.isEmpty(ids)).throwMessage(STATE.ParamErr,"请选择要删除的行");
//
List<AppUser> appUserUsed = appUserService.lambdaQuery().eq(AppUser::getIsDel,0).in(AppUser::getCompanyId, ids).list();
if(CollUtil.isNotEmpty(appUserUsed)){
Set<String> userCompanyIds = appUserUsed.stream().map(u -> u.getCompanyId()).collect(Collectors.toSet());
public ApiResult<Boolean> del(@RequestBody List<Integer> ids) {
VUtils.trueThrow(CollUtil.isEmpty(ids)).throwMessage(STATE.ParamErr, "请选择要删除的行");
List<AppUser> appUserUsed = appUserService.lambdaQuery().eq(AppUser::getIsDel, 0).in(AppUser::getCompanyId, ids).list();
if (CollUtil.isNotEmpty(appUserUsed)) {
Set<String> userCompanyIds = appUserUsed.stream().map(AppUser::getCompanyId).collect(Collectors.toSet());
List<TBaseCustomer> checkResult = baseCustomerService.lambdaQuery().in(TBaseCustomer::getId, userCompanyIds).list();
if(CollUtil.isNotEmpty(checkResult)){
Set<String> collect = checkResult.stream().map(u -> u.getAgencyCompanyName()).collect(Collectors.toSet());
if(CollUtil.isNotEmpty(collect)){
throw new NflgException(STATE.ParamErr, StrUtil.join(",", collect)+"已在代理商账号中使用,无法删除");
if (CollUtil.isNotEmpty(checkResult)) {
Set<String> collect = checkResult.stream().map(TBaseCustomer::getAgencyCompanyName).collect(Collectors.toSet());
if (CollUtil.isNotEmpty(collect)) {
throw new NflgException(STATE.ParamErr, StrUtil.join(",", collect) + "已在代理商账号中使用,无法删除");
}
}
}
@ -186,8 +182,7 @@ public class CustomerController extends ControllerBase {
@GetMapping("downTemplate")
@ApiMark(moduleName = "客户管理", apiName = "导入模板下载")
public void downTemplate(HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response,"客户导入模板");
EecExcelUtil.setResponseExcelHeader(response, "客户导入模板");
final ListSheet<ComstomerImportTemplate> listSheet = new ListSheet<ComstomerImportTemplate>() {
@Override
protected List<ComstomerImportTemplate> more() {
@ -205,16 +200,14 @@ public class CustomerController extends ControllerBase {
@GetMapping("exportData")
@ApiMark(moduleName = "客户管理", apiName = "导出")
public void exportData(HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response,"客户列表");
EecExcelUtil.setResponseExcelHeader(response, "客户列表");
final ListSheet<CustomerExcelVO> listSheet = new ListSheet<CustomerExcelVO>() {
int i=0;
int i = 0;
@Override
protected List<CustomerExcelVO> more() {
List<TBaseCustomer> list = baseCustomerService.list();
i++;
return i>1?null: Convert.toList(CustomerExcelVO.class, list);
return i > 1 ? null : Convert.toList(CustomerExcelVO.class, list);
}
};
EecExcelUtil.eecExcel("客户列表", listSheet, response);
@ -228,14 +221,13 @@ public class CustomerController extends ControllerBase {
*/
@PostMapping("importData")
@ApiMark(moduleName = "客户管理", apiName = "导入")
public ApiResult<Boolean> importData( @RequestParam(value = "file") MultipartFile file){
public ApiResult<Boolean> importData(@RequestParam(value = "file") MultipartFile file) {
try {
List<CustomerExcelVO> data = EecExcelUtil.getExcelContext(file.getInputStream(), CustomerExcelVO.class);
List<CustomerExcelVO> data = EecExcelUtil.getExcelContext(file.getInputStream(), CustomerExcelVO.class);
VUtils.trueThrowBusinessError(CollUtil.isEmpty(data)).throwMessage("导入文件内容为空");
adminCustomerService.importData(data);
} catch (IOException e) {
throw new NflgException(STATE.BusinessError, "导出失败:"+e.getMessage());
throw new NflgException(STATE.BusinessError, "导出失败:" + e.getMessage());
}
return ApiResult.success(true);
}
@ -247,8 +239,8 @@ public class CustomerController extends ControllerBase {
*/
@PostMapping("syncFromCrm")
@MethodInfoMark(value = "同步数据" ,menuName = "客户管理")
public ApiResult<Boolean> syncFromCrm(@RequestBody SyncFromCrmDTO param){
@MethodInfoMark(value = "同步数据", menuName = "客户管理")
public ApiResult<Boolean> syncFromCrm(@RequestBody SyncFromCrmDTO param) {
adminCustomerService.syncFromCrm(param);
return ApiResult.success(true);
}

View File

@ -2,11 +2,13 @@ package com.nflg.mobilebroken.common.pojo.request;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
@Data
@Accessors(chain = true)
public class ProductModelSearchRequest extends PageRequest{
/**

View File

@ -46,12 +46,12 @@ public class ModelDiscountConfigVO {
private List<ModelDiscountConfigAreaVO> areas;
/**
* 更新
* 创建
*/
private String updateBy;
private String createBy;
/**
* 更新时间
* 创建时间
*/
private LocalDateTime updateTime;
private LocalDateTime createTime;
}

View File

@ -5,25 +5,39 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nflg.mobilebroken.common.constant.Constant;
import com.nflg.mobilebroken.common.constant.PublishState;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.pojo.PageData;
import com.nflg.mobilebroken.common.pojo.request.ModelConfigSearchRequest;
import com.nflg.mobilebroken.common.pojo.request.ProductModelSearchRequest;
import com.nflg.mobilebroken.common.pojo.vo.DynamicHeaderVO;
import com.nflg.mobilebroken.common.pojo.vo.ModelDiscountConfigVO;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.DateTimeUtil;
import com.nflg.mobilebroken.common.util.NumberUtil;
import com.nflg.mobilebroken.common.pojo.vo.ProductModelSearchVO;
import com.nflg.mobilebroken.common.util.*;
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
import com.nflg.mobilebroken.quotation.pojo.dto.DiscountForbidImportAreaDTO;
import com.nflg.mobilebroken.quotation.pojo.dto.DiscountForbidImportDTO;
import com.nflg.mobilebroken.quotation.pojo.vo.DiscountApplyForVO;
import com.nflg.mobilebroken.repository.entity.*;
import com.nflg.mobilebroken.repository.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
@ -32,6 +46,7 @@ import java.util.stream.Collectors;
/**
* (管理端)机型折扣管理
*/
@Slf4j
@RestController
@RequestMapping("/discount/config")
public class DiscountConfigController extends ControllerBase {
@ -54,6 +69,37 @@ public class DiscountConfigController extends ControllerBase {
@Resource
private IQuotationModelPriceItemAreaService priceItemAreaService;
@Resource
private ITBaseCustomerService customerService;
@Resource
private IQuotationModelPriceService priceService;
@Resource
private IProductModelService productModelService;
/**
* 根据机型获取价格
*/
@GetMapping("/modelPrice")
public ApiResult<Map<String, Object>> getModelPrice(@RequestParam Long modelId) {
List<QuotationModelPriceItemArea> modelPrices = priceItemAreaService.getByModelId(modelId);
VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(modelPrices)).throwMessage("未找到价格信息");
Map<String, Object> map = new HashMap<>();
map.put("modelId", modelId);
List<DictionaryItem> areas = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DIRECT_SALES_CATEGORY);
areas.forEach(area -> {
QuotationModelPriceItemArea areaPrice = modelPrices.stream()
.filter(m -> Objects.equals(m.getAreaId(), area.getId()))
.findFirst()
.orElse(null);
if (Objects.nonNull(areaPrice)) {
map.put(area.getCode() + "_price", NumberUtil.format(areaPrice.getAmount()));
}
});
return ApiResult.success(map);
}
/**
* 获取动态表头
*/
@ -70,7 +116,7 @@ public class DiscountConfigController extends ControllerBase {
.setChildren(
List.of(new DynamicHeaderVO().setProp(area.getCode() + "_price").setLabel("标配保护价")
, new DynamicHeaderVO().setProp(area.getCode() + "_ratio").setLabel("折扣系数")
, new DynamicHeaderVO().setProp(area.getCode() + "_discount_price").setLabel("折扣系数")
, new DynamicHeaderVO().setProp(area.getCode() + "_discount_price").setLabel("折扣价(" + area.getName() + ")")
, new DynamicHeaderVO().setProp(area.getCode() + "_start").setLabel("折扣开始时间")
, new DynamicHeaderVO().setProp(area.getCode() + "_end").setLabel("折扣结束时间")
, new DynamicHeaderVO().setProp(area.getCode() + "_days").setLabel("折扣天数")
@ -101,6 +147,10 @@ public class DiscountConfigController extends ControllerBase {
List<QuotationModelDiscountArea> discountAreas = discountAreaService.lambdaQuery()
.in(QuotationModelDiscountArea::getDiscountId, pdata.getRecords().stream().map(ModelDiscountConfigVO::getId).collect(Collectors.toList()))
.list();
List<QuotationModelDiscountApply> applies = discountApplyService.lambdaQuery()
.eq(QuotationModelDiscountApply::getSourceType, 1)
.in(QuotationModelDiscountApply::getDiscountId, pdata.getRecords().stream().map(ModelDiscountConfigVO::getId).collect(Collectors.toList()))
.list();
return ApiResult.success(pdata, data -> {
Map<String, Object> map = objectMapper.convertValue(data, new TypeReference<>() {
});
@ -121,6 +171,26 @@ public class DiscountConfigController extends ControllerBase {
map.put(area.getCode() + "_end", DateTimeUtil.format(Optional.ofNullable(discountArea).map(QuotationModelDiscountArea::getDiscountEndDate).orElse(null), "yyyy-MM-dd"));
map.put(area.getCode() + "_days", Optional.ofNullable(discountArea).map(QuotationModelDiscountArea::getDays).orElse(null));
});
List<TBaseCustomer> customers = customerService.lambdaQuery()
.in(TBaseCustomer::getId, applies.stream()
.filter(apply -> apply.getDiscountId().equals(data.getId()))
.map(QuotationModelDiscountApply::getSourceId)
.collect(Collectors.toList())
)
.list();
map.put("applyFors", customers.stream()
.map(c -> new DiscountApplyForVO()
.setId(c.getId())
.setAgencyCompanyName(c.getAgencyCompanyName())
.setAreaName(
areas.stream()
.filter(area -> area.getId().equals(c.getCategoryId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse("未知")
)
).collect(Collectors.toList())
);
return map;
});
}
@ -130,13 +200,13 @@ public class DiscountConfigController extends ControllerBase {
*/
@Transactional
@PostMapping("/save")
public ApiResult<Void> save(@RequestBody @NotEmpty List<Map<String, String>> datas) {
List<Long> modelIds = datas.stream().map(data -> Long.parseLong(data.get("modelId"))).collect(Collectors.toList());
public ApiResult<Void> save(@RequestBody @NotEmpty List<JsonNode> datas) {
List<Long> modelIds = datas.stream().map(data -> data.get("modelId").asLong()).collect(Collectors.toList());
List<QuotationModelDiscount> discounts = new ArrayList<>();
List<QuotationModelDiscountArea> discountAreas = new ArrayList<>();
List<QuotationModelDiscountApply> discountApplies = new ArrayList<>();
datas.forEach(data -> {
Long modelId = Long.parseLong(data.get("modelId"));
Long modelId = data.get("modelId").asLong();
QuotationModelDiscount discount = new QuotationModelDiscount()
.setId(IdUtil.getSnowflakeNextId())
.setModelId(modelId)
@ -146,25 +216,27 @@ public class DiscountConfigController extends ControllerBase {
discounts.add(discount);
List<DictionaryItem> areas = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DIRECT_SALES_CATEGORY);
for (DictionaryItem area : areas) {
if (data.containsKey(area.getCode() + "_ratio")) {
if (data.has(area.getCode() + "_ratio")) {
QuotationModelDiscountArea discountArea = new QuotationModelDiscountArea()
.setDiscountId(discount.getId())
.setAreaId(area.getId())
.setRatio(new BigDecimal(data.get(area.getCode() + "_ratio")))
.setDiscountStartDate(DateTimeUtil.parse(data.get(area.getCode() + "_start"), "yyyy-MM-dd"))
.setDiscountEndDate(DateTimeUtil.parse(data.get(area.getCode() + "_end"), "yyyy-MM-dd"));
.setRatio(new BigDecimal(data.get(area.getCode() + "_ratio").asText()))
.setDiscountStartDate(DateTimeUtil.parse(data.get(area.getCode() + "_start").asText()).atStartOfDay())
.setDiscountEndDate(DateTimeUtil.parse(data.get(area.getCode() + "_end").asText()).atStartOfDay());
discountAreas.add(discountArea);
}
}
int[] userIds = StrUtil.splitToInt(data.get("apply"), ',');
for (Integer userId : userIds) {
discountApplies.add(new QuotationModelDiscountApply()
.setDiscountId(discount.getId())
.setSourceId(userId)
.setCreateById(AdminUserUtil.getUserId())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
if (data.has("applyFors")) {
VUtils.trueThrowBusinessError(!data.get("applyFors").isArray()).throwMessage("折扣对象类型不正确");
for (JsonNode apply : data.get("applyFors")) {
discountApplies.add(new QuotationModelDiscountApply()
.setDiscountId(discount.getId())
.setSourceId(apply.get("id").asInt())
.setCreateById(AdminUserUtil.getUserId())
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
}
}
});
discountService.lambdaUpdate()
@ -176,4 +248,259 @@ public class DiscountConfigController extends ControllerBase {
discountApplyService.saveBatch(discountApplies);
return ApiResult.success();
}
/**
* 导出
*/
@GetMapping("/export")
public void export(HttpServletResponse response, @Valid @RequestBody ModelConfigSearchRequest request) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "机型折扣配置");
Set<CellRangeAddress> cellRangeAddresses = new HashSet<>();
try (org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook()) {
Sheet sheet = workbook.createSheet("sheet1");
sheet.setVerticallyCenter(true);
sheet.setDefaultRowHeightInPoints(20);
CellStyle headerStyle = workbook.createCellStyle();
headerStyle.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
CellStyle dataStyle = workbook.createCellStyle();
dataStyle.setAlignment(HorizontalAlignment.LEFT);
dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataStyle.setBorderTop(BorderStyle.THIN);
dataStyle.setBorderBottom(BorderStyle.THIN);
dataStyle.setBorderLeft(BorderStyle.THIN);
dataStyle.setBorderRight(BorderStyle.THIN);
Font headerFont = workbook.createFont();
headerFont.setBold(true);
headerStyle.setFont(headerFont);
//填充表头
Row row0 = sheet.createRow(0);
Row row1 = sheet.createRow(1);
Cell cell0_0 = row0.createCell(0);
cell0_0.setCellValue("产品机型");
cell0_0.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 0, 0);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 0, 0));
Cell cell0_1 = row0.createCell(1);
cell0_1.setCellValue("所属平台");
cell0_1.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 1, 1);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 1, 1));
Cell cell0_2 = row0.createCell(2);
cell0_2.setCellValue("产品系列");
cell0_2.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 2, 2);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 2, 2));
Cell cell0_3 = row0.createCell(3);
cell0_3.setCellValue("产品类型");
cell0_3.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 3, 3);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 3, 3));
List<DictionaryItem> areas = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DIRECT_SALES_CATEGORY);
for (int i = 0; i < areas.size(); i++) {
DictionaryItem area = areas.get(i);
Cell cc = row0.createCell(4 + (i * 6));
cc.setCellValue(area.getName());
cc.setCellStyle(headerStyle);
createEmptyCell(row0, headerStyle, 4 + (i * 6) + 1, 4 + ((i + 1) * 6 - 1));
cellRangeAddresses.add(new CellRangeAddress(0, 0, 4 + (i * 6), 4 + ((i + 1) * 6 - 1)));
Cell cc1 = row1.createCell(4 + (i * 6));
cc1.setCellValue("标配保护价");
cc1.setCellStyle(headerStyle);
Cell cc2 = row1.createCell(4 + (i * 6) + 1);
cc2.setCellValue("折扣系数");
cc2.setCellStyle(headerStyle);
Cell cc3 = row1.createCell(4 + (i * 6) + 2);
cc3.setCellValue("折扣价(" + area.getName() + ")");
cc3.setCellStyle(headerStyle);
Cell cc4 = row1.createCell(4 + (i * 6) + 3);
cc4.setCellValue("折扣开始时间");
cc4.setCellStyle(headerStyle);
Cell cc5 = row1.createCell(4 + (i * 6) + 4);
cc5.setCellValue("折扣截止时间");
cc5.setCellStyle(headerStyle);
Cell cc6 = row1.createCell(4 + (i * 6) + 5);
cc6.setCellValue("折扣天数");
cc6.setCellStyle(headerStyle);
}
Cell cell6_4 = row0.createCell(6 * areas.size() + 4);
cell6_4.setCellValue("折扣对象");
cell6_4.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 6 * areas.size() + 4, 6 * areas.size() + 4);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 6 * areas.size() + 4, 6 * areas.size() + 4));
Cell cell6_5 = row0.createCell(6 * areas.size() + 5);
cell6_5.setCellValue("设置人");
cell6_5.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 6 * areas.size() + 5, 6 * areas.size() + 5);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 6 * areas.size() + 5, 6 * areas.size() + 5));
Cell cell6_6 = row0.createCell(6 * areas.size() + 6);
cell6_6.setCellValue("设置时间");
cell6_6.setCellStyle(headerStyle);
createEmptyCell(row1, headerStyle, 6 * areas.size() + 6, 6 * areas.size() + 6);
cellRangeAddresses.add(new CellRangeAddress(0, 1, 6 * areas.size() + 6, 6 * areas.size() + 6));
//填充数据
request.setPage(1);
request.setPageSize(Integer.MAX_VALUE);
IPage<ModelDiscountConfigVO> pdata = discountService.search(request);
if (pdata.getTotal() > 0) {
List<QuotationModelPriceItemArea> modelPrices = priceItemAreaService.lambdaQuery()
.eq(QuotationModelPriceItemArea::getPriceItemId, 0)
.in(QuotationModelPriceItemArea::getPriceId, pdata.getRecords().stream().map(ModelDiscountConfigVO::getPriceId).collect(Collectors.toList()))
.list();
List<QuotationModelDiscountArea> discountAreas = discountAreaService.lambdaQuery()
.in(QuotationModelDiscountArea::getDiscountId, pdata.getRecords().stream().map(ModelDiscountConfigVO::getId).collect(Collectors.toList()))
.list();
List<QuotationModelDiscountApply> applies = discountApplyService.lambdaQuery()
.eq(QuotationModelDiscountApply::getSourceType, 1)
.in(QuotationModelDiscountApply::getDiscountId, pdata.getRecords().stream().map(ModelDiscountConfigVO::getId).collect(Collectors.toList()))
.list();
pdata.getRecords().forEach(data -> {
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
Cell cell0 = row.createCell(0);
cell0.setCellValue(data.getModelNo());
cell0.setCellStyle(dataStyle);
Cell cell1 = row.createCell(1);
cell1.setCellValue(data.getSeriesName());
cell1.setCellStyle(dataStyle);
Cell cell2 = row.createCell(2);
cell2.setCellValue(data.getTypeName());
cell2.setCellStyle(dataStyle);
for (int i = 0; i < areas.size(); i++) {
DictionaryItem area = areas.get(i);
QuotationModelPriceItemArea modelPrice = modelPrices.stream()
.filter(price -> price.getAreaId().equals(area.getId()))
.findFirst()
.get();
Cell cc = row.createCell(4 + (i * 6));
cc.setCellValue(NumberUtil.format(modelPrice.getAmount()));
cc.setCellStyle(dataStyle);
QuotationModelDiscountArea discountArea = discountAreas.stream()
.filter(price -> price.getAreaId().equals(area.getId()))
.findFirst()
.orElse(null);
BigDecimal ratio = Optional.ofNullable(discountArea).map(QuotationModelDiscountArea::getRatio).orElse(BigDecimal.ONE);
Cell cc2 = row.createCell(4 + (i * 6) + 1);
cc2.setCellValue(NumberUtil.format(ratio));
cc2.setCellStyle(dataStyle);
Cell cc3 = row.createCell(4 + (i * 6) + 2);
cc3.setCellValue(NumberUtil.format(ratio.multiply(modelPrice.getAmount())));
cc3.setCellStyle(dataStyle);
Cell cc4 = row.createCell(4 + (i * 6) + 3);
cc4.setCellValue(DateTimeUtil.format(Optional.ofNullable(discountArea).map(QuotationModelDiscountArea::getDiscountStartDate).orElse(null), "yyyy-MM-dd"));
cc4.setCellStyle(dataStyle);
Cell cc5 = row.createCell(4 + (i * 6) + 4);
cc5.setCellValue(DateTimeUtil.format(Optional.ofNullable(discountArea).map(QuotationModelDiscountArea::getDiscountEndDate).orElse(null), "yyyy-MM-dd"));
cc5.setCellStyle(dataStyle);
Cell cc6 = row.createCell(4 + (i * 6) + 5);
cc6.setCellValue(Optional.ofNullable(discountArea).map(QuotationModelDiscountArea::getDays).orElse(null));
cc6.setCellStyle(dataStyle);
}
//折扣对象
List<String> customers = customerService.lambdaQuery()
.select(TBaseCustomer::getAgencyCompanyName)
.in(TBaseCustomer::getId, applies.stream().map(QuotationModelDiscountApply::getSourceId).collect(Collectors.toList()))
.list()
.stream()
.map(TBaseCustomer::getAgencyCompanyName)
.collect(Collectors.toList());
Cell cell4 = row.createCell(6 * areas.size() + 4);
cell4.setCellValue(StrUtil.join(",", customers));
cell4.setCellStyle(dataStyle);
Cell cell5 = row.createCell(6 * areas.size() + 5);
cell5.setCellValue(data.getCreateBy());
cell5.setCellStyle(dataStyle);
Cell cell6 = row.createCell(6 * areas.size() + 6);
cell6.setCellValue(DateTimeUtil.format(data.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
cell6.setCellStyle(dataStyle);
});
}
//设置自动列宽
for (int i = 0; i < sheet.getRow(0).getLastCellNum(); i++) {
sheet.autoSizeColumn(i, true);
sheet.setColumnWidth(i, sheet.getColumnWidth(i) + 5 * 256);
}
cellRangeAddresses.forEach(sheet::addMergedRegion);
workbook.write(response.getOutputStream());
}
}
/**
* 导入
*/
@Transactional
@PostMapping("/import")
public ApiResult<Void> importFromExcel(@Valid @RequestParam(value = "file") @NotNull MultipartFile file) throws IOException {
DataFormatter dataFormatter = new DataFormatter();
List<DiscountForbidImportDTO> datas = new ArrayList<>();
try (InputStream inputStream = file.getInputStream(); org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(inputStream)) {
Sheet sheet = workbook.getSheetAt(0);
List<DictionaryItem> areas = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DIRECT_SALES_CATEGORY);
//处理表头
int areaCount = 0;
String cname = dataFormatter.formatCellValue(sheet.getRow(0).getCell(4));
while (StrUtil.isNotBlank(cname)) {
final String currentCname = cname;
if (areas.stream().anyMatch(area -> StrUtil.equals(area.getName(), currentCname))) {
areaCount++;
cname = dataFormatter.formatCellValue(sheet.getRow(0).getCell(4 + areaCount * 6));
} else {
break;
}
}
for (int index = 2, count = sheet.getLastRowNum(); index <= count; index++) {
log.info("处理第{}行", index);
Row row = sheet.getRow(index);
String modelNo = dataFormatter.formatCellValue(row.getCell(0));
VUtils.trueThrowBusinessError(StrUtil.isBlank(modelNo)).throwMessage("机型不能为空");
ProductModelSearchVO modelVO = CollectionUtil.get(productModelService.getList(new ProductModelSearchRequest()
.setNo(modelNo)
.setState(PublishState.Published.getState())
.setEnable(true)
).getRecords(), 0
);
VUtils.trueThrowBusinessError(Objects.isNull(modelVO)).throwMessage("机型" + modelNo + "不存在");
VUtils.trueThrowBusinessError(!priceService.lambdaQuery()
.eq(QuotationModelPrice::getModelId, modelVO.getBatchNumber())
.eq(QuotationModelPrice::getPriceStatus, 1)
.exists()
).throwMessage("机型" + modelNo + "未设置价格");
DiscountForbidImportDTO dto = new DiscountForbidImportDTO()
.setModelId(modelVO.getBatchNumber())
.setModelNo(modelNo)
.setSeriesName(modelVO.getSeriesName())
.setTypeName(modelVO.getTypeName());
for (int i = 1; i <= areaCount; i++) {
int colIndex = 4 + i * 6;
String areaName = row.getCell(colIndex).getStringCellValue();
DictionaryItem area=areas.stream()
.filter(di -> StrUtil.equals(di.getName(), areaName))
.findFirst()
.get();
String startDate=dataFormatter.formatCellValue(row.getCell(colIndex + 3));
// VUtils.trueThrowBusinessError(StrUtil.isNotBlank(startDate) && !DateUtil.(startDate))
// .throwMessage("折扣开始时间不能为空");
// DiscountForbidImportAreaDTO areaDTO=new DiscountForbidImportAreaDTO()
// .setAreaId(area.getId())
// .setRatio(new BigDecimal(dataFormatter.formatCellValue(row.getCell(colIndex + 1))))
// .setDiscountStartDate();
}
datas.add(dto);
}
}
return ApiResult.success();
}
private void createEmptyCell(Row row, CellStyle style, int colStart, int colEnd) {
for (int colIndex = colStart; colIndex <= colEnd; colIndex++) {
Cell cell = row.createCell(colIndex);
cell.setCellStyle(style);
cell.setCellValue("");
}
}
}

View File

@ -222,6 +222,7 @@ public class RatioDirectConfigController extends ControllerBase {
if (CollectionUtil.isEmpty(users)) {
return ApiResult.success(new DynamicTableVO());
}
boolean isMarketingDirector = AdminUserUtil.getRoles().contains(Constant.ROLE_CODE_MARKETING_DIRECTOR);
List<DictionaryItem> categories = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DIRECT_SALES_CATEGORY);
List<TBaseDepartment> departments = departmentService.list();
List<RatioDirectEffectiveDTO> ratioDirects = ratioDirectService.getEffectives();
@ -251,6 +252,31 @@ public class RatioDirectConfigController extends ControllerBase {
)
)
);
if (isMarketingDirector) {
add(new DynamicHeaderVO()
.setProp(user.getId() + "-standardRatio")
.setLabel("标配系数")
);
add(new DynamicHeaderVO()
.setProp(user.getId() + "-optionalRatio")
.setLabel("选配系数")
);
} else {
add(new DynamicHeaderVO()
.setProp(user.getId() + "-standardRatio")
.setLabel("销售定价系数")
);
}
add(new DynamicHeaderVO()
.setProp(user.getId() + "-salePrice")
.setLabel("市场价" + getCategoryName(
categories.stream()
.filter(c -> c.getId().equals(user.getCategoryId()))
.findFirst()
.orElse(null)
)
)
);
}
}
)
@ -263,6 +289,11 @@ public class RatioDirectConfigController extends ControllerBase {
Map<String, Object> data = new HashMap<>();
users.forEach(user -> {
data.put(user.getId() + "-standardPrice", getUserStandardPrice(model.getBatchNumber(), user, users, ratioDirects, prices, userPrices));
data.put(user.getId() + "-standardRatio", null);
if (isMarketingDirector) {
data.put(user.getId() + "-optionalRatio", null);
}
data.put(user.getId() + "-salePrice", null);
});
vo.getDatas().add(data);
});

View File

@ -103,6 +103,9 @@ public class ShoppingController extends ControllerBase {
@Resource
private ITBaseCustomerService customerService;
@Resource
private IQuotationModelForbidService forbidService;
/**
* 购物车-获取报价对象
*/
@ -133,6 +136,8 @@ public class ShoppingController extends ControllerBase {
@PostMapping("/cart/init")
public ApiResult<ShoppingCartVO> init(@Valid @RequestBody ShoppingInitRequest request) {
Long categoryId = getCategoryId();
VUtils.trueThrowBusinessError(forbidService.isForbid(request.getModelId(), 1,request.getTargetId()))
.throwMessage("该机型已禁售");
ModelPrice1VO modelPrice = priceService.getModelPrice(request.getModelId(), categoryId);
VUtils.trueThrowBusinessError(Objects.isNull(modelPrice)).throwMessage("该机型尚未设置价格");
ShoppingCartVO vo = new ShoppingCartVO()

View File

@ -0,0 +1,26 @@
package com.nflg.mobilebroken.quotation.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@Accessors(chain = true)
public class DiscountForbidImportAreaDTO {
private Long areaId;
private BigDecimal ratio;
/**
* 折扣开始时间
*/
private LocalDateTime discountStartDate;
/**
* 折扣结束时间
*/
private LocalDateTime discountEndDate;
}

View File

@ -0,0 +1,34 @@
package com.nflg.mobilebroken.quotation.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
@Data
@Accessors(chain = true)
public class DiscountForbidImportDTO {
/**
* 机型表batch_number
*/
private Long modelId;
/**
* 系列名称
*/
private String seriesName;
/**
* 类型名称
*/
private String typeName;
/**
* 机型编号
*/
private String modelNo;
private List<DiscountForbidImportAreaDTO> areas=new ArrayList<>();
}

View File

@ -0,0 +1,15 @@
package com.nflg.mobilebroken.quotation.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class DiscountApplyForVO {
private Integer id;
private String agencyCompanyName;
private String areaName;
}

View File

@ -56,9 +56,9 @@ public class QuotationModelDiscountArea implements Serializable {
private LocalDateTime discountEndDate;
@TableField(exist = false)
private Long days;
private String days;
public Long getDays() {
return ChronoUnit.DAYS.between(discountStartDate, discountEndDate) + 1;
public String getDays() {
return String.valueOf(ChronoUnit.DAYS.between(discountStartDate, discountEndDate) + 1);
}
}

View File

@ -18,4 +18,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface QuotationModelForbidMapper extends BaseMapper<QuotationModelForbid> {
IPage<ProductModelSimpleVO> search(ModelConfigSearchRequest request, Page<?> page);
boolean isForbid(Long modelId, Integer type,Integer targetId);
}

View File

@ -3,6 +3,8 @@ package com.nflg.mobilebroken.repository.mapper;
import com.nflg.mobilebroken.repository.entity.QuotationModelPriceItemArea;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* 报价-机型价格-子项区域价格 Mapper 接口
@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface QuotationModelPriceItemAreaMapper extends BaseMapper<QuotationModelPriceItemArea> {
List<QuotationModelPriceItemArea> getByModelId(Long modelId);
}

View File

@ -26,4 +26,8 @@ public interface TBaseAreaMapper extends BaseMapper<TBaseArea> {
void upState(@Param("areaState") Integer areaState , @Param("ids")List<Integer> ids ,@Param("userNo")String userNo , @Param("userName")String userName);
Integer getCount();
void updateChildrenCategory(Integer id, Long categoryId);
void updateCustomerCategory(String areaCode, Long categoryId);
}

View File

@ -7,6 +7,7 @@ import com.nflg.mobilebroken.repository.entity.QuotationModelForbid;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
/**
* <p>
@ -19,4 +20,6 @@ import javax.validation.Valid;
public interface IQuotationModelForbidService extends IService<QuotationModelForbid> {
IPage<ProductModelSimpleVO> search(ModelConfigSearchRequest request);
boolean isForbid(Long modelId, Integer type,Integer targetId);
}

View File

@ -3,6 +3,8 @@ package com.nflg.mobilebroken.repository.service;
import com.nflg.mobilebroken.repository.entity.QuotationModelPriceItemArea;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 报价-机型价格-子项区域价格 服务类
@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IQuotationModelPriceItemAreaService extends IService<QuotationModelPriceItemArea> {
List<QuotationModelPriceItemArea> getByModelId(Long modelId);
}

View File

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

View File

@ -25,4 +25,9 @@ public class QuotationModelForbidServiceImpl extends ServiceImpl<QuotationModelF
public IPage<ProductModelSimpleVO> search(ModelConfigSearchRequest request) {
return baseMapper.search(request,new Page<>(request.getPage(), request.getPageSize()));
}
@Override
public boolean isForbid(Long modelId, Integer type,Integer targetId) {
return baseMapper.isForbid(modelId, type,targetId);
}
}

View File

@ -6,6 +6,8 @@ import com.nflg.mobilebroken.repository.service.IQuotationModelPriceItemAreaServ
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 报价-机型价格-子项区域价格 服务实现类
@ -17,4 +19,8 @@ import org.springframework.stereotype.Service;
@Service
public class QuotationModelPriceItemAreaServiceImpl extends ServiceImpl<QuotationModelPriceItemAreaMapper, QuotationModelPriceItemArea> implements IQuotationModelPriceItemAreaService {
@Override
public List<QuotationModelPriceItemArea> getByModelId(Long modelId) {
return baseMapper.getByModelId(modelId);
}
}

View File

@ -41,4 +41,14 @@ public class TBaseAreaServiceImpl extends ServiceImpl<TBaseAreaMapper, TBaseArea
return this.getBaseMapper().getCount();
}
@Override
public void updateChildrenCategory(Integer id, Long categoryId) {
baseMapper.updateChildrenCategory(id, categoryId);
}
@Override
public void updateCustomerCategory(String areaCode, Long categoryId) {
baseMapper.updateCustomerCategory(areaCode, categoryId);
}
}

View File

@ -3,7 +3,7 @@
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelDiscountMapper">
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ModelDiscountConfigVO">
SELECT qmd.model_id,qmp.id as 'priceId',ps.name as 'seriesName',pt.name as 'typeName',pm.`no` as 'modelNo',qmp.update_by,qmp.update_time
SELECT qmd.id,qmd.model_id,qmp.id as 'priceId',ps.name as 'seriesName',pt.name as 'typeName',pm.`no` as 'modelNo',qmp.create_by,qmp.create_time
FROM quotation_model_discount qmd
INNER JOIN quotation_model_price qmp ON qmp.model_id=qmd.model_id and qmp.price_status=1
INNER JOIN product_model pm ON qmd.model_id=pm.batch_number

View File

@ -23,4 +23,10 @@
</if>
order by pm.id
</select>
<select id="isForbid" resultType="boolean">
select is_forbid
from quotation_model_forbid
where model_id=#{modelId} and source_type=#{type} and source_id=#{targetId}
</select>
</mapper>

View File

@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelPriceItemAreaMapper">
<select id="getByModelId" resultType="com.nflg.mobilebroken.repository.entity.QuotationModelPriceItemArea">
select qmpa.*
from quotation_model_price qmp
inner join quotation_model_price_item_area qmpa on qmp.id=qmpa.price_id and qmpa.price_item_id=0
where qmp.price_status=1 and qmp.model_id=#{modelId}
</select>
</mapper>

View File

@ -43,4 +43,14 @@
<select id="getCount" resultType="java.lang.Integer">
select count(1) from t_base_area
</select>
<update id="updateChildrenCategory">
UPDATE t_base_area SET category_id=#{categoryId} WHERE FIND_IN_SET(id, get_area_child_ids(#{id}));
</update>
<update id="updateCustomerCategory">
UPDATE t_base_customer
SET category_id=#{categoryId}
WHERE FIND_IN_SET(#{areaCode},area_code);
</update>
</mapper>