修改第三方订单启动和结算订单

This commit is contained in:
yuyang 2022-03-09 13:43:24 +08:00
parent 7c4fde9a3a
commit b98305c061
11 changed files with 256 additions and 43 deletions

View File

@ -5,6 +5,10 @@ package com.xhpc.common.util;
* @date 2021/12/29 16:48
*/
public class UserTypeUtil {
//超管数据id
public static final Long USER_ID = 1L;
//c端用户
public static final String USER = "C";
//流量端用户

View File

@ -355,4 +355,20 @@ public class XhpcStatisticsController extends BaseController {
{
xhpcStatisticsService.getMechanismExport(request,response,chargingStationIds,internetUserId,operatorId,startTime,endTime,userId,type,source);
}
//-------------------------------------------------首页------------------------------------------------------------
/**
* 今日订单量今日订电量今日营收今日充电枪状态
*/
@GetMapping("/getToday")
public void getToday(@RequestParam("operatorId") Long operatorId, @RequestParam("chargingStationId")Long chargingStationId,@RequestParam("chargingPileId")Long chargingPileId)
{
xhpcStatisticsService.getToday(operatorId,chargingStationId,chargingPileId);
}
}

View File

@ -22,6 +22,7 @@ public interface XhpcHistoryOrderMapper {
*/
public int insert(XhpcHistoryOrder xhpcHistoryOrder);
int updateXhpcHistoryOrderSerialNumber(XhpcHistoryOrder xhpcHistoryOrder);
/**
* 更新 历史订单信息
*

View File

@ -180,4 +180,8 @@ public interface XhpcStatisticsServiceMapper {
* 获取登陆用户信息
*/
Map<String, Object> getLandUser(@Param("userId")Long userId);
//今日订单量
Map<String, Object> getTodayNUmber(Long operatorId, Long chargingStationId, Long chargingPileId,String tenantId);
}

View File

@ -49,6 +49,9 @@ public interface IXhpcHistoryOrderService {
void insert(XhpcHistoryOrder xhpcHistoryOrder);
int updateXhpcHistoryOrderSerialNumber(XhpcHistoryOrder xhpcHistoryOrder);
/**
* 历史订单记录PC
* @return

View File

@ -274,4 +274,9 @@ public interface IXhpcStatisticsService {
void terminalIntervalExport(HttpServletRequest request,HttpServletResponse response, String chargingStationId, String terminalId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException;
void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source) throws IOException ;
/**
* 今日订单量今日订电量今日营收今日充电枪状态
*/
Map<String, Object> getToday(Long operatorId,Long chargingStationId,Long chargingPileId);
}

View File

@ -196,13 +196,13 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}
}
}
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<无效的终端编号>>>>"+terminalSerialNumber+">>>>>>>>>>>>>"+tenantId);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<终端编号>>>>"+terminalSerialNumber+">>>>>>>>>>>>>"+tenantId);
//终端信息
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(terminalSerialNumber,tenantId);
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
return AjaxResult.error(1104, "无效的终端编号");
}
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<无效的终端编号>>>>666666>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<终端编号>>>>>>>>>>>>>>>>");
//余额
String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString();
@ -567,11 +567,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方充电返回>>>>>>>>>>>>>>>>>");
if (r1.getCode() != 200) {
r.setCode(500);
r.setMsg(r1.getMsg());
return r;
}
String startTime = DateUtil.format(date, "yyyy-MM-dd HH: mm: ss");
Map<String, Object> extraData1 = xhpcChargeOrderMapper.selectDate3rdNeedBy(connectorId).get(0);
Long rateModelId = Long.valueOf(r1.getData().toString());
@ -583,13 +579,12 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
Long userId = (Long) extraData2.get("userId");
int res = xhpcChargeOrderMapper.addBy3rd(internetSerialNumber, orderNo, driverId, chargingAmt, plateNum, status, date, rateModelId, terminalId, power, chargingStationId, chargingMode, 1, userId);
Map<String, Object> data = new HashMap<>();
System.out.println(res);
data.put("orderNo", orderNo);
data.put("startTime", startTime);
r.setData(data);
if (res != 0) {
r.setCode(200);
data.put("orderNo", orderNo);
data.put("startTime", startTime);
r.setMsg("成功");
r.setData(data);
} else {
r.setCode(500);
r.setMsg("内部服务调用错误");

View File

@ -201,6 +201,11 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
xhpcHistoryOrderMapper.insert(xhpcHistoryOrder);
}
@Override
public int updateXhpcHistoryOrderSerialNumber(XhpcHistoryOrder xhpcHistoryOrder) {
return xhpcHistoryOrderMapper.updateXhpcHistoryOrderSerialNumber(xhpcHistoryOrder);
}
@Override
public List<Map<String, Object>> getListPage(String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult) {
@ -222,7 +227,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
String tenantId = loginUser.getTenantId();
//桩的统计该时段金额
List<Map<String, Object>> list = new ArrayList<>();
if (userId != 1) {
if (userId != UserTypeUtil.USER_ID) {
Map<String, Object> landUser = xhpcHistoryOrderMapper.getLandUser(logUserId);
if (landUser != null) {
if (landUser.get("userType") != null) {
@ -268,7 +273,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
//桩的统计该时段金额
List<Map<String, Object>> list = new ArrayList<>();
if (userId != 1) {
if (userId != UserTypeUtil.USER_ID) {
Map<String, Object> landUser = xhpcHistoryOrderMapper.getLandUser(logUserId);
if (landUser != null) {
if (landUser.get("userType") != null) {

View File

@ -633,13 +633,18 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
map.put("remark","充电结算自动申请退款");
}
}
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
int number = xhpcHistoryOrderService.updateXhpcHistoryOrderSerialNumber(xhpcHistoryOrder);
if(number==0){
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
}
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
logger.info("<<<<<<<<<<<<<<<<订单结束异步之前>>>>>>>>>>>>>>>>>"+xhpcHistoryOrder.getSerialNumber());
final BigDecimal balance = actPrice;
final String balance2 = subtract.toString();
final String openids =openid;
final String refundTypes =refundType;
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
// 另起线程处理业务上传redis数据
executorService.execute(new Runnable() {
@Override
@ -653,26 +658,26 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
Map<String, Object> userMessage = (Map<String, Object>)user.getData();
if (userMessage != null && userMessage.get("phone") != null) {
logger.info("<<<<<<<<<<<<<<<<进行入短信发送222>>>>>>>>>>>>>>>>>");
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("elec", xhpcChargeOrder.getEndSoc());
paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMessage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap);
// if("1".equals(xhpcChargingPile.get("type").toString())){
// HashMap<String, String> paramMap = new HashMap<>();
// paramMap.put("elec", xhpcChargeOrder.getEndSoc());
// paramMap.put("sumMoney", balance.toString());
// paramMap.put("phone", userMessage.get("phone").toString());
// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
// smsService.sendNotice(paramMap);
// }else {
// HashMap<String, String> paramMap = new HashMap<>();
// paramMap.put("sumMoney", balance.toString());
// paramMap.put("phone", userMessage.get("phone").toString());
// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。");
// smsService.sendNotice(paramMap);
// }
// HashMap<String, String> paramMap = new HashMap<>();
// paramMap.put("elec", xhpcChargeOrder.getEndSoc());
// paramMap.put("sumMoney", balance.toString());
// paramMap.put("phone", userMessage.get("phone").toString());
// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
// smsService.sendNotice(paramMap);
if("1".equals(xhpcChargingPile.get("type").toString())){
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("elec", xhpcChargeOrder.getEndSoc());
paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMessage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap);
}else {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMessage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap);
}
}
}
}
@ -683,10 +688,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
try{
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
logger.info("<<<<<<<<<<<<<<<<进入自动退款111>>>>>>>>>>>>>>>>>");
if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode()) ||UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode()) ){
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
logger.info("<<<<<<<<<<<<<<<<进入自动退款222>>>>>>>>>>>>>>>>>");
refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
}
}
@ -719,14 +722,14 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
Date date = new Date();
Long chargeOrderId = xhpcChargeOrder.getChargeOrderId();
//删除实时数据获取最新的实时数据
deleteRealTimeOrder(xhpcChargeOrder.getChargeOrderId());
//deleteRealTimeOrder(xhpcChargeOrder.getChargeOrderId());
//添加新的实时数据
List<CacheRealtimeData> list = (List<CacheRealtimeData>) cacheMap.get("realtimeDataList");
if (list != null && list.size() > 0) {
for (CacheRealtimeData cacheRealtimeData : list) {
addOrderTime(cacheRealtimeData, xhpcChargeOrder, orderNo, type);
}
}
// List<CacheRealtimeData> list = (List<CacheRealtimeData>) cacheMap.get("realtimeDataList");
// if (list != null && list.size() > 0) {
// for (CacheRealtimeData cacheRealtimeData : list) {
// addOrderTime(cacheRealtimeData, xhpcChargeOrder, orderNo, type);
// }
// }
//添加redis到数据库
XhpcOrderRedisRecord xhpcOrderRedisRecord =new XhpcOrderRedisRecord();
xhpcOrderRedisRecord.setChargeOrderId(chargeOrderId);

View File

@ -964,5 +964,40 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
IoUtil.close(out);
}
/**
* 今日订单量今日订电量今日营收今日充电枪状态
*
* @param operatorId
* @param chargingStationId
* @param chargingPileId
*/
@Override
public Map<String, Object> getToday(Long operatorId, Long chargingStationId, Long chargingPileId) {
LoginUser loginUser = tokenService.getLoginUser();
String tenantId = loginUser.getTenantId();
SysUser sysUser = loginUser.getSysUser();
//今日订单量
if(tenantId !=null && !"".equals(tenantId)){
if(sysUser.getUserId() !=UserTypeUtil.USER_ID){
if ("01".equals(sysUser.getUserType())) {
Long logOperatorId = sysUser.getOperatorId();
}else{
}
}else{
}
}
//今日订电量
//今日营收
//今日充电枪状态
return null;
}
}

View File

@ -979,4 +979,146 @@
and co.tenant_id = #{tenantId}
</if>
</select>
<update id="updateXhpcHistoryOrderSerialNumber" parameterType="com.xhpc.order.domain.XhpcHistoryOrder">
UPDATE xhpc_history_order
<set>
<if test="chargingStationId != null">
charging_station_id = #{chargingStationId},
</if>
<if test="chargeOrderId != null">
charge_order_id = #{chargeOrderId},
</if>
<if test="userId != null">
user_id = #{userId},
</if>
<if test="terminalId != null">
terminal_id = #{terminalId},
</if>
<if test="serialNumber != null">
serial_number = #{serialNumber},
</if>
<if test="internetSerialNumber != null and ''!=internetSerialNumber">
internet_serial_number = #{internetSerialNumber},
</if>
<if test="powerPriceTotal != null">
power_price_total = #{powerPriceTotal},
</if>
<if test="servicePriceTotal != null">
service_price_total = #{servicePriceTotal},
</if>
<if test="totalPrice != null">
total_price = #{totalPrice},
</if>
<if test="promotionDiscount != null">
promotion_discount = #{promotionDiscount},
</if>
<if test="actPrice != null">
act_price = #{actPrice},
</if>
<if test="actPowerPrice != null">
act_power_price = #{actPowerPrice},
</if>
<if test="actServicePrice != null">
act_service_price = #{actServicePrice},
</if>
<if test="internetCommission != null">
internet_commission = #{internetCommission},
</if>
<if test="internetSvcCommission != null">
internet_svc_commission = #{internetSvcCommission},
</if>
<if test="platformCommission != null">
platform_commission = #{platformCommission},
</if>
<if test="platformSvcCommisssion != null">
platform_svc_commisssion = #{platformSvcCommisssion},
</if>
<if test="operationCommission != null">
operation_commission = #{operationCommission},
</if>
<if test="operationSvcCommission != null">
operation_svc_commission = #{operationSvcCommission},
</if>
<if test="startSoc != null">
start_soc = #{startSoc},
</if>
<if test="endSoc != null">
end_soc = #{endSoc},
</if>
<if test="reconciliationStatus != null">
reconciliation_status = #{reconciliationStatus},
</if>
<if test="sortingStatus != null">
sorting_status = #{sortingStatus},
</if>
<if test="type != null">
`type` = #{type},
</if>
<if test="status != null">
`status` = #{status},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="state != null">
`state` = #{state},
</if>
<if test="vinNormal != null">
vin_normal = #{vinNormal},
</if>
<if test="searchValue != null">
search_value = #{searchValue},
</if>
<if test="operatorIdEvcs != null">
operator_id_evcs = #{operatorIdEvcs},
</if>
<if test="chargeModelEvcs != null">
charge_model_evcs = #{chargeModelEvcs},
</if>
<if test="connectorPowerEvcs != null">
connector_power_evcs = #{connectorPowerEvcs},
</if>
<if test="meterValueEndEvcs != null">
meter_value_end_evcs = #{meterValueEndEvcs},
</if>
<if test="meterValueStartEvcs != null">
meter_value_start_evcs = #{meterValueStartEvcs},
</if>
<if test="operatorId3rdptyEvcs != null">
operator_id3rdpty_evcs = #{operatorId3rdptyEvcs},
</if>
<if test="startTime != null">
start_time = #{startTime},
</if>
<if test="stopReasonEvcs != null">
stop_reason_evcs = #{stopReasonEvcs},
</if>
<if test="totalPower != null">
total_power = #{totalPower},
</if>
<if test="userNameEvcs != null">
user_name_evcs = #{userNameEvcs},
</if>
<if test="phone != null">
phone = #{phone},
</if>
</set>
where internet_serial_number = #{internetSerialNumber}
</update>
</mapper>