记得上下班打卡 | git大法好,push需谨慎

Commit f85c7a5c authored by jiangxiulong's avatar jiangxiulong

double 全部使用bigdecimal

parent 7d30602d
...@@ -23,10 +23,10 @@ public class RefundApplyParam implements Serializable { ...@@ -23,10 +23,10 @@ public class RefundApplyParam implements Serializable {
private String reason; private String reason;
private Double RefundPriceExpress; private BigDecimal RefundPriceExpress;
private List<String> ticketEntityIds; private List<String> ticketEntityIds;
private List<Double> entitiesPrice; private List<BigDecimal> entitiesPrice;
private List<String> ids; private List<String> ids;
......
...@@ -3,6 +3,7 @@ package com.liquidnet.service.kylin.dto.param; ...@@ -3,6 +3,7 @@ package com.liquidnet.service.kylin.dto.param;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* <p> * <p>
...@@ -45,7 +46,7 @@ public class RefundCallbackParam implements Serializable { ...@@ -45,7 +46,7 @@ public class RefundCallbackParam implements Serializable {
private String refund_code; private String refund_code;
private double refund_price; private BigDecimal refund_price;
private String refund_reason; private String refund_reason;
......
...@@ -20,7 +20,6 @@ import com.liquidnet.service.kylin.dao.OrderRefundDao; ...@@ -20,7 +20,6 @@ import com.liquidnet.service.kylin.dao.OrderRefundDao;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam; import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam; import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.param.RefundSearchParam; import com.liquidnet.service.kylin.dto.param.RefundSearchParam;
import com.liquidnet.service.kylin.dto.param.SysDamaiParam;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo; import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo;
...@@ -92,13 +91,11 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -92,13 +91,11 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
public ResponseDto refundApply(RefundApplyParam refundApplyParam) { public ResponseDto refundApply(RefundApplyParam refundApplyParam) {
String orderTicketsId = refundApplyParam.getOrderTicketsId(); String orderTicketsId = refundApplyParam.getOrderTicketsId();
List<String> ticketEntityIds = refundApplyParam.getTicketEntityIds(); List<String> ticketEntityIds = refundApplyParam.getTicketEntityIds();
List<Double> entitiesPrice = refundApplyParam.getEntitiesPrice(); List<BigDecimal> entitiesPrice = refundApplyParam.getEntitiesPrice();
Double RefundPriceExpressDouble = refundApplyParam.getRefundPriceExpress(); BigDecimal RefundPriceExpress = refundApplyParam.getRefundPriceExpress();
if (null == RefundPriceExpressDouble) { if (null == RefundPriceExpress) {
RefundPriceExpressDouble = 0.0; RefundPriceExpress = new BigDecimal(0);
} }
BigDecimal RefundPriceExpress = BigDecimal.valueOf(RefundPriceExpressDouble);
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne( KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId) new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
...@@ -121,19 +118,19 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -121,19 +118,19 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
} }
// TODO: 2021/6/16 是否能单独退快递飞 批量退款是否退快递费 现在做的是自动退剩余快递费 // TODO: 2021/6/16 是否能单独退快递飞 批量退款是否退快递费 现在做的是自动退剩余快递费
// 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费) // 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费)
Double refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费 BigDecimal refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费
orderTicketsId, orderTicketsId,
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL
); );
if (null == refundPriceExpressSum) { if (null == refundPriceExpressSum) {
refundPriceExpressSum = 0.0; refundPriceExpressSum = new BigDecimal(0);
} }
if (null == refundApplyParam.getOrderRefundBatchesId() || refundApplyParam.getOrderRefundBatchesId().isEmpty()) { // 不是批量退款 if (null == refundApplyParam.getOrderRefundBatchesId() || refundApplyParam.getOrderRefundBatchesId().isEmpty()) { // 不是批量退款
if (RefundPriceExpress.compareTo(priceExpress.subtract(BigDecimal.valueOf(refundPriceExpressSum))) > 0) { if (RefundPriceExpress.compareTo(priceExpress.subtract(refundPriceExpressSum)) > 0) {
return ResponseDto.failure("快递费不能大于实际减去已退的快递费"); return ResponseDto.failure("快递费不能大于实际减去已退的快递费");
} }
} else { } else {
RefundPriceExpress = priceExpress.subtract(BigDecimal.valueOf(refundPriceExpressSum)); RefundPriceExpress = priceExpress.subtract(refundPriceExpressSum);
} }
// todo 出票未出票 // todo 出票未出票
...@@ -157,22 +154,22 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -157,22 +154,22 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
.ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0) .ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
); );
BigDecimal onePrice = priceActual.subtract(priceExpress).divide(BigDecimal.valueOf(allEntitiesCount));//单价 BigDecimal onePrice = priceActual.subtract(priceExpress).divide(BigDecimal.valueOf(allEntitiesCount));//单价
List<Double> realRefundPriceList = new ArrayList<>(); List<BigDecimal> realRefundPriceList = new ArrayList<>();
if (null == refundApplyParam.getOrderRefundBatchesId() || refundApplyParam.getOrderRefundBatchesId().isEmpty()) { // 不是批量退款 if (null == refundApplyParam.getOrderRefundBatchesId() || refundApplyParam.getOrderRefundBatchesId().isEmpty()) { // 不是批量退款
for (int i = 0; i <= ticketEntityIds.size() - 1; i++) { for (int i = 0; i <= ticketEntityIds.size() - 1; i++) {
BigDecimal price = BigDecimal.valueOf(entitiesPrice.get(i)); BigDecimal price = entitiesPrice.get(i);
if (price.compareTo(BigDecimal.ZERO) <= 0) { if (price.compareTo(BigDecimal.ZERO) <= 0) {
return ResponseDto.failure(ErrorMapping.get("20021")); return ResponseDto.failure(ErrorMapping.get("20021"));
} else { } else {
Double refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退 BigDecimal refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退
orderTicketsId, orderTicketsId,
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL, KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL,
ticketEntityIds.get(i) ticketEntityIds.get(i)
); );
if (null == refundedPrice) { if (null == refundedPrice) {
refundedPrice = 0.0; refundedPrice = new BigDecimal(0);
} }
if (price.compareTo(onePrice.subtract(BigDecimal.valueOf(refundedPrice))) > 0) { if (price.compareTo(onePrice.subtract(refundedPrice)) > 0) {
return ResponseDto.failure("超过可退款金额"); return ResponseDto.failure("超过可退款金额");
} }
} }
...@@ -181,17 +178,17 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -181,17 +178,17 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
} else { // 批量 计算入场人订单可退金额 } else { // 批量 计算入场人订单可退金额
List<String> ticketEntityIdsNew = new ArrayList<>(); List<String> ticketEntityIdsNew = new ArrayList<>();
for (int i = 0; i <= ticketEntityIds.size() - 1; i++) { for (int i = 0; i <= ticketEntityIds.size() - 1; i++) {
Double refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退 包含退款中 BigDecimal refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退 包含退款中
orderTicketsId, orderTicketsId,
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL, KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL,
ticketEntityIds.get(i) ticketEntityIds.get(i)
); );
if (null == refundedPrice) { if (null == refundedPrice) {
refundedPrice = 0.0; refundedPrice = new BigDecimal(0);
} }
BigDecimal price = onePrice.subtract(BigDecimal.valueOf(refundedPrice)); // 计算可退金额 BigDecimal price = onePrice.subtract(refundedPrice); // 计算可退金额
if (price.compareTo(BigDecimal.ZERO) > 0) { if (price.compareTo(BigDecimal.ZERO) > 0) {
realRefundPriceList.add(price.doubleValue()); realRefundPriceList.add(price);
ticketEntityIdsNew.add(ticketEntityIds.get(i)); ticketEntityIdsNew.add(ticketEntityIds.get(i));
} }
} }
...@@ -201,7 +198,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -201,7 +198,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding( boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding(
refundApplyParam, orderInfo, orderTicketsId, refundApplyParam, orderInfo, orderTicketsId,
RefundPriceExpress.doubleValue(), RefundPriceExpress,
ticketEntityIds, realRefundPriceList ticketEntityIds, realRefundPriceList
); );
...@@ -319,7 +316,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -319,7 +316,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
RefundCallbackParam refundCallbackParam = new RefundCallbackParam(); RefundCallbackParam refundCallbackParam = new RefundCallbackParam();
refundCallbackParam.setRefund_code(refundInfo.getRefundCode()); refundCallbackParam.setRefund_code(refundInfo.getRefundCode());
double refundPrice = refundInfo.getPrice().doubleValue() + refundInfo.getPriceExpress().doubleValue(); BigDecimal refundPrice = refundInfo.getPrice().add(refundInfo.getPriceExpress());
refundCallbackParam.setRefund_price(refundPrice); refundCallbackParam.setRefund_price(refundPrice);
refundCallbackParam.setRefund_type("UNKNOWN"); refundCallbackParam.setRefund_type("UNKNOWN");
refundCallbackParam.setRefund_id(refundInfo.getRefundId()); refundCallbackParam.setRefund_id(refundInfo.getRefundId());
...@@ -405,15 +402,15 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -405,15 +402,15 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
new QueryWrapper<KylinOrderTickets>().eq("order_code", orderCode) new QueryWrapper<KylinOrderTickets>().eq("order_code", orderCode)
); );
// 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费) // 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费)
Double refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费 BigDecimal refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费
kylinOrderTickets.getOrderTicketsId(), kylinOrderTickets.getOrderTicketsId(),
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL
); );
if (null == refundPriceExpressSum) { if (null == refundPriceExpressSum) {
refundPriceExpressSum = 0.0; refundPriceExpressSum = new BigDecimal(0);
} }
Double RefundPriceExpress = kylinOrderTickets.getPriceExpress().doubleValue() - refundPriceExpressSum; BigDecimal RefundPriceExpress = kylinOrderTickets.getPriceExpress().subtract(refundPriceExpressSum);
kylinOrderTickets.setPriceExpress(BigDecimal.valueOf(RefundPriceExpress)); kylinOrderTickets.setPriceExpress(RefundPriceExpress);
// 订单关联 获取演出id // 订单关联 获取演出id
KylinOrderTicketRelations kylinOrderTicketRelations = kylinOrderTicketRelationsMapper.selectOne( KylinOrderTicketRelations kylinOrderTicketRelations = kylinOrderTicketRelationsMapper.selectOne(
...@@ -437,14 +434,14 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -437,14 +434,14 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
); );
BigDecimal onePrice = (priceActual.subtract(priceExpress)).divide(BigDecimal.valueOf(allEntitiesCount));//单价 BigDecimal onePrice = (priceActual.subtract(priceExpress)).divide(BigDecimal.valueOf(allEntitiesCount));//单价
for (KylinOrderTicketEntitiesDao entities : entitiesListTemp) { for (KylinOrderTicketEntitiesDao entities : entitiesListTemp) {
Double refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退 包含退款中 BigDecimal refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退 包含退款中
kylinOrderTickets.getOrderTicketsId(), kylinOrderTickets.getOrderTicketsId(),
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL, KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL,
entities.getOrderTicketEntitiesId() entities.getOrderTicketEntitiesId()
); );
BigDecimal canRefundedPrice; BigDecimal canRefundedPrice;
if (null != refundedPrice) { if (null != refundedPrice) {
canRefundedPrice = onePrice.subtract(BigDecimal.valueOf(refundedPrice)); canRefundedPrice = onePrice.subtract(refundedPrice);
} else { } else {
canRefundedPrice = onePrice; canRefundedPrice = onePrice;
} }
......
...@@ -70,8 +70,8 @@ public class KylinRefundExecuteServiceImpl { ...@@ -70,8 +70,8 @@ public class KylinRefundExecuteServiceImpl {
refundApplyParam.setReason(reason); refundApplyParam.setReason(reason);
refundApplyParam.setOrderTicketsId(order.getOrderTicketsId()); refundApplyParam.setOrderTicketsId(order.getOrderTicketsId());
refundApplyParam.setTicketEntityIds(ticketEntityIds); refundApplyParam.setTicketEntityIds(ticketEntityIds);
if (order.getPriceExpress() != null) { if (null != order.getPriceExpress()) {
refundApplyParam.setRefundPriceExpress(order.getPriceExpress().doubleValue()); refundApplyParam.setRefundPriceExpress(order.getPriceExpress());
} }
try { try {
ResponseDto res = kylinOrderRefundsServiceImpl.refundApply(refundApplyParam); ResponseDto res = kylinOrderRefundsServiceImpl.refundApply(refundApplyParam);
......
...@@ -91,8 +91,8 @@ public class KylinRefundsStatusServiceImpl { ...@@ -91,8 +91,8 @@ public class KylinRefundsStatusServiceImpl {
public Boolean orderTicketRefunding( public Boolean orderTicketRefunding(
RefundApplyParam refundApplyParam, KylinOrderTickets orderInfo, String orderTicketsId, RefundApplyParam refundApplyParam, KylinOrderTickets orderInfo, String orderTicketsId,
double RefundPriceExpress, BigDecimal RefundPriceExpress,
List<String> ticketEntityIds, List<Double> entitiesPrice List<String> ticketEntityIds, List<BigDecimal> entitiesPrice
) { ) {
if (CollectionUtil.isEmpty(ticketEntityIds)) { if (CollectionUtil.isEmpty(ticketEntityIds)) {
return false; return false;
...@@ -103,7 +103,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -103,7 +103,7 @@ public class KylinRefundsStatusServiceImpl {
String reason = refundApplyParam.getReason(); String reason = refundApplyParam.getReason();
String orderRefundBatchesId = refundApplyParam.getOrderRefundBatchesId(); String orderRefundBatchesId = refundApplyParam.getOrderRefundBatchesId();
// 本次退款票总金额 // 本次退款票总金额
double entitiesPriceSum = entitiesPrice.stream().mapToDouble(Double::doubleValue).sum(); BigDecimal entitiesPriceSum = entitiesPrice.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
// TODO: 2021/5/27 事物 and 部分退款 // TODO: 2021/5/27 事物 and 部分退款
// 更新数据 // 更新数据
...@@ -163,8 +163,8 @@ public class KylinRefundsStatusServiceImpl { ...@@ -163,8 +163,8 @@ public class KylinRefundsStatusServiceImpl {
String orderRefundCode = orderInfo.getOrderCode(); String orderRefundCode = orderInfo.getOrderCode();
String codeNum = StringUtils.leftPad(String.valueOf(refundCount), 3, "0"); String codeNum = StringUtils.leftPad(String.valueOf(refundCount), 3, "0");
kylinOrderRefunds.setOrderRefundCode(orderRefundCode.concat(codeNum)); kylinOrderRefunds.setOrderRefundCode(orderRefundCode.concat(codeNum));
kylinOrderRefunds.setPrice(BigDecimal.valueOf(entitiesPriceSum)); kylinOrderRefunds.setPrice(entitiesPriceSum);
kylinOrderRefunds.setPriceExpress(BigDecimal.valueOf(RefundPriceExpress)); kylinOrderRefunds.setPriceExpress(RefundPriceExpress);
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY); kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY);
kylinOrderRefunds.setType(KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY); kylinOrderRefunds.setType(KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY);
...@@ -172,11 +172,11 @@ public class KylinRefundsStatusServiceImpl { ...@@ -172,11 +172,11 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds.setApplicantName(authName); kylinOrderRefunds.setApplicantName(authName);
kylinOrderRefunds.setApplicantAt(LocalDateTime.now()); kylinOrderRefunds.setApplicantAt(LocalDateTime.now());
kylinOrderRefunds.setReason(reason); kylinOrderRefunds.setReason(reason);
if (RefundPriceExpress > 0 && entitiesPriceSum > 0) { if (RefundPriceExpress.compareTo(BigDecimal.ZERO) > 0 && entitiesPriceSum.compareTo(BigDecimal.ZERO) > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3);
} else if (RefundPriceExpress > 0) { } else if (RefundPriceExpress.compareTo(BigDecimal.ZERO) > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE2); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE2);
} else if (entitiesPriceSum > 0) { } else if (entitiesPriceSum.compareTo(BigDecimal.ZERO) > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE1); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE1);
} }
kylinOrderRefunds.setCreatedAt(LocalDateTime.now()); kylinOrderRefunds.setCreatedAt(LocalDateTime.now());
...@@ -192,7 +192,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -192,7 +192,7 @@ public class KylinRefundsStatusServiceImpl {
String orderRefundsEntitiesId = IDGenerator.nextSnowId(); String orderRefundsEntitiesId = IDGenerator.nextSnowId();
kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId); kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId);
kylinOrderRefundEntities.setOrderRefundsId(orderRefundsId); kylinOrderRefundEntities.setOrderRefundsId(orderRefundsId);
kylinOrderRefundEntities.setRefundPrice(BigDecimal.valueOf(entitiesPrice.get(i))); kylinOrderRefundEntities.setRefundPrice(entitiesPrice.get(i));
kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i)); kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i));
kylinOrderRefundEntities.setCreatedAt(LocalDateTime.now()); kylinOrderRefundEntities.setCreatedAt(LocalDateTime.now());
int rowsR = kylinOrderRefundsEntitiesMapper.insert(kylinOrderRefundEntities); int rowsR = kylinOrderRefundsEntitiesMapper.insert(kylinOrderRefundEntities);
...@@ -237,7 +237,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -237,7 +237,7 @@ public class KylinRefundsStatusServiceImpl {
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne( KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId) new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
); );
if (orderInfo.getPriceRefund().doubleValue() > 0) { // 已经有退完的 那就是部分退款了 if (orderInfo.getPriceRefund().compareTo(BigDecimal.ZERO) > 0) { // 已经有退完的 那就是部分退款了
newStatus = KylinTableStatusConst.ORDER_STATUS6; newStatus = KylinTableStatusConst.ORDER_STATUS6;
} else { } else {
newStatus = KylinTableStatusConst.ORDER_STATUS1; newStatus = KylinTableStatusConst.ORDER_STATUS1;
...@@ -276,7 +276,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -276,7 +276,7 @@ public class KylinRefundsStatusServiceImpl {
KylinOrderTicketEntities entitiesInfo = kylinOrderTicketEntitiesMapper.selectOne( KylinOrderTicketEntities entitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(
new QueryWrapper<KylinOrderTicketEntities>().eq("order_ticket_entities_id", entitiesId) new QueryWrapper<KylinOrderTicketEntities>().eq("order_ticket_entities_id", entitiesId)
); );
if (entitiesInfo.getRefundPrice().doubleValue() > 0) { // 已经有退完的 那就是部分退款了 if (entitiesInfo.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) { // 已经有退完的 那就是部分退款了
newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT4; newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT4;
} else { } else {
newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT1; newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT1;
...@@ -406,7 +406,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -406,7 +406,7 @@ public class KylinRefundsStatusServiceImpl {
new QueryWrapper<KylinOrderTickets>() new QueryWrapper<KylinOrderTickets>()
.eq("order_tickets_id", refund.getOrderTicketsId()) .eq("order_tickets_id", refund.getOrderTicketsId())
); );
double refundPrice = refund.getPrice().doubleValue() + refund.getPriceExpress().doubleValue(); BigDecimal refundPrice = refund.getPrice().add(refund.getPriceExpress());
MultiValueMap<String, String> params = new LinkedMultiValueMap(); MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("code", oderInfo.getPayCode()); params.add("code", oderInfo.getPayCode());
params.add("order_refund_code", refund.getOrderRefundCode()); params.add("order_refund_code", refund.getOrderRefundCode());
...@@ -468,7 +468,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -468,7 +468,7 @@ public class KylinRefundsStatusServiceImpl {
); );
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus(); KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
int newStatus = 0; int newStatus = 0;
if (refundCallbackParam.getRefund_price() + orderInfo.getPriceRefund().doubleValue() == orderInfo.getPriceActual().doubleValue()) { if (refundCallbackParam.getRefund_price().add(orderInfo.getPriceRefund()).compareTo(orderInfo.getPriceActual()) == 0) {
newStatus = KylinTableStatusConst.ORDER_STATUS4; newStatus = KylinTableStatusConst.ORDER_STATUS4;
} else { } else {
newStatus = KylinTableStatusConst.ORDER_STATUS6; newStatus = KylinTableStatusConst.ORDER_STATUS6;
...@@ -535,11 +535,11 @@ public class KylinRefundsStatusServiceImpl { ...@@ -535,11 +535,11 @@ public class KylinRefundsStatusServiceImpl {
} }
// 订单表 // 订单表
double price = orderInfo.getPriceRefund().doubleValue() + refundCallbackParam.getRefund_price(); BigDecimal price = orderInfo.getPriceRefund().add(refundCallbackParam.getRefund_price());
Integer num = orderInfo.getRefundNumber() + refundNumber; Integer num = orderInfo.getRefundNumber() + refundNumber;
KylinOrderTickets update = new KylinOrderTickets(); KylinOrderTickets update = new KylinOrderTickets();
update.setRefundNumber(num); update.setRefundNumber(num);
update.setPriceRefund(BigDecimal.valueOf(price)); update.setPriceRefund(price);
update.setUpdatedAt(LocalDateTime.now()); update.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketsMapper.update( kylinOrderTicketsMapper.update(
update, new UpdateWrapper<KylinOrderTickets>() update, new UpdateWrapper<KylinOrderTickets>()
...@@ -548,7 +548,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -548,7 +548,7 @@ public class KylinRefundsStatusServiceImpl {
HashMap<String, Object> orderVo = new HashMap<>(); HashMap<String, Object> orderVo = new HashMap<>();
orderVo.put("updatedAt", DateUtil.getNowTime()); orderVo.put("updatedAt", DateUtil.getNowTime());
orderVo.put("priceRefund", BigDecimal.valueOf(price)); orderVo.put("priceRefund", price);
orderVo.put("status", newStatus); orderVo.put("status", newStatus);
orderVo.put("refundNumber", num); orderVo.put("refundNumber", num);
BasicDBObject orderVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(orderVo)); BasicDBObject orderVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(orderVo));
......
...@@ -5,6 +5,7 @@ import com.liquidnet.service.kylin.dao.OrderRefundDao; ...@@ -5,6 +5,7 @@ import com.liquidnet.service.kylin.dao.OrderRefundDao;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds; import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -35,7 +36,7 @@ public interface KylinOrderRefundsMapper extends BaseMapper<KylinOrderRefunds> { ...@@ -35,7 +36,7 @@ public interface KylinOrderRefundsMapper extends BaseMapper<KylinOrderRefunds> {
@Param("ticketEntityIds") List<String> ticketEntityIds @Param("ticketEntityIds") List<String> ticketEntityIds
); );
Double RefundPriceExpressSum( BigDecimal RefundPriceExpressSum(
@Param("orderTicketsId") String orderTicketsId, @Param("orderTicketsId") String orderTicketsId,
@Param("orderRefundStatusCancel") Integer orderRefundStatusCancel @Param("orderRefundStatusCancel") Integer orderRefundStatusCancel
); );
......
...@@ -6,6 +6,7 @@ import com.liquidnet.service.kylin.entity.KylinOrderTicketEntities; ...@@ -6,6 +6,7 @@ import com.liquidnet.service.kylin.entity.KylinOrderTicketEntities;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -22,13 +23,13 @@ public interface KylinOrderTicketEntitiesMapper extends BaseMapper<KylinOrderTic ...@@ -22,13 +23,13 @@ public interface KylinOrderTicketEntitiesMapper extends BaseMapper<KylinOrderTic
List<KylinOrderTicketEntitiesDao> getRefundEntitiesList(String orderTicketsId); List<KylinOrderTicketEntitiesDao> getRefundEntitiesList(String orderTicketsId);
Double getRefundEntitiesPrice( BigDecimal getRefundEntitiesPrice(
@Param("orderTicketsId") String orderTicketsId, @Param("orderTicketsId") String orderTicketsId,
@Param("orderRefundStatusCancel") Integer orderRefundStatusCancel, @Param("orderRefundStatusCancel") Integer orderRefundStatusCancel,
@Param("orderTicketEntitiesId") String orderTicketEntitiesId @Param("orderTicketEntitiesId") String orderTicketEntitiesId
); );
Double getRefundOverEntitiesPrice( BigDecimal getRefundOverEntitiesPrice(
@Param("orderTicketsId") String orderTicketsId, @Param("orderTicketsId") String orderTicketsId,
@Param("orderRefundStatus") Integer orderRefundStatus, @Param("orderRefundStatus") Integer orderRefundStatus,
@Param("entitiesId") String entitiesId @Param("entitiesId") String entitiesId
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
</foreach> </foreach>
</where> </where>
</select> </select>
<select id="RefundPriceExpressSum" resultType="java.lang.Double"> <select id="RefundPriceExpressSum" resultType="java.math.BigDecimal">
SELECT SUM(price_express) SELECT SUM(price_express)
FROM kylin_order_refunds FROM kylin_order_refunds
<where> <where>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
AND a.is_payment != 3 AND a.is_payment != 3
</where> </where>
</select> </select>
<select id="getRefundEntitiesPrice" resultType="java.lang.Double"> <select id="getRefundEntitiesPrice" resultType="java.math.BigDecimal">
SELECT SUM(b.refund_price) SELECT SUM(b.refund_price)
FROM kylin_order_refunds AS a FROM kylin_order_refunds AS a
JOIN kylin_order_refund_entities AS b ON a.order_refunds_id = b.order_refunds_id JOIN kylin_order_refund_entities AS b ON a.order_refunds_id = b.order_refunds_id
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
AND b.order_ticket_entities_id = #{orderTicketEntitiesId} AND b.order_ticket_entities_id = #{orderTicketEntitiesId}
</where> </where>
</select> </select>
<select id="getRefundOverEntitiesPrice" resultType="java.lang.Double"> <select id="getRefundOverEntitiesPrice" resultType="java.math.BigDecimal">
SELECT SUM(b.refund_price) SELECT SUM(b.refund_price)
FROM kylin_order_refunds AS a FROM kylin_order_refunds AS a
JOIN kylin_order_refund_entities AS b ON a.order_refunds_id = b.order_refunds_id JOIN kylin_order_refund_entities AS b ON a.order_refunds_id = b.order_refunds_id
......
...@@ -58,8 +58,8 @@ public class KylinRefundsStatusServiceImpl { ...@@ -58,8 +58,8 @@ public class KylinRefundsStatusServiceImpl {
public Boolean orderTicketRefunding( public Boolean orderTicketRefunding(
KylinOrderTicketVo orderInfo, String orderTicketsId, KylinOrderTicketVo orderInfo, String orderTicketsId,
double RefundPriceExpress, BigDecimal RefundPriceExpress,
List<String> ticketEntityIds, List<Double> entitiesPrice List<String> ticketEntityIds, List<BigDecimal> entitiesPrice
) { ) {
if (CollectionUtil.isEmpty(ticketEntityIds)) { if (CollectionUtil.isEmpty(ticketEntityIds)) {
return false; return false;
...@@ -69,7 +69,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -69,7 +69,7 @@ public class KylinRefundsStatusServiceImpl {
String authName = "system_overtime_order_refund"; String authName = "system_overtime_order_refund";
String reason = "订单支付超时自动退款"; String reason = "订单支付超时自动退款";
// 本次退款票总金额 // 本次退款票总金额
double entitiesPriceSum = entitiesPrice.stream().mapToDouble(Double::doubleValue).sum(); BigDecimal entitiesPriceSum = entitiesPrice.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
// 更新数据 // 更新数据
// 订单状态表 和 缓存 // 订单状态表 和 缓存
...@@ -127,19 +127,19 @@ public class KylinRefundsStatusServiceImpl { ...@@ -127,19 +127,19 @@ public class KylinRefundsStatusServiceImpl {
String orderRefundCode = orderInfo.getOrderCode(); String orderRefundCode = orderInfo.getOrderCode();
String codeNum = StringUtils.leftPad(String.valueOf(5), 3, "0"); String codeNum = StringUtils.leftPad(String.valueOf(5), 3, "0");
kylinOrderRefunds.setOrderRefundCode(orderRefundCode.concat(codeNum)); kylinOrderRefunds.setOrderRefundCode(orderRefundCode.concat(codeNum));
kylinOrderRefunds.setPrice(BigDecimal.valueOf(entitiesPriceSum)); kylinOrderRefunds.setPrice(entitiesPriceSum);
kylinOrderRefunds.setPriceExpress(BigDecimal.valueOf(RefundPriceExpress)); kylinOrderRefunds.setPriceExpress(RefundPriceExpress);
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY); kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY);
kylinOrderRefunds.setType(KylinTableStatusConst.ORDER_REFUND_TYPE_AUTO); kylinOrderRefunds.setType(KylinTableStatusConst.ORDER_REFUND_TYPE_AUTO);
kylinOrderRefunds.setApplicantId(authId); kylinOrderRefunds.setApplicantId(authId);
kylinOrderRefunds.setApplicantName(authName); kylinOrderRefunds.setApplicantName(authName);
kylinOrderRefunds.setApplicantAt(nowTime); kylinOrderRefunds.setApplicantAt(nowTime);
kylinOrderRefunds.setReason(reason); kylinOrderRefunds.setReason(reason);
if (RefundPriceExpress > 0 && entitiesPriceSum > 0) { if (RefundPriceExpress.compareTo(BigDecimal.ZERO) > 0 && entitiesPriceSum.compareTo(BigDecimal.ZERO) > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3);
} else if (RefundPriceExpress > 0) { } else if (RefundPriceExpress.compareTo(BigDecimal.ZERO) > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE2); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE2);
} else if (entitiesPriceSum > 0) { } else if (entitiesPriceSum.compareTo(BigDecimal.ZERO) > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE1); kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE1);
} }
kylinOrderRefunds.setCreatedAt(nowTime); kylinOrderRefunds.setCreatedAt(nowTime);
...@@ -158,7 +158,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -158,7 +158,7 @@ public class KylinRefundsStatusServiceImpl {
for (int i = 0; i <= ticketEntityIds.size() - 1; i++) { for (int i = 0; i <= ticketEntityIds.size() - 1; i++) {
String orderRefundsEntitiesId = IDGenerator.nextSnowId(); String orderRefundsEntitiesId = IDGenerator.nextSnowId();
kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId); kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId);
kylinOrderRefundEntities.setRefundPrice(BigDecimal.valueOf(entitiesPrice.get(i))); kylinOrderRefundEntities.setRefundPrice(entitiesPrice.get(i));
kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i)); kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i));
sqlsDataD.add(new Object[]{ sqlsDataD.add(new Object[]{
......
...@@ -37,22 +37,22 @@ public class OrderRefundOvertimeServiceImpl implements IKylinOrderRefundsService ...@@ -37,22 +37,22 @@ public class OrderRefundOvertimeServiceImpl implements IKylinOrderRefundsService
public Boolean refundApply(String orderTicketsId) { public Boolean refundApply(String orderTicketsId) {
KylinOrderTicketVo orderInfo = dataUtils.getOrderTicketVo(orderTicketsId); KylinOrderTicketVo orderInfo = dataUtils.getOrderTicketVo(orderTicketsId);
// 快递费 未进行判断 // 快递费 未进行判断
Double RefundPriceExpress = orderInfo.getPriceExpress().doubleValue(); BigDecimal RefundPriceExpress = orderInfo.getPriceExpress();
double priceActual = orderInfo.getPriceActual().doubleValue(); BigDecimal priceActual = orderInfo.getPriceActual();
double priceExpress = orderInfo.getPriceExpress().doubleValue(); BigDecimal priceExpress = orderInfo.getPriceExpress();
// 查询订单入场人 // 查询订单入场人
List<KylinOrderTicketEntitiesVo> entitiesList = orderInfo.getEntitiesVoList(); List<KylinOrderTicketEntitiesVo> entitiesList = orderInfo.getEntitiesVoList();
if (!CollectionUtil.isEmpty(entitiesList)) { if (!CollectionUtil.isEmpty(entitiesList)) {
int allEntitiesCount = entitiesList.size();// 总入场人数量 排出未付款的 用来计算单入场人的价格 int allEntitiesCount = entitiesList.size();// 总入场人数量 排出未付款的 用来计算单入场人的价格
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价 BigDecimal onePrice = priceActual.subtract(priceExpress).divide(BigDecimal.valueOf(allEntitiesCount));//单价
for (KylinOrderTicketEntitiesVo entities : entitiesList) { for (KylinOrderTicketEntitiesVo entities : entitiesList) {
entities.setCanRefundedPrice(BigDecimal.valueOf(onePrice)); entities.setCanRefundedPrice(onePrice);
} }
} }
List<String> ticketEntityIds = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getOrderTicketEntitiesId()).collect(Collectors.toList()); List<String> ticketEntityIds = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getOrderTicketEntitiesId()).collect(Collectors.toList());
List<Double> entitiesPrice = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getCanRefundedPrice().doubleValue()).collect(Collectors.toList()); List<BigDecimal> entitiesPrice = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getCanRefundedPrice()).collect(Collectors.toList());
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding( boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding(
orderInfo, orderTicketsId, orderInfo, orderTicketsId,
......
...@@ -92,7 +92,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -92,7 +92,7 @@ public class KylinRefundsStatusServiceImpl {
); );
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus(); KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
int newStatus = 0; int newStatus = 0;
if (refundCallbackParam.getRefund_price() + orderInfo.getPriceRefund().doubleValue() == orderInfo.getPriceActual().doubleValue()) { if (refundCallbackParam.getRefund_price().add(orderInfo.getPriceRefund()).compareTo(orderInfo.getPriceActual()) == 0) {
newStatus = KylinTableStatusConst.ORDER_STATUS4; newStatus = KylinTableStatusConst.ORDER_STATUS4;
} else { } else {
newStatus = KylinTableStatusConst.ORDER_STATUS6; newStatus = KylinTableStatusConst.ORDER_STATUS6;
...@@ -159,11 +159,11 @@ public class KylinRefundsStatusServiceImpl { ...@@ -159,11 +159,11 @@ public class KylinRefundsStatusServiceImpl {
} }
// 订单表 // 订单表
double price = orderInfo.getPriceRefund().doubleValue() + refundCallbackParam.getRefund_price(); BigDecimal price = orderInfo.getPriceRefund().add(refundCallbackParam.getRefund_price());
Integer num = orderInfo.getRefundNumber() + refundNumber; Integer num = orderInfo.getRefundNumber() + refundNumber;
KylinOrderTickets update = new KylinOrderTickets(); KylinOrderTickets update = new KylinOrderTickets();
update.setRefundNumber(num); update.setRefundNumber(num);
update.setPriceRefund(BigDecimal.valueOf(price)); update.setPriceRefund(price);
update.setUpdatedAt(LocalDateTime.now()); update.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketsMapper.update( kylinOrderTicketsMapper.update(
update, new UpdateWrapper<KylinOrderTickets>() update, new UpdateWrapper<KylinOrderTickets>()
...@@ -172,7 +172,7 @@ public class KylinRefundsStatusServiceImpl { ...@@ -172,7 +172,7 @@ public class KylinRefundsStatusServiceImpl {
HashMap<String, Object> orderVo = new HashMap<>(); HashMap<String, Object> orderVo = new HashMap<>();
orderVo.put("updatedAt", DateUtil.getNowTime()); orderVo.put("updatedAt", DateUtil.getNowTime());
orderVo.put("priceRefund", BigDecimal.valueOf(price)); orderVo.put("priceRefund", price);
orderVo.put("status", newStatus); orderVo.put("status", newStatus);
orderVo.put("refundNumber", num); orderVo.put("refundNumber", num);
BasicDBObject orderVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(orderVo)); BasicDBObject orderVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(orderVo));
......
...@@ -21,8 +21,6 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -21,8 +21,6 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/** /**
* <p> * <p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment