修改测试
This commit is contained in:
@@ -16,6 +16,7 @@ public class PrcCustomerPriceSet extends BaseEntity
|
||||
private Long customerPricesetId;
|
||||
private Long priceSetId;
|
||||
private Long customerId;
|
||||
private String customerCode;
|
||||
private String customerName;
|
||||
/** 数字越小越优先 */
|
||||
private Integer bindPriority;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class PrcQuote extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long quoteId;
|
||||
private String quoteId;
|
||||
private String quoteKey;
|
||||
private Long customerId;
|
||||
private String productCode;
|
||||
|
||||
@@ -12,8 +12,8 @@ public class PrcQuoteFee implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long feeId;
|
||||
private Long quoteId;
|
||||
private String feeId;
|
||||
private String quoteId;
|
||||
/** bms_fee_type: BASIC_FREIGHT / REGISTRATION_FEE / SURCHARGE */
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
|
||||
+2
-1
@@ -12,9 +12,10 @@ public class TmsPriceQuoteRequest implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "customerId is required")
|
||||
private Long customerId;
|
||||
|
||||
private String customerCode;
|
||||
|
||||
@NotBlank(message = "productCode is required")
|
||||
private String productCode;
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private String roundMode;
|
||||
/** 费用明细:运费/挂号费各一行,附加费按具体名称各一行 */
|
||||
private List<TmsPriceQuoteFeeLine> feeDetails;
|
||||
private Long quoteId;
|
||||
private String quoteId;
|
||||
/** true=命中已落库试算 */
|
||||
private Boolean fromCache;
|
||||
}
|
||||
|
||||
+8
@@ -30,6 +30,10 @@ public interface PrcCustomerPriceSetMapper
|
||||
@Param("excludeId") Long excludeId,
|
||||
@Param("excludePriceSetId") Long excludePriceSetId);
|
||||
|
||||
public int countByCustomerCode(@Param("customerCode") String customerCode,
|
||||
@Param("excludeId") Long excludeId,
|
||||
@Param("excludePriceSetId") Long excludePriceSetId);
|
||||
|
||||
public int countOverlap(@Param("customerId") Long customerId,
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("beginDate") java.util.Date beginDate,
|
||||
@@ -41,4 +45,8 @@ public interface PrcCustomerPriceSetMapper
|
||||
public java.util.List<PrcCustomerPriceSet> selectEffectiveByCustomer(
|
||||
@Param("customerId") Long customerId,
|
||||
@Param("bizDate") java.util.Date bizDate);
|
||||
|
||||
public java.util.List<PrcCustomerPriceSet> selectEffectiveByCustomerCode(
|
||||
@Param("customerCode") String customerCode,
|
||||
@Param("bizDate") java.util.Date bizDate);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import com.ruoyi.price.domain.PrcQuoteFee;
|
||||
/** billing quote fee detail mapper */
|
||||
public interface PrcQuoteFeeMapper
|
||||
{
|
||||
public List<PrcQuoteFee> selectByQuoteId(Long quoteId);
|
||||
public List<PrcQuoteFee> selectByQuoteId(String quoteId);
|
||||
|
||||
public int insertPrcQuoteFee(PrcQuoteFee fee);
|
||||
|
||||
public int insertBatch(@Param("list") List<PrcQuoteFee> fees);
|
||||
|
||||
public int deleteByQuoteId(Long quoteId);
|
||||
public int deleteByQuoteId(String quoteId);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ public interface PrcQuoteMapper
|
||||
{
|
||||
public PrcQuote selectPrcQuoteByKey(String quoteKey);
|
||||
|
||||
public PrcQuote selectPrcQuoteById(Long quoteId);
|
||||
public PrcQuote selectPrcQuoteById(String quoteId);
|
||||
|
||||
public List<PrcQuote> selectPrcQuoteList(PrcQuote quote);
|
||||
|
||||
public int insertPrcQuote(PrcQuote quote);
|
||||
|
||||
public int updateQuoteAmounts(@Param("quoteId") Long quoteId,
|
||||
public int updateQuoteAmounts(@Param("quoteId") String quoteId,
|
||||
@Param("surchargeAmount") BigDecimal surchargeAmount,
|
||||
@Param("payableTotal") BigDecimal payableTotal);
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,5 +20,5 @@ public interface ITmsPriceQuoteService
|
||||
|
||||
List<PrcQuote> selectQuoteList(PrcQuote query);
|
||||
|
||||
TmsPriceQuoteResult getQuote(Long quoteId);
|
||||
TmsPriceQuoteResult getQuote(String quoteId);
|
||||
}
|
||||
|
||||
+29
-9
@@ -1,11 +1,13 @@
|
||||
package com.ruoyi.price.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.CRC32;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -406,21 +408,21 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
|
||||
List<PrcCustomerPriceSet> customers = filterCustomers(set.getCustomers());
|
||||
Set<Long> seenCustomers = new HashSet<Long>();
|
||||
Set<String> seenCustomers = new HashSet<String>();
|
||||
int bound = 0;
|
||||
boolean dupInSet = false;
|
||||
for (PrcCustomerPriceSet c : customers)
|
||||
{
|
||||
if (c.getCustomerId() == null)
|
||||
if (StringUtils.isEmpty(c.getCustomerCode()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!seenCustomers.add(c.getCustomerId()))
|
||||
if (!seenCustomers.add(c.getCustomerCode()))
|
||||
{
|
||||
dupInSet = true;
|
||||
continue;
|
||||
}
|
||||
bound += customerMapper.countByCustomerId(c.getCustomerId(), c.getCustomerPricesetId(),
|
||||
bound += customerMapper.countByCustomerCode(c.getCustomerCode(), c.getCustomerPricesetId(),
|
||||
set.getPriceSetId());
|
||||
}
|
||||
if (dupInSet || bound > 0)
|
||||
@@ -581,10 +583,10 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
if (set.getCustomers() != null)
|
||||
{
|
||||
customerMapper.deletePrcCustomerPriceSetByPriceSetId(set.getPriceSetId());
|
||||
Set<Long> seenCustomers = new HashSet<Long>();
|
||||
Set<String> seenCustomers = new HashSet<String>();
|
||||
for (PrcCustomerPriceSet c : filterCustomers(set.getCustomers()))
|
||||
{
|
||||
if (c.getCustomerId() != null && !seenCustomers.add(c.getCustomerId()))
|
||||
if (StringUtils.isNotEmpty(c.getCustomerCode()) && !seenCustomers.add(c.getCustomerCode()))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.alreadyBound"));
|
||||
}
|
||||
@@ -759,7 +761,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
|
||||
private void validateCustomer(PrcCustomerPriceSet customer, PrcPriceSet set)
|
||||
{
|
||||
if (customer.getCustomerId() == null || customer.getCustomerId().longValue() <= 0)
|
||||
if (StringUtils.isEmpty(customer.getCustomerCode()))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.customerId.empty"));
|
||||
}
|
||||
@@ -779,12 +781,30 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.priority.invalid"));
|
||||
}
|
||||
int exists = customerMapper.countByCustomerId(customer.getCustomerId(),
|
||||
int exists = customerMapper.countByCustomerCode(customer.getCustomerCode(),
|
||||
customer.getCustomerPricesetId(), null);
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.alreadyBound"));
|
||||
}
|
||||
customer.setCustomerId(resolveNumericCustomerId(customer));
|
||||
}
|
||||
|
||||
private Long resolveNumericCustomerId(PrcCustomerPriceSet customer)
|
||||
{
|
||||
if (customer.getCustomerId() != null && customer.getCustomerId().longValue() > 0)
|
||||
{
|
||||
return customer.getCustomerId();
|
||||
}
|
||||
return hashCustomerCode(customer.getCustomerCode());
|
||||
}
|
||||
|
||||
private static Long hashCustomerCode(String customerCode)
|
||||
{
|
||||
CRC32 crc = new CRC32();
|
||||
crc.update(customerCode.getBytes(StandardCharsets.UTF_8));
|
||||
long v = crc.getValue();
|
||||
return v == 0L ? Long.valueOf(1L) : Long.valueOf(v);
|
||||
}
|
||||
|
||||
private void assertBasicEditable(PrcPriceSet db)
|
||||
@@ -882,7 +902,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
for (PrcCustomerPriceSet c : customers)
|
||||
{
|
||||
if (c != null && c.getCustomerId() != null && c.getCustomerId().longValue() > 0)
|
||||
if (c != null && StringUtils.isNotEmpty(c.getCustomerCode()))
|
||||
{
|
||||
list.add(c);
|
||||
}
|
||||
|
||||
+20
-8
@@ -9,6 +9,7 @@ import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -119,7 +120,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
|
||||
@Override
|
||||
public TmsPriceQuoteResult getQuote(Long quoteId)
|
||||
public TmsPriceQuoteResult getQuote(String quoteId)
|
||||
{
|
||||
if (quoteId == null)
|
||||
{
|
||||
@@ -152,8 +153,17 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
|
||||
String productName = resolveProductName(productCode, bizDate);
|
||||
List<PrcCustomerPriceSet> binds = customerPriceSetMapper.selectEffectiveByCustomer(
|
||||
request.getCustomerId(), bizDate);
|
||||
List<PrcCustomerPriceSet> binds;
|
||||
if (StringUtils.isNotEmpty(request.getCustomerCode()))
|
||||
{
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomerCode(
|
||||
request.getCustomerCode(), bizDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomer(
|
||||
request.getCustomerId(), bizDate);
|
||||
}
|
||||
|
||||
if (binds != null)
|
||||
{
|
||||
@@ -455,8 +465,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
Date bizDate, TmsPriceQuoteResult result)
|
||||
{
|
||||
PrcQuote quote = new PrcQuote();
|
||||
quote.setQuoteId(UUID.randomUUID().toString());
|
||||
quote.setQuoteKey(quoteKey);
|
||||
quote.setCustomerId(request.getCustomerId());
|
||||
quote.setCustomerId(request.getCustomerId() == null ? Long.valueOf(0L) : request.getCustomerId());
|
||||
quote.setProductCode(result.getProductCode());
|
||||
quote.setProductName(result.getProductName());
|
||||
quote.setCountryCode(result.getCountryCode());
|
||||
@@ -538,7 +549,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return false;
|
||||
}
|
||||
|
||||
private void replaceQuoteFees(Long quoteId, TmsPriceQuoteResult result)
|
||||
private void replaceQuoteFees(String quoteId, TmsPriceQuoteResult result)
|
||||
{
|
||||
quoteFeeMapper.deleteByQuoteId(quoteId);
|
||||
List<PrcQuoteFee> fees = toFeeRows(quoteId, result);
|
||||
@@ -549,7 +560,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal());
|
||||
}
|
||||
|
||||
private List<PrcQuoteFee> toFeeRows(Long quoteId, TmsPriceQuoteResult result)
|
||||
private List<PrcQuoteFee> toFeeRows(String quoteId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcQuoteFee> fees = new ArrayList<PrcQuoteFee>();
|
||||
if (result.getFeeDetails() == null)
|
||||
@@ -664,7 +675,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
String countryName = emptyToNull(request.getCountryName());
|
||||
String biz = new SimpleDateFormat("yyyy-MM-dd").format(bizDate);
|
||||
String raw = request.getCustomerId() + "|"
|
||||
String raw = (StringUtils.isNotEmpty(request.getCustomerCode())
|
||||
? request.getCustomerCode() : String.valueOf(request.getCustomerId())) + "|"
|
||||
+ request.getProductCode().trim() + "|"
|
||||
+ nvlStr(countryCode) + "|"
|
||||
+ nvlStr(countryName) + "|"
|
||||
@@ -758,7 +770,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.quote.requestBodyRequired"));
|
||||
}
|
||||
if (request.getCustomerId() == null)
|
||||
if (StringUtils.isEmpty(request.getCustomerCode()) && request.getCustomerId() == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.quote.customerIdRequired"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user