diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java index a49a30aa..60f1954c 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java @@ -64,6 +64,8 @@ public class XhpcRechargeOrder extends BaseEntity { */ private Integer source; + private String tenantId; + public Long getRechargeOrderId() { return rechargeOrderId; } @@ -143,4 +145,14 @@ public class XhpcRechargeOrder extends BaseEntity { public void setSource(Integer source) { this.source = source; } + + @Override + public String getTenantId() { + return tenantId; + } + + @Override + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java index 059a901a..6e8bada0 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java @@ -101,4 +101,14 @@ public class UserTypeUtil { public static final Long SYS_USER_TYPE_ADMIN = 1L; + + /** + * 登录状态 + */ + public static final String LOGIN = "1"; + + /** + * 未登录状态 + */ + public static final String NO_LOGIN = "0"; } 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 2eb50e79..3428ead5 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 @@ -637,21 +637,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe executorService.execute(new Runnable() { @Override public void run() { - 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(),"充电结算自动申请退款"); - } - } - } - }catch (Exception e){ - e.printStackTrace(); - logger.info("<<<<<<<<<<<<<<<<自动退款失败>>>>>>>>>>>>>>>>>"); - } try{ logger.info("<<<<<<<<<<<<<<<<进行入短信发送>>>>>>>>>>>>>>>>>"); if(!UserTypeUtil.INTERNET_TYPE.equals(source)){ @@ -688,6 +673,21 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); } addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); + 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(),"充电结算自动申请退款"); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + logger.info("<<<<<<<<<<<<<<<<自动退款失败>>>>>>>>>>>>>>>>>"); + } } }); }catch (Exception e){ @@ -767,6 +767,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>订单号:>>>"+orderNo+">>>>>"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>订单号:>>>"+orderNo+">>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>订单号:>>>"+orderNo+">>>>>>>>"); + + } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java index ce3cb205..6f9eda2f 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java @@ -38,6 +38,7 @@ import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -58,6 +59,8 @@ import java.util.Set; @Api(value = "支付宝支付接口", tags = "支付宝支付接口") public class AlipayPaymentController { + @Autowired + private Environment environment; @Autowired private IXhpcRechargeOrderService iXhpcRechargeOrderService; @Autowired @@ -79,7 +82,7 @@ public class AlipayPaymentController { @NoRepeatSubmit @PostMapping("/payment") @ApiOperation(value = "支付宝支付") - private AjaxResult payment(HttpServletRequest servletRequest, @RequestBody Map map) throws Exception { + public AjaxResult payment(HttpServletRequest servletRequest, @RequestBody Map map) throws Exception { String openid = StringUtils.valueOf(map.get("openid")); if (StringUtils.isEmpty(openid)) { return AjaxResult.error(HttpStatus.NOT_NULL, "openid不能为空"); @@ -185,7 +188,7 @@ public class AlipayPaymentController { if(xhpcRechargeOrder!=null){ XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_ALI_PAY_TYPE, xhpcRechargeOrder.getTenantId()); if(xhpcSettingConfig !=null){ - String publiccertpath = getAlipayPublicKey(xhpcSettingConfig.getZfbAlipayCertPublicKeyRsa()); + String publiccertpath = getAlipayPublicKey(environment.getProperty("PUBLICCERTPATH")); logger.info("<<<<<<<<<<<<支付宝公钥证书>>>>>>>>>"+publiccertpath); // 调用SDK验证签名 boolean signVerified = AlipaySignature.rsaCheckV1(params, publiccertpath, "utf-8", "RSA2"); diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java index 0a334b97..2086c658 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java @@ -197,10 +197,6 @@ public class XhpcRefundOrderController extends BaseController { } //是否有实时数据 Long userid = Long.valueOf(userId); - int i = iXhpcRefundOrderService.countXhpcRealTimeOrder(userid, source, tenantId); - if (i > 0) { - return R.fail("车辆正在充电,不能退款"); - } // 是否有异常订单 int j = iXhpcRefundOrderService.countXhpcChargeOrder(userid, source, tenantId); if (j > 0) { @@ -210,7 +206,6 @@ public class XhpcRefundOrderController extends BaseController { String orderOutNumber = StringUtils.numFormat(userid, Integer.parseInt(type), StatusConstants.FLOWING_WATER_REFUND_TYPE); - logger.info("<<<<<<<<<<<<<<<<开始创建退款订单>>>>>>>>>>>>>>>>>"); AjaxResult ajaxResult = iXhpcRefundOrderService.addRefundOrder("" + userid, BigDecimal.valueOf(Double.parseDouble(amount)), type, orderOutNumber, openid, remark, source, tenantId); if("200".equals(ajaxResult.get("code"))){ diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcSettingConfigImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcSettingConfigImpl.java index 238977e1..a3f40340 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcSettingConfigImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcSettingConfigImpl.java @@ -3,6 +3,7 @@ package com.xhpc.payment.service.impl; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.domain.XhpcSettingConfig; +import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.LogUserUtils; import com.xhpc.common.util.UserTypeUtil; import com.xhpc.payment.mapper.XhpcSettingConfigMapper; @@ -14,6 +15,7 @@ import org.springframework.stereotype.Service; import javax.annotation.security.DenyAll; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,6 +30,8 @@ public class XhpcSettingConfigImpl implements IXhpcSettingConfigService { private XhpcSettingConfigMapper xhpcSettingConfigMapper; @Autowired private LogUserUtils logUserUtils; + @Autowired + private TokenService tokenService; @Override public R insertXhpcSettingConfig(XhpcSettingConfig xhpcSettingConfig) { @@ -50,11 +54,11 @@ public class XhpcSettingConfigImpl implements IXhpcSettingConfigService { @Override public Map getXhpcSettingConfigStatus(HttpServletRequest request, Integer status) { - //获取登陆用户 - Long userId = SecurityUtils.getUserId(); - //桩的统计、该时段金额 - LoginUser logUser = logUserUtils.getLogUser(request); - String tenantId = logUser.getSysUser().getTenantId(); + LoginUser logUser = tokenService.getLoginUser(request); + if(logUser==null){ + return new HashMap<>(); + } + String tenantId = logUser.getTenantId(); return xhpcSettingConfigMapper.getXhpcSettingConfigStatus(status,tenantId); } } 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 b64bf7b8..18a452ef 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -20,6 +20,7 @@ + - select * - from xhpc_recharge_order xro - where xro.del_flag = 0 and xro.recharge_order_number = #{rechargeOrderNumber} + select * + from xhpc_recharge_order + where del_flag = 0 and recharge_order_number = #{rechargeOrderNumber} diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcSettingConfigMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcSettingConfigMapper.xml index c4088027..6f730beb 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcSettingConfigMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcSettingConfigMapper.xml @@ -155,7 +155,6 @@ UPDATE xhpc_setting_config - wx_app_id =#{wxAppId}, @@ -217,26 +216,30 @@ WHERE setting_config_id = #{settingConfigId} - select setting_config_id as settingConfigId, - wx_app_id as wxAppId, - wx_app_secret as wxAppSecret, - wx_mch_id as wxMchId, - wx_mch_key as wxMchKey, - wx_payment_url as wxPaymentUrl, - wx_callback_url as wxCallbackUrl, - wx_transfers_url as wxTransfersUrl, - concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as wxApiclientCertPem, - concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as wxApiclientKeyPem, - concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as wxAppCertPublicKey, - zfb_app_id as zfbAppId, - zfb_private_key as zfbPrivateKey, - zfb_callback_url as zfbCallbackUrl, - concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as zfbAppCertPublicKey, - concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as zfbAlipayCertPublicKeyRsa, - concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as zfbAlipayRootCert, - zhb_server_url as zhbServerUrl, + + wx_app_id as wxAppId, + wx_app_secret as wxAppSecret, + wx_mch_id as wxMchId, + wx_mch_key as wxMchKey, + wx_payment_url as wxPaymentUrl, + wx_callback_url as wxCallbackUrl, + wx_transfers_url as wxTransfersUrl, + concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as wxApiclientCertPem, + concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as wxApiclientKeyPem, + concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as wxAppCertPublicKey, + + + zfb_app_id as zfbAppId, + zfb_private_key as zfbPrivateKey, + zfb_callback_url as zfbCallbackUrl, + concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as zfbAppCertPublicKey, + concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as zfbAlipayCertPublicKeyRsa, + concat("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png") as zfbAlipayRootCert, + zhb_server_url as zhbServerUrl, + status as status, del_flag as delFlag, tenant_id as tenantId diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java index 51755111..7bd46975 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcAppUserMapper.java @@ -100,4 +100,11 @@ public interface XhpcAppUserMapper { * @return */ Map getUserLoginTime(@Param("type")Integer type,@Param("openid")String openid,@Param("tenantId")String tenantId); + + /** + * 该账号之前的登录信息,进行退出操作 + * @param account + * @return + */ + int updateUserLoginTime(@Param("account")String account); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index 94c24333..f06d3813 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -264,6 +264,8 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU xhpcAppUserMapper.updateCustomersPersonnel(appUserId,null,openid,null,UserConstants.LOGIN); } } + //去退出账号之前登录的信息 + xhpcAppUserMapper.updateUserLoginTime(username); //添加最后一次登录数据 xhpcAppUserMapper.addUserLoginTime(appUserId,username,userInfo.getUserType(),openid,Integer.valueOf(type),null,tenantId,new Date()); @@ -327,6 +329,8 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU } xhpcAppUserMapper.update(user); redisService.deleteObject("pvToken:" + user.getPhone()); + //去退出账号之前登录的信息 + xhpcAppUserMapper.updateUserLoginTime(username); //添加最后一次登录数据 xhpcAppUserMapper.addUserLoginTime(user.getAppUserId(),username,userInfo.getUserType(),openid,Integer.valueOf(type),UserConstants.LOGIN,tenantId,new Date()); // 获取登录token @@ -403,9 +407,13 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU if(userLoginTime ==null){ return R.fail(HttpStatus.USER_LOGIN, "请重新登录"); } - if(UserConstants.NO_LOGIN.equals(userLoginTime.get("status").toString())){ + logger.info("-------userLoginTime---"+userLoginTime.toString()); + if(userLoginTime.get("status") == null){ + return R.fail(HttpStatus.USER_LOGIN, "请重新登录"); + } else if(UserTypeUtil.NO_LOGIN.equals(userLoginTime.get("status").toString())){ return R.fail(HttpStatus.USER_LOGIN, "请重新登录"); } + logger.info("-------status---"+userLoginTime.get("status").toString()); return appLogin(userLoginTime.get("account").toString(), type, openid, tenantId); } diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml index 730ac0c4..ebf0b1f9 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml @@ -347,4 +347,8 @@ order by create_time desc limit 1 + + + update xhpc_user_login set status =0 where account=#{account} and status=1 +