mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 计算订单会员折扣逻辑
This commit is contained in:
@@ -23,10 +23,7 @@ import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
|
||||
import com.jsowell.pile.vo.web.BalanceDeductionAmountVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.pile.vo.web.*;
|
||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -751,4 +748,47 @@ public abstract class AbstractProgramLogic implements InitializingBean {
|
||||
transactionService.doCreateOrder(createOrderTransactionDTO);
|
||||
return orderBasicInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算订单折扣
|
||||
* @param orderBasicInfo 订单主表
|
||||
* @param orderDetail 订单详情
|
||||
*/
|
||||
protected void calculateOrderDiscounts(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) {
|
||||
String memberId = orderBasicInfo.getMemberId(); // 会员id
|
||||
String merchantId = orderBasicInfo.getMerchantId(); // 运营商id
|
||||
String stationId = orderBasicInfo.getStationId(); // 站点id
|
||||
|
||||
// 电费折扣金额
|
||||
BigDecimal discountElectricityAmount = BigDecimal.ZERO;
|
||||
// 服务费折扣金额
|
||||
BigDecimal discountServiceAmount = BigDecimal.ZERO;
|
||||
|
||||
// 查询会员在此站点会员折扣
|
||||
MemberDiscountVO memberDiscountVO = memberGroupService.queryMemberDiscount(merchantId, stationId, memberId);
|
||||
if (memberDiscountVO != null) {
|
||||
BigDecimal discount = memberDiscountVO.getDiscount(); // 折扣率
|
||||
String groupType = memberDiscountVO.getGroupType(); // 类型(1-服务费折扣,2-电费折扣 ,3-电费和服务费一起折扣)
|
||||
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount(); // 电费
|
||||
BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount(); // 服务费
|
||||
|
||||
BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
if (Constants.ONE.equals(groupType)) {
|
||||
discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
} else if (Constants.TWO.equals(groupType)) {
|
||||
discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
} else {
|
||||
// BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
// BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
}
|
||||
}
|
||||
// 订单折扣金额
|
||||
BigDecimal discountAmount = discountServiceAmount.add(discountElectricityAmount);
|
||||
orderBasicInfo.setDiscountAmount(discountAmount);
|
||||
orderDetail.setDiscountElectricityAmount(discountElectricityAmount);
|
||||
orderDetail.setDiscountServiceAmount(discountServiceAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.web.BalanceDeductionAmountVO;
|
||||
import com.jsowell.pile.vo.web.MemberDiscountVO;
|
||||
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
import com.jsowell.wxpay.dto.WechatSendMsgDTO;
|
||||
@@ -41,7 +40,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -371,49 +369,6 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
||||
logger.info("结算订单end:{} OrderTransactionDTO:{}", orderBasicInfo.getOrderCode(), JSONObject.toJSONString(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算订单折扣
|
||||
* @param orderBasicInfo 订单主表
|
||||
* @param orderDetail 订单详情
|
||||
*/
|
||||
private void calculateOrderDiscounts(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) {
|
||||
String memberId = orderBasicInfo.getMemberId(); // 会员id
|
||||
String merchantId = orderBasicInfo.getMerchantId(); // 运营商id
|
||||
String stationId = orderBasicInfo.getStationId(); // 站点id
|
||||
|
||||
// 电费折扣金额
|
||||
BigDecimal discountElectricityAmount = BigDecimal.ZERO;
|
||||
// 服务费折扣金额
|
||||
BigDecimal discountServiceAmount = BigDecimal.ZERO;
|
||||
|
||||
// 查询会员在此站点会员折扣
|
||||
MemberDiscountVO memberDiscountVO = memberGroupService.queryMemberDiscount(merchantId, stationId, memberId);
|
||||
if (memberDiscountVO != null) {
|
||||
BigDecimal discount = memberDiscountVO.getDiscount(); // 折扣率
|
||||
String groupType = memberDiscountVO.getGroupType(); // 类型(1-服务费折扣,2-电费折扣 ,3-电费和服务费一起折扣)
|
||||
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount(); // 电费
|
||||
BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount(); // 服务费
|
||||
|
||||
BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
if (Constants.ONE.equals(groupType)) {
|
||||
discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
} else if (Constants.TWO.equals(groupType)) {
|
||||
discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
} else {
|
||||
// BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount);
|
||||
// BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN);
|
||||
discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount);
|
||||
}
|
||||
}
|
||||
// 订单折扣金额
|
||||
BigDecimal discountAmount = discountServiceAmount.add(discountElectricityAmount);
|
||||
orderBasicInfo.setDiscountAmount(discountAmount);
|
||||
orderDetail.setDiscountElectricityAmount(discountElectricityAmount);
|
||||
orderDetail.setDiscountServiceAmount(discountServiceAmount);
|
||||
}
|
||||
|
||||
// uniApp 发送停止充电订阅消息
|
||||
private void sendMsg(OrderBasicInfo orderBasicInfo) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user