历史订单,修改websocket返回状态

This commit is contained in:
yuyang 2021-08-23 19:59:57 +08:00
parent 7c85579c86
commit cf16298b79
15 changed files with 210 additions and 30 deletions

View File

@ -30,7 +30,7 @@ public interface PileOrderService {
* 桩停止回调接口
*
* @param orderNo 订单号
* @param status 1 成功 2失败
* @param status 1 成功 2失败 3数据中断 4恢复数据
* @param remark 备注
* @return
*/

View File

@ -38,7 +38,7 @@ public class CacheOrderData extends BaseData {
private String cardNo; //物理卡号
private int startSoc;
private int endSoc;
private int status;
private int status;//1自动结算2异常
public String getOrderNo() {

View File

@ -97,7 +97,7 @@ public class HxpcPileOrderController extends BaseController {
* 桩停止回调接口
*
* @param orderNo 订单号
* @param status 1 成功 2失败
* @param status 1 成功 2失败 3数据中断 4恢复数据
* @param remark 备注
* @return
*/
@ -107,16 +107,37 @@ public class HxpcPileOrderController extends BaseController {
//解析订单编号
//String s1 = orderNo.substring(6);
Integer code = 300;
Integer code = 500;
Long userId = update(0, remark, orderNo, 1);
Map<String, Object> map = new HashMap<>();
map.put("code", code);
map.put("userId", userId);
if (status == 1) {
map.put("message", "停止充电成功");
} else {
} else if(status==2){
//停止充电失败
code=300;
map.put("message", remark);
}else if(status==3 || status==4){
//订单定位异常,修改充电订单状态
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(orderNo);
if(status==3){
hxpcChargeOrder.setStatus(2);
hxpcChargeOrder.setUpdateTime(new Date());
}else{
if(hxpcChargeOrder.getStatus()==1 || hxpcChargeOrder.getStatus()==3){
//不修改订单
}else{
hxpcChargeOrder.setStatus(0);
}
}
hxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
code=300;
map.put("message", remark);
}else{
//修改订单判断订单
}
map.put("code", code);
JSONObject json = new JSONObject(map);
//消息对了内容
rabbimt(userId + "##" + json);
@ -262,7 +283,6 @@ public class HxpcPileOrderController extends BaseController {
/**
* 桩订单结束回调
*
*/
@Transactional
@PostMapping("/chargeOrder/pileEndOrder")
@ -293,7 +313,8 @@ public class HxpcPileOrderController extends BaseController {
hxpcChargeOrder.setStartSoc(startSoc+"");
hxpcChargeOrder.setEndSoc(endSoc+"");
hxpcChargeOrder.setStatus(cacheOrderData.getStatus());
int status = cacheOrderData.getStatus();
hxpcChargeOrder.setStatus(status);
DateTime startTime = DateUtil.parse(cacheOrderData.getStartTime());
DateTime endTime = DateUtil.parse(cacheOrderData.getEndTime());
@ -314,7 +335,8 @@ public class HxpcPileOrderController extends BaseController {
hxpcChargeOrder.setAmountCharged(money.toString());
String stopReason = cacheOrderData.getStopReason();
hxpcChargeOrder.setErroRemark(stopReason);
hxpcChargeOrder.setUpdateTime(date);
hxpcChargeOrder.setStatus(status);
//历史订单
Long userId =hxpcChargeOrder.getUserId();
//生成一条历史订单
@ -333,10 +355,6 @@ public class HxpcPileOrderController extends BaseController {
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);
//流量方服务费抽成
@ -447,7 +465,7 @@ public class HxpcPileOrderController extends BaseController {
//订单总价---运维服务费抽成
xhpcHistoryOrder.setTotalPrice(money);
xhpcHistoryOrder.setPromotionDiscount(promotionDiscount);
xhpcHistoryOrder.setActPowerPrice(actPowerPrice);
xhpcHistoryOrder.setActPrice(actPrice);
xhpcHistoryOrder.setActPowerPrice(surplusPowerPrice);
xhpcHistoryOrder.setActServicePrice(surplusServicePrice);
xhpcHistoryOrder.setInternetCommission(internetCommission);
@ -490,17 +508,20 @@ public class HxpcPileOrderController extends BaseController {
private Long update(Integer status, String remark, String serialNumber, Integer type) {
logger.info("状态:"+status+"备注++"+"remark"+"订单号"+serialNumber);
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(serialNumber);
Date date = new Date();
if(status==0){
hxpcChargeOrder.setStatus(0);
hxpcChargeOrder.setStartTime(date);
}else{
hxpcChargeOrder.setStatus(-1);
hxpcChargeOrder.setDelFlag(1);
hxpcChargeOrder.setEndTime(date);
}
hxpcChargeOrder.setErroRemark(remark);
Long userId = hxpcChargeOrder.getUserId();
if (type == 1) {
Date date = new Date();
//充电订单 --结束soc充电时长充电度数
hxpcChargeOrder.setEndTime(date);
}

View File

@ -24,8 +24,31 @@ import java.util.Map;
@Api(value = "历史订单清接口", tags = "历史订单接口")
public class XhpcHistoryOrderController extends BaseController {
@Autowired
private IXhpcHistoryOrderService xhpcHistoryOrderService;
/**
* 历史订单
* @param phone 用户账号
* @param transactionNumber 订单编号
* @param type 1 自动结算 2 平台结算
* @param chargingStationName 电站名称
* @param operatorId 运营商id
* @param source 用户类型 0C端用户 1流量用户
* @param startTime 订单开始时间
* @param endTime 订单结束时间
* @param userId 用户id
* @param status 1 平台 2 运营商 3流量方
* @return
*/
@GetMapping("/getListPage")
public TableDataInfo getListPage(String phone,String transactionNumber,Integer status,String chargingStationName,Long operatorId,Integer source,String startTime,String endTime,@RequestParam("userId") Long userId,@RequestParam("type") Integer type)
{
startPage();
List<Map<String, Object>> listPage = xhpcHistoryOrderService.getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, startTime, endTime, userId, type);
return getDataTable(listPage);
}
}

View File

@ -37,13 +37,15 @@ public class XhpcRealTimeOrderController extends BaseController {
* @param startTime 订单开始时间
* @param endTime 订单结束时间
* @param status 状态-1准备充电 0开始充电 1自动结算2异常3平台结算
* @param userId 用户id
* @param type 1 平台 2 运营商 3流量方
* @return
*/
@GetMapping("/list")
public TableDataInfo list(String phone,String transactionNumber,Integer source,String chargingStationName,String terminalName,Long operatorId,String startTime,String endTime,@RequestParam("status") Integer status)
public TableDataInfo list(String phone,String transactionNumber,Integer source,String chargingStationName,String terminalName,Long operatorId,String startTime,String endTime,@RequestParam("status") Integer status,@RequestParam("userId") Long userId,@RequestParam("type") Integer type)
{
startPage();
List<Map<String,Object>> list = xhpcRealTimeOrderService.list(phone, transactionNumber, source, chargingStationName,terminalName, operatorId, startTime, endTime,status);
List<Map<String,Object>> list = xhpcRealTimeOrderService.list(phone, transactionNumber, source, chargingStationName,terminalName, operatorId, startTime, endTime,status,userId,type);
return getDataTable(list);
}
@ -81,5 +83,10 @@ public class XhpcRealTimeOrderController extends BaseController {
return xhpcRealTimeOrderService.timeChartList(chargingOrderId);
}
/**
*
*/
}

View File

@ -69,4 +69,10 @@ public interface XhpcHistoryOrderMapper {
* @return
*/
Map<String, Object> gethistotyOrderMessage(@Param("userId") Long userId, @Param("historyOrderId") Long historyOrderId, @Param("type") Integer type, @Param("chargingOrderId") Long chargingOrderId);
/**
* 历史订单记录PC
* @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);
}

View File

@ -56,10 +56,10 @@ public interface XhpcRealTimeOrderMapper {
* @param operatorId 运营商
* @param startTime 订单开始时间
* @param endTime 订单结束时间
* @param type 0 都没有 1 phone 2 用户类型有 3 都有
* @param number 0 都没有 1 phone 2 用户类型有 3 都有
* @return
*/
List<Map<String,Object>> list(@Param("phone") String phone,@Param("transactionNumber") String transactionNumber,@Param("source") Integer source,@Param("chargingStationName") String chargingStationName,@Param("terminalName")String terminalName,@Param("operatorId") Long operatorId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("type") Integer type,@Param("status")Integer status);
List<Map<String,Object>> list(@Param("phone") String phone,@Param("transactionNumber") String transactionNumber,@Param("source") Integer source,@Param("chargingStationName") String chargingStationName,@Param("terminalName")String terminalName,@Param("operatorId") Long operatorId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("number") Integer number,@Param("status")Integer status,@Param("userId")Long userId,@Param("type")Integer type);
/**
* 实时订单详情接口(PC端)

View File

@ -36,4 +36,12 @@ public interface IXhpcHistoryOrderService {
* @return 结果
*/
void insert(XhpcHistoryOrder xhpcHistoryOrder);
/**
* 历史订单记录PC
* @return
*/
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);
}

View File

@ -28,9 +28,11 @@ public interface IXhpcRealTimeOrderService {
* @param startTime 订单开始时间
* @param endTime 订单结束时间
* @param status 状态-1准备充电 0开始充电 1自动结算2异常3平台结算
* @param userId 用户id
* @param type 1 平台 2 运营商 3流量方
* @return
*/
List<Map<String,Object>> list(String phone,String transactionNumber,Integer source,String chargingStationName,String terminalName,Long operatorId,String startTime,String endTime,Integer status);
List<Map<String,Object>> list(String phone,String transactionNumber,Integer source,String chargingStationName,String terminalName,Long operatorId,String startTime,String endTime,Integer status,Long userId,Integer type);
/**
* 实时订单详情接口(PC端)

View File

@ -155,7 +155,7 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
}else{
hxpcChargeOrder.setChargingMode("小华充电支付宝");
}
hxpcChargeOrder.setStartTime(date);
hxpcChargeOrder.setCreateTime(date);
hxpcChargeOrderMapper.addXhpcChargeOrder(hxpcChargeOrder);
return AjaxResult.success();

View File

@ -8,6 +8,7 @@ import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -35,4 +36,18 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
xhpcHistoryOrderMapper.insert(xhpcHistoryOrder);
}
@Override
public 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) {
Integer number=0;
if(!"".equals(phone) && phone!=null && !"".equals(source) && source !=null){
number =3;
}else if (!"".equals(phone) && phone!=null){
number =1;
}else{
number =2;
}
return xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,status,chargingStationName,operatorId,source,startTime,endTime,userId,type,number);
}
}

View File

@ -10,6 +10,7 @@ import com.xhpc.order.service.IXhpcRealTimeOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -26,17 +27,20 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
@Override
public List<Map<String, Object>> list(String phone, String transactionNumber, Integer source, String chargingStationName, String terminalName, Long operatorId, String startTime, String endTime,Integer status) {
public List<Map<String, Object>> list(String phone, String transactionNumber, Integer source, String chargingStationName, String terminalName, Long operatorId, String startTime, String endTime,Integer status,Long userId,Integer type) {
Integer type =0;
Integer number=0;
if(!"".equals(phone) && phone!=null && !"".equals(source) && source !=null){
type =3;
number =3;
}else if (!"".equals(phone) && phone!=null){
type =1;
number =1;
}else{
type =2;
number =2;
}
return xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,type,status);
if(type ==null || userId ==null){
return new ArrayList<>();
}
return xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,number,status,userId,type);
}
@Override

View File

@ -238,6 +238,7 @@
<if test="endSoc != null">end_soc = #{endSoc},</if>
<if test="status != null">status=#{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="chargingTime != null">charging_time = #{chargingTime},</if>
<if test="chargingDegree != null">charging_degree = #{chargingDegree},</if>

View File

@ -345,4 +345,87 @@
and ho.charge_order_id =#{chargingOrderId}
</if>
</select>
<select id="getListPage" resultType="map">
select
ho.history_order_id as historyOrderId,
ho.serial_number as serialNumber,
ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber,
ter.name as terminalName,
op.operator_id as operatorId,
op.name as operatorName,
cp.power as power,
cp.type as type,
ho.type as orderType,
ho.start_soc as startSoc,
ho.end_soc as endSoc,
ho.internet_serial_number as internetSerialNumber,
ho.total_price as totalPrice,
ho.act_price as actPrice,
co.charging_time as chargingTime,
co.charging_degree as chargingDegree,
co.start_time as startTime,
co.end_time as endTime,
co.update_time as updateTime,
co.source as source,
(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 as 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.status =0 and ho.del_flag=0
<if test="type !=null">
and ho.type=#{type}
</if>
<if test="startTime !=null and startTime !=''">
and ho.start_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and ho.start_time &lt;= #{startTime}
</if>
<if test="transactionNumber !=null and transactionNumber !=''">
and ho.serial_number like concat('%', #{transactionNumber}, '%')
</if>
<if test="chargingStationName !=null and chargingStationName !=''">
and co.serial_number like concat('%', #{transactionNumber}, '%')
</if>
<if test="operatorId !=null">
and op.operator_id =#{operatorId}
</if>
<if test="number==1">
and co.user_id in (SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%')) or
co.user_id in (SELECT internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%'))
</if>
<if test="number==2">
<if test="source !=null and source ==0">
and co.user_id in (SELECT app_user_id FROM xhpc_app_user)
</if>
<if test="source !=null and source ==1">
and co.user_id in (SELECT internet_user_id from xhpc_internet_user)
</if>
</if>
<if test="number==3">
<if test="source !=null and source ==0">
and co.user_id in (SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%'))
</if>
<if test="source !=null and source ==1">
and co.user_id in (SELECT internet_user_id from xhpc_internet_user where phone like concat('%',
#{phone}, '%'))
</if>
</if>
<if test="type==2">
and co.source =0
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="type==3">
and co.source =1
and co.user_id=#{userId}
</if>
order by ho.create_time desc
</select>
</mapper>

View File

@ -382,7 +382,9 @@
cp.power as power,
cp.type as type,
co.status as status,
co.erro_remark as erroRemark,
co.create_time as createTime,
co.start_time as startTime,
(select real_time_order_id from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) realTimeOrderId,
(select soc from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) soc,
(select charging_degree from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) chargingDegree,
@ -414,11 +416,11 @@
<if test="operatorId !=null">
and op.operator_id =#{operatorId}
</if>
<if test="type==1">
<if test="number==1">
and co.user_id in (SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%')) or
co.user_id in (SELECT internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%'))
</if>
<if test="type==2">
<if test="number==2">
<if test="source !=null and source ==0">
and co.user_id in (SELECT app_user_id FROM xhpc_app_user)
</if>
@ -426,7 +428,7 @@
and co.user_id in (SELECT internet_user_id from xhpc_internet_user)
</if>
</if>
<if test="type==3">
<if test="number==3">
<if test="source !=null and source ==0">
and co.user_id in (SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%'))
</if>
@ -435,6 +437,14 @@
#{phone}, '%'))
</if>
</if>
<if test="type==2">
and co.source =0
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="type==3">
and co.source =1
and co.user_id=#{userId}
</if>
order by co.create_time desc
</select>