diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java index 603d7604..af3e9904 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java @@ -8,6 +8,7 @@ import com.xhpc.common.domain.XhpcRateTime; import org.apache.ibatis.annotations.Param; import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.List; import java.util.Map; @@ -250,4 +251,5 @@ public interface IXhpcChargingStationService { */ int insertXhpcRateTime(XhpcRateTime xhpcRateTime); + Map activityDiscountTime(Long userId, Date startTime, Integer source, Long chargingStationId, String tenantId); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index 3cc6510c..d126230d 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -1405,11 +1405,11 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc } //判断是否有活动 + @Override public Map activityDiscountTime(Long userId,Date startTime,Integer source,Long chargingStationId,String tenantId){ Map map =new HashMap<>(); List activityDiscountTime = xhpcChargingStationMapper.getActivityDiscountTime(userId, DateUtil.formatDateTime(startTime), source, chargingStationId, tenantId); if(activityDiscountTime !=null && activityDiscountTime.size()>0){ - //折扣电费、服务费 BigDecimal totalDiscountRate =new BigDecimal(0); int totalDiscountType = 0; diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java index 3855e72c..f3c8356c 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java @@ -5,12 +5,14 @@ import com.xhpc.charging.station.mapper.XhpcTerminalMapper; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.service.BaseService; import com.xhpc.common.domain.XhpcTerminal; +import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.LogUserUtils; import com.xhpc.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.*; /** @@ -32,6 +34,9 @@ public class XhpcTerminalServiceImpl extends BaseService implements IXhpcTermina private IXhpcChargingStationService xhpcChargingStationService; @Autowired private LogUserUtils logUserUtils; + + @Autowired + private TokenService tokenService; /** * PC端页面统计 * @@ -125,7 +130,35 @@ public class XhpcTerminalServiceImpl extends BaseService implements IXhpcTermina //HH:mm:ss String tiem = DateUtil.formatTime(new Date()); Map xhpcRateTime = xhpcRateTimeService.getXhpcRateTime(tiem, chargingStationId); + + LoginUser loginUser = tokenService.getLoginUser(); if (xhpcRateTime != null) { + if(loginUser !=null){ + BigDecimal serviceFee =new BigDecimal(xhpcRateTime.get("serviceFee").toString()); + BigDecimal powerFee =new BigDecimal(xhpcRateTime.get("powerFee").toString()); + Map objectMap = xhpcChargingStationService.activityDiscountTime(loginUser.getUserid(), new Date(),loginUser.getUserType(), chargingStationId, loginUser.getTenantId()); + if("1".equals(objectMap.get("state").toString())){ + if("1".equals(objectMap.get("totalDiscountType").toString())||"3".equals(objectMap.get("totalDiscountType").toString())){ + BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); + serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); + powerFee = powerFee.subtract(powerFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); + map.put("activityServiceFee", serviceFee); + map.put("activityPowerFee", powerFee); + map.put("activityMoney", serviceFee.add(powerFee)); + }else{ + BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); + serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); + map.put("activityServiceFee", serviceFee); + map.put("activityPowerFee", powerFee); + map.put("activityMoney", serviceFee.add(powerFee)); + } + if(objectMap.get("appletActivityName") !=null && !"".equals(objectMap.get("appletActivityName").toString())){ + map.put("appletActivityName", objectMap.get("appletActivityName").toString()); + }else{ + map.put("appletActivityName", ""); + } + } + } map.putAll(xhpcRateTime); } //图片信息 diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml index 6ac49a8f..d6d60590 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -983,7 +983,7 @@ xad.check_by as checkBy, xad.check_time as checkTime, xat.discount_type discountType, - xad.applet_activity_name appletActivityName, + xat.applet_activity_name appletActivityName, xat.discount_rate discountRate from xhpc_activity_discount as xad join xhpc_activity_template as xat on xat.activity_template_id = xad.template_id and xat.del_flag =0 and xat.status=1