feat(quotation): 完善价格配置和比例配置功能
- 在ModelPriceConfigVO中启用id字段用于数据标识 - 优化PriceConfigController中的条件查询逻辑,改进代码可读性 - 添加价格状态更新逻辑,当配置生效时自动更新相关价格记录状态 - 更新QuotationModelPriceMapper.xml查询语句,增加价格记录id返回 - 修改QuotationModelRatioAgentMapper.xml数据源,关联价格视图进行查询 - 重构RatioConfigController中代理商和直销比例配置的数据过滤逻辑 - 在RatioDirectConfigController中引入ProductModelSimpleVO简化数据传输 - 优化比例配置的数据检索方式,提升查询性能和准确性
This commit is contained in:
parent
24185b09e5
commit
e12dd45cd4
|
|
@ -13,7 +13,7 @@ import java.util.Objects;
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class ModelPriceConfigVO {
|
public class ModelPriceConfigVO {
|
||||||
|
|
||||||
// private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机型表batch_number
|
* 机型表batch_number
|
||||||
|
|
|
||||||
|
|
@ -429,6 +429,11 @@ public class PriceConfigController extends ControllerBase {
|
||||||
.eq(QuotationModelConfig::getConfigStatus, 1)
|
.eq(QuotationModelConfig::getConfigStatus, 1)
|
||||||
.one();
|
.one();
|
||||||
if (Objects.nonNull(config)) {
|
if (Objects.nonNull(config)) {
|
||||||
|
priceService.lambdaUpdate()
|
||||||
|
.set(QuotationModelPrice::getPriceStatus, 2)
|
||||||
|
.eq(QuotationModelPrice::getModelId, price.getModelId())
|
||||||
|
.eq(QuotationModelPrice::getPriceStatus, 1)
|
||||||
|
.update();
|
||||||
price.setPriceStatus(1);
|
price.setPriceStatus(1);
|
||||||
price.setConfigId(config.getId());
|
price.setConfigId(config.getId());
|
||||||
price.setPriceVersion("MP" + DateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmm"));
|
price.setPriceVersion("MP" + DateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmm"));
|
||||||
|
|
|
||||||
|
|
@ -118,15 +118,22 @@ public class RatioConfigController extends ControllerBase {
|
||||||
.eq(TBaseCustomer::getDelIs, 0)
|
.eq(TBaseCustomer::getDelIs, 0)
|
||||||
.eq(TBaseCustomer::getEnableState, 1)
|
.eq(TBaseCustomer::getEnableState, 1)
|
||||||
.list();
|
.list();
|
||||||
|
List<QuotationModelRatioAgentItemDTO> agentItems = isMarketingDirector ? ratioAgentItemService.getEffectives() : null;
|
||||||
|
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
||||||
pdatas.getRecords().forEach(data -> {
|
pdatas.getRecords().forEach(data -> {
|
||||||
RatioConfigSearchVO vo = new RatioConfigSearchVO().setModelNo(data.getModelNo());
|
RatioConfigSearchVO vo = new RatioConfigSearchVO().setModelNo(data.getModelNo());
|
||||||
vos.add(vo);
|
vos.add(vo);
|
||||||
if (isMarketingDirector) {
|
if (isMarketingDirector) {
|
||||||
RatioConfigSearchVO voc1 = new RatioConfigSearchVO().setName("代理商");
|
RatioConfigSearchVO voc1 = new RatioConfigSearchVO().setName("代理商");
|
||||||
List<QuotationModelRatioAgentItemDTO> agentItems = ratioAgentItemService.getEffectives();
|
List<QuotationModelRatioAgentItemDTO> modelAgentItems= agentItems.stream()
|
||||||
if (CollectionUtil.isNotEmpty(agentItems)) {
|
.filter(ai -> ai.getModelId().equals(data.getModelId()))
|
||||||
List<AppUser> users = appUserService.listByIds(agentItems.stream().map(QuotationModelRatioAgentItemDTO::getUserId).collect(Collectors.toList()));
|
.collect(Collectors.toList());
|
||||||
agentItems.stream()
|
if (CollectionUtil.isNotEmpty(modelAgentItems)) {
|
||||||
|
List<AppUser> users = appUserService.listByIds(modelAgentItems.stream()
|
||||||
|
.map(QuotationModelRatioAgentItemDTO::getUserId)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
modelAgentItems.stream()
|
||||||
.filter(QuotationModelRatioAgentItemDTO::getIsPrimary)
|
.filter(QuotationModelRatioAgentItemDTO::getIsPrimary)
|
||||||
.forEach(ai -> {
|
.forEach(ai -> {
|
||||||
//主账号
|
//主账号
|
||||||
|
|
@ -174,12 +181,17 @@ public class RatioConfigController extends ControllerBase {
|
||||||
}
|
}
|
||||||
vo.getChildren().add(voc1);
|
vo.getChildren().add(voc1);
|
||||||
RatioConfigSearchVO voc2 = new RatioConfigSearchVO().setName("直销");
|
RatioConfigSearchVO voc2 = new RatioConfigSearchVO().setName("直销");
|
||||||
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
List<QuotationModelRatioDirectItemDTO> modelDirectItems = directItems.stream()
|
||||||
if (CollectionUtil.isNotEmpty(directItems)) {
|
.filter(di -> di.getModelId().equals(data.getModelId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(modelDirectItems)) {
|
||||||
List<AdminUser> adminUsers = adminUserService.lambdaQuery()
|
List<AdminUser> adminUsers = adminUserService.lambdaQuery()
|
||||||
.in(AdminUser::getId, directItems.stream().map(QuotationModelRatioDirectItemDTO::getUserId).collect(Collectors.toList()))
|
.in(AdminUser::getId, modelDirectItems.stream()
|
||||||
|
.map(QuotationModelRatioDirectItemDTO::getUserId)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
)
|
||||||
.list();
|
.list();
|
||||||
directItems.stream()
|
modelDirectItems.stream()
|
||||||
.filter(item -> item.getParentId().equals(AdminUserUtil.getUserId()))
|
.filter(item -> item.getParentId().equals(AdminUserUtil.getUserId()))
|
||||||
.forEach(directItem -> {
|
.forEach(directItem -> {
|
||||||
AdminUser user = adminUsers.stream()
|
AdminUser user = adminUsers.stream()
|
||||||
|
|
@ -220,7 +232,6 @@ public class RatioConfigController extends ControllerBase {
|
||||||
}
|
}
|
||||||
vo.getChildren().add(voc2);
|
vo.getChildren().add(voc2);
|
||||||
} else {
|
} else {
|
||||||
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
|
||||||
RatioConfigSearchVO vop = new RatioConfigSearchVO()
|
RatioConfigSearchVO vop = new RatioConfigSearchVO()
|
||||||
.setName(AdminUserUtil.getUserName())
|
.setName(AdminUserUtil.getUserName())
|
||||||
.setCategoryName(AdminUserUtil.getCategoryName());
|
.setCategoryName(AdminUserUtil.getCategoryName());
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.nflg.mobilebroken.common.pojo.request.ModelRatioDirectUserSearchReque
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.DynamicHeaderVO;
|
import com.nflg.mobilebroken.common.pojo.vo.DynamicHeaderVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.DynamicTableVO;
|
import com.nflg.mobilebroken.common.pojo.vo.DynamicTableVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.ModelPriceVO;
|
import com.nflg.mobilebroken.common.pojo.vo.ModelPriceVO;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO;
|
||||||
import com.nflg.mobilebroken.common.util.*;
|
import com.nflg.mobilebroken.common.util.*;
|
||||||
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
|
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
|
||||||
import com.nflg.mobilebroken.quotation.pojo.vo.QuotationModelRatioVO;
|
import com.nflg.mobilebroken.quotation.pojo.vo.QuotationModelRatioVO;
|
||||||
|
|
@ -58,6 +59,9 @@ public class RatioDirectConfigController extends ControllerBase {
|
||||||
@Resource
|
@Resource
|
||||||
private IProductModelService productModelService;
|
private IProductModelService productModelService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IQuotationModelRatioAgentService ratioAgentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取动态表头
|
* 获取动态表头
|
||||||
*/
|
*/
|
||||||
|
|
@ -153,7 +157,7 @@ public class RatioDirectConfigController extends ControllerBase {
|
||||||
Long departmentId = AdminUserUtil.getDepartmentId();
|
Long departmentId = AdminUserUtil.getDepartmentId();
|
||||||
VUtils.trueThrowBusinessError(Objects.isNull(departmentId)).throwMessage("未设置部门,请联系管理员");
|
VUtils.trueThrowBusinessError(Objects.isNull(departmentId)).throwMessage("未设置部门,请联系管理员");
|
||||||
QuotationModelRatioDirect ratioAgent = ratioDirectService.getEffectiveByUser(AdminUserUtil.getUserId());
|
QuotationModelRatioDirect ratioAgent = ratioDirectService.getEffectiveByUser(AdminUserUtil.getUserId());
|
||||||
IPage<ProductModel> pdatas = productModelService.searchForQuotation(request);
|
IPage<ProductModelSimpleVO> pdatas = ratioAgentService.search(request);
|
||||||
if (CollectionUtil.isEmpty(pdatas.getRecords())) {
|
if (CollectionUtil.isEmpty(pdatas.getRecords())) {
|
||||||
return ApiResult.successWithExtras(Convert.convert(QuotationModelRatioVO.class, ratioAgent));
|
return ApiResult.successWithExtras(Convert.convert(QuotationModelRatioVO.class, ratioAgent));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelPriceMapper">
|
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelPriceMapper">
|
||||||
|
|
||||||
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ModelPriceConfigVO">
|
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ModelPriceConfigVO">
|
||||||
SELECT pm.batch_number as 'modelId',pm.`no` as 'modelNo',qmp.id as 'priceId',pm.`no` as 'partName',qmp.price_version
|
SELECT qmp.id,pm.batch_number as 'modelId',pm.`no` as 'modelNo',qmp.id as 'priceId',pm.`no` as 'partName'
|
||||||
,qmp.price_status,qmp.update_by,qmp.update_time
|
,qmp.price_version,qmp.price_status,qmp.update_by,qmp.update_time
|
||||||
,if(qmp.price_status=1,qmc2.config_version,qmc1.config_version) as 'configVersion'
|
,if(qmp.price_status=1,qmc2.config_version,qmc1.config_version) as 'configVersion'
|
||||||
,if(qmp.price_status=1,qmc2.id,qmc1.id) as 'configId'
|
,if(qmp.price_status=1,qmc2.id,qmc1.id) as 'configId'
|
||||||
FROM quotation_model_config qmc1
|
FROM quotation_model_config qmc1
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,12 @@
|
||||||
|
|
||||||
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO">
|
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO">
|
||||||
SELECT pm.batch_number,pm.no
|
SELECT pm.batch_number,pm.no
|
||||||
FROM product_model pm
|
FROM v_quotation_model_price vqmp
|
||||||
|
LEFT JOIN product_model pm on vqmp.model_id=pm.batch_number and pm.state=1
|
||||||
LEFT JOIN product_type pt on pm.type_number=pt.batch_number AND pt.state=1
|
LEFT JOIN product_type pt on pm.type_number=pt.batch_number AND pt.state=1
|
||||||
LEFT JOIN product_series ps ON pm.series_number=ps.batch_number AND ps.state=1
|
LEFT JOIN product_series ps ON pm.series_number=ps.batch_number AND ps.state=1
|
||||||
LEFT JOIN dictionary_item di ON di.id=pm.module_id
|
LEFT JOIN dictionary_item di ON di.id=pm.module_id
|
||||||
WHERE pm.state=1
|
<where>
|
||||||
<if test="request.moduleId!=null">
|
<if test="request.moduleId!=null">
|
||||||
AND pm.module_id=#{request.moduleId}
|
AND pm.module_id=#{request.moduleId}
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -21,6 +22,7 @@
|
||||||
<if test="request.no!=null and request.no!=''">
|
<if test="request.no!=null and request.no!=''">
|
||||||
AND pm.`no` like concat('%', #{request.no}, '%')
|
AND pm.`no` like concat('%', #{request.no}, '%')
|
||||||
</if>
|
</if>
|
||||||
order by pm.id
|
</where>
|
||||||
|
order by vqmp.id desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue