桩回调接口
This commit is contained in:
parent
1091b95236
commit
682c4a8c35
@ -3,8 +3,12 @@ package com.xhpc.common.api;
|
||||
import com.xhpc.common.api.factory.PileOrderFallbackFactory;
|
||||
import com.xhpc.common.core.constant.ServiceNameConstants;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.dto.PileEndOrder;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
@ -36,4 +40,21 @@ public interface PileOrderService {
|
||||
@GetMapping("/chargeOrder/pileStop")
|
||||
R pileStop(@RequestParam(value = "orderNo") String orderNo, @RequestParam(value = "status") Integer status, @RequestParam(value = "remark") String remark);
|
||||
|
||||
|
||||
/**
|
||||
* 桩订单结束回调接口
|
||||
* @param pileEndOrder 订单结束回调实体类
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/chargeOrder/pileEndOrder")
|
||||
R pileEndOrder(@Validated @RequestBody PileEndOrder pileEndOrder);
|
||||
|
||||
|
||||
/**
|
||||
* 桩订单实时订单回调接口
|
||||
* @param orderNo 订单号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/chargeOrder/pileRimeOrder")
|
||||
R pileRimeOrder(@RequestParam(value = "orderNo") String orderNo);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.xhpc.common.api.factory;
|
||||
|
||||
import com.xhpc.common.api.PileOrderService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.dto.PileEndOrder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
@ -32,6 +33,18 @@ public class PileOrderFallbackFactory implements FallbackFactory<PileOrderServic
|
||||
|
||||
return R.fail("桩停止回调接口失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R pileEndOrder(PileEndOrder pileEndOrder) {
|
||||
|
||||
return R.fail("桩订单结束回调接口失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R pileRimeOrder(String orderNo) {
|
||||
|
||||
return R.fail("桩实时订单回调接口失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.xhpc.common.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单结束回调实体类
|
||||
*/
|
||||
@ -15,7 +17,7 @@ public class PileEndOrder {
|
||||
private Integer powerPrice;//电费(分)
|
||||
private Integer servicePrice;//服务费(分)
|
||||
private String erroRemark; //备注
|
||||
|
||||
private Date createTime;//时间
|
||||
|
||||
public String getOrderNo() {
|
||||
|
||||
@ -117,4 +119,14 @@ public class PileEndOrder {
|
||||
this.servicePrice = servicePrice;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.xhpc.order.api;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
@ -7,19 +9,19 @@ import com.xhpc.common.api.PileOrderService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.data.redis.CacheRealtimeData;
|
||||
import com.xhpc.common.dto.PileEndOrder;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.common.util.ConnectionRabbitMQUtil;
|
||||
import com.xhpc.order.domain.HxpcChargeOrder;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.domain.XhpcRealTimeOrder;
|
||||
import com.xhpc.order.service.IHxpcChargeOrderService;
|
||||
import com.xhpc.order.service.IXhpcHistoryOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@ -118,17 +120,58 @@ public class HxpcPileOrderController extends BaseController {
|
||||
|
||||
/**
|
||||
* 桩实时数据回调接口
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param status 离线、故障、充电、空闲、计费错误(重新计算费用,电量默认为正确)
|
||||
* @param remark 备注
|
||||
* @param rateModel 费率模型id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pileRealtime")
|
||||
public AjaxResult pileRealtime(String orderNo, Integer status, String remark, String rateModel) {
|
||||
@GetMapping("/chargeOrder/pileRimeOrder")
|
||||
public R pileRealtime(String orderNo) {
|
||||
|
||||
return AjaxResult.success();
|
||||
Date date = new Date();
|
||||
//获取实时订单
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:"+orderNo);
|
||||
JSONArray st = (JSONArray)cacheMap.get("realtimeDataList");
|
||||
System.out.println(st.toString());
|
||||
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(orderNo);
|
||||
if(st!=null && st.size()>0){
|
||||
for (int i = 0; i <st.size() ; i++) {
|
||||
CacheRealtimeData cacheRealtimeData = JSON.toJavaObject(st.getJSONObject(0), CacheRealtimeData.class);
|
||||
|
||||
XhpcRealTimeOrder xhpcRealTimeOrder =new XhpcRealTimeOrder();
|
||||
xhpcRealTimeOrder.setChargingOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
xhpcRealTimeOrder.setTransactionNumber(orderNo);
|
||||
xhpcRealTimeOrder.setPileNumber(cacheRealtimeData.getPileNo());
|
||||
xhpcRealTimeOrder.setGunNumber(cacheRealtimeData.getGunId());
|
||||
if("00".equals(cacheRealtimeData.getPileGunStatus())){
|
||||
xhpcRealTimeOrder.setPileGunStatus(0);
|
||||
}else if("01".equals(cacheRealtimeData.getPileGunStatus())){
|
||||
xhpcRealTimeOrder.setPileGunStatus(1);
|
||||
}else{
|
||||
xhpcRealTimeOrder.setPileGunStatus(2);
|
||||
}
|
||||
if("00".equals(cacheRealtimeData.getVehicleGunStatus())){
|
||||
xhpcRealTimeOrder.setVehicleGunStatus(0);
|
||||
}else{
|
||||
xhpcRealTimeOrder.setVehicleGunStatus(1);
|
||||
}
|
||||
BigDecimal v = new BigDecimal(cacheRealtimeData.getWorkingVoltage()).divide(new BigDecimal(10));
|
||||
BigDecimal c = new BigDecimal(cacheRealtimeData.getWorkingCurrent()).divide(new BigDecimal(10));
|
||||
xhpcRealTimeOrder.setVoltage(v);
|
||||
xhpcRealTimeOrder.setElectricCurrent(c);
|
||||
xhpcRealTimeOrder.setGunLineTemperature(cacheRealtimeData.getGunLineTemperature());
|
||||
xhpcRealTimeOrder.setGunLineNumber(cacheRealtimeData.getGunLineNumber());
|
||||
xhpcRealTimeOrder.setSoc(cacheRealtimeData.getSoc().toString());
|
||||
xhpcRealTimeOrder.setMaxTemperature(cacheRealtimeData.getMaxTemperature());
|
||||
cacheRealtimeData.getChargingTime();
|
||||
xhpcRealTimeOrder.setChargingTime(cacheRealtimeData.getChargingTime().toString());
|
||||
|
||||
//实时数据存入MYsql、soc、电流、电压
|
||||
|
||||
}
|
||||
}else{
|
||||
return R.fail(500,"无实时数据");
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -137,240 +180,197 @@ public class HxpcPileOrderController extends BaseController {
|
||||
*
|
||||
*/
|
||||
@Transactional
|
||||
@GetMapping("/pileEndOrder")
|
||||
public R pileEndOrder(@RequestBody PileEndOrder pileEndOrder) {
|
||||
@PostMapping("/chargeOrder/pileEndOrder")
|
||||
public R pileEndOrder(@Validated @RequestBody PileEndOrder pileEndOrder) {
|
||||
|
||||
//解析订单编号
|
||||
String s = pileEndOrder.getOrderNo().split("\\.")[0];
|
||||
String s1 = s.split(":")[1];
|
||||
Date date = new Date();
|
||||
//总金额
|
||||
BigDecimal money = new BigDecimal((pileEndOrder.getAmountCharged()/100));
|
||||
//总电费
|
||||
BigDecimal powerPrice = new BigDecimal((pileEndOrder.getPowerPrice()/100));
|
||||
//总服务费
|
||||
BigDecimal servicePrice = new BigDecimal((pileEndOrder.getServicePrice()/100));
|
||||
//剩余的电费
|
||||
BigDecimal surplusPowerPrice = powerPrice;
|
||||
//剩余的服务费
|
||||
BigDecimal surplusServicePrice = servicePrice;
|
||||
try{
|
||||
//解析订单编号
|
||||
String s = pileEndOrder.getOrderNo().split("\\.")[0];
|
||||
String s1 = s.split(":")[1];
|
||||
Date date = new Date();
|
||||
//总金额
|
||||
BigDecimal money = new BigDecimal((pileEndOrder.getAmountCharged()/100));
|
||||
//总电费
|
||||
BigDecimal powerPrice = new BigDecimal((pileEndOrder.getPowerPrice()/100));
|
||||
//总服务费
|
||||
BigDecimal servicePrice = new BigDecimal((pileEndOrder.getServicePrice()/100));
|
||||
//剩余的电费
|
||||
BigDecimal surplusPowerPrice = powerPrice;
|
||||
//剩余的服务费
|
||||
BigDecimal surplusServicePrice = servicePrice;
|
||||
|
||||
//获取充电订单
|
||||
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(s1);
|
||||
hxpcChargeOrder.setStartSoc(pileEndOrder.getStartSoc());
|
||||
hxpcChargeOrder.setEndSoc(pileEndOrder.getEndSoc());
|
||||
hxpcChargeOrder.setStatus(pileEndOrder.getStatus());
|
||||
hxpcChargeOrder.setEndTime(date);
|
||||
hxpcChargeOrder.setChargingTime(pileEndOrder.getChargingTime().toString());
|
||||
hxpcChargeOrder.setChargingDegree(pileEndOrder.getChargingDegree().toString());
|
||||
hxpcChargeOrder.setAmountCharged(money.toString());
|
||||
hxpcChargeOrder.setErroRemark(pileEndOrder.getErroRemark());
|
||||
//获取充电订单
|
||||
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(s1);
|
||||
hxpcChargeOrder.setStartSoc(pileEndOrder.getStartSoc());
|
||||
hxpcChargeOrder.setEndSoc(pileEndOrder.getEndSoc());
|
||||
hxpcChargeOrder.setStatus(pileEndOrder.getStatus());
|
||||
hxpcChargeOrder.setEndTime(pileEndOrder.getCreateTime());
|
||||
hxpcChargeOrder.setChargingTime(pileEndOrder.getChargingTime().toString());
|
||||
hxpcChargeOrder.setChargingDegree(pileEndOrder.getChargingDegree().toString());
|
||||
hxpcChargeOrder.setAmountCharged(money.toString());
|
||||
hxpcChargeOrder.setErroRemark(pileEndOrder.getErroRemark());
|
||||
|
||||
//历史订单
|
||||
Long userId =hxpcChargeOrder.getUserId();
|
||||
//生成一条历史订单
|
||||
XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
//历史订单
|
||||
Long userId =hxpcChargeOrder.getUserId();
|
||||
//生成一条历史订单
|
||||
XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
|
||||
Map<String, Object> userMessage = hxpcChargeOrderService.getUserMessage(userId);
|
||||
if(userMessage ==null || userMessage.get("balance") ==null){
|
||||
//订单异常
|
||||
hxpcChargeOrder.setStatus(2);
|
||||
//异常原因
|
||||
hxpcChargeOrder.setErroRemark("桩异常:"+pileEndOrder.getErroRemark()+">>>>用户id:"+userId+"为空");
|
||||
}
|
||||
BigDecimal balance = new BigDecimal(userMessage.get("balance").toString()).divide(new BigDecimal(100));
|
||||
|
||||
//电站活动抵扣--抵扣的总金额
|
||||
BigDecimal promotionDiscount = new BigDecimal(0);
|
||||
//实际价格-用户支付的钱
|
||||
BigDecimal actPrice =new BigDecimal(0);
|
||||
//实收电费-运营商电费
|
||||
BigDecimal actPowerPrice =new BigDecimal(0);
|
||||
//实收服务费-运营商服务费
|
||||
BigDecimal actServicePrice =new BigDecimal(0);
|
||||
//流量方总金额抽成
|
||||
BigDecimal internetCommission =new BigDecimal(0);
|
||||
//流量方服务费抽成
|
||||
BigDecimal internetSvcCommission =new BigDecimal(0);
|
||||
//平台总金额抽成
|
||||
BigDecimal platformCommission =new BigDecimal(0);
|
||||
//平台服务费抽成
|
||||
BigDecimal platformSvcCommission =new BigDecimal(0);
|
||||
//运维总抽成
|
||||
BigDecimal operationCommission =new BigDecimal(0);
|
||||
//运维服务费抽成
|
||||
BigDecimal operationSvcCommission =new BigDecimal(0);
|
||||
|
||||
//判断是C端用户还是流量端用户
|
||||
if(hxpcChargeOrder.getSource() ==0){
|
||||
String state ="";
|
||||
BigDecimal discount =new BigDecimal(0);
|
||||
//用户第几次充电
|
||||
int count = hxpcChargeOrderService.getCount(userId);
|
||||
if(count==0){
|
||||
//活动折扣
|
||||
Map<String, Object> promotion = hxpcChargeOrderService.getPromotion();
|
||||
if(promotion !=null && promotion.get("state") !=null && promotion.get("discount") !=null){
|
||||
//state 1.总金额 2.电费 3.服务费 discount 折扣率
|
||||
state = promotion.get("state").toString();
|
||||
discount = (BigDecimal)promotion.get("discount");
|
||||
}
|
||||
}
|
||||
if(!"".equals(state)){
|
||||
|
||||
if("1".equals(state)){
|
||||
//总金额
|
||||
promotionDiscount=money.multiply(balance);
|
||||
actPrice = money.subtract(promotionDiscount);
|
||||
surplusPowerPrice = surplusPowerPrice.subtract(promotionDiscount.divide(new BigDecimal(2)));
|
||||
surplusServicePrice= surplusServicePrice.subtract(promotionDiscount.divide(new BigDecimal(2)));
|
||||
}else if("2".equals(state)){
|
||||
//电费
|
||||
promotionDiscount =powerPrice.multiply(balance);
|
||||
actPrice = money.subtract(promotionDiscount);
|
||||
surplusPowerPrice=surplusPowerPrice.subtract(promotionDiscount);
|
||||
}else if("3".equals(state)){
|
||||
//服务费
|
||||
promotionDiscount = servicePrice.multiply(balance);
|
||||
actPrice = money.subtract(promotionDiscount);
|
||||
surplusServicePrice =surplusServicePrice.subtract(promotionDiscount);
|
||||
}
|
||||
}
|
||||
xhpcHistoryOrder.setInternetCommission(internetCommission);
|
||||
xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission);
|
||||
}else{
|
||||
//流量方,未实现
|
||||
}
|
||||
|
||||
//获取运营商
|
||||
Map<String, Object> operatorMessage = hxpcChargeOrderService.getOperatorMessage(hxpcChargeOrder.getChargingStationId());
|
||||
if(operatorMessage !=null){
|
||||
if(operatorMessage.get("maintenanceCommissionRate") !=null && operatorMessage.get("commissionType") !=null && operatorMessage.get("platformCommissionRate") !=null){
|
||||
Integer commissionType = (Integer) operatorMessage.get("commissionType");
|
||||
//运维提成
|
||||
BigDecimal maintenanceCommissionRate = new BigDecimal(userMessage.get("maintenanceCommissionRate").toString()).divide(new BigDecimal(100));
|
||||
//平台提成
|
||||
BigDecimal platformCommissionRate = new BigDecimal(userMessage.get("platformCommissionRate").toString()).divide(new BigDecimal(100));
|
||||
//提成类型(0总金额提成 1服务费提成)
|
||||
if(commissionType==0){
|
||||
BigDecimal multiply1 = surplusPowerPrice.multiply(platformCommissionRate);
|
||||
BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate);
|
||||
platformCommission = multiply1.add(multiply2);
|
||||
//剩下的钱
|
||||
surplusPowerPrice = surplusPowerPrice.subtract(multiply1);
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply2);
|
||||
BigDecimal multiply3 = surplusPowerPrice.multiply(maintenanceCommissionRate);
|
||||
BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate);
|
||||
operationCommission = multiply1.add(multiply2);
|
||||
//剩下的钱
|
||||
surplusPowerPrice = surplusPowerPrice.subtract(multiply3);
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply4);
|
||||
|
||||
}else if(commissionType==1){
|
||||
BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate);
|
||||
platformSvcCommission=multiply2;
|
||||
//剩下的钱
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply2);
|
||||
|
||||
BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate);
|
||||
operationCommission = multiply4;
|
||||
//剩下的钱
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply4);
|
||||
}
|
||||
}else{
|
||||
Map<String, Object> userMessage = hxpcChargeOrderService.getUserMessage(userId);
|
||||
if(userMessage ==null || userMessage.get("balance") ==null){
|
||||
//订单异常
|
||||
hxpcChargeOrder.setStatus(2);
|
||||
//异常原因
|
||||
hxpcChargeOrder.setErroRemark("桩异常:"+pileEndOrder.getErroRemark()+">>>>用户id:"+userId+"为空"+">>>>运营商提出为空");
|
||||
|
||||
hxpcChargeOrder.setErroRemark("桩异常:"+pileEndOrder.getErroRemark()+">>>>用户id:"+userId+"为空");
|
||||
}
|
||||
BigDecimal balance = new BigDecimal(userMessage.get("balance").toString()).divide(new BigDecimal(100));
|
||||
|
||||
//电站活动抵扣--抵扣的总金额
|
||||
BigDecimal promotionDiscount = new BigDecimal(0);
|
||||
//实际价格-用户支付的钱
|
||||
BigDecimal actPrice =new BigDecimal(0);
|
||||
//实收电费-运营商电费
|
||||
BigDecimal actPowerPrice =new BigDecimal(0);
|
||||
//实收服务费-运营商服务费
|
||||
BigDecimal actServicePrice =new BigDecimal(0);
|
||||
//流量方总金额抽成
|
||||
BigDecimal internetCommission =new BigDecimal(0);
|
||||
//流量方服务费抽成
|
||||
BigDecimal internetSvcCommission =new BigDecimal(0);
|
||||
//平台总金额抽成
|
||||
BigDecimal platformCommission =new BigDecimal(0);
|
||||
//平台服务费抽成
|
||||
BigDecimal platformSvcCommission =new BigDecimal(0);
|
||||
//运维总抽成
|
||||
BigDecimal operationCommission =new BigDecimal(0);
|
||||
//运维服务费抽成
|
||||
BigDecimal operationSvcCommission =new BigDecimal(0);
|
||||
|
||||
//判断是C端用户还是流量端用户
|
||||
if(hxpcChargeOrder.getSource() ==0){
|
||||
String state ="";
|
||||
BigDecimal discount =new BigDecimal(0);
|
||||
//用户第几次充电
|
||||
int count = hxpcChargeOrderService.getCount(userId);
|
||||
if(count==0){
|
||||
//活动折扣
|
||||
Map<String, Object> promotion = hxpcChargeOrderService.getPromotion();
|
||||
if(promotion !=null && promotion.get("state") !=null && promotion.get("discount") !=null){
|
||||
//state 1.总金额 2.电费 3.服务费 discount 折扣率
|
||||
state = promotion.get("state").toString();
|
||||
discount = (BigDecimal)promotion.get("discount");
|
||||
}
|
||||
}
|
||||
if(!"".equals(state)){
|
||||
|
||||
if("1".equals(state)){
|
||||
//总金额
|
||||
promotionDiscount=money.multiply(balance);
|
||||
actPrice = money.subtract(promotionDiscount);
|
||||
surplusPowerPrice = surplusPowerPrice.subtract(promotionDiscount.divide(new BigDecimal(2)));
|
||||
surplusServicePrice= surplusServicePrice.subtract(promotionDiscount.divide(new BigDecimal(2)));
|
||||
}else if("2".equals(state)){
|
||||
//电费
|
||||
promotionDiscount =powerPrice.multiply(balance);
|
||||
actPrice = money.subtract(promotionDiscount);
|
||||
surplusPowerPrice=surplusPowerPrice.subtract(promotionDiscount);
|
||||
}else if("3".equals(state)){
|
||||
//服务费
|
||||
promotionDiscount = servicePrice.multiply(balance);
|
||||
actPrice = money.subtract(promotionDiscount);
|
||||
surplusServicePrice =surplusServicePrice.subtract(promotionDiscount);
|
||||
}
|
||||
}
|
||||
xhpcHistoryOrder.setInternetCommission(internetCommission);
|
||||
xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission);
|
||||
}else{
|
||||
//流量方,未实现
|
||||
}
|
||||
|
||||
//获取运营商
|
||||
Map<String, Object> operatorMessage = hxpcChargeOrderService.getOperatorMessage(hxpcChargeOrder.getChargingStationId());
|
||||
if(operatorMessage !=null){
|
||||
if(operatorMessage.get("maintenanceCommissionRate") !=null && operatorMessage.get("commissionType") !=null && operatorMessage.get("platformCommissionRate") !=null){
|
||||
Integer commissionType = (Integer) operatorMessage.get("commissionType");
|
||||
//运维提成
|
||||
BigDecimal maintenanceCommissionRate = new BigDecimal(userMessage.get("maintenanceCommissionRate").toString()).divide(new BigDecimal(100));
|
||||
//平台提成
|
||||
BigDecimal platformCommissionRate = new BigDecimal(userMessage.get("platformCommissionRate").toString()).divide(new BigDecimal(100));
|
||||
//提成类型(0总金额提成 1服务费提成)
|
||||
if(commissionType==0){
|
||||
BigDecimal multiply1 = surplusPowerPrice.multiply(platformCommissionRate);
|
||||
BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate);
|
||||
platformCommission = multiply1.add(multiply2);
|
||||
//剩下的钱
|
||||
surplusPowerPrice = surplusPowerPrice.subtract(multiply1);
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply2);
|
||||
BigDecimal multiply3 = surplusPowerPrice.multiply(maintenanceCommissionRate);
|
||||
BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate);
|
||||
operationCommission = multiply1.add(multiply2);
|
||||
//剩下的钱
|
||||
surplusPowerPrice = surplusPowerPrice.subtract(multiply3);
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply4);
|
||||
|
||||
}else if(commissionType==1){
|
||||
BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate);
|
||||
platformSvcCommission=multiply2;
|
||||
//剩下的钱
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply2);
|
||||
|
||||
BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate);
|
||||
operationCommission = multiply4;
|
||||
//剩下的钱
|
||||
surplusServicePrice = surplusServicePrice.subtract(multiply4);
|
||||
}
|
||||
}else{
|
||||
//订单异常
|
||||
hxpcChargeOrder.setStatus(2);
|
||||
//异常原因
|
||||
hxpcChargeOrder.setErroRemark("桩异常:"+pileEndOrder.getErroRemark()+">>>>用户id:"+userId+"为空"+">>>>运营商提出为空");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
|
||||
xhpcHistoryOrder.setUserId(userId);
|
||||
xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
|
||||
xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
|
||||
xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
|
||||
xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
xhpcHistoryOrder.setSortingStatus(0);
|
||||
xhpcHistoryOrder.setType(1);
|
||||
xhpcHistoryOrder.setStatus(0);
|
||||
xhpcHistoryOrder.setDelFlag(0);
|
||||
//订单总价---运维服务费抽成
|
||||
xhpcHistoryOrder.setTotalPrice(money);
|
||||
xhpcHistoryOrder.setPromotionDiscount(promotionDiscount);
|
||||
xhpcHistoryOrder.setActPowerPrice(actPowerPrice);
|
||||
xhpcHistoryOrder.setActPowerPrice(surplusPowerPrice);
|
||||
xhpcHistoryOrder.setActServicePrice(surplusServicePrice);
|
||||
xhpcHistoryOrder.setInternetCommission(internetCommission);
|
||||
xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission);
|
||||
xhpcHistoryOrder.setPlatformCommission(platformCommission);
|
||||
xhpcHistoryOrder.setPlatformSvcCommisssion(platformSvcCommission);
|
||||
xhpcHistoryOrder.setOperationCommission(operationCommission);
|
||||
xhpcHistoryOrder.setOperationSvcCommission(operationSvcCommission);
|
||||
xhpcHistoryOrder.setStartSoc(pileEndOrder.getStartSoc());
|
||||
xhpcHistoryOrder.setEndSoc(pileEndOrder.getEndSoc());
|
||||
xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
xhpcHistoryOrder.setCreateTime(date);
|
||||
|
||||
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
|
||||
hxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
|
||||
//删除实时数据,获取最新的实时数据
|
||||
//hxpcChargeOrderService.deleteRealTimeOrder(hxpcChargeOrder.getChargeOrderId());
|
||||
|
||||
//添加新的实时数据
|
||||
}catch (Exception e){
|
||||
return R.fail(500,"添加订单回调失败");
|
||||
}
|
||||
|
||||
|
||||
xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
|
||||
xhpcHistoryOrder.setUserId(userId);
|
||||
xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
|
||||
xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
|
||||
xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
|
||||
xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
xhpcHistoryOrder.setSortingStatus(0);
|
||||
xhpcHistoryOrder.setType(1);
|
||||
xhpcHistoryOrder.setStatus(0);
|
||||
xhpcHistoryOrder.setDelFlag(0);
|
||||
xhpcHistoryOrder.setCreateTime(date);
|
||||
//订单总价---运维服务费抽成
|
||||
xhpcHistoryOrder.setTotalPrice(money);
|
||||
xhpcHistoryOrder.setPromotionDiscount(promotionDiscount);
|
||||
xhpcHistoryOrder.setActPowerPrice(actPowerPrice);
|
||||
xhpcHistoryOrder.setActPowerPrice(surplusPowerPrice);
|
||||
xhpcHistoryOrder.setActServicePrice(surplusServicePrice);
|
||||
xhpcHistoryOrder.setInternetCommission(internetCommission);
|
||||
xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission);
|
||||
xhpcHistoryOrder.setPlatformCommission(platformCommission);
|
||||
xhpcHistoryOrder.setPlatformSvcCommisssion(platformSvcCommission);
|
||||
xhpcHistoryOrder.setOperationCommission(operationCommission);
|
||||
xhpcHistoryOrder.setOperationSvcCommission(operationSvcCommission);
|
||||
xhpcHistoryOrder.setStartSoc(pileEndOrder.getStartSoc());
|
||||
xhpcHistoryOrder.setEndSoc(pileEndOrder.getEndSoc());
|
||||
xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
xhpcHistoryOrder.setCreateTime(date);
|
||||
|
||||
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
|
||||
hxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
|
||||
//删除实时数据,获取最新的实时数据
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
private void gun(){
|
||||
// Date date = new Date();
|
||||
// //获取实时订单
|
||||
// Map<String, Object> cacheMap = redisService.getCacheMap("order:"+serialNumber);
|
||||
// JSONArray st = (JSONArray)cacheMap.get("realtimeDataList");
|
||||
// System.out.println(st.toString());
|
||||
// CacheRealtimeData cacheRealtimeData = JSON.toJavaObject(st.getJSONObject(0), CacheRealtimeData.class);
|
||||
//
|
||||
// //用户第几次充电
|
||||
// int count = iHxpcChargeOrderService.getCount(userId);
|
||||
// String state ="";
|
||||
// String discount ="";
|
||||
// if(count==0){
|
||||
// //活动折扣
|
||||
// Map<String, Object> promotion = iHxpcChargeOrderService.getPromotion();
|
||||
// if(promotion !=null){
|
||||
// //state 1.总金额 2.金额 3.服务费 discount 折扣率
|
||||
// state = promotion.get("state").toString();
|
||||
// discount = promotion.get("discount").toString();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //生成一条历史订单
|
||||
// XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
// xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
// xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
|
||||
// xhpcHistoryOrder.setUserId(userId);
|
||||
// xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
|
||||
// xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
|
||||
// xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
|
||||
// xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
// xhpcHistoryOrder.setSortingStatus(0);
|
||||
// xhpcHistoryOrder.setType(1);
|
||||
// xhpcHistoryOrder.setStatus(0);
|
||||
// xhpcHistoryOrder.setDelFlag(0);
|
||||
// xhpcHistoryOrder.setCreateTime(date);
|
||||
// //订单总价---运维服务费抽成
|
||||
// //结束时soc
|
||||
// xhpcHistoryOrderService.insert(xhpcHistoryOrder);
|
||||
//
|
||||
// //充电订单 --结束soc、充电时长、充电度数
|
||||
// hxpcChargeOrder.setEndTime(date);
|
||||
//
|
||||
// //实时数据存入MYsql、soc、电流、电压
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param status 状态
|
||||
* @param delFlag 是否删除
|
||||
|
||||
@ -2,6 +2,8 @@ package com.xhpc.order.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/8/7 15:06
|
||||
@ -35,23 +37,23 @@ public class XhpcRealTimeOrder extends BaseEntity {
|
||||
/**
|
||||
* 是否插枪(0否 1是)
|
||||
*/
|
||||
private Long vehicleGunStatus;
|
||||
private Integer vehicleGunStatus;
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
private Double voltage;
|
||||
private BigDecimal voltage;
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
private Double electricCurrent;
|
||||
private BigDecimal electricCurrent;
|
||||
/**
|
||||
* 枪线温度
|
||||
*/
|
||||
private Double gunLineTemperature;
|
||||
private Integer gunLineTemperature;
|
||||
/**
|
||||
* 枪线编码
|
||||
*/
|
||||
private Double gunLineNumber;
|
||||
private String gunLineNumber;
|
||||
/**
|
||||
* SOC
|
||||
*/
|
||||
@ -59,7 +61,7 @@ public class XhpcRealTimeOrder extends BaseEntity {
|
||||
/**
|
||||
* 电池组最高温度
|
||||
*/
|
||||
private Double maxTemperature;
|
||||
private Integer maxTemperature;
|
||||
/**
|
||||
* 累计充电时间
|
||||
*/
|
||||
@ -142,52 +144,52 @@ public class XhpcRealTimeOrder extends BaseEntity {
|
||||
this.pileGunStatus = pileGunStatus;
|
||||
}
|
||||
|
||||
public Long getVehicleGunStatus() {
|
||||
public Integer getVehicleGunStatus() {
|
||||
|
||||
return vehicleGunStatus;
|
||||
}
|
||||
|
||||
public void setVehicleGunStatus(Long vehicleGunStatus) {
|
||||
public void setVehicleGunStatus(Integer vehicleGunStatus) {
|
||||
|
||||
this.vehicleGunStatus = vehicleGunStatus;
|
||||
}
|
||||
|
||||
public Double getVoltage() {
|
||||
public BigDecimal getVoltage() {
|
||||
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setVoltage(Double voltage) {
|
||||
public void setVoltage(BigDecimal voltage) {
|
||||
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public Double getElectricCurrent() {
|
||||
public BigDecimal getElectricCurrent() {
|
||||
|
||||
return electricCurrent;
|
||||
}
|
||||
|
||||
public void setElectricCurrent(Double electricCurrent) {
|
||||
public void setElectricCurrent(BigDecimal electricCurrent) {
|
||||
|
||||
this.electricCurrent = electricCurrent;
|
||||
}
|
||||
|
||||
public Double getGunLineTemperature() {
|
||||
public Integer getGunLineTemperature() {
|
||||
|
||||
return gunLineTemperature;
|
||||
}
|
||||
|
||||
public void setGunLineTemperature(Double gunLineTemperature) {
|
||||
public void setGunLineTemperature(Integer gunLineTemperature) {
|
||||
|
||||
this.gunLineTemperature = gunLineTemperature;
|
||||
}
|
||||
|
||||
public Double getGunLineNumber() {
|
||||
public String getGunLineNumber() {
|
||||
|
||||
return gunLineNumber;
|
||||
}
|
||||
|
||||
public void setGunLineNumber(Double gunLineNumber) {
|
||||
public void setGunLineNumber(String gunLineNumber) {
|
||||
|
||||
this.gunLineNumber = gunLineNumber;
|
||||
}
|
||||
@ -202,12 +204,12 @@ public class XhpcRealTimeOrder extends BaseEntity {
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
public Double getMaxTemperature() {
|
||||
public Integer getMaxTemperature() {
|
||||
|
||||
return maxTemperature;
|
||||
}
|
||||
|
||||
public void setMaxTemperature(Double maxTemperature) {
|
||||
public void setMaxTemperature(Integer maxTemperature) {
|
||||
|
||||
this.maxTemperature = maxTemperature;
|
||||
}
|
||||
|
||||
@ -96,9 +96,20 @@ public interface HxpcChargeOrderMapper {
|
||||
|
||||
/**
|
||||
* 获取运营商信息
|
||||
* @param operatorId
|
||||
* @param chargingStationId
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getOperatorMessage(@Param("chargingStationId") Long chargingStationId);
|
||||
|
||||
|
||||
/**
|
||||
* 删除之前的实时订单数据
|
||||
*/
|
||||
void deleteRealTimeOrder(@Param("chargingStationId")Long chargingOrderId);
|
||||
|
||||
void deleteChargeVoltage(@Param("chargingStationId")Long chargingOrderId);
|
||||
|
||||
void deleteChargeOrderSoc(@Param("chargingStationId")Long chargingOrderId);
|
||||
|
||||
void deleteChargeOrderCurrent(@Param("chargingStationId")Long chargingOrderId);
|
||||
}
|
||||
|
||||
@ -82,8 +82,13 @@ public interface IHxpcChargeOrderService {
|
||||
|
||||
/**
|
||||
* 获取运营商信息
|
||||
* @param operatorId
|
||||
* @param chargingStationId
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getOperatorMessage( Long chargingStationId);
|
||||
|
||||
/**
|
||||
* 删除之前的实时订单数据
|
||||
*/
|
||||
void deleteRealTimeOrder(Long chargingOrderId);
|
||||
}
|
||||
|
||||
@ -212,4 +212,12 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
|
||||
return hxpcChargeOrderMapper.getOperatorMessage(chargingStationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRealTimeOrder(Long chargingOrderId) {
|
||||
hxpcChargeOrderMapper.deleteRealTimeOrder(chargingOrderId);
|
||||
hxpcChargeOrderMapper.deleteChargeOrderCurrent(chargingOrderId);
|
||||
hxpcChargeOrderMapper.deleteChargeOrderSoc(chargingOrderId);
|
||||
hxpcChargeOrderMapper.deleteChargeVoltage(chargingOrderId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -285,4 +285,20 @@
|
||||
maintenance_commission_rate as maintenanceCommissionRate
|
||||
from xhpc_operator where operator_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
|
||||
</select>
|
||||
|
||||
<delete id="deleteRealTimeOrder">
|
||||
delete from xhpc_real_time_order where charging_order_id=#{chargingOrderId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteChargeVoltage">
|
||||
delete from xhpc_charge_order_current where charging_order_id=#{chargingOrderId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteChargeOrderSoc">
|
||||
delete from xhpc_charge_order_soc where charging_order_id=#{chargingOrderId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteChargeOrderCurrent">
|
||||
delete from xhpc_charge_order_voltage where charging_order_id=#{chargingOrderId}
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user