From 8bd1aa2e069041f8899ac544b595e6b2bfe8c435 Mon Sep 17 00:00:00 2001 From: yuyang Date: Fri, 28 Jan 2022 15:39:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/XhpcRealTimeOrderServiceImpl.java | 34 ++++++++++---- .../mapper/XhpcHistoryOrderMapper.xml | 46 +++++++++++-------- .../mapper/XhpcRealTimeOrderMapper.xml | 32 ++++++++----- .../mapper/XhpcRechargeOrderMapper.xml | 14 +++--- .../mapper/XhpcRefundOrderMapper.xml | 16 ++++--- 5 files changed, 87 insertions(+), 55 deletions(-) diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 92ecce43..8ff2b5fa 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -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 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 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)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()); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 3f2d1945..7b092d9c 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -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 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 where ho.status =0 and ho.del_flag=0 @@ -744,30 +748,30 @@ - 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) - 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) - 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) - 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) - 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}, '%')) - 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}, '%')) - 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}, '%')) - 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}, '%')) @@ -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远程停止" diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml index 14881db3..98afb3df 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -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 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 where co.status=#{status} and co.del_flag=0 @@ -455,22 +465,18 @@ - 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}, '%')) - 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}, '%')) - 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}, '%')) - 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}, '%')) @@ -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 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml index 97b2d8ec..b64bf7b8 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -139,10 +139,13 @@ @@ -161,15 +164,14 @@ LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'recharge_order_status' and sdd.dict_value = xro.`status` 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 where xro.del_flag = 0 - and xro.source=#{source} and xau.phone like concat('%', #{phone}, '%') diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml index 6a40cbb0..2c1ca9ca 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -172,12 +172,14 @@