|
|
@@ -10,6 +10,7 @@ import com.kym.entity.admin.MonitorLog;
|
|
|
import com.kym.entity.common.RedisKeys;
|
|
|
import com.kym.entity.enplus.EnConnectorStatusInfo;
|
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
|
+import com.kym.entity.miniapp.OrderRechargeRights;
|
|
|
import com.kym.entity.miniapp.WalletDetail;
|
|
|
import com.kym.service.admin.EquipmentInfoService;
|
|
|
import com.kym.service.admin.MonitorLogService;
|
|
|
@@ -17,6 +18,7 @@ import com.kym.service.enplus.EnNotifyService;
|
|
|
import com.kym.service.enplus.EnPlusService;
|
|
|
import com.kym.service.miniapp.AccountService;
|
|
|
import com.kym.service.miniapp.ChargeOrderService;
|
|
|
+import com.kym.service.miniapp.OrderRechargeRightsService;
|
|
|
import com.kym.service.miniapp.WalletDetailService;
|
|
|
import com.kym.service.utils.KymCache;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -51,6 +53,8 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
|
|
|
private final EquipmentInfoService equipmentInfoService;
|
|
|
|
|
|
+ private final OrderRechargeRightsService orderRechargeRightsService;
|
|
|
+
|
|
|
private final KymCache kymCache;
|
|
|
|
|
|
private final RedisDBChangeUtil redisDBChangeUtil;
|
|
|
@@ -61,13 +65,14 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
public EnNotifyServiceImpl(EnPlusService enPlusService, ChargeOrderService chargeOrderService,
|
|
|
AccountService accountService, WalletDetailService walletDetailService,
|
|
|
MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService,
|
|
|
- KymCache kymCache, RedisDBChangeUtil redisDBChangeUtil) {
|
|
|
+ OrderRechargeRightsService orderRechargeRightsService, KymCache kymCache, RedisDBChangeUtil redisDBChangeUtil) {
|
|
|
this.enPlusService = enPlusService;
|
|
|
this.chargeOrderService = chargeOrderService;
|
|
|
this.accountService = accountService;
|
|
|
this.walletDetailService = walletDetailService;
|
|
|
this.monitorLogService = monitorLogService;
|
|
|
this.equipmentInfoService = equipmentInfoService;
|
|
|
+ this.orderRechargeRightsService = orderRechargeRightsService;
|
|
|
this.kymCache = kymCache;
|
|
|
this.redisDBChangeUtil = redisDBChangeUtil;
|
|
|
}
|
|
|
@@ -250,14 +255,37 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
// EN+平台推送重试策略是当天失败第二天再推送一次,仅此一次。EN+订单页面可以多次手动推送,所以这里要先判断订单状态,避免重复处理。
|
|
|
if (chargeOrder.getChargeStatus() != ChargeOrder.CHARGE_STATUS_已结束 || chargeOrder.getOrderStatus() != ChargeOrder.ORDER_STATUS_成功) {
|
|
|
// 更新订单信息
|
|
|
- chargeOrder.setEndTime(LocalDateTime.parse(data.getString("EndTime"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
- chargeOrder.setTotalPower(data.getDoubleValue("TotalPower"));
|
|
|
- chargeOrder.setElecMoney((int) Math.round(data.getDouble("TotalElecMoney") * 100));
|
|
|
- chargeOrder.setServiceMoney((int) Math.round(data.getDoubleValue("TotalSeviceMoney") * 100)); // 这里文档service单词错误,按文档填写
|
|
|
- chargeOrder.setTotalMoney((int) Math.round(data.getDoubleValue("TotalMoney") * 100));
|
|
|
- chargeOrder.setStopReason(data.getIntValue("StopReason"));
|
|
|
- chargeOrder.setSumPeriod(data.getIntValue("SumPeriod"));
|
|
|
- chargeOrder.setChargeDetail(data.getString("ChargeDetails"));
|
|
|
+ chargeOrder
|
|
|
+ .setEndTime(LocalDateTime.parse(data.getString("EndTime"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
|
|
|
+ .setTotalPower(data.getDoubleValue("TotalPower"))
|
|
|
+ .setElecMoney((int) Math.round(data.getDouble("TotalElecMoney") * 100))
|
|
|
+ .setServiceMoney((int) Math.round(data.getDoubleValue("TotalSeviceMoney") * 100)) // 这里文档service单词错误,按文档填写
|
|
|
+ .setTotalMoney((int) Math.round(data.getDoubleValue("TotalMoney") * 100))
|
|
|
+ .setStopReason(data.getIntValue("StopReason"))
|
|
|
+ .setSumPeriod(data.getIntValue("SumPeriod"))
|
|
|
+ .setChargeDetail(data.getString("ChargeDetails"));
|
|
|
+
|
|
|
+ // 获取订单权益,计算订单优惠金额,实付金额,服务费优惠金额
|
|
|
+ var orderRechargeRights = orderRechargeRightsService.lambdaQuery()
|
|
|
+ .eq(OrderRechargeRights::getStartChargeSeq, chargeOrder.getStartChargeSeq())
|
|
|
+ .eq(OrderRechargeRights::getUserId, chargeOrder.getUserId())
|
|
|
+ .one();
|
|
|
+ if (orderRechargeRights != null) {
|
|
|
+ // 获取折扣,计算优惠
|
|
|
+ var discount = orderRechargeRights.getDiscount();
|
|
|
+ var serviceMoneyDiscount = chargeOrder.getServiceMoney() * (discount / 100); // 只保留到分,分以下不进行四舍五入
|
|
|
+ chargeOrder
|
|
|
+ .setPayAmount(chargeOrder.getTotalMoney() - serviceMoneyDiscount)
|
|
|
+ .setDiscountAmount(serviceMoneyDiscount)
|
|
|
+ .setServiceMoney(serviceMoneyDiscount);
|
|
|
+
|
|
|
+ // 更新订单权益的最终优惠金额
|
|
|
+ orderRechargeRights.setDiscountAmount(serviceMoneyDiscount);
|
|
|
+ orderRechargeRightsService.updateById(orderRechargeRights);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 优惠券(将来如果有多种活动形式,进行链式处理)
|
|
|
+
|
|
|
// 订单成功
|
|
|
chargeOrder.setOrderStatus(ChargeOrder.ORDER_STATUS_成功);
|
|
|
// 充电结束
|
|
|
@@ -280,6 +308,7 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
// 已确认
|
|
|
walletDetail.setStatus(WalletDetail.STATUS_已确认);
|
|
|
walletDetailService.save(walletDetail);
|
|
|
+
|
|
|
}
|
|
|
return """
|
|
|
{
|