桩订单结束回调接口
This commit is contained in:
parent
db5af94803
commit
26733849ec
@ -11,9 +11,9 @@ public class PileEndOrder {
|
||||
private Integer status; //状态 (1 成功 2 异常)
|
||||
private Integer chargingTime; //累计充电时间
|
||||
private Integer chargingDegree; //充电度数
|
||||
private String amountCharged; //已充金额(分)
|
||||
private String powerPrice;//电费(分)
|
||||
private String servicePrice;//服务费(分)
|
||||
private Integer amountCharged; //已充金额(分)
|
||||
private Integer powerPrice;//电费(分)
|
||||
private Integer servicePrice;//服务费(分)
|
||||
private String erroRemark; //备注
|
||||
|
||||
|
||||
@ -87,32 +87,32 @@ public class PileEndOrder {
|
||||
this.erroRemark = erroRemark;
|
||||
}
|
||||
|
||||
public String getAmountCharged() {
|
||||
public Integer getAmountCharged() {
|
||||
|
||||
return amountCharged;
|
||||
}
|
||||
|
||||
public void setAmountCharged(String amountCharged) {
|
||||
public void setAmountCharged(Integer amountCharged) {
|
||||
|
||||
this.amountCharged = amountCharged;
|
||||
}
|
||||
|
||||
public String getPowerPrice() {
|
||||
public Integer getPowerPrice() {
|
||||
|
||||
return powerPrice;
|
||||
}
|
||||
|
||||
public void setPowerPrice(String powerPrice) {
|
||||
public void setPowerPrice(Integer powerPrice) {
|
||||
|
||||
this.powerPrice = powerPrice;
|
||||
}
|
||||
|
||||
public String getServicePrice() {
|
||||
public Integer getServicePrice() {
|
||||
|
||||
return servicePrice;
|
||||
}
|
||||
|
||||
public void setServicePrice(String servicePrice) {
|
||||
public void setServicePrice(Integer servicePrice) {
|
||||
|
||||
this.servicePrice = servicePrice;
|
||||
}
|
||||
|
||||
@ -144,6 +144,16 @@ public class HxpcPileOrderController extends BaseController {
|
||||
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);
|
||||
@ -153,7 +163,7 @@ public class HxpcPileOrderController extends BaseController {
|
||||
hxpcChargeOrder.setEndTime(date);
|
||||
hxpcChargeOrder.setChargingTime(pileEndOrder.getChargingTime().toString());
|
||||
hxpcChargeOrder.setChargingDegree(pileEndOrder.getChargingDegree().toString());
|
||||
hxpcChargeOrder.setAmountCharged(pileEndOrder.getAmountCharged());
|
||||
hxpcChargeOrder.setAmountCharged(money.toString());
|
||||
hxpcChargeOrder.setErroRemark(pileEndOrder.getErroRemark());
|
||||
|
||||
//历史订单
|
||||
@ -161,8 +171,6 @@ public class HxpcPileOrderController extends BaseController {
|
||||
//生成一条历史订单
|
||||
XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
|
||||
|
||||
|
||||
Map<String, Object> userMessage = hxpcChargeOrderService.getUserMessage(userId);
|
||||
if(userMessage ==null || userMessage.get("balance") ==null){
|
||||
//订单异常
|
||||
@ -170,56 +178,113 @@ public class HxpcPileOrderController extends BaseController {
|
||||
//异常原因
|
||||
hxpcChargeOrder.setErroRemark("桩异常:"+pileEndOrder.getErroRemark()+">>>>用户id:"+userId+"为空");
|
||||
}
|
||||
BigDecimal balance = new BigDecimal(userMessage.get("balance").toString());
|
||||
//总金额
|
||||
BigDecimal money = new BigDecimal(pileEndOrder.getAmountCharged());
|
||||
//总电费
|
||||
BigDecimal powerPrice = new BigDecimal(pileEndOrder.getPowerPrice());
|
||||
//总服务费
|
||||
BigDecimal servicePrice = new BigDecimal(pileEndOrder.getServicePrice());
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String state ="";
|
||||
BigDecimal discount =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){
|
||||
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());
|
||||
@ -235,14 +300,26 @@ public class HxpcPileOrderController extends BaseController {
|
||||
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);
|
||||
//删除实时数据,获取最新的实时数据
|
||||
|
||||
|
||||
|
||||
|
||||
//结束时soc
|
||||
// xhpcHistoryOrderService.insert(xhpcHistoryOrder);
|
||||
// hxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ public class XhpcHistoryOrder extends BaseEntity {
|
||||
/**
|
||||
* 运维服务费抽成
|
||||
*/
|
||||
private String operationSvcCommission;
|
||||
private BigDecimal operationSvcCommission;
|
||||
|
||||
/**
|
||||
* 开始充电soc
|
||||
@ -299,11 +299,11 @@ public class XhpcHistoryOrder extends BaseEntity {
|
||||
this.reconciliationStatus = reconciliationStatus;
|
||||
}
|
||||
|
||||
public String getOperationSvcCommission() {
|
||||
public BigDecimal getOperationSvcCommission() {
|
||||
return operationSvcCommission;
|
||||
}
|
||||
|
||||
public void setOperationSvcCommission(String operationSvcCommission) {
|
||||
public void setOperationSvcCommission(BigDecimal operationSvcCommission) {
|
||||
this.operationSvcCommission = operationSvcCommission;
|
||||
}
|
||||
|
||||
|
||||
@ -93,4 +93,12 @@ public interface HxpcChargeOrderMapper {
|
||||
* @return
|
||||
*/
|
||||
HxpcChargeOrder getChargingOrderId(@Param("chargingOrderId") Long chargingOrderId);
|
||||
|
||||
/**
|
||||
* 获取运营商信息
|
||||
* @param operatorId
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getOperatorMessage(@Param("chargingStationId") Long chargingStationId);
|
||||
|
||||
}
|
||||
|
||||
@ -79,4 +79,11 @@ public interface IHxpcChargeOrderService {
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getUserMessage(Long userId);
|
||||
|
||||
/**
|
||||
* 获取运营商信息
|
||||
* @param operatorId
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getOperatorMessage( Long chargingStationId);
|
||||
}
|
||||
|
||||
@ -207,4 +207,9 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
|
||||
return hxpcChargeOrderMapper.getUserMessage(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getOperatorMessage(Long chargingStationId) {
|
||||
return hxpcChargeOrderMapper.getOperatorMessage(chargingStationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -276,4 +276,13 @@
|
||||
<select id="getChargingOrderId" resultMap="BaseResultMap">
|
||||
select * from xhpc_charge_order where charge_order_id=#{chargingOrderId}
|
||||
</select>
|
||||
|
||||
<select id="getOperatorMessage" resultType="map">
|
||||
select
|
||||
operator_id as operatorId,
|
||||
commission_type as commissionType,
|
||||
platform_commission_rate as platformCommissionRate,
|
||||
maintenance_commission_rate as maintenanceCommissionRate
|
||||
from xhpc_operator where operator_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user