修改订单查询

This commit is contained in:
yuyang 2022-01-28 15:39:25 +08:00
parent 3677a32f5a
commit 8bd1aa2e06
5 changed files with 87 additions and 55 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.RefundOrderService;
import com.xhpc.common.api.SmsService;
import com.xhpc.common.api.UserTypeService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
@ -56,6 +57,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
@Autowired
private RefundOrderService refundOrderService;
@Autowired
private UserTypeService userTypeService;
private final ExecutorService executorService = Executors.newFixedThreadPool(20);
@ -321,15 +325,21 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcChargeOrder.setStatus(3);
xhpcChargeOrder.setAmountCharged(money);
Long userId = xhpcChargeOrder.getUserId();
Map<String, Object> userMessage = xhpcChargeOrderService.getUserMessage(userId);
if(xhpcChargeOrder.getInternetSerialNumber() ==null && xhpcChargeOrder.getStatus()==0){
if (userMessage == null || userMessage.get("balance") == null) {
//订单异常
xhpcChargeOrder.setStatus(2);
//异常原因
xhpcChargeOrder.setErroRemark("".equals(xhpcChargeOrder.getErroRemark())?"用户id:" + userId + "为空":xhpcChargeOrder.getErroRemark()+"用户id:" + userId + "为空");
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
return AjaxResult.error("用户id:" + userId + "为空");
Integer source = xhpcChargeOrder.getSource();
String tenantId = xhpcChargeOrder.getTenantId();
Map<String, Object> userMessage =new HashMap<>();
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
R user = userTypeService.getUser(null, userId, source, null, tenantId);
if(user !=null && user.getData() !=null){
userMessage = (Map<String, Object>)user.getData();
if (userMessage == null || userMessage.get("balance") == null) {
//订单异常
xhpcChargeOrder.setStatus(2);
//异常原因
xhpcChargeOrder.setErroRemark("".equals(xhpcChargeOrder.getErroRemark())?"用户id:" + userId + "为空":xhpcChargeOrder.getErroRemark()+"用户id:" + userId + "为空");
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
return AjaxResult.error("用户id:" + userId + "为空");
}
}
}
//生成一条历史订单
@ -568,7 +578,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
map.put("tenantId",xhpcChargeOrder.getTerminalId());
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString());
xhpcHistoryOrder.setPhone(userMessage.get("phone").toString());
if(UserTypeUtil.USER_TYPE.equals(source)){
xhpcHistoryOrder.setPhone(userMessage.get("phone").toString());
}else{
xhpcHistoryOrder.setPhone(userMessage.get("account").toString());
}
//增加流水订单号
if(operatorMessage!=null && operatorMessage.get("operatorId")!=null){
String evcs = EvcsUtil.transferInternetOrderNo(xhpcChargeOrder.getSerialNumber(), operatorMessage.get("operatorId").toString());

View File

@ -662,6 +662,8 @@
ho.platform_svc_commisssion as platformSvcCommisssion,
ho.operation_commission as operationCommission,
ho.operation_svc_commission as operationSvcCommission,
cop.account as communityAccount,
cup.account as customersAccount,
case when co.source=0 then "C端用户"
when co.source=1 then "流量方用户"
when co.source=2 then "社区用户"
@ -682,18 +684,20 @@
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
left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2
left join xhpc_internet_user as inu on inu.internet_user_id = ho.user_id and ho.internet_serial_number is not null
left join xhpc_app_user as apu on apu.app_user_id = ho.user_id and ho.internet_serial_number is null
left join xhpc_internet_user as inu on inu.internet_user_id = ho.user_id and ho.internet_serial_number is not null and ho.source=1
left join xhpc_app_user as apu on apu.app_user_id = ho.user_id and ho.internet_serial_number is null and ho.source=0
left join xhpc_community_personnel as cop on cop.community_personnel_id = ho.user_id and ho.internet_serial_number is null and ho.source=2
left join xhpc_customers_personnel as cup on cup.customers_personnel_id = ho.user_id and ho.internet_serial_number is null and ho.source=3
<if test="number==1">
inner join (
select xiu.internet_user_id as user_id from xhpc_internet_user as xiu inner join(select user_id from xhpc_history_order where source=1) us1 on us1.user_id = xiu.internet_user_id where xiu.phone like concat('%', #{phone}, '%')
union
select xau.app_user_id as user_id from xhpc_app_user as xau inner join(select user_id from xhpc_history_order where source=0) us2 on us2.user_id = xau.app_user_id where xau.phone like concat('%', #{phone}, '%')
union
select xcp.community_personnel_id as user_id from xhpc_community_personnel as xcp inner join(select user_id from xhpc_history_order where source=2)us3 on us3.user_id = xcp.community_personnel_id where xcp.account like concat('%', #{phone}, '%')
union
select xcup.customers_personnel_id as user_id from xhpc_customers_personnel as xcup inner join(select user_id from xhpc_history_order where source=3)us3 on us4.user_id = xcup.customers_personnel_id where xcup.account like concat('%', #{phone}, '%')
) ut on ut.app_user_id = ho.user_id
select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where hio.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
union
select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = hio.user_id where hio.source=1 and xiu.phone LIKE concat('%',#{phone}, '%')
union
select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = hio.user_id where hio.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = hio.user_id where hio.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.history_order_id = ho.history_order_id
</if>
where ho.status =0 and ho.del_flag=0
<if test="type !=null">
@ -744,30 +748,30 @@
<if test="number==2">
<if test="source ==0">
and ho.user_id in(select app_user_id from xhpc_app_user where app_user_id in (select user_id from xhpc_history_order where source=0))
and ho.history_order_id in (select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where hio.source=0)
</if>
<if test="source ==1">
and ho.user_id in(select internet_user_id from xhpc_internet_user where internet_user_id in (select user_id from xhpc_history_order where source=1))
and ho.history_order_id in(select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = hio.user_id where hio.source=1)
</if>
<if test="source ==2">
and ho.user_id in(select community_personnel_id from xhpc_community_personnel where community_personnel_id in (select user_id from xhpc_history_order where source=2))
and ho.history_order_id in (select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = hio.user_id where hio.source=2)
</if>
<if test="source ==3">
and ho.user_id in(select customers_personnel_id from xhpc_customers_personnel where customers_personnel_id in (select user_id from xhpc_history_order where source=3))
and ho.history_order_id in (select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = hio.user_id where hio.source=3)
</if>
</if>
<if test="number==3">
<if test="source ==0">
and ho.user_id in(select app_user_id from xhpc_app_user where phone like concat('%', #{phone}, '%') and app_user_id in (select user_id from xhpc_history_order where source=0))
and ho.history_order_id in(select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where hio.source=0 and xau.phone LIKE concat('%',#{phone}, '%'))
</if>
<if test="source ==1">
and ho.user_id in(select internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%') and internet_user_id in (select user_id from xhpc_history_order where source=1))
and ho.history_order_id in(select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = hio.user_id where hio.source=1 and xiu.phone LIKE concat('%',#{phone}, '%'))
</if>
<if test="source ==2">
and ho.user_id in(select community_personnel_id from xhpc_community_personnel where account like concat('%', #{phone}, '%') and community_personnel_id in (select user_id from xhpc_history_order where source=2))
and ho.history_order_id in(select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = hio.user_id where hio.source=2 and xcp.account LIKE concat('%',#{phone}, '%'))
</if>
<if test="source ==3">
and ho.user_id in(select customers_personnel_id from xhpc_customers_personnel where account like concat('%', #{phone}, '%') and customers_personnel_id in (select user_id from xhpc_history_order where source=3))
and ho.history_order_id in(select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = hio.user_id where hio.source=3 and xcup.account LIKE concat('%',#{phone}, '%'))
</if>
</if>
<if test="status==1">
@ -842,8 +846,10 @@
else "自定义!"
end sanDisputeReason,
ed.check_order_seq as sanCheckOrderSeq,
(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,
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id and ho.source=0) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id and ho.source=1) as internetUserPhone,
(SELECT account from xhpc_community_personnel where community_personnel_id = co.user_id and ho.source=2) as communityAccount,
(SELECT account from xhpc_customers_personnel where customers_personnel_id = co.user_id and ho.source=3) as customersAccount,
co.Plate_num as plateNum,
(SELECT name from xhpc_internet_user where internet_user_id = co.user_id and co.source =1) as internetName,
case when ho.stop_reason_evcs=40 then "APP远程停止"

View File

@ -401,6 +401,10 @@
co.Plate_num as plateNum,
inu.name as internetName,
inu.phone as internetUserPhone,
cup.name as customersName,
cup.account as customersAccount,
cop.name as communityName,
cop.account as communityAccount,
apu.phone as appUserPhone
from xhpc_charge_order co
left join xhpc_charging_station as ct on ct.charging_station_id = co.charging_station_id
@ -409,16 +413,22 @@
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join xhpc_internet_user as inu on inu.internet_user_id = co.user_id and co.source =1
left join xhpc_app_user as apu on apu.app_user_id = co.user_id and co.source =0
left join xhpc_community_personnel as cop on cop.community_personnel_id = co.user_id and co.source =2
left join xhpc_customers_personnel as cup on cup.customers_personnel_id = co.user_id and co.source =3
LEFT JOIN (
SELECT charging_order_id,real_time_order_id,soc,charging_degree,charging_time FROM xhpc_real_time_order
WHERE real_time_order_id IN ( SELECT max( real_time_order_id ) FROM xhpc_real_time_order GROUP BY charging_order_id )
) ro ON ro.charging_order_id = co.charge_order_id
<if test="number==1">
inner join (
SELECT cro.user_id user_id FROM xhpc_charge_order cro inner join(SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%')) us1 on us1.app_user_id = cro.user_id where xco.source = 0
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_app_user as xau on xau.app_user_id = xco.user_id where xco.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
union
SELECT cro.user_id user_id FROM xhpc_charge_order xco inner join(SELECT internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%')) us2 on us2.internet_user_id = xco.user_id where xco.source = 1
) ut on ut.app_user_id = xro.user_id
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = xco.user_id where xco.source=1 and xiu.phone LIKE concat('%',#{phone}, '%')
union
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = xco.user_id where xco.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = xco.user_id where xco.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.charge_order_id = co.charge_order_id
</if>
where co.status=#{status} and co.del_flag=0
<if test="internetId !=null">
@ -455,22 +465,18 @@
</if>
<if test="number==2">
<if test="source !=null and source ==0">
and co.user_id in (
SELECT cro.user_id FROM xhpc_charge_order cro WHERE cro.source = 0 AND cro.user_id IN ( SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%')))
and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_app_user as xau on xau.app_user_id = xco.user_id where xco.source=0 and xau.phone LIKE concat('%',#{phone}, '%'))
</if>
<if test="source !=null and source ==1">
and co.user_id in (
SELECT cro.user_id FROM xhpc_charge_order cro WHERE cro.source = 1 AND cro.user_id IN (SELECT internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%')))
and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = xco.user_id where xco.source=1 and xiu.phone LIKE concat('%',#{phone}, '%'))
</if>
</if>
<if test="number==3">
<if test="source !=null and source ==0">
and co.user_id in (
SELECT cro.user_id FROM xhpc_charge_order cro WHERE cro.source = 0 AND cro.user_id IN ( SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%')))
and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_app_user as xau on xau.app_user_id = xco.user_id where xco.source=0 and xau.phone LIKE concat('%',#{phone}, '%'))
</if>
<if test="source !=null and source ==1">
and co.user_id in (
SELECT cro.user_id FROM xhpc_charge_order cro WHERE cro.source = 1 AND cro.user_id IN (SELECT internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%')))
a and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = xco.user_id where xco.source=1 and xiu.phone LIKE concat('%',#{phone}, '%'))
</if>
</if>
<if test="type==1">
@ -509,7 +515,9 @@
co.Plate_num as plateNum,
(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,
(SELECT name from xhpc_internet_user where internet_user_id = co.user_id and co.source=1) as internetName
(SELECT name from xhpc_internet_user where internet_user_id = co.user_id and co.source=1) as internetName,
(SELECT account from xhpc_community_personnel where community_personnel_id = co.user_id and co.source=2) as communityAccount,
(SELECT account from xhpc_customers_personnel where customers_personnel_id = co.user_id and co.source=3) as customersAccount
from xhpc_real_time_order ro
Left join xhpc_charge_order co on co.serial_number = ro.transaction_number
Left join xhpc_charging_station as ct on ct.charging_station_id = ro.charging_station_id

View File

@ -139,10 +139,13 @@
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
select xro.recharge_order_id rechargeOrderId ,xro.recharge_order_number rechargeOrderNumber,
xro.alipay_number alipayNumber ,xro.prepay_id prepayid,xro.user_id userId,xro.amount,
xro.alipay_number alipayNumber ,xro.prepay_id prepayid,xro.user_id userId,xro.amount,cop.phone communityPhone,cop.account communityAccount,
cup.phone customersPhone,cup.account customersAccount,
xro.type ,xro.`status`,xro.create_time createTime,xro.source source,xau.phone,sdd.dict_label statusName
from xhpc_recharge_order xro
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id
LEFT JOIN xhpc_community_personnel cop on cop.community_personnel_id = xro.user_id and xro.source=2
LEFT JOIN xhpc_customers_personnel cup on cup.customers_personnel_id = xro.user_id and xro.source=3
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'recharge_order_status' and sdd.dict_value = xro.`status`
where xro.del_flag = 0 and xro.recharge_order_id = #{rechargeOrderId}
</select>
@ -161,15 +164,14 @@
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'recharge_order_status' and sdd.dict_value = xro.`status`
<if test="source == null and phone != null and phone != ''">
inner join (
select xau.app_user_id from xhpc_app_user as xau inner join (select user_id from xhpc_recharge_order where source=0) us1 on us1.user_id=xau.app_user_id where xau.phone like concat('%', #{phone}, '%')
select ro.recharge_order_id as recharge_order_id from xhpc_recharge_order as ro INNER JOIN xhpc_app_user as xau on xau.app_user_id = ro.user_id where ro.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
union
select xcop.community_personnel_id as app_user_id from xhpc_community_personnel as xcop inner join (select user_id from xhpc_recharge_order where source=2) us2 on us2.user_id=xcop.community_personnel_id where xcop.phone like concat('%', #{phone}, '%')
select ro.recharge_order_id as recharge_order_id from xhpc_recharge_order as ro INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = ro.user_id where ro.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select xcup.customers_personnel_id as app_user_id from xhpc_customers_personnel as xcup inner join (select user_id from xhpc_recharge_order where source=3) us3 on us3.user_id = xcup.customers_personnel_id where xcup.phone like concat('%', #{phone}, '%')
) ut on ut.app_user_id = xro.user_id
select ro.recharge_order_id as recharge_order_id from xhpc_recharge_order as ro INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = ro.user_id where ro.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.recharge_order_id = xro.recharge_order_id
</if>
where xro.del_flag = 0
<if test="source != null and phone != null and phone != ''">
<if test="source==0 ">
and xro.source=#{source} and xau.phone like concat('%', #{phone}, '%')

View File

@ -172,12 +172,14 @@
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber,xro.tenant_id tenantId,
xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount,xro.source source,cop.phone communityPhone,
xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount,xro.source source,cop.phone communityPhone,cop.account communityAccount,
cup.phone customersPhone,cup.account customersAccount,
xro.type,xro.examine_status examineStatus,xro.`status`,xro.source source,xro.create_time createTime,xau.phone,
sdd.dict_label statusName,sdds.dict_label examineStatusName
from xhpc_refund_order xro
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id and xro.source=0
LEFT JOIN xhpc_community_personnel cop on cop.community_personnel_id = xro.user_id and xro.source=2
LEFT JOIN xhpc_customers_personnel cup on cup.customers_personnel_id = xro.user_id and xro.source=3
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value = xro.examine_status
where xro.del_flag = 0 and xro.refund_order_id = #{refundOrderId}
@ -196,12 +198,12 @@
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value =xro.examine_status
<if test="source == null and phone != null and phone !=''">
inner join (
select xau.app_user_id from xhpc_app_user as xau inner join(select user_id from xhpc_recharge_order where source=0) us1 on us1.user_id = xau.app_user_id where xau.phone like concat('%', #{phone}, '%')
union
select xcop.community_personnel_id as app_user_id from xhpc_community_personnel as xcop inner join (select user_id from xhpc_recharge_order where source=2) us2 on us2.user_id=xcop.community_personnel_id where xcop.phone like concat('%', #{phone}, '%')
union
select xcup.customers_personnel_id as app_user_id from xhpc_customers_personnel as xcup inner join (select user_id from xhpc_recharge_order where source=3) us3 on us3.user_id = xcup.customers_personnel_id where xcup.phone like concat('%', #{phone}, '%')
) ut on ut.app_user_id = xro.user_id
select ro.refund_order_id as refund_order_id from xhpc_refund_order as ro INNER JOIN xhpc_app_user as xau on xau.app_user_id = ro.user_id where ro.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
union
select ro.refund_order_id as refund_order_id from xhpc_refund_order as ro INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = ro.user_id where ro.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select ro.refund_order_id as refund_order_id from xhpc_refund_order as ro INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = ro.user_id where ro.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.refund_order_id = xro.refund_order_id
</if>
where xro.del_flag = 0
<if test="source != null and phone != null">