From a402fea185d75e1d7ab5c09d01ac1338f29847ec Mon Sep 17 00:00:00 2001 From: yuyang Date: Mon, 10 Jan 2022 13:52:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E9=85=8D=E7=BD=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xhpc/common/api/UserTypeService.java | 2 +- .../api/factory/UserTypeFallbackFactory.java | 2 +- .../controller/AlipayPaymentController.java | 21 +++++++++++++++++-- .../controller/WxPaymentController.java | 21 +++++++++++++++++-- .../user/controller/XhpcCommonController.java | 6 +++--- .../user/domain/XhpcCommunityPersonnel.java | 5 +++++ .../user/domain/XhpcCustomersPersonnel.java | 4 ++++ .../user/service/IXhpcAppUserUserService.java | 2 +- .../xhpc/user/service/IXhpcCommonService.java | 2 +- .../service/impl/XhpcCommonServiceImpl.java | 10 ++++----- .../impl/XhpcCommunityServiceImpl.java | 10 +++++++-- .../impl/XhpcCustomersServiceImpl.java | 11 +++++++--- .../resources/mapper/XhpcCommonMapper.xml | 3 +++ 13 files changed, 77 insertions(+), 22 deletions(-) diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java index 584dcf54..4508fe61 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java @@ -38,6 +38,6 @@ public interface UserTypeService { * @return */ @GetMapping("/common/insertUserBalance") - R insertUserBalance(@RequestParam(value = "money")BigDecimal money, @RequestParam(value = "userId")Long userId, @RequestParam(value = "userType")Integer userType, @RequestParam(value = "tenantId")String tenantId, @RequestParam(value = "type")Integer type, @RequestParam(value = "status")Integer status, @RequestParam(value = "remark")String remark); + R insertUserBalance(@RequestParam(value = "money")BigDecimal money, @RequestParam(value = "userId")Long userId, @RequestParam(value = "userType")Integer userType, @RequestParam(value = "tenantId")String tenantId, @RequestParam(value = "type")Integer type, @RequestParam(value = "status")Integer status, @RequestParam(value = "remark")String remark,@RequestParam(value = "moneyOrderId")Long moneyOrderId); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java index 393c154e..0e956717 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java @@ -27,7 +27,7 @@ public class UserTypeFallbackFactory implements FallbackFactory } @Override - public R insertUserBalance(BigDecimal money,Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark) { + public R insertUserBalance(BigDecimal money,Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId) { return R.fail("添加用户金额信息失败:" + cause.getMessage()); } }; 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 c6171ea0..1e2cb869 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 @@ -287,8 +287,25 @@ public class AlipayPaymentController { //充电中 postRefreshBalance(money, serialMumber); } - //增加用户余额 - userTypeService.insertUserBalance(money,userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null); + if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){ + //增加用户余额 + XhpcAppUser xhpcAppUser = new XhpcAppUser(); + xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId()); + xhpcAppUser.setBalance(money); + xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser); + XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); + xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId()); + xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId()); + xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount()); + xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance()); + xhpcUserAccountStatement.setCreateTime(new Date()); + xhpcUserAccountStatement.setRemark("支付宝充值订单!"); + xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + }else{ + //增加用户余额 + userTypeService.insertUserBalance(money,userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId()); + } } } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java index 1c1d83bc..e5fdab6d 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/WxPaymentController.java @@ -390,8 +390,25 @@ public class WxPaymentController { //充电中 postRefreshBalance(money, serialMumber); } - //增加用户余额 - userTypeService.insertUserBalance(money,userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null); + if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){ + //增加用户余额 + XhpcAppUser xhpcAppUser = new XhpcAppUser(); + xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId()); + xhpcAppUser.setBalance(money); + xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser); + XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); + xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId()); + xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId()); + xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount()); + xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance()); + xhpcUserAccountStatement.setCreateTime(new Date()); + xhpcUserAccountStatement.setRemark("微信充值订单!"); + xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + }else{ + //增加用户余额 + userTypeService.insertUserBalance(money,userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId()); + } } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java index cb35e60b..3280d413 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java @@ -28,7 +28,7 @@ public class XhpcCommonController extends BaseController { * @param phone * @param userId * @param userType - * @param SerialNumber 桩号 + * @param serialNumber 桩号 * @return */ @GetMapping(value = "/getUser") @@ -63,9 +63,9 @@ public class XhpcCommonController extends BaseController { * @return */ @GetMapping(value = "/insertUserBalance") - public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type, Integer status,String remark) { + public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type, Integer status,String remark,Long moneyOrderId) { - return xhpcCommonService.insertUserBalance(money,userId,userType,tenantId,type,status,remark); + return xhpcCommonService.insertUserBalance(money,userId,userType,tenantId,type,status,remark,moneyOrderId); } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java index c1a36526..d4d62bf6 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java @@ -74,4 +74,9 @@ public class XhpcCommunityPersonnel extends BaseEntity { * 充值渠道(1微信 2支付宝 3平台) */ private Integer rechargeType; + + /** + * 充值订单id、退款订单id + */ + private Long moneyOrderId; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java index 4efaaf38..8403471e 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCustomersPersonnel.java @@ -73,4 +73,8 @@ public class XhpcCustomersPersonnel extends BaseEntity { * 充值渠道(1微信 2支付宝 3平台) */ private Integer rechargeType; + /** + * 充值订单id、退款订单id + */ + private Long moneyOrderId; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java index 37e37dbf..42812998 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java @@ -106,7 +106,7 @@ public interface IXhpcAppUserUserService { public R updateIsRefund(Long userId, Integer userType,Integer isRefund); /** - * 设置小程序用户自动退款功能 + * 设置小程序用户电池保护 * @return */ public R batteryProtect(HttpServletRequest request, Integer soc,Integer socProtect,Integer userType); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java index 0b5b0ecc..a93e20b3 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java @@ -27,5 +27,5 @@ public interface IXhpcCommonService { * @param remark 备注 * @return */ - AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark); + AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java index 86b3fac0..f97db2cf 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java @@ -44,13 +44,9 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { } @Override - public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark) { + public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId) { if(UserTypeUtil.USER_TYPE.equals(userType)){ - Map appUser = xhpcCommonMapper.getAppUser(null, userId, tenantId); - //增加用户余额 - if(appUser!=null){ - - } + //C端用户暂不考虑 }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ Map communityUser = xhpcCommonMapper.getCommunityUser(null, userId, null, tenantId); @@ -62,6 +58,7 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { xhpcCommunityPersonnel.setRemark(remark); xhpcCommunityPersonnel.setRechargeType(type); xhpcCommunityPersonnel.setTenantId(tenantId); + xhpcCommunityPersonnel.setMoneyOrderId(moneyOrderId); return xhpcCommunityService.addRecharge(xhpcCommunityPersonnel); } } @@ -75,6 +72,7 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { xhpcCustomersPersonnel.setRemark(remark); xhpcCustomersPersonnel.setRechargeType(type); xhpcCustomersPersonnel.setTenantId(tenantId); + xhpcCustomersPersonnel.setMoneyOrderId(moneyOrderId); return xhpcCustomersService.addRecharge(xhpcCustomersPersonnel); } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java index 2fe781fc..a1dcd9ab 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java @@ -202,8 +202,14 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { xhpcCommunityPersonnel1.setSurplusMoney(remainingSum); xhpcCommunityPersonnel1.setRechargeMoney(rechargeMoney1.add(rechargeMoney)); xhpcCommunityMapper.updateCommunityPersonnel(xhpcCommunityPersonnel1); - //增加充值记录 - Long rechargeOrderId = mechanismService.addRechargeOrder(communityPersonnelId, UserTypeUtil.COMMUNIT_TYPE, rechargeMoney, remainingSum, xhpcCommunityPersonnel1.getRechargeType()); + + Long rechargeOrderId=null; + if(UserTypeUtil.RECHARGE_PT.equals(xhpcCommunityPersonnel.getRechargeType())){ + //增加充值记录 + rechargeOrderId = mechanismService.addRechargeOrder(communityPersonnelId, UserTypeUtil.COMMUNIT_TYPE, rechargeMoney, remainingSum, xhpcCommunityPersonnel1.getRechargeType()); + }else{ + rechargeOrderId=xhpcCommunityPersonnel.getMoneyOrderId(); + } //增加用户流水 mechanismService.insertUserAccount(communityPersonnelId,rechargeMoney,remainingSum,null,rechargeOrderId,null,UserTypeUtil.INSERT_BALANCE,xhpcCommunityPersonnel1.getTenantId(),UserTypeUtil.COMMUNIT_TYPE); return AjaxResult.success(); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java index 64023412..6e0a20c8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java @@ -123,7 +123,7 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { xhpcCustomersMapper.updateCustomers(xhpcCustomers); mechanismService.updateMechanism(xhpcCustomers.getCustomersId(),1); if(!"".equals(chargingStationIds) && chargingStationIds !=null){ - mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCustomers.getCustomersId(),0); + mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCustomers.getCustomersId(),1); } return AjaxResult.success(); } @@ -212,8 +212,13 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { xhpcCustomersPersonnel1.setSurplusMoney(remainingSum); xhpcCustomersPersonnel1.setRechargeMoney(rechargeMoney1.add(rechargeMoney)); xhpcCustomersMapper.updateCustomersPersonnel(xhpcCustomersPersonnel1); - //增加充值记录 - Long rechargeOrderId =mechanismService.addRechargeOrder(customersPersonnelId, UserTypeUtil.CUSTOMERS_TYPE,rechargeMoney,remainingSum,xhpcCustomersPersonnel1.getRechargeType()); + Long rechargeOrderId=null; + if(UserTypeUtil.RECHARGE_PT.equals(xhpcCustomersPersonnel.getRechargeType())){ + //增加充值记录 + rechargeOrderId =mechanismService.addRechargeOrder(customersPersonnelId, UserTypeUtil.CUSTOMERS_TYPE,rechargeMoney,remainingSum,xhpcCustomersPersonnel1.getRechargeType()); + }else{ + rechargeOrderId= xhpcCustomersPersonnel.getMoneyOrderId(); + } //增加用户流水 mechanismService.insertUserAccount(customersPersonnelId,rechargeMoney,remainingSum,null,rechargeOrderId,null,UserTypeUtil.INSERT_BALANCE,xhpcCustomersPersonnel1.getTenantId(),UserTypeUtil.CUSTOMERS_TYPE); return AjaxResult.success(); diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml index b3339669..c100293e 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml @@ -22,6 +22,7 @@ alipay_login as alipayLogin, del_flag delFlag, concat(0) as userType, + concat("C") as userTypeName, tenant_id tenantId, create_time as createTime from xhpc_app_user @@ -55,6 +56,7 @@ tenant_id tenantId, del_flag delFlag, concat(2) as userType, + concat("ST") as userTypeName, (select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, @@ -90,6 +92,7 @@ del_flag delFlag, tenant_id tenantId, concat(3) as userType, + concat("BE") as userTypeName, (select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,