适配小桔订单结算

This commit is contained in:
yuyang 2022-05-05 14:12:56 +08:00
parent 3a2fb41228
commit c95150946a
20 changed files with 404 additions and 288 deletions

View File

@ -378,56 +378,108 @@ public class XhpcPileOrderController extends BaseController {
BigDecimal t2powerFee =new BigDecimal(0);
BigDecimal t3powerFee =new BigDecimal(0);
BigDecimal t4powerFee =new BigDecimal(0);
BigDecimal t1serviceFee =new BigDecimal(0);
BigDecimal t2serviceFee =new BigDecimal(0);
BigDecimal t3serviceFee =new BigDecimal(0);
BigDecimal t4serviceFee =new BigDecimal(0);
//费率计费模型
List<XhpcRate> rateModelList = xhpcChargeOrderService.getRateModelId(xhpcChargeOrder.getRateModelId());
logger.info("&&&&&&&&&&&&&&&&&&&&&&&&&&&&订单号:"+xhpcChargeOrder.getSerialNumber()+"&&&&&&&&&&&&&&费率模型id"+xhpcChargeOrder.getRateModelId());
for (XhpcRate xhpcRate:rateModelList) {
if("00".equals(xhpcRate.getRateValue())){
t1powerFee = xhpcRate.getPowerFee();
t1serviceFee =xhpcRate.getServiceFee();
}
if("01".equals(xhpcRate.getRateValue())){
t2powerFee = xhpcRate.getPowerFee();
t2serviceFee =xhpcRate.getServiceFee();
}
if("02".equals(xhpcRate.getRateValue())){
t3powerFee = xhpcRate.getPowerFee();
t3serviceFee = xhpcRate.getServiceFee();
}
if("03".equals(xhpcRate.getRateValue())){
t4powerFee = xhpcRate.getPowerFee();
t4serviceFee =xhpcRate.getServiceFee();
}
}
//总电费
BigDecimal powerPrice =new BigDecimal(0);
Integer totalPower =0;
if(!"0".equals(cacheOrderData.getT1PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT2PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT3PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT4PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
powerPrice =powerPrice.setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal servicePrice =new BigDecimal(0);
//总服务费
BigDecimal servicePrice = money.subtract(powerPrice);
//防止出现负数
if(powerPrice.compareTo(money)>0){
powerPrice =money;
if(xhpcChargeOrder.getUserId()==4 && xhpcChargeOrder.getSource()==1){
//因桩有误差电费和服务费重新计算
if(!"0".equals(cacheOrderData.getT1PowerQuantity().toString())){
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
BigDecimal multiply1 = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal multiply2 = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1serviceFee).setScale(2, BigDecimal.ROUND_HALF_UP);
powerPrice=powerPrice.add(multiply1);
servicePrice=servicePrice.add(multiply2);
}
if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){
totalPower =totalPower+cacheOrderData.getT2PowerQuantity();
BigDecimal multiply1 = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal multiply2 = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2serviceFee).setScale(2, BigDecimal.ROUND_HALF_UP);
powerPrice=powerPrice.add(multiply1);
servicePrice=servicePrice.add(multiply2);
}
if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){
totalPower =totalPower+cacheOrderData.getT3PowerQuantity();
BigDecimal multiply1 = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal multiply2 = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3serviceFee).setScale(2, BigDecimal.ROUND_HALF_UP);
powerPrice=powerPrice.add(multiply1);
servicePrice=servicePrice.add(multiply2);
}
if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){
totalPower =totalPower+cacheOrderData.getT4PowerQuantity();
BigDecimal multiply1 = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal multiply2 = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4serviceFee).setScale(2, BigDecimal.ROUND_HALF_UP);
powerPrice=powerPrice.add(multiply1);
servicePrice=servicePrice.add(multiply2);
}
powerPrice =powerPrice.setScale(2,BigDecimal.ROUND_HALF_UP);
//总服务费
servicePrice =servicePrice.setScale(2,BigDecimal.ROUND_HALF_UP);
//防止出现负数
if(powerPrice.add(servicePrice).compareTo(money)==-1){
if(powerPrice.compareTo(money)==1){
powerPrice =money;
servicePrice = money.subtract(powerPrice);
}else{
servicePrice = money.subtract(powerPrice);
}
}
}else{
if(!"0".equals(cacheOrderData.getT1PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT2PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT3PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPower =totalPower+cacheOrderData.getT4PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
powerPrice =powerPrice.setScale(2,BigDecimal.ROUND_HALF_UP);
//总服务费
servicePrice = money.subtract(powerPrice);
//防止出现负数
if(powerPrice.compareTo(money)==1){
powerPrice =money;
servicePrice = money.subtract(powerPrice);
}
}
//剩余的电费
BigDecimal surplusPowerPrice = powerPrice;

View File

@ -577,7 +577,11 @@ public class XhpcHistoryOrderController extends BaseController {
if(xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), rateModelId);
String endTime1 = DateUtil.formatTime(endTime);
if("00:00:00".equals(endTime1)){
endTime1="23:59:59";
}
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), endTime1, rateModelId);
Map<String, Object> map = reatTimeList.get(0);
xhpcSt.setElecPriceEvcs(new BigDecimal(map.get("powerFee").toString()));
xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString()));
@ -858,6 +862,9 @@ public class XhpcHistoryOrderController extends BaseController {
private Map<String, Object> getReatTimeList(String startTime,String endTime,Long rateModelId) {
Map<String, Object> map =new HashMap<>();
if("00:00:00".equals(endTime)){
endTime="23:59:59";
}
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime,endTime, rateModelId);
for (int j = 0; j < reatTimeList.size(); j++) {
Map<String, Object> map1 = reatTimeList.get(j);

View File

@ -173,14 +173,25 @@ public class XhpcStatisticsController extends BaseController {
* @return
*/
@GetMapping("/getOperatorList")
public AjaxResult getOperatorList(HttpServletRequest request,Long operatorId, @RequestParam("userId") Long userId, @RequestParam("type")Integer type)
public AjaxResult getOperatorList(HttpServletRequest request,Long operatorId, @RequestParam("userId") Long userId, @RequestParam("type")Integer type,String tenantId)
{
if (type == null || type==3) {
return AjaxResult.success();
}
return xhpcStatisticsService.getOperatorList(request,operatorId, userId, type);
return xhpcStatisticsService.getOperatorList(request,operatorId, userId, type,tenantId);
}
/**
* 租户列表
* @return
*/
@GetMapping("/getTenantList")
public AjaxResult getTenantList()
{
return xhpcStatisticsService.getTenantList();
}
/**
* 流量方列表
* @param internetUserId 流量方id
@ -226,8 +237,6 @@ public class XhpcStatisticsController extends BaseController {
/**
* 订单来源第三方支付宝微信运营商权限划分
* @param internetUserIds 订单来源集合
* @param userId 用户id
* @param type 1 平台 2 运营商 3流量方
* @return
*/
@GetMapping("/getSumSourceList")

View File

@ -117,7 +117,7 @@ public interface XhpcStatisticsServiceMapper {
*/
List<Map<String, Object>> getOperatorList(@Param("operatorId")Long operatorId,@Param("userId")Long userId,@Param("type")Integer type,@Param("tenantId")String tenantId);
List<Map<String, Object>> getTenantList(@Param("userId")Long userId,@Param("type")Integer type);
/**
* 流量方列表
* @param internetUserId 流量方id

View File

@ -124,7 +124,10 @@ public interface IXhpcStatisticsService {
* @param type 1 平台 2 运营商 3流量方
* @return
*/
AjaxResult getOperatorList(HttpServletRequest request,Long operatorId,Long userId,Integer type);
AjaxResult getOperatorList(HttpServletRequest request,Long operatorId,Long userId,Integer type,String tenantId);
AjaxResult getTenantList();
/**
* 流量方列表

View File

@ -652,7 +652,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
xhpcChargeOrderMapper.updateStatus(2,chargeOrderId);
}
}else{
xhpcChargeOrderMapper.updateStatus(2,chargeOrderId);
if(cacheRealtimeData.getCreateTime() !=null){
long l = System.currentTimeMillis();//
Date date = DateUtil.parse(cacheRealtimeData.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
if(l-date.getTime()>360000){
xhpcChargeOrderMapper.updateStatus(2,chargeOrderId);
}
}else{
xhpcChargeOrderMapper.updateStatus(2,chargeOrderId);
}
}
}
}

View File

@ -445,12 +445,12 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
Date updateTime = DateUtil.endOfDay(startTime2);
Map<String, Object> map1 = getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list);
//获取
BigDecimal powerPriceTotal1 = new BigDecimal(map1.get("powerPriceTotal").toString());
BigDecimal servicePriceTotal1 = new BigDecimal(map1.get("servicePriceTotal").toString());
// BigDecimal powerPriceTotal1 = new BigDecimal(map1.get("powerPriceTotal").toString());
// BigDecimal servicePriceTotal1 = new BigDecimal(map1.get("servicePriceTotal").toString());
//明天
DateTime tomorrow = DateUtil.offsetDay(startTime2, 1);
Date startTime3 = DateUtil.beginOfDay(tomorrow);
Map<String, Object> map2 = getBigDecimal(totalPrice, powerPriceTotal1, servicePriceTotal1, chargeOrder, rateModelId, startTime3, updateTime2, chargingDegree, list);
Map<String, Object> map2 = getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime3, updateTime2, chargingDegree, list);
return map2;
}
}
@ -466,6 +466,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
map1.put("chargingDegree", chargeOrder.getChargingDegree());
map1.put("actPrice", totalPrice);
list.add(map1);
map.put("powerPriceTotal", 0);
map.put("servicePriceTotal", 0);
map.put("list", list);//数据列表
return map;
}
@ -482,13 +484,19 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
map1.put("actPrice", totalPrice);
list.add(map1);
map.put("list", list);//数据列表
map.put("powerPriceTotal", 0);
map.put("servicePriceTotal", 0);
return map;
}
//每分钟多少度
BigDecimal degree = chargingDegree.divide(decimal, 2, BigDecimal.ROUND_HALF_UP);
//获取费率时间段
String startTime = DateUtil.formatTime(startTime2);
String endTime = DateUtil.formatTime(updateTime2);
if("00:00:00".equals(endTime)){
endTime="23:59:59";
}
List<Map<String, Object>> reatTimeList = getReatTimeList(startTime, endTime, rateModelId);
if (reatTimeList != null && reatTimeList.size() > 0) {
Map<String, Object> map1 = new HashMap<>();
@ -504,6 +512,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
map1.put("chargingDegree", chargeOrder.getChargingDegree());
map1.put("actPrice", totalPrice);
list.add(map1);
powerPriceTotal =powerPriceTotal.add(powerFee.multiply(degree).setScale(2, BigDecimal.ROUND_HALF_UP));
servicePriceTotal =servicePriceTotal.add(servicePrice.multiply(chargingDegree).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
for (int i = 0; i < reatTimeList.size(); i++) {
Map<String, Object> objectMap = reatTimeList.get(i);
@ -528,7 +538,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
}
}
}
map.put("powerPriceTotal", powerPriceTotal);
map.put("servicePriceTotal", servicePriceTotal);
map.put("list", list);//数据列表
//map.put("chargingTimeTotal",chargeOrder.getChargingTime());//总时长
//map.put("powerPriceTotal",powerPriceTotal);//总电费单价(/)
@ -567,6 +578,9 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
//获取费率时间段
String startTime = DateUtil.formatTime(startTime2);
String endTime = DateUtil.formatTime(updateTime2);
if("00:00:00".equals(endTime)){
endTime="23:59:59";
}
List<Map<String, Object>> reatTimeList = getReatTimeList(startTime, endTime, rateModelId);
if (reatTimeList != null && reatTimeList.size() > 0) {
int size = reatTimeList.size();
@ -602,6 +616,9 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
private BigDecimal getBigDecimal(Long rateModelId, String startTime, String updateTime, BigDecimal powerPriceTotal, BigDecimal divide) {
if("00:00:00".equals(updateTime)){
updateTime="23:59:59";
}
List<Map<String, Object>> reatTimeList = getReatTimeList(startTime,updateTime, rateModelId);
for (int i = 0; i <reatTimeList.size() ; i++) {
int size = reatTimeList.size();

View File

@ -467,41 +467,20 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
Double totalPower = xhpcHistoryOrder.getTotalPower();
//yyyy-mm-dd(当前时间)
String parse2 = DateUtil.formatDate(startTime);
long time1 = xhpcChargeOrder.getStartTime().getTime();
long time2 = xhpcChargeOrder.getEndTime().getTime();
long time1 = startTime.getTime();
long time2 = endTime.getTime();
if( time1 != time2){
if( time1 != time2 && time2>time1){
List<XhpcActivityInternetDomainDto> activityStationTime = xhpcRealTimeOrderMapper.getActivityStationTime(internetUserId, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime), xhpcChargeOrder.getChargingStationId(), xhpcChargeOrder.getTenantId());
//activityInternetTime 用户充电时间大于活动时间快电恒大不做活动计算
boolean activityInternetTime =true;
// activityTime 用户充电开始时间是否活动时间
boolean activityStartTime =false;
// activityTime 用户充电结束时间是否活动时间
boolean activityEndTime =true;
//1时间没有跨天
DateTime parse = DateUtil.parse(DateUtil.format(startTime, "yyyy-MM-dd"), "yyyy-MM-dd");
DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd");
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
if(activityStationTime !=null && activityStationTime.size()>0){
XhpcActivityInternetDomainDto activityInternet1 =activityStationTime.get(0);
if(activityInternet1.getStartTime().getTime()-time1>0){
activityStartTime =true;
if(xhpcChargeOrder.getUserId()==1L || xhpcChargeOrder.getUserId()==2L){
activityInternetTime =false;
}
}
int size = activityStationTime.size();
if(size==1){
if(time2-activityInternet1.getEndTime().getTime()>0){
activityEndTime =false;
}
}else{
if(time2-activityStationTime.get(1).getEndTime().getTime()>0){
activityEndTime =false;
}
}
}
if(activityStationTime !=null && activityStationTime.size()>0 && activityStationTime.size()<=2 && activityInternetTime){
if(activityStationTime !=null && activityStationTime.size()==1){
logger.info("<<<<<<<<<<<<<<<有流量方活动>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber());
judge =true;
int number = activityStationTime.size();
String start = DateUtil.formatTime(startTime);
String end = DateUtil.formatTime(endTime);
String activityId ="";
@ -510,98 +489,17 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
List<XhpcActivityFormulaDomainDto> activityFormulaTime1 =new ArrayList<>();
List<XhpcActivityFormulaDomainDto> activityFormulaTime2 =new ArrayList<>();
XhpcActivityInternetDomainDto activityInternet1 =new XhpcActivityInternetDomainDto();
XhpcActivityInternetDomainDto activityInternet2 =new XhpcActivityInternetDomainDto();
Long rateModelId = xhpcChargeOrder.getRateModelId();
if(number==2){
if(betweenDay>0){
activityInternet1 = activityStationTime.get(0);
activityInternet2 = activityStationTime.get(1);
if(activityStartTime){
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), "00:00:00", "24:00:00");
activityFormulaTime2 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet2.getActivityId(), "00:00:00", end);
}else{
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, "24:00:00");
activityFormulaTime2 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet2.getActivityId(), "00:00:00", end);
}
activityId =activityInternet1.getActivityId()+","+activityInternet2.getActivityId();
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, "24:00:00");
activityFormulaTime2 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), "00:00:00", start);
activityId =activityInternet1.getActivityId()+"";
}else{
activityInternet1 = activityStationTime.get(0);
if(activityStartTime){
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), "00:00:00", end);
}else{
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, end);
}
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, end);
activityId =activityInternet1.getActivityId()+"";
}
if(activityStartTime){
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(start, "00:00:00", rateModelId);
if(reatTimeList.size()>0){
String substring = internetSerialNumber.substring(0, 9);
Map<String, Object> operatorIdEvcs = xhpcRealTimeOrderMapper.getOperatorIdEvcs(substring);
if(operatorIdEvcs !=null){
if(operatorIdEvcs.get("operatorIdEvcs")!=null && operatorIdEvcs.get("commissionType")!=null && operatorIdEvcs.get("commissionRate")!=null){
BigDecimal commissionRate = new BigDecimal(operatorIdEvcs.get("commissionRate").toString()).divide(new BigDecimal(100));
String commissionType = operatorIdEvcs.get("commissionType").toString();
for (int i = 0; i < reatTimeList.size(); i++) {
Map<String, Object> map = reatTimeList.get(i);
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString());
String startTime1 =map.get("startTime").toString();
String endTime1 =map.get("endTime").toString();
BigDecimal degree =new BigDecimal(0);
if(DateUtil.parse(start).getTime() - DateUtil.parse(startTime1).getTime()>=0){
if(DateUtil.parse(end).getTime() - DateUtil.parse(endTime1).getTime()>=0){
degree =new BigDecimal(xhpcRealTimeOrderMapper.getRealTimeOrderTime(chargeOrderId, parse2+" "+start, parse2+" "+endTime1)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
degree =new BigDecimal(xhpcRealTimeOrderMapper.getRealTimeOrderTime(chargeOrderId, parse2+" "+start, parse2+" "+end)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}else{
if(DateUtil.parse(end).getTime() - DateUtil.parse(endTime1).getTime()>=0){
degree =new BigDecimal(xhpcRealTimeOrderMapper.getRealTimeOrderTime(chargeOrderId, parse2+" "+startTime1, parse2+" "+endTime1)).setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
degree =new BigDecimal(xhpcRealTimeOrderMapper.getRealTimeOrderTime(chargeOrderId, parse2+" "+startTime1, parse2+" "+end)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}
//挡前服务费
BigDecimal activityServicePrice1 = serviceFee.multiply(degree);
//活动总服务费
activityServicePriceTotal = activityServicePriceTotal.add(activityServicePrice1);
//挡前电费
BigDecimal activityPowerPrice1 = powerFee.multiply(degree);
//活动总电费
activityPowerPriceTotal = activityPowerPriceTotal.add(activityPowerPrice1);
//活动总金额
activityTotalPriceTotal = activityTotalPriceTotal.add(activityServicePrice1.add(activityPowerPrice1));
if(new BigDecimal(0).compareTo(commissionRate)==-1){
if("0".equals(commissionType) || "1".equals(commissionType)|| "2".equals(commissionType)){
//流量方的钱
if("0".equals(commissionType)){
BigDecimal decimal1 = activityPowerPrice1.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal decimal2 = activityServicePrice1.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP);
internetCommission = internetCommission.add(decimal1.add(decimal2));
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1.subtract(decimal1));
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(decimal2));
}else if("1".equals(commissionType)){
BigDecimal decimal2 = activityServicePrice1.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP);
internetSvcCommission = internetSvcCommission.add(decimal2);
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(decimal2));
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
}else{
//电量抽成
BigDecimal commissionRate1 = degree.multiply(new BigDecimal(operatorIdEvcs.get("commissionRate").toString())).setScale(2, BigDecimal.ROUND_HALF_UP);
internetDegreeCommission = internetDegreeCommission.add(commissionRate1);
//减服务费
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(internetDegreeCommission));
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
}
}
}
chargingDegree = chargingDegree.add(degree);
}
}
}
}
}
for (int j = 0; j < activityFormulaTime1.size(); j++) {
XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime1.get(j);
//计费类型
@ -611,7 +509,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
//计算公式
String computeFormula = activityFormula.getComputeFormula();
BigDecimal degree =new BigDecimal(0);
if (activityFormulaTime2.size()==0 && activityFormulaTime1.size()-1==j && activityEndTime) {
if (activityFormulaTime2.size()==0 && activityFormulaTime1.size()-1==j) {
degree = new BigDecimal(totalPower).subtract(chargingDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
}else{
degree =getRealOrderTime(chargeOrderId, parse2+" "+activityFormula.getStartTime(), parse2+" "+activityFormula.getEndTime()).setScale(2,BigDecimal.ROUND_HALF_UP);;
@ -653,14 +551,14 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
if(activityFormulaTime2.size()>0){
for (int j = 0; j < activityFormulaTime2.size(); j++) {
//计费类型
int computeType = activityInternet2.getComputeType();
int computeType = activityInternet1.getComputeType();
XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime1.get(j);
BigDecimal activityServicePriceFormula = activityFormula.getServicePrice();
BigDecimal activityPowerPriceFormula = activityFormula.getPowerPrice();
//计算公式
String computeFormula = activityFormula.getComputeFormula();
BigDecimal degree =new BigDecimal(0);
if (activityFormulaTime2.size()-1==j && activityEndTime) {
if (activityFormulaTime2.size()-1==j) {
degree = new BigDecimal(totalPower).subtract(chargingDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
}else{
degree =getRealOrderTime(chargeOrderId, parse2+" "+activityFormula.getStartTime(), parse2+" "+activityFormula.getEndTime()).setScale(2,BigDecimal.ROUND_HALF_UP);;
@ -700,67 +598,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
chargingDegree = chargingDegree.add(degree);
}
}
if(!activityEndTime){
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList("00:00:00", end, rateModelId);
if(reatTimeList.size()>0){
String substring = internetSerialNumber.substring(0, 9);
Map<String, Object> operatorIdEvcs = xhpcRealTimeOrderMapper.getOperatorIdEvcs(substring);
if(operatorIdEvcs !=null){
if(operatorIdEvcs.get("operatorIdEvcs")!=null && operatorIdEvcs.get("commissionType")!=null && operatorIdEvcs.get("commissionRate")!=null){
BigDecimal commissionRate = new BigDecimal(operatorIdEvcs.get("commissionRate").toString()).divide(new BigDecimal(100));
String commissionType = operatorIdEvcs.get("commissionType").toString();
for (int i = 0; i < reatTimeList.size(); i++) {
Map<String, Object> map = reatTimeList.get(i);
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString());
String startTime1 =map.get("startTime").toString();
String endTime1 =map.get("endTime").toString();
BigDecimal degree =new BigDecimal(xhpcRealTimeOrderMapper.getRealTimeOrderTime(chargeOrderId, startTime1, endTime1));
//挡前服务费
BigDecimal activityServicePrice1 = serviceFee.multiply(degree);
//活动总服务费
activityServicePriceTotal = activityServicePriceTotal.add(activityServicePrice1);
//挡前电费
BigDecimal activityPowerPrice1 = powerFee.multiply(degree);
//活动总电费
activityPowerPriceTotal = activityPowerPriceTotal.add(activityPowerPrice1);
//活动总金额
activityTotalPriceTotal = activityTotalPriceTotal.add(activityServicePrice1.add(activityPowerPrice1));
if(new BigDecimal(0).compareTo(commissionRate)==-1){
if("0".equals(commissionType) || "1".equals(commissionType)|| "2".equals(commissionType)){
//流量方的钱
if("0".equals(commissionType)){
BigDecimal decimal1 = activityPowerPrice1.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal decimal2 = activityServicePrice1.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP);
internetCommission = internetCommission.add(decimal1.add(decimal2));
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1.subtract(decimal1));
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(decimal2));
}else if("1".equals(commissionType)){
BigDecimal decimal2 = activityServicePrice1.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP);
internetSvcCommission = internetSvcCommission.add(decimal2);
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(decimal2));
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
}else{
//电量抽成
BigDecimal commissionRate1 = degree.multiply(new BigDecimal(operatorIdEvcs.get("commissionRate").toString())).setScale(2, BigDecimal.ROUND_HALF_UP);
internetDegreeCommission = internetDegreeCommission.add(commissionRate1);
//减服务费
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(internetDegreeCommission));
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
}
}
}
chargingDegree = chargingDegree.add(degree);
}
}
}
}
}
promotionDiscount = money.subtract(activityTotalPriceTotal);
xhpcHistoryOrder.setActivityId(activityId);
}else{
if(activityStationTime.size()>2){
xhpcHistoryOrder.setActivityId("活动有问题");
if(activityStationTime.size()>1){
xhpcHistoryOrder.setActivityId("同一时间活动有2个");
}else{
xhpcHistoryOrder.setActivityId("无活动");
}
@ -838,7 +680,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
}
}else{
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(start, "00:00:00", xhpcChargeOrder.getRateModelId());
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(start, "23:59:59", xhpcChargeOrder.getRateModelId());
for (int j = 0; j < reatTimeList.size(); j++) {
BigDecimal powerFee = new BigDecimal(0);
BigDecimal serviceFee = new BigDecimal(0);
@ -1531,6 +1374,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
private BigDecimal getBigDecimal(Long rateModelId, String startTime, String updateTime, BigDecimal powerPriceTotal, BigDecimal divide) {
if("00:00:00".equals(updateTime)){
updateTime="23:59:59";
}
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime,updateTime, rateModelId);
for (int i = 0; i <reatTimeList.size() ; i++) {
int size = reatTimeList.size();

View File

@ -14,7 +14,6 @@ import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.order.domain.XhpcStatisticsStation;
import com.xhpc.order.domain.XhpcStatisticsTimeInterval;
import com.xhpc.order.mapper.XhpcStatisticsServiceMapper;
import com.xhpc.order.service.IXhpcHistoryOrderService;
import com.xhpc.order.service.IXhpcStatisticsService;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
@ -325,13 +324,13 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, logOperatorId, 1,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, logOperatorId, 1,null));
}else{
//查询赋值的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, sysUserId, 2,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, sysUserId, 2,null));
}
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, sysUserId, 0,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, sysUserId, 0,null));
}
}
@ -356,34 +355,65 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingPileList(chargingStationId,operatorId, logOperatorId, 1,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingPileList(chargingStationId,operatorId, logOperatorId, 1,null));
}else{
//查询赋值的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingPileList(chargingStationId,operatorId, sysUserId, 2,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingPileList(chargingStationId,operatorId, sysUserId, 2,null));
}
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingPileList(chargingStationId,operatorId, sysUserId, 0,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingPileList(chargingStationId,operatorId, sysUserId, 0,null));
}
}
@Override
public AjaxResult getOperatorList(HttpServletRequest request,Long operatorId, Long userId, Integer type) {
public AjaxResult getOperatorList(HttpServletRequest request,Long operatorId, Long userId, Integer type,String tenantId) {
//获取登陆用户
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long sysUserId = sysUser.getUserId();
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, logOperatorId, 1,tenantId));
if(tenantId !=null && "".equals(tenantId)){
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, logOperatorId, 1,tenantId));
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, logOperatorId, 1,null));
}
}else{
//查询赋值的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, sysUserId, 2,tenantId));
if(tenantId !=null && "".equals(tenantId)){
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, sysUserId, 2,tenantId));
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, sysUserId, 2,null));
}
}
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, sysUserId, 0,tenantId));
if(tenantId !=null && "".equals(tenantId)){
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, sysUserId, 0,tenantId));
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, sysUserId, 0,null));
}
}
}
@Override
public AjaxResult getTenantList() {
//获取登陆用户
LoginUser loginUser = tokenService.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long sysUserId = sysUser.getUserId();
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getTenantList(logOperatorId, 1));
}else{
//查询赋值的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getTenantList(sysUserId, 2));
}
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getTenantList(sysUserId, 0));
}
}
@ -407,13 +437,13 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, logOperatorId, 1,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, logOperatorId, 1,null));
}else{
//查询赋值的场站
return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, sysUserId, 2,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, sysUserId, 2,null));
}
}else{
return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, sysUserId, 0,tenantId));
return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, sysUserId, 0,null));
}
}
@ -557,6 +587,9 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
map.put("powerPrice","0.00");
map.put("servicePrice","0.00");
map.put("totalPrice","0.00");
map.put("activityPowerPriceTotal","0.00");
map.put("activityServicePriceTotal","0.00");
map.put("activityTotalPrice","0.00");
map.put("promotionDiscount","0.00");
map.put("actPrice","0.00");
map.put("actPowerPrice","0.00");

View File

@ -825,9 +825,10 @@
rt.rate_time_id in (
SELECT rate_time_id FROM xhpc_rate_time WHERE rate_model_id = #{rateModelId} AND start_time &lt;= #{startTime} AND replace(end_time, '00:00:00', '23:59:59') &gt;= #{startTime} AND del_flag=0
)
AND rt.rate_time_id in (
or rt.rate_time_id in (
SELECT rate_time_id FROM xhpc_rate_time WHERE rate_model_id = #{rateModelId} AND start_time &lt;= #{endTime} AND replace(end_time, '00:00:00', '23:59:59') &gt;= #{endTime} AND del_flag=0
)
and rt.rate_model_id = #{rateModelId}
</select>
<select id="getById" resultType="map">

View File

@ -751,8 +751,8 @@
from xhpc_activity_formula
where
activity_id = #{activityId}
and activity_formula_id &gt;= (SELECT activity_formula_id FROM xhpc_activity_formula WHERE start_time &lt;= #{startTime} AND end_time &gt;= #{startTime} and activity_id = #{activityId})
and activity_formula_id &lt;= (SELECT activity_formula_id FROM xhpc_activity_formula WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{endTime} and activity_id = #{activityId})
and activity_formula_id in (SELECT activity_formula_id FROM xhpc_activity_formula WHERE start_time &lt;= #{startTime} AND end_time &gt;= #{startTime} and activity_id = #{activityId})
or activity_formula_id in (SELECT activity_formula_id FROM xhpc_activity_formula WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{endTime} and activity_id = #{activityId})
order by activity_formula_id
</select>
@ -775,10 +775,7 @@
and find_in_set(#{chargingStationId}, station_list)
and internet_name = (select name from xhpc_internet_user where internet_user_id =#{internetUserId} and del_flag =0)
and status =3 and del_flag=0
and activity_id in (
SELECT activity_id FROM xhpc_activity_internet WHERE start_time &lt;= #{startTime} AND end_time &gt;= #{startTime} and status =3 and del_flag=0)
and activity_id in (
SELECT activity_id FROM xhpc_activity_internet WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{endTime} and status =3 and del_flag=0)
and start_time &lt;= #{startTime} AND end_time &gt;= #{startTime}
order by end_time
</select>

View File

@ -47,7 +47,7 @@
format(ifnull(sum(activity_total_price),0), 2) activityTotalPrice,
format(ifnull(sum(charging_degree),0), 2) chargingDegree,
format(ifnull(sum(charging_time),0), 2) chargingTime,
format(ifnull(sum(charging_number),0), 2) chargingNumber,
ifnull(sum(charging_number),0) chargingNumber,
format(ifnull(sum(power_price),0), 2) powerPrice,
format(ifnull(sum(service_price),0), 2) servicePrice,
format(ifnull(sum(total_price),0), 2) totalPrice,
@ -116,7 +116,7 @@
select
format(ifnull(sum(charging_degree),0), 2) chargingDegree,
format(ifnull(sum(charging_time),0), 2) chargingTime,
format(ifnull(sum(charging_number),0), 2) chargingNumber,
ifnull(sum(charging_number),0) chargingNumber,
format(ifnull(sum(power_price),0), 2) powerPrice,
format(ifnull(sum(service_price),0), 2) servicePrice,
format(ifnull(sum(total_price),0), 2) totalPrice,
@ -167,7 +167,7 @@
select
format(ifnull(sum(ss.charging_degree),0), 2) chargingDegree,
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
format(ifnull(sum(ss.charging_number),0), 2) chargingNumber,
ifnull(sum(ss.charging_number),0) chargingNumber,
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
@ -227,7 +227,7 @@
select
format(ifnull(sum(ss.charging_degree),0), 2) chargingDegree,
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
format(ifnull(sum(ss.charging_number),0), 2) chargingNumber,
ifnull(sum(ss.charging_number),0) chargingNumber,
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
@ -279,7 +279,7 @@
select
format(ifnull(sum(ss.charging_degree),0), 2) chargingDegree,
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
format(ifnull(sum(ss.charging_number),0), 2) chargingNumber,
ifnull(sum(ss.charging_number),0) chargingNumber,
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
@ -327,7 +327,7 @@
select
format(ifnull(sum(ss.charging_degree),0), 2) chargingDegree,
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
format(ifnull(sum(ss.charging_number),0), 2) chargingNumber,
ifnull(sum(ss.charging_number),0) chargingNumber,
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
@ -392,6 +392,9 @@
<if test="tenantId !=null and tenantId !=''">
and tenant_id = #{tenantId}
</if>
<if test="operatorId !=null">
and operator_id =#{operatorId}
</if>
</select>
<select id="getChargingPileList" resultType="map">
@ -433,6 +436,23 @@
</if>
</select>
<select id="getTenantList" resultType="map">
select
xt.tenant_id as tenantId,
xt.tenant_name as tenantName
from xhpc_charging_station as xcs
join xhpc_tenant as xt on xt.tenant_id = xcs.tenant_id
where 1=1
<if test="type==1">
and operator_id=#{userId}
</if>
<if test="type==2">
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
group by xt.tenant_id
</select>
<select id="getInternetUserIList" resultType="map">
select
internet_user_id as operinternetUserId,
@ -471,7 +491,7 @@
select
format(ifnull(sum(charging_degree),0), 2) chargingDegree,
format(ifnull(sum(charging_time),0), 2) chargingTime,
format(ifnull(sum(charging_number),0), 2) chargingNumber,
ifnull(sum(charging_number),0) chargingNumber,
format(ifnull(sum(power_price),0), 2) powerPrice,
format(ifnull(sum(service_price),0), 2) servicePrice,
format(ifnull(sum(total_price),0), 2) totalPrice,
@ -961,7 +981,7 @@
select
format(ifnull(sum(ss.charging_degree),0), 2) chargingDegree,
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
format(ifnull(sum(ss.charging_number),0), 2) chargingNumber,
ifnull(sum(ss.charging_number),0) chargingNumber,
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,

View File

@ -24,7 +24,7 @@ public class XhpcMechanismController extends BaseController {
private IMechanismService mechanismService;
/**
* 数据维度
* @param status 0 地区 1.运营商 2. 运营商-地区
* @param status 0 地区 1.运营商 2. 运营商-地区 3 租户下所有运营商场站
* @return
*/
@GetMapping(value = "/getMechanism")

View File

@ -76,6 +76,8 @@ public class XhpcOperatorController extends BaseController {
if (t2.compareTo(t4) < 0) {
return AjaxResult.error("运维提成不能小于0");
}
}else{
return AjaxResult.error("平台提成或运维提成不能小于0");
}
if("".equals(xhpcOperator.getSoc()) || xhpcOperator.getSoc() ==null){
return AjaxResult.error("请填写充电终止的soc");

View File

@ -123,13 +123,13 @@ public class XhpcOperator extends BaseEntity {
* 平台提成
*/
@NotNull(message = "平台提成不能为空")
private Double platformCommissionRate;
private String platformCommissionRate;
/**
* 运维提成
*/
@NotNull(message = "运维提成不能为空")
private Double maintenanceCommissionRate;
private String maintenanceCommissionRate;
/**
* 营业执照id
@ -277,19 +277,19 @@ public class XhpcOperator extends BaseEntity {
this.commissionType = commissionType;
}
public Double getPlatformCommissionRate() {
public String getPlatformCommissionRate() {
return platformCommissionRate;
}
public void setPlatformCommissionRate(Double platformCommissionRate) {
public void setPlatformCommissionRate(String platformCommissionRate) {
this.platformCommissionRate = platformCommissionRate;
}
public Double getMaintenanceCommissionRate() {
public String getMaintenanceCommissionRate() {
return maintenanceCommissionRate;
}
public void setMaintenanceCommissionRate(Double maintenanceCommissionRate) {
public void setMaintenanceCommissionRate(String maintenanceCommissionRate) {
this.maintenanceCommissionRate = maintenanceCommissionRate;
}

View File

@ -41,7 +41,7 @@ public interface MechanismMapper {
* 通过登录用户分组查询运营商
* @return 结果
*/
public List<Map<String, Object>> groupOperatorById(@Param("userId") Long userId, @Param("type") Integer type,@Param("code") String cityCode);
public List<Map<String, Object>> groupOperatorById(@Param("userId") Long userId, @Param("type") Integer type,@Param("code") String cityCode,@Param("tenantId") String tenantId);
/**
* 通过登录用户分组查询场站
@ -67,16 +67,14 @@ public interface MechanismMapper {
/**
* 增加一条平台充值记录
* @param userId
* @param amount
* @param orderNumber
* @param type
* @param source
* @param date
* @return
*/
int insertRechargeOrder(XhpcRechargeOrder xhpcRechargeOrder);
int insertUserAccount(@Param("userId")Long userId,@Param("amount")BigDecimal amount,@Param("remainingSum")BigDecimal remainingSum,@Param("chargeOrderId")Long chargeOrderId,@Param("rechargeOrderId")Long rechargeOrderId,@Param("refundOrderId")Long refundOrderId,@Param("type")Integer type,@Param("tenantId")String tenantId,@Param("source")Integer source,@Param("createTime") Date createTime);
//获取租户
List<Map<String, Object>> getTenantList(@Param("userId")Long userId,@Param("number")Integer number);
}

View File

@ -4,8 +4,12 @@ import cn.hutool.core.date.DateUtil;
import com.xhpc.common.core.constant.StatusConstants;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcRechargeOrder;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.user.dto.MechanismDto;
import com.xhpc.user.mapper.MechanismMapper;
import com.xhpc.user.service.IMechanismService;
@ -27,34 +31,37 @@ public class IMechanismServiceImpl implements IMechanismService {
@Autowired
private MechanismMapper mechanismMapper;
@Autowired
private TokenService tokenService;
@Override
public List<MechanismDto> dataList(Integer status) {
//获取登陆用户
Long logUserId = SecurityUtils.getUserId();
LoginUser loginUser = tokenService.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long logUserId = sysUser.getUserId();
int type =1;
//根据权限获取场站
if(logUserId !=1){
Map<String, Object> landUser = mechanismMapper.getLandUser(logUserId);
if(landUser !=null){
if(landUser.get("userType") !=null){
if("01".equals(landUser.get("userType").toString())){
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
logUserId=logOperatorId;
type =1;
}else{
type =2;
}
}
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(logUserId)){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
logUserId=logOperatorId;
}else{
type =2;
}
}else{
type=0;
}
if(status==0){
return regionTree(logUserId,type);
return regionTree(logUserId,type,tenantId);
}else if(status==1){
return operatorTree(logUserId,type);
return operatorTree(logUserId,type,tenantId);
}else if(status==1){
return operatorRegionTree(logUserId,type,tenantId);
}else{
return operatorRegionTree(logUserId,type);
return tenantOperatorTree(logUserId,type);
}
}
@ -113,7 +120,7 @@ public class IMechanismServiceImpl implements IMechanismService {
* @param type
* @return
*/
public List<MechanismDto> regionTree(Long userId, Integer type){
public List<MechanismDto> regionTree(Long userId, Integer type,String tenantId){
List<MechanismDto> mechanismDtos =new ArrayList<>();
//
List<Map<String, Object>> list = mechanismMapper.groupProvinceById(userId, type,null);
@ -141,7 +148,7 @@ public class IMechanismServiceImpl implements IMechanismService {
mechanismArea.setLabel(areaMap.get("name").toString());
List<MechanismDto> mechanismOperatorList =new ArrayList<>();
//运营商
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, codeArea);
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, codeArea,tenantId);
for (Map<String, Object> operatorMap:operatorList) {
MechanismDto mechanismOperator =new MechanismDto();
String operatorId = operatorMap.get("operatorId").toString();
@ -176,9 +183,9 @@ public class IMechanismServiceImpl implements IMechanismService {
/**
* 运营商树
*/
public List<MechanismDto> operatorTree(Long userId, Integer type){
public List<MechanismDto> operatorTree(Long userId, Integer type,String tenantId){
List<MechanismDto> mechanismDtos =new ArrayList<>();
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null);
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null,tenantId);
if(operatorList !=null && operatorList.size()>0){
for (Map<String, Object> operatorMap:operatorList) {
MechanismDto mechanismOperator =new MechanismDto();
@ -208,10 +215,10 @@ public class IMechanismServiceImpl implements IMechanismService {
* @param type
* @return
*/
public List<MechanismDto> operatorRegionTree(Long userId, Integer type){
public List<MechanismDto> operatorRegionTree(Long userId, Integer type,String tenantId){
List<MechanismDto> mechanismDtos =new ArrayList<>();
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null);
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null,tenantId);
if(operatorList !=null && operatorList.size()>0){
for (Map<String, Object> operatorMap:operatorList) {
MechanismDto mechanismOperator =new MechanismDto();
@ -266,5 +273,55 @@ public class IMechanismServiceImpl implements IMechanismService {
}
}
return mechanismDtos;
}
/**
* 租户-运营商-场站
* @param userId
* @param type
* @return
*/
public List<MechanismDto> tenantOperatorTree(Long userId, Integer type){
List<MechanismDto> mechanismDtos =new ArrayList<>();
//查询租户
List<Map<String, Object>> tenantList = mechanismMapper.getTenantList(userId, type);
if(tenantList !=null && tenantList.size()>0){
for (Map<String, Object> tenantMap:tenantList) {
MechanismDto mechanismTenant =new MechanismDto();
String tenantId = tenantMap.get("tenantId").toString();
mechanismTenant.setId("Tenant"+tenantId);
mechanismTenant.setLabel(tenantMap.get("tenantName").toString());
List<MechanismDto> mechanismOperatorList =new ArrayList<>();
List<Map<String, Object>> operatorList = mechanismMapper.groupOperatorById(userId, type, null,tenantId);
if(operatorList !=null && operatorList.size()>0){
for (Map<String, Object> operatorMap:operatorList) {
MechanismDto mechanismOperator =new MechanismDto();
String operatorId = operatorMap.get("operatorId").toString();
mechanismOperator.setId("Yun"+operatorId);
mechanismOperator.setLabel(operatorMap.get("name").toString());
List<MechanismDto> mechanismdataList =new ArrayList<>();
//场站
List<Map<String, Object>> dataList = mechanismMapper.dataChargingStationId(userId, type, operatorId,null);
for (Map<String, Object> dataMap:dataList) {
MechanismDto mechanismData =new MechanismDto();
String codeData = dataMap.get("chargingStationId").toString();
mechanismData.setId(codeData);
mechanismData.setLabel(dataMap.get("name").toString());
mechanismdataList.add(mechanismData);
}
mechanismOperator.setChildren(mechanismdataList);
mechanismOperatorList.add(mechanismOperator);
}
}
mechanismTenant.setChildren(mechanismOperatorList);
mechanismDtos.add(mechanismTenant);
}
}
return mechanismDtos;
}
}

View File

@ -10,6 +10,7 @@ import com.xhpc.common.domain.XhpcChargingStation;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.DateUtil;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.user.constant.InvoiceMapHistoryOrderStatusConst;
import com.xhpc.user.constant.InvoiceStatusConst;
import com.xhpc.user.constant.IsReadStatusConst;
@ -358,6 +359,12 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
invoicedOrderResponse.setRecordsMonth(nextQueryParamDateStr);
}
invoicedOrderResponse.setItems(itemsDTOS);
try {
LoginUser loginUser = tokenService.getLoginUser();
getCreatorRead(loginUser.getUserid(),loginUser.getUserType(),loginUser.getTenantId());
}catch (Exception e){
}
return invoicedOrderResponse;
}
@ -424,6 +431,12 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
redisService.deleteObject(redisKey);
} else {
redisService.setCacheObject(redisKey, notReadCount);
}
try {
LoginUser loginUser = tokenService.getLoginUser();
getCreatorRead(loginUser.getUserid(),loginUser.getUserType(),loginUser.getTenantId());
}catch (Exception e){
}
return specificInvoicedResponse;
}
@ -517,6 +530,14 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
invoiceHistoryRecordsResponse.setItems(itemsDTOS);
Long userInvoiceItems = xhpcInvoiceMapper.getUserInvoiceItemsByCreatorIdAndCreatorType(invoiceHistoryRecordsRequest.getCreatorId(), invoiceHistoryRecordsRequest.getCreatorType());
invoiceHistoryRecordsResponse.setTotalItems(userInvoiceItems);
try {
LoginUser loginUser = tokenService.getLoginUser();
getCreatorRead(loginUser.getUserid(),loginUser.getUserType(),loginUser.getTenantId());
}catch (Exception e){
}
return invoiceHistoryRecordsResponse;
}
@ -532,6 +553,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
@Override
@Transactional(rollbackFor = Exception.class)
public void saveInvoiceInfo(SaveInvoiceInfoRequest saveInvoiceInfoRequest) throws Exception {
//判断传入的历史订单是否被其他发票包含
List<Integer> historyOrderIds = saveInvoiceInfoRequest.getHistoryOrderIds();
List<XhpcInvoiceMapHistoryOrder> lockOrderList = xhpcInvoiceMapHistoryOrderMapper.getLockedOnesByHistoryOrderId(historyOrderIds);
@ -595,6 +618,13 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
xhpcInvoice.setInvoiceOrderEletricTotalMoney(BigDecimal.valueOf(totalPowerPrice));
xhpcInvoice.setInvoiceOrderServiceTotalMoney(BigDecimal.valueOf(totalServicePrice));
xhpcInvoiceMapper.updateElectricAndServiceById(xhpcInvoice);
try {
LoginUser loginUser = tokenService.getLoginUser();
getCreatorRead(saveInvoiceInfoRequest.getCreatorId(),saveInvoiceInfoRequest.getCreatorType(),loginUser.getTenantId());
}catch (Exception e){
}
}
/**
@ -760,4 +790,23 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
specificInvoiceWrap.setHistoryOrderScope(minTime + "," + maxTime);
return specificInvoiceWrap;
}
private void getCreatorRead(Long creatorId,Integer creatorType, String tenantId){
String globalInvoice="global:invoice:"+ tenantId +":";
String invoice ="";
if(UserTypeUtil.USER_TYPE.equals(creatorType)){
invoice =globalInvoice + UserTypeUtil.USER + creatorId;
}else if(UserTypeUtil.INTERNET_TYPE.equals(creatorType)){
invoice =globalInvoice + UserTypeUtil.INTERNET + creatorId;
}else if(UserTypeUtil.COMMUNIT_TYPE.equals(creatorType)){
invoice =globalInvoice + UserTypeUtil.COMMUNIT + creatorId;
}else{
invoice =globalInvoice + UserTypeUtil.CUSTOMERS + creatorId;
}
Long notRead =findNotReadCount(creatorId, creatorType);
redisService.setCacheObject(invoice,notRead);
}
}

View File

@ -90,6 +90,9 @@
and xcs.area_code = #{code}
</if>
)
<if test="tenantId != null and '' != tenantId">
and tenant_id =#{tenantId}
</if>
</select>
<select id="dataCodeById" parameterType="java.lang.String" resultType="java.util.Map">
@ -132,6 +135,7 @@
<update id="updateMechanism">
update xhpc_mechanism set del_flag =1 where mechanism_id=#{mechanismId} and source=#{source }
</update>
<insert id="insertMechanism">
insert into xhpc_mechanism (charging_station_id,mechanism_id,source) VALUES
<foreach collection="chargingStationIds" item="item" open="(" separator="),(" close=")">
@ -232,10 +236,6 @@
</trim>
</insert>
<insert id="insertUserAccount">
insert into xhpc_user_account_statement
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -303,4 +303,20 @@
</if>
</trim>
</insert>
<select id="getTenantList" resultType="map">
select
xt.tenant_id as tenantId,
xt.tenant_name as tenantName
from xhpc_charging_station as xcs
join xhpc_tenant as xt on xcs.tenant_id = xt.tenant_id and xcs.del_flag=0
where xcs.del_flag=0
<if test="number==1">
and xcs.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="number==2">
and xcs.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
GROUP BY xt.tenant_id
</select>
</mapper>

View File

@ -106,7 +106,7 @@
<if test="null != businessLicenseId and '' != businessLicenseId">
business_license_id,
</if>
<if test="null != withdrawalTime and '' != withdrawalTime">
<if test="null != withdrawalTime">
withdrawal_time,
</if>
<if test="null != soc and '' != soc">