启动页面增加优惠金额

This commit is contained in:
yuyang 2022-06-14 13:46:53 +08:00
parent 3d7d2bfde3
commit 90e93b2774
4 changed files with 37 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import com.xhpc.common.domain.XhpcRateTime;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -250,4 +251,5 @@ public interface IXhpcChargingStationService {
*/ */
int insertXhpcRateTime(XhpcRateTime xhpcRateTime); int insertXhpcRateTime(XhpcRateTime xhpcRateTime);
Map<String,Object> activityDiscountTime(Long userId, Date startTime, Integer source, Long chargingStationId, String tenantId);
} }

View File

@ -1405,11 +1405,11 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
} }
//判断是否有活动 //判断是否有活动
@Override
public Map<String,Object> activityDiscountTime(Long userId,Date startTime,Integer source,Long chargingStationId,String tenantId){ public Map<String,Object> activityDiscountTime(Long userId,Date startTime,Integer source,Long chargingStationId,String tenantId){
Map<String,Object> map =new HashMap<>(); Map<String,Object> map =new HashMap<>();
List<XhpcActivityDiscountDto> activityDiscountTime = xhpcChargingStationMapper.getActivityDiscountTime(userId, DateUtil.formatDateTime(startTime), source, chargingStationId, tenantId); List<XhpcActivityDiscountDto> activityDiscountTime = xhpcChargingStationMapper.getActivityDiscountTime(userId, DateUtil.formatDateTime(startTime), source, chargingStationId, tenantId);
if(activityDiscountTime !=null && activityDiscountTime.size()>0){ if(activityDiscountTime !=null && activityDiscountTime.size()>0){
//折扣电费服务费 //折扣电费服务费
BigDecimal totalDiscountRate =new BigDecimal(0); BigDecimal totalDiscountRate =new BigDecimal(0);
int totalDiscountType = 0; int totalDiscountType = 0;

View File

@ -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.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService; import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.domain.XhpcTerminal; import com.xhpc.common.domain.XhpcTerminal;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.LogUserUtils; import com.xhpc.common.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser; import com.xhpc.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
/** /**
@ -32,6 +34,9 @@ public class XhpcTerminalServiceImpl extends BaseService implements IXhpcTermina
private IXhpcChargingStationService xhpcChargingStationService; private IXhpcChargingStationService xhpcChargingStationService;
@Autowired @Autowired
private LogUserUtils logUserUtils; private LogUserUtils logUserUtils;
@Autowired
private TokenService tokenService;
/** /**
* PC端页面统计 * PC端页面统计
* *
@ -125,7 +130,35 @@ public class XhpcTerminalServiceImpl extends BaseService implements IXhpcTermina
//HH:mm:ss //HH:mm:ss
String tiem = DateUtil.formatTime(new Date()); String tiem = DateUtil.formatTime(new Date());
Map<String, Object> xhpcRateTime = xhpcRateTimeService.getXhpcRateTime(tiem, chargingStationId); Map<String, Object> xhpcRateTime = xhpcRateTimeService.getXhpcRateTime(tiem, chargingStationId);
LoginUser loginUser = tokenService.getLoginUser();
if (xhpcRateTime != null) { if (xhpcRateTime != null) {
if(loginUser !=null){
BigDecimal serviceFee =new BigDecimal(xhpcRateTime.get("serviceFee").toString());
BigDecimal powerFee =new BigDecimal(xhpcRateTime.get("powerFee").toString());
Map<String, Object> 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); map.putAll(xhpcRateTime);
} }
//图片信息 //图片信息

View File

@ -983,7 +983,7 @@
xad.check_by as checkBy, xad.check_by as checkBy,
xad.check_time as checkTime, xad.check_time as checkTime,
xat.discount_type discountType, xat.discount_type discountType,
xad.applet_activity_name appletActivityName, xat.applet_activity_name appletActivityName,
xat.discount_rate discountRate xat.discount_rate discountRate
from xhpc_activity_discount as xad 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 join xhpc_activity_template as xat on xat.activity_template_id = xad.template_id and xat.del_flag =0 and xat.status=1