PC端历史订单详情接口

This commit is contained in:
yuyang 2021-08-25 18:45:52 +08:00
parent 08dfe64046
commit 6b2cce56d8
9 changed files with 236 additions and 21 deletions

View File

@ -218,7 +218,6 @@ public class HxpcPileOrderController extends BaseController {
//充电时长 //充电时长
Long tiem = (endTime.getTime()-startTime.getTime())%1000; Long tiem = (endTime.getTime()-startTime.getTime())%1000;
if(tiem>60){ if(tiem>60){
long mins = tiem % 60; long mins = tiem % 60;
long hours = tiem / 60; long hours = tiem / 60;
@ -227,6 +226,7 @@ public class HxpcPileOrderController extends BaseController {
long mins = tiem % 60; long mins = tiem % 60;
hxpcChargeOrder.setChargingTime(mins+""); hxpcChargeOrder.setChargingTime(mins+"");
} }
hxpcChargeOrder.setChargingTimeNumber(tiem.intValue());
BigDecimal divide = new BigDecimal(cacheOrderData.getTotalPowerQuantity()).divide(bigDecimal); BigDecimal divide = new BigDecimal(cacheOrderData.getTotalPowerQuantity()).divide(bigDecimal);
hxpcChargeOrder.setChargingDegree(divide.toString()); hxpcChargeOrder.setChargingDegree(divide.toString());
hxpcChargeOrder.setAmountCharged(money.toString()); hxpcChargeOrder.setAmountCharged(money.toString());

View File

@ -50,5 +50,13 @@ public class XhpcHistoryOrderController extends BaseController {
return getDataTable(listPage); return getDataTable(listPage);
} }
/**
* 历史订单详情
* @param historyOrderId 历史订单id
* @return
*/
@GetMapping("/getById")
public AjaxResult getById(@RequestParam("historyOrderId")Long historyOrderId){
return xhpcHistoryOrderService.getById(historyOrderId);
}
} }

View File

@ -82,6 +82,9 @@ public class HxpcChargeOrder extends BaseEntity {
/** 充电时长 */ /** 充电时长 */
private String chargingTime; private String chargingTime;
/** 充电时长(分) */
private Integer chargingTimeNumber;
/** 充电度数 */ /** 充电度数 */
private String chargingDegree; private String chargingDegree;
@ -307,4 +310,14 @@ public class HxpcChargeOrder extends BaseEntity {
this.power = power; this.power = power;
} }
public Integer getChargingTimeNumber() {
return chargingTimeNumber;
}
public void setChargingTimeNumber(Integer chargingTimeNumber) {
this.chargingTimeNumber = chargingTimeNumber;
}
} }

View File

@ -137,6 +137,17 @@ public class XhpcHistoryOrder extends BaseEntity {
*/ */
private Integer delFlag; private Integer delFlag;
/**
* 总电费
*/
private BigDecimal powerPriceTotal;
/**
* 总服务费
*/
private BigDecimal servicePriceTotal;
public Long getHistoryOrderId() { public Long getHistoryOrderId() {
return historyOrderId; return historyOrderId;
} }
@ -338,4 +349,25 @@ public class XhpcHistoryOrder extends BaseEntity {
public void setDelFlag(Integer delFlag) { public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag; this.delFlag = delFlag;
} }
public BigDecimal getPowerPriceTotal() {
return powerPriceTotal;
}
public void setPowerPriceTotal(BigDecimal powerPriceTotal) {
this.powerPriceTotal = powerPriceTotal;
}
public BigDecimal getServicePriceTotal() {
return servicePriceTotal;
}
public void setServicePriceTotal(BigDecimal servicePriceTotal) {
this.servicePriceTotal = servicePriceTotal;
}
} }

View File

@ -75,4 +75,20 @@ public interface XhpcHistoryOrderMapper {
* @return * @return
*/ */
List<Map<String,Object>> getListPage(@Param("phone")String phone,@Param("transactionNumber")String transactionNumber,@Param("status")Integer status,@Param("chargingStationName")String chargingStationName,@Param("operatorId")Long operatorId,@Param("source")Integer source,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("userId")Long userId,@Param("type")Integer type,@Param("number")Integer number); List<Map<String,Object>> getListPage(@Param("phone")String phone,@Param("transactionNumber")String transactionNumber,@Param("status")Integer status,@Param("chargingStationName")String chargingStationName,@Param("operatorId")Long operatorId,@Param("source")Integer source,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("userId")Long userId,@Param("type")Integer type,@Param("number")Integer number);
/**
* 获取费率时段
* @param startTime 开始时间
* @param endTime 结束时间
* @param rateModelId 计费模型
* @return
*/
List<Map<String,Object>> getReatTimeList(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("rateModelId")Long rateModelId);
/**
* 历史订单详情PC
* @param historyOrderId 历史订单id
* @return
*/
Map<String,Object> getById(@Param("historyOrderId")Long historyOrderId);
} }

View File

@ -2,7 +2,6 @@ package com.xhpc.order.service;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.order.domain.XhpcHistoryOrder; import com.xhpc.order.domain.XhpcHistoryOrder;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -44,4 +43,11 @@ public interface IXhpcHistoryOrderService {
*/ */
List<Map<String,Object>> getListPage(String phone,String transactionNumber,Integer status,String chargingStationName,Long operatorId,Integer source,String startTime,String endTime,Long userId,Integer type); List<Map<String,Object>> getListPage(String phone,String transactionNumber,Integer status,String chargingStationName,Long operatorId,Integer source,String startTime,String endTime,Long userId,Integer type);
/**
* 历史订单详情PC
* @param historyOrderId 历史订单id
* @return
*/
AjaxResult getById(Long historyOrderId);
} }

View File

@ -1,5 +1,6 @@
package com.xhpc.order.service.impl; package com.xhpc.order.service.impl;
import cn.hutool.core.date.DateUtil;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.order.domain.HxpcChargeOrder; import com.xhpc.order.domain.HxpcChargeOrder;
import com.xhpc.order.domain.XhpcHistoryOrder; import com.xhpc.order.domain.XhpcHistoryOrder;
@ -10,10 +11,8 @@ import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
* @author yuyang * @author yuyang
@ -56,28 +55,95 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
return xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,status,chargingStationName,operatorId,source,startTime,endTime,userId,type,number); return xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,status,chargingStationName,operatorId,source,startTime,endTime,userId,type,number);
} }
@Override
public AjaxResult getById(Long historyOrderId) {
Map<String, Object> byId = xhpcHistoryOrderMapper.getById(historyOrderId);
if(byId !=null){
byId.putAll(getRateTime(byId.get("serialNumber").toString(),byId.get("actPrice").toString()));
}
return AjaxResult.success(byId);
}
/** /**
* 历史信息费率时段 * 历史信息费率时段
*/ */
private void getRateTime(){ private Map<String, Object> getRateTime(String serialNumber,String actPrice){
String serialNumber=""; Map<String, Object> map =new HashMap<>();
BigDecimal powerPriceTotal =new BigDecimal(0);
BigDecimal servicePriceTotal =new BigDecimal(0);
//充电订单信息 //充电订单信息
HxpcChargeOrder chargeOrder = xhpcChargeOrderService.getSerialNumberMessage(serialNumber); HxpcChargeOrder chargeOrder = xhpcChargeOrderService.getSerialNumberMessage(serialNumber);
//累计充电时间计费模型开始时间结束时间已充金额 //累计充电时间计费模型开始时间结束时间已充金额
int i = Integer.valueOf(chargeOrder.getChargingTime()).intValue();
Long rateModelId = chargeOrder.getRateModelId(); Long rateModelId = chargeOrder.getRateModelId();
Date startTime = chargeOrder.getStartTime(); String startTime = DateUtil.formatTime(chargeOrder.getStartTime());
Date endTime = chargeOrder.getEndTime(); String endTime = DateUtil.formatTime(chargeOrder.getEndTime());
String amountCharged = chargeOrder.getAmountCharged();
//每分钟充电度数=累计时间/60 //每分钟充电度数=累计时间/60
//Double rate =(Double) i%60; Integer chargingTimeNumber = chargeOrder.getChargingTimeNumber();
double s = (double) (chargingTimeNumber / 60);
List<Map<String, Object>> list =new ArrayList<>();
//获取费率时段集合 //获取费率时段集合
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderMapper.getReatTimeList(startTime, endTime, rateModelId);
if(reatTimeList !=null && reatTimeList.size()>0){
Map<String, Object> map1 =new HashMap<>();
int size = reatTimeList.size();
if(size==1){
BigDecimal powerFee = new BigDecimal(reatTimeList.get(0).get("powerFee").toString());
powerPriceTotal.add(powerFee);
BigDecimal servicePrice = new BigDecimal(reatTimeList.get(0).get("servicePrice").toString());
servicePriceTotal.add(servicePrice);
map1.put("time",startTime+"-"+endTime);
map1.put("powerPrice",powerFee);
map1.put("servicePrice",servicePrice);
map1.put("chargingDegree",chargeOrder.getChargingDegree());
map1.put("actPrice",actPrice);
list.add(map1);
}else{
for (int i = 0; i <reatTimeList.size() ; i++) {
Map<String, Object> objectMap = reatTimeList.get(i);
BigDecimal powerPrice =new BigDecimal(objectMap.get("powerFee").toString());
BigDecimal servicePrice =new BigDecimal(objectMap.get("servicePrice").toString());
String startTime1 = objectMap.get("startTime").toString();
String endTime1 = objectMap.get("endTime").toString();
powerPriceTotal.add(powerPrice);
servicePriceTotal.add(servicePrice);
if(i==0){
list.add(getRateTimeList(startTime,endTime1,s,powerPrice,servicePrice));
}else{
if(size==2){
list.add(getRateTimeList(startTime1,endTime,s,powerPrice,servicePrice));
}else{
//三个时段以上
if(i<size-1){
list.add(getRateTimeList(startTime1,endTime1,s,powerPrice,servicePrice));
}else{
list.add(getRateTimeList(startTime1,endTime,s,powerPrice,servicePrice));
}
}
}
}
}
}
map.put("list",list);//数据列表
map.put("chargingTimeTotal",chargeOrder.getChargingTime());//总时长
map.put("powerPriceTotal",powerPriceTotal);//总电费单价(/)
map.put("servicePriceTotal",servicePriceTotal);//总服务费单价(/)
map.put("chargingDegreeTotal",chargeOrder.getChargingDegree());//总度数
map.put("actPriceTotal",actPrice);//总费用
return map;
} }
private Map<String, Object> getRateTimeList(String startTime,String endTime,double s,BigDecimal powerPrice,BigDecimal servicePrice){
Map<String, Object> map =new HashMap<>();
double v = (DateUtil.parse(endTime).getTime() - DateUtil.parse(startTime).getTime()) * s;
BigDecimal multiply = powerPrice.add(servicePrice).multiply(new BigDecimal(v));
map.put("time",startTime+"-"+endTime);
map.put("powerPrice",powerPrice);
map.put("servicePrice",servicePrice);
map.put("chargingDegree",v);
map.put("actPrice",multiply);
return map;
}
} }

View File

@ -31,6 +31,7 @@
<result column="erro_remark" property="erroRemark"/> <result column="erro_remark" property="erroRemark"/>
<result column="amount_charged" property="amountCharged"/> <result column="amount_charged" property="amountCharged"/>
<result column="power" property="power"/> <result column="power" property="power"/>
<result column="charging_time_number" property="chargingTimeNumber"/>
</resultMap> </resultMap>
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcTerminal"> <resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcTerminal">
@ -249,7 +250,8 @@
<if test="type != null">type = #{type},</if> <if test="type != null">type = #{type},</if>
<if test="power != null">power = #{power},</if> <if test="power != null">power = #{power},</if>
<if test="erroRemark != null">erro_remark = #{erroRemark},</if> <if test="erroRemark != null">erro_remark = #{erroRemark},</if>
<if test="amountCharged != null">amount_charged = #{amountCharged}</if> <if test="amountCharged != null">amount_charged = #{amountCharged},</if>
<if test="chargingTimeNumber != null">charging_time_number = #{chargingTimeNumber}</if>
</set> </set>
where charge_order_id = #{chargeOrderId} where charge_order_id = #{chargeOrderId}
</update> </update>

View File

@ -34,6 +34,8 @@
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
<result column="update_by" property="updateBy"/> <result column="update_by" property="updateBy"/>
<result column="remark" property="remark"/> <result column="remark" property="remark"/>
<result column="power_price_total" property="powerPriceTotal"/>
<result column="service_price_total" property="servicePriceTotal"/>
</resultMap> </resultMap>
<insert id="insert" parameterType="com.xhpc.order.domain.XhpcHistoryOrder" useGeneratedKeys="true" <insert id="insert" parameterType="com.xhpc.order.domain.XhpcHistoryOrder" useGeneratedKeys="true"
@ -125,7 +127,13 @@
update_by, update_by,
</if> </if>
<if test="null != remark and '' != remark"> <if test="null != remark and '' != remark">
remark remark,
</if>
<if test="null != powerPriceTotal and '' != powerPriceTotal">
power_price_total,
</if>
<if test="null != servicePriceTotal and '' != servicePriceTotal">
service_price_total
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -214,7 +222,13 @@
#{updateBy}, #{updateBy},
</if> </if>
<if test="null != remark and '' != remark"> <if test="null != remark and '' != remark">
#{remark} #{remark},
</if>
<if test="null != powerPriceTotal and '' != powerPriceTotal">
#{powerPriceTotal},
</if>
<if test="null != servicePriceTotal and '' != servicePriceTotal">
#{servicePriceTotal}
</if> </if>
</trim> </trim>
</insert> </insert>
@ -270,7 +284,9 @@
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if> <if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
<if test="null != updateTime">update_time = #{updateTime},</if> <if test="null != updateTime">update_time = #{updateTime},</if>
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if> <if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
<if test="null != remark and '' != remark">remark = #{remark}</if> <if test="null != remark and '' != remark">remark = #{remark},</if>
<if test="null != powerPriceTotal and '' != remark">power_price_total = #{powerPriceTotal},</if>
<if test="null != servicePriceTotal and '' != remark">service_price_total = #{servicePriceTotal}</if>
</set> </set>
WHERE history_order_id = #{historyOrderId} WHERE history_order_id = #{historyOrderId}
</update> </update>
@ -350,6 +366,7 @@
<select id="getListPage" resultType="map"> <select id="getListPage" resultType="map">
select select
ho.history_order_id as historyOrderId, ho.history_order_id as historyOrderId,
co.charge_order_id as chargeOrderId,
ho.serial_number as serialNumber, ho.serial_number as serialNumber,
ct.name as chargingStationName, ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber, ter.pile_serial_number as pileSerialNumber,
@ -429,4 +446,59 @@
order by ho.create_time desc order by ho.create_time desc
</select> </select>
<select id="getReatTimeList" resultType="map">
select
rt.start_time as startTime,
rt.end_time as endTime,
ra.power_fee as powerFee,
ra.service_fee as serviceFee
from xhpc_rate_time as rt
left join xhpc_rate ra on rt.rate_id =ra.rate_id
where rt.rate_model_id=#{rateModelId}
and rt.end_time &gt;= #{startTime}
and rt.start_time &lt;= #{startTime}
</select>
<select id="getById" resultType="map">
select
ho.history_order_id as historyOrderId,
co.charge_order_id as chargeOrderId,
ho.serial_number as serialNumber,
ho.internet_serial_number as internetSerialNumber,
co.source as source,
ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber,
ter.name as terminalName,
op.operator_id as operatorId,
op.name as operatorName,
cp.type as type,
co.type as orderType,
co.create_time as createTime,
co.start_time as startTime,
co.end_time as endTime,
co.update_time as updateTime,
ho.total_price as totalPrice,
ho.promotion_discount as promotionDiscount,
ho.act_price as actPrice,
co.erro_remark as erroRemark,
ho.power_price_total as powerPriceTotal,
ho.service_price_total as servicePriceTotal,
ho.internet_commission as internetCommission,
ho.internet_svc_commission as internetSvcCommission,
ho.platform_commission as platformCommission,
ho.platform_svc_commisssion as platformSvcCommisssion,
ho.operation_commission as operationCommission,
ho.operation_svc_commission as operationSvcCommission,
ho.act_power_price as actPowerPrice,
ho.act_service_price as actServicePrice,
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone
from xhpc_history_order ho
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id
left join xhpc_operator as op on op.operator_id = ct.operator_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
where ho.history_order_id=#{historyOrderId}
</select>
</mapper> </mapper>