diff --git a/sql/v2.1.sql b/sql/v2.1.sql index c42c64bb..60f61d49 100644 --- a/sql/v2.1.sql +++ b/sql/v2.1.sql @@ -281,3 +281,47 @@ ALTER TABLE `xhpc_vin_blacklist` ALTER TABLE `xhpc_user_account_statement` ADD COLUMN `source` INT(4) NULL DEFAULT '0' COMMENT '订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户)' AFTER `tenant_id`; + +ALTER TABLE `xhpc_app_user` + ADD COLUMN `soc_protect` INT(4) NULL DEFAULT '0' COMMENT '是否开启电池保护 0 未开启 1开启' AFTER `tenant_id`; +ALTER TABLE `xhpc_community_personnel` + ADD COLUMN `soc_protect` INT(4) NULL DEFAULT '0' COMMENT '是否开启电池保护 0 未开启 1开启' AFTER `tenant_id`; +ALTER TABLE `xhpc_customers_personnel` + ADD COLUMN `soc_protect` INT(4) NULL DEFAULT '0' COMMENT '是否开启电池保护 0 未开启 1开启' AFTER `tenant_id`; + +ALTER TABLE `xhpc_setting_config` + CHANGE COLUMN `zhb_server_url` `zhb_server_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝网管' COLLATE 'utf8mb4_general_ci' AFTER `zfb_alipay_root_cert`; + +CREATE TABLE `xhpc_setting_config` ( + `setting_config_id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `wx_app_id` VARCHAR(50) NULL DEFAULT NULL COMMENT '微信小程序id' COLLATE 'utf8mb4_general_ci', + `wx_app_secret` VARCHAR(50) NULL DEFAULT NULL COMMENT '微信小程序密钥' COLLATE 'utf8mb4_general_ci', + `wx_mch_id` VARCHAR(20) NULL DEFAULT NULL COMMENT '微信商户id' COLLATE 'utf8mb4_general_ci', + `wx_mch_key` VARCHAR(50) NULL DEFAULT NULL COMMENT '微信商户平台Key' COLLATE 'utf8mb4_general_ci', + `wx_payment_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信小程序支付地址' COLLATE 'utf8mb4_general_ci', + `wx_callback_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信回调地址' COLLATE 'utf8mb4_general_ci', + `wx_transfers_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '向微信用户个人付款地址' COLLATE 'utf8mb4_general_ci', + `wx_apiclient_cert_pem` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信证书' COLLATE 'utf8mb4_general_ci', + `wx_apiclient_key_pem` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信证书' COLLATE 'utf8mb4_general_ci', + `wx_app_cert_public_key` VARCHAR(255) NULL DEFAULT NULL COMMENT '微信证书' COLLATE 'utf8mb4_general_ci', + `zfb_app_id` VARCHAR(50) NULL DEFAULT NULL COMMENT '支付宝appid' COLLATE 'utf8mb4_general_ci', + `zfb_private_key` VARCHAR(500) NULL DEFAULT NULL COMMENT '支付宝应用私钥' COLLATE 'utf8mb4_general_ci', + `zfb_callback_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝回调地址' COLLATE 'utf8mb4_general_ci', + `zfb_app_cert_public_key` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝应用公钥证书路径' COLLATE 'utf8mb4_general_ci', + `zfb_alipay_cert_public_key_rsa` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝公钥证书路径' COLLATE 'utf8mb4_general_ci', + `zfb_alipay_root_cert` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝根证书路径' COLLATE 'utf8mb4_general_ci', + `zhb_server_url` VARCHAR(255) NULL DEFAULT NULL COMMENT '支付宝网管' COLLATE 'utf8mb4_general_ci', + `status` INT(4) NULL DEFAULT '0' COMMENT '1微信 2支付宝', + `del_flag` INT(1) NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)', + `create_by` VARCHAR(64) NULL DEFAULT '' COMMENT '创建者' COLLATE 'utf8mb4_general_ci', + `create_time` DATETIME NULL DEFAULT NULL COMMENT '创建时间', + `update_by` VARCHAR(64) NULL DEFAULT '' COMMENT '更新者' COLLATE 'utf8mb4_general_ci', + `update_time` DATETIME NULL DEFAULT NULL COMMENT '更新时间', + `remark` VARCHAR(500) NULL DEFAULT NULL COMMENT '备注' COLLATE 'utf8mb4_general_ci', + `tenant_id` VARCHAR(12) NULL DEFAULT '000000' COMMENT '租户id' COLLATE 'utf8mb4_general_ci', + PRIMARY KEY (`setting_config_id`) USING BTREE +) + COLLATE='utf8mb4_general_ci' +ENGINE=InnoDB +AUTO_INCREMENT=3 +; diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml index 5ed1000e..0d529603 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -846,7 +846,8 @@ select IF(SUM(total_power) IS NULL, 0, SUM(total_power)) as chargingDegreeSum, COUNT(history_order_id) as realTimeOrderIdCount, - COUNT(DISTINCT user_id) as userIdCount + ((SELECT count(user_id) from xhpc_history_order where charging_station_id =#{chargingStationId} and create_time >= #{createTime} and source=1 ) + + (SELECT count(DISTINCT user_id) from xhpc_history_order where charging_station_id =#{chargingStationId} and create_time >= #{createTime} and source!=1 )) as userIdCount from xhpc_history_order where charging_station_id =#{chargingStationId} and create_time >= #{createTime} 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 0df29642..584dcf54 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 @@ -7,6 +7,8 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.math.BigDecimal; + /** * @author yuyang * @date 2021/12/29 10:23 @@ -21,4 +23,21 @@ public interface UserTypeService { */ @GetMapping("/common/getUser") R getUser(@RequestParam(value = "phone")String phone,@RequestParam(value = "userId")Long userId,@RequestParam(value = "userType")Integer userType,@RequestParam(value = "serialNumber")String serialNumber,@RequestParam(value = "tenantId")String tenantId); + + + + /** + * 根据用户类型,用户id,充值记录,增加流水 + * @param money 充值金额 + * @param userId 充值用户 + * @param userType 用户类型 + * @param tenantId 租户id + * @param type 充值渠道(1微信 2支付宝 3平台) + * @param status 1 充值 2退款 + * @param remark 备注 + * @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); + } 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 242ff7e3..393c154e 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 @@ -7,6 +7,8 @@ import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; +import java.math.BigDecimal; + /** * @author yuyang * @date 2021/12/29 10:27 @@ -23,6 +25,11 @@ public class UserTypeFallbackFactory implements FallbackFactory public R getUser(String phone, Long userId, Integer userType,String serialNumber,String tenantId) { return R.fail("用户信息获取失败:" + cause.getMessage()); } + + @Override + public R insertUserBalance(BigDecimal money,Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark) { + return R.fail("添加用户金额信息失败:" + cause.getMessage()); + } }; } } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRechargeOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java similarity index 98% rename from xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRechargeOrder.java rename to xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java index ac7ff9d2..a49a30aa 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRechargeOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRechargeOrder.java @@ -1,4 +1,4 @@ -package com.xhpc.payment.domain; +package com.xhpc.common.domain; import com.xhpc.common.core.web.domain.BaseEntity; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRefundOrder.java similarity index 99% rename from xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java rename to xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRefundOrder.java index c7485ef9..1325a56b 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcRefundOrder.java @@ -1,4 +1,4 @@ -package com.xhpc.payment.domain; +package com.xhpc.common.domain; import com.xhpc.common.core.web.domain.BaseEntity; 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 3394ceb7..da87eb51 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 @@ -26,4 +26,51 @@ public class UserTypeUtil { //重新登录 public static final Integer LOGIN_TYPE = 1999; + + /** + * 微信操作渠道 + */ + public static final Integer OPERATION_WX_TYPE = 1; + + /** + * 支付宝操作渠道 + */ + public static final Integer OPERATION_ALI_PAY_TYPE = 2; + + /** + * 用户增加余额 + */ + public static final Integer INSERT_BALANCE = 1; + /** + * 用户减少余额 + */ + public static final Integer UPDATE_BALANCE = 2; + + /** + * 微信支付 + */ + public static final Integer RECHARGE_WX = 1; + /** + * 支付宝支付 + */ + public static final Integer RECHARGE_ZHB = 2; + /** + * 平台支付 + */ + public static final Integer RECHARGE_PT = 3; + + /** + * 支付状态-待支付 + */ + public static final Integer RECHARGE_STATUS_ZERO= 0; + /** + * 支付状态-充值成功 + */ + public static final Integer RECHARGE_STATUS_ONE = 1; + /** + * 支付状态-充值失败 + */ + public static final Integer RECHARGE_STATUS_TWO = 2; + + } 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 432b2813..c6171ea0 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 @@ -1,34 +1,32 @@ package com.xhpc.payment.controller; -import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayClient; import com.alipay.api.CertAlipayRequest; import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.AlipayTradeAppPayModel; import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.internal.util.AntCertificationUtil; -import com.alipay.api.request.AlipayTradeAppPayRequest; import com.alipay.api.request.AlipayTradeCreateRequest; -import com.alipay.api.request.AlipayTradeRoyaltyRelationBindRequest; import com.alipay.api.response.AlipayTradeCreateResponse; -import com.alipay.api.response.AlipayTradeRoyaltyRelationBindResponse; import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.api.UserTypeService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.down.StartChargingData; -import com.xhpc.payment.domain.AlipayNotifyParam; -import com.xhpc.payment.domain.XhpcAppUser; -import com.xhpc.payment.domain.XhpcRechargeOrder; -import com.xhpc.payment.domain.XhpcUserAccountStatement; +import com.xhpc.common.domain.XhpcRechargeOrder; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.payment.domain.*; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; +import com.xhpc.payment.service.IXhpcCommonPayment; import com.xhpc.payment.service.IXhpcRechargeOrderService; import com.xhpc.payment.service.IXhpcRefundOrderService; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -59,6 +57,13 @@ public class AlipayPaymentController { private PowerPileService powerPileService; @Autowired private IXhpcRefundOrderService iXhpcRefundOrderService; + @Autowired + private TokenService tokenService; + @Autowired + private IXhpcCommonPayment xhpcCommonPayment; + @Autowired + private UserTypeService userTypeService; + private static final Logger logger = LoggerFactory.getLogger(AlipayPaymentController.class); @@ -83,30 +88,40 @@ public class AlipayPaymentController { if (StringUtils.isEmpty(userId)) { return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空"); } - Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId)); + + LoginUser loginUser = tokenService.getLoginUser(servletRequest); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + + Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId); if (StringUtils.isNotNull(refundOrder)) { return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "用户存正在退款"); } - String orderNumber = StringUtils.numFormat(Long.parseLong(userId), 1, StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + String orderNumber = StringUtils.numFormat(userid, 1, StatusConstants.FLOWING_WATER_RECHARGE_TYPE); + XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_ALI_PAY_TYPE, tenantId); + if(xhpcSettingConfig ==null){ + return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "支付宝充值失败,继续充值请联系客服"); + } //生成充值订单 - XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "2", orderNumber); + XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId+"", BigDecimal.valueOf(Double.parseDouble(amount)), "2", orderNumber,userType); String attach = attachYu(StringUtils.valueOf(xhpcRechargeOrder.getRechargeOrderId()), StringUtils.valueOf(amount), null, orderNumber); /** 初始化 **/ CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); /** 支付宝网关 **/ - certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); + certAlipayRequest.setServerUrl(xhpcSettingConfig.getZhbServerUrl()); /** 应用id,如何获取请参考:https://opensupport.alipay.com/support/helpcenter/190/201602493024 **/ - certAlipayRequest.setAppId(environment.getProperty("ALIPAYAPPID")); + certAlipayRequest.setAppId(xhpcSettingConfig.getZfbAppId()); /** 应用私钥, 如何获取请参考:https://opensupport.alipay.com/support/helpcenter/207/201602471154?ant_source=antsupport **/ - certAlipayRequest.setPrivateKey(environment.getProperty("ALIPAYPRIVATEKEY")); + certAlipayRequest.setPrivateKey(xhpcSettingConfig.getZfbPrivateKey()); /** 应用公钥证书路径,下载后保存位置的绝对路径 **/ - certAlipayRequest.setCertPath(environment.getProperty("CERTPATH")); + certAlipayRequest.setCertPath(xhpcSettingConfig.getZfbAppCertPublicKey()); /** 支付宝公钥证书路径,下载后保存位置的绝对路径 **/ - certAlipayRequest.setAlipayPublicCertPath(environment.getProperty("PUBLICCERTPATH")); + certAlipayRequest.setAlipayPublicCertPath(xhpcSettingConfig.getZfbAlipayCertPublicKeyRsa()); /** 支付宝根证书路径,下载后保存位置的绝对路径 **/ - certAlipayRequest.setRootCertPath(environment.getProperty("ROOTCRETPATH")); + certAlipayRequest.setRootCertPath(xhpcSettingConfig.getZfbAlipayRootCert()); /** 设置签名类型 **/ certAlipayRequest.setSignType("RSA2"); /** 设置请求格式,固定值json **/ @@ -125,7 +140,7 @@ public class AlipayPaymentController { "\"passback_params\":\""+encode+"\"," + "\"buyer_id\":\""+openid+"\"" + "}"); - request.setNotifyUrl(environment.getProperty("ALIPAYPSERVERDOMAIN")); + request.setNotifyUrl(xhpcSettingConfig.getZfbCallbackUrl()); try { //这里和普通的接口调用不同,使用的是sdkExecute AlipayTradeCreateResponse response = alipayClient.certificateExecute(request); @@ -153,43 +168,47 @@ public class AlipayPaymentController { Map params = convertRequestParamsToMap(request); // 将异步通知中收到的待验证所有参数都存放到map中 logger.info("<<<<<<<<<<<>>>>>>>>"+params); - logger.info("<<<<<<<<<<<<>>>>>>>>>"); try{ - String publiccertpath = getAlipayPublicKey(environment.getProperty("PUBLICCERTPATH")); - logger.info("<<<<<<<<<<<<支付宝公钥证书>>>>>>>>>"+publiccertpath); - // 调用SDK验证签名 - boolean signVerified = AlipaySignature.rsaCheckV1(params, publiccertpath, "utf-8", "RSA2"); - logger.info("<<<<<<<<<<<<验证签名>>>>>>>>>"+signVerified); - if (signVerified) { - //("支付宝回调签名认证成功"); - AlipayNotifyParam param = buildAlipayNotifyParam(params); - String trade_status = param.getTradeStatus(); - // 支付成功 - if (trade_status.equals("TRADE_SUCCESS") || trade_status.equals("TRADE_FINISHED")) { - // 处理支付成功逻辑 - try{ - String passbackParams = param.getPassbackParams(); - String tradeStatus = param.getTradeStatus(); - if ("TRADE_SUCCESS".equals(tradeStatus)) { - // 业务参数主要转码回来 - JSONObject jsonObject = JSON.parseObject(URLDecoder.decode(passbackParams)); - logger.info("<<<<<<<<<<<>>>>>>>>"+jsonObject.toString()); - String out_trade_no = jsonObject.getString("out_trade_no"); - String transaction_id = params.get("trade_no"); - paymentCallback(out_trade_no, transaction_id); + XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.infoRechargeOrderNumber(params.get("out_trade_no").toString()); + if(xhpcRechargeOrder!=null){ + XhpcSettingConfig xhpcSettingConfig = xhpcCommonPayment.getXhpcSettingConfigTenantId(UserTypeUtil.OPERATION_ALI_PAY_TYPE, xhpcRechargeOrder.getTenantId()); + if(xhpcSettingConfig !=null){ + String publiccertpath = getAlipayPublicKey(xhpcSettingConfig.getZfbAlipayCertPublicKeyRsa()); + logger.info("<<<<<<<<<<<<支付宝公钥证书>>>>>>>>>"+publiccertpath); + // 调用SDK验证签名 + boolean signVerified = AlipaySignature.rsaCheckV1(params, publiccertpath, "utf-8", "RSA2"); + logger.info("<<<<<<<<<<<<验证签名>>>>>>>>>"+signVerified); + if (signVerified) { + //("支付宝回调签名认证成功"); + AlipayNotifyParam param = buildAlipayNotifyParam(params); + String trade_status = param.getTradeStatus(); + // 支付成功 + if (trade_status.equals("TRADE_SUCCESS") || trade_status.equals("TRADE_FINISHED")) { + // 处理支付成功逻辑 + try{ + String passbackParams = param.getPassbackParams(); + String tradeStatus = param.getTradeStatus(); + if ("TRADE_SUCCESS".equals(tradeStatus)) { + // 业务参数主要转码回来 + JSONObject jsonObject = JSON.parseObject(URLDecoder.decode(passbackParams)); + String out_trade_no = jsonObject.getString("out_trade_no"); + String transaction_id = params.get("trade_no"); + paymentCallback(out_trade_no, transaction_id); + } + }catch (Exception e){ + //("支付宝回调业务处理报错,params:" + paramsJson, e); + } + }else{ + //("没有处理支付宝回调业务,支付宝交易状态:{},params:{}",trade_status,paramsJson); } - }catch (Exception e){ - //("支付宝回调业务处理报错,params:" + paramsJson, e); + // 业务处理失败,可查看日志进行补偿,跟支付宝已经没多大关系。 + return "success"; + }else{ + return "failure"; } - }else{ - //("没有处理支付宝回调业务,支付宝交易状态:{},params:{}",trade_status,paramsJson); } - - // 业务处理失败,可查看日志进行补偿,跟支付宝已经没多大关系。 - return "success"; - }else{ - return "failure"; } + return "failure"; }catch (Exception e){ e.printStackTrace(); //logger.error("支付宝回调签名认证失败,paramsJson:{},errorMsg:{}", paramsJson, e.getMessage()); @@ -252,31 +271,24 @@ public class AlipayPaymentController { //修改充值订单状态 iXhpcRechargeOrderService.updateRechargeOrder(xhpcRechargeOrder.getRechargeOrderId(), StatusConstants.OPERATION_ALI_PAY_TYPE, StatusConstants.RECHARGE_ORDER_STATUS_SUCCESS, transaction_id); } - Map appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId()); - if (StringUtils.isNotNull(appUserInfo)) { - String balance = StringUtils.valueOf(appUserInfo.get("balance")); + Long userId = xhpcRechargeOrder.getUserId(); + Integer source = xhpcRechargeOrder.getSource(); + String tenantId = xhpcRechargeOrder.getTenantId(); + //判断用户 + R user = userTypeService.getUser(null,userId, source, null, tenantId); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + String balance = StringUtils.valueOf(map.get("balance")); BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount()); //判断用户是否在充电中 - String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId()); + String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId); logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber:"+serialMumber); if(!"".equals(serialMumber) && serialMumber !=null){ //充电中 postRefreshBalance(money, serialMumber); } //增加用户余额 - 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); + userTypeService.insertUserBalance(money,userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null); } } 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 ced388b9..60c21bf2 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 @@ -1,6 +1,7 @@ package com.xhpc.payment.controller; import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.api.UserTypeService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.domain.R; @@ -8,12 +9,15 @@ import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.utils.WXPayUtil; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.down.StartChargingData; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.payment.domain.XhpcAppUser; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import com.xhpc.payment.domain.XhpcUserAccountStatement; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRechargeOrderService; import com.xhpc.payment.service.IXhpcRefundOrderService; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -66,6 +70,11 @@ public class WxPaymentController { @Autowired private PowerPileService powerPileService; + @Autowired + private TokenService tokenService; + @Autowired + private UserTypeService userTypeService; + private static final Logger logger = LoggerFactory.getLogger(WxPaymentController.class); private int number; @@ -96,10 +105,12 @@ public class WxPaymentController { return AjaxResult.error(HttpStatus.NOT_NULL, "请在我的里面进行充值"); } String userId = StringUtils.valueOf(map.get("userId")); -// if (StringUtils.isEmpty(userId)) { -// return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空"); -// } - Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId)); + + LoginUser loginUser = tokenService.getLoginUser(servletRequest); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId); if (StringUtils.isNotNull(refundOrder)) { return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "用户存正在退款"); } @@ -109,7 +120,7 @@ public class WxPaymentController { return AjaxResult.error(HttpStatus.NOT_NULL, "充值金额不能为0"); } //生成充值订单 - XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "1", orderNumber); + XhpcRechargeOrder xhpcRechargeOrder = iXhpcRechargeOrderService.addRechargeOrder(userId, BigDecimal.valueOf(Double.parseDouble(amount)), "1", orderNumber,userType); //附加数据(否) String attach = attachYu(StringUtils.valueOf(xhpcRechargeOrder.getRechargeOrderId()), StringUtils.valueOf(amount), null, orderNumber); //商品描述(是) @@ -365,32 +376,26 @@ public class WxPaymentController { //修改充值订单状态 iXhpcRechargeOrderService.updateRechargeOrder(xhpcRechargeOrder.getRechargeOrderId(), StatusConstants.OPERATION_WX_TYPE, StatusConstants.RECHARGE_ORDER_STATUS_SUCCESS, transaction_id); } - Map appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId()); - if (StringUtils.isNotNull(appUserInfo)) { - String balance = StringUtils.valueOf(appUserInfo.get("balance")); + + Long userId = xhpcRechargeOrder.getUserId(); + Integer source = xhpcRechargeOrder.getSource(); + String tenantId = xhpcRechargeOrder.getTenantId(); + R user = userTypeService.getUser(null,userId, source, null, tenantId); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + String balance = StringUtils.valueOf(map.get("balance")); BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount()); //判断用户是否在充电中 - String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId()); + String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId); logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber:"+serialMumber); if(!"".equals(serialMumber) && serialMumber !=null){ - //充电中 - postRefreshBalance(money, serialMumber); + //充电中 + postRefreshBalance(money, serialMumber); } //增加用户余额 - 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); + userTypeService.insertUserBalance(money,userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null); } + } private void postRefreshBalance(BigDecimal money, String serialMumber) { diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java index 7133c268..df85b500 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java @@ -16,13 +16,15 @@ import com.xhpc.common.core.utils.WXPayUtil; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.security.service.TokenService; import com.xhpc.payment.domain.XhpcAppUser; import com.xhpc.payment.domain.XhpcRefundAudit; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRefundAuditService; import com.xhpc.payment.service.IXhpcRefundOrderService; import com.xhpc.payment.service.impl.XhpcUserAccountStatementServiceImpl; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; @@ -45,6 +47,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.*; import javax.net.ssl.SSLContext; +import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -77,6 +80,8 @@ public class XhpcRefundAuditController extends BaseController { @Autowired private SmsService smsService; + @Autowired + private TokenService tokenService; private static final Logger logger = LoggerFactory.getLogger(XhpcRefundAuditController.class); /** @@ -160,12 +165,16 @@ public class XhpcRefundAuditController extends BaseController { @PostMapping("/cancelExamine") @ApiOperation(value = "取消申请") @Transactional - public AjaxResult cancelExamine(@RequestBody Map map) { + public AjaxResult cancelExamine(HttpServletRequest request, @RequestBody Map map) { String userId = StringUtils.valueOf(map.get("userId")); if (StringUtils.isEmpty(userId)) { return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空"); } - Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId)); + LoginUser loginUser = tokenService.getLoginUser(request); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + Map refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId); if (StringUtils.isNull(refundOrder)) { return AjaxResult.error(HttpStatus.DATA_ERROR, "退款订单不存在"); } 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 655b0d23..86b29c50 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 @@ -6,12 +6,15 @@ import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.security.service.TokenService; import com.xhpc.payment.service.IXhpcRefundOrderService; +import com.xhpc.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; @@ -25,7 +28,8 @@ public class XhpcRefundOrderController extends BaseController { @Autowired private IXhpcRefundOrderService iXhpcRefundOrderService; - + @Autowired + private TokenService tokenService; /** * 申请退款 * @@ -94,8 +98,12 @@ public class XhpcRefundOrderController extends BaseController { */ @GetMapping("/getNotRefundOrder") @ApiOperation(value = "用户id查询未完成退款订单") - public AjaxResult getNotRefundOrder(@RequestParam Long userId) { - return AjaxResult.success(iXhpcRefundOrderService.getNotRefundOrder(userId)); + public AjaxResult getNotRefundOrder(HttpServletRequest request, @RequestParam Long userId) { + LoginUser loginUser = tokenService.getLoginUser(request); + Long userid = loginUser.getUserid(); + Integer userType = loginUser.getUserType(); + String tenantId = loginUser.getTenantId(); + return AjaxResult.success(iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId)); } /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcSettingConfig.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcSettingConfig.java new file mode 100644 index 00000000..6c256745 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcSettingConfig.java @@ -0,0 +1,100 @@ +package com.xhpc.payment.domain; + +import com.xhpc.common.core.web.domain.BaseEntity; +import lombok.Data; + +/** + * @author yuyang + * @date 2022/1/6 14:33 + */ +@Data +public class XhpcSettingConfig extends BaseEntity { + + /** + * 支付设置 + */ + private Long settingConfigId; + + /** + * 微信小程序id + */ + private String wxAppId; + + /** + * 微信小程序密钥 + */ + private String wxAppSecret; + /** + * 微信商户id + */ + private String wxMchId; + /** + * 微信商户平台Key + */ + private String wxMchKey; + /** + * 微信小程序支付地址 + */ + private String wxPaymentUrl; + /** + * 微信回调地址 + */ + private String wxCallbackUrl; + /** + * 向微信用户个人付款地址 + */ + private String wxTransfersUrl; + /** + * 微信证书 + */ + private String wxApiclientCertPem; + /** + * 微信证书 + */ + private String wxApiclientKeyPem; + /** + * 微信证书 + */ + private String wxAppCertPublicKey; + /** + * 支付宝appid + */ + private String zfbAppId; + /** + * 支付宝应用私钥 + */ + private String zfbPrivateKey; + /** + * 支付宝回调地址 + */ + private String zfbCallbackUrl; + /** + * 支付宝应用公钥证书路径 + */ + private String zfbAppCertPublicKey; + /** + * 支付宝公钥证书路径 + */ + private String zfbAlipayCertPublicKeyRsa; + /** + * 支付宝根证书路径 + */ + private String zfbAlipayRootCert; + /** + * 支付宝网管 + */ + private String zhbServerUrl; + /** + * 1微信 2支付宝 + */ + private Integer status; + /** + *删除标志(0代表存在 1代表删除) + */ + private Integer delFlag; + /** + *租户id + */ + private String tenantId; + +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcCommonPaymentMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcCommonPaymentMapper.java new file mode 100644 index 00000000..3f543b1a --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcCommonPaymentMapper.java @@ -0,0 +1,16 @@ +package com.xhpc.payment.mapper; + +import com.xhpc.payment.domain.XhpcSettingConfig; +import org.apache.ibatis.annotations.Param; + +/** + * @author yuyang + * @date 2022/1/6 14:31 + */ +public interface XhpcCommonPaymentMapper { + + /** + * 根据租户id获取支付信息 + */ + XhpcSettingConfig getXhpcSettingConfigTenantId(@Param("status") Integer status,@Param("tenantId") String tenantId); +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java index e0734153..ae67f17f 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java @@ -1,6 +1,6 @@ package com.xhpc.payment.mapper; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import org.apache.ibatis.annotations.Param; import java.util.List; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java index 0b82e388..7c619a6c 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java @@ -1,6 +1,6 @@ package com.xhpc.payment.mapper; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -94,7 +94,7 @@ public interface XhpcRefundOrderMapper { * @param userId 用户id * @return 结果 */ - public Map getNotRefundOrder(@Param("userId") Long userId); + public Map getNotRefundOrder(@Param("userId") Long userId,@Param("userType")Integer userType,@Param("tenantId")String tenantId); /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java index 77b4c458..0738c2e7 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java @@ -70,6 +70,6 @@ public interface XhpcUserAccountStatementMapper { * @param userId * @return */ - String getUserHistotyChargeOrder(@Param("userId") Long userId); + String getUserHistotyChargeOrder(@Param("userId") Long userId,@Param("source") Integer source,@Param("tenantId")String tenantId); } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcCommonPayment.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcCommonPayment.java new file mode 100644 index 00000000..a0b616b1 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcCommonPayment.java @@ -0,0 +1,15 @@ +package com.xhpc.payment.service; + +import com.xhpc.payment.domain.XhpcSettingConfig; + +/** + * @author yuyang + * @date 2022/1/6 14:29 + */ +public interface IXhpcCommonPayment { + + /** + * 根据租户id获取支付信息 + */ + XhpcSettingConfig getXhpcSettingConfigTenantId(Integer status,String tenantId); +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java index 11a43ceb..fefa9812 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java @@ -1,6 +1,6 @@ package com.xhpc.payment.service; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -76,7 +76,7 @@ public interface IXhpcRechargeOrderService { * @param type 充值渠道(1微信 2支付宝) * @return */ - public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber); + public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber,Integer userType); /** * 修改订单状态 充值订单 diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java index a05cbd02..d57e7c95 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java @@ -1,8 +1,7 @@ package com.xhpc.payment.service; import com.xhpc.common.core.web.domain.AjaxResult; -import com.xhpc.payment.domain.XhpcRefundOrder; -import org.apache.ibatis.annotations.Param; +import com.xhpc.common.domain.XhpcRefundOrder; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -88,7 +87,7 @@ public interface IXhpcRefundOrderService { * @param userId 用户id * @return 结果 */ - public Map getNotRefundOrder(Long userId); + public Map getNotRefundOrder(Long userId,Integer userType,String tenantId); /** * 修改退款订单信息 diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcCommonPaymentImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcCommonPaymentImpl.java new file mode 100644 index 00000000..62945d05 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcCommonPaymentImpl.java @@ -0,0 +1,22 @@ +package com.xhpc.payment.service.impl; + +import com.xhpc.payment.domain.XhpcSettingConfig; +import com.xhpc.payment.mapper.XhpcCommonPaymentMapper; +import com.xhpc.payment.service.IXhpcCommonPayment; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author yuyang + * @date 2022/1/6 14:29 + */ +@Service +public class XhpcCommonPaymentImpl implements IXhpcCommonPayment { + + @Autowired + private XhpcCommonPaymentMapper xhpcCommonPaymentMapper; + @Override + public XhpcSettingConfig getXhpcSettingConfigTenantId(Integer status, String tenantId) { + return xhpcCommonPaymentMapper.getXhpcSettingConfigTenantId(status, tenantId); + } +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java index 0b80771c..106a3800 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java @@ -4,8 +4,7 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.xhpc.common.core.constant.StatusConstants; -import com.xhpc.common.core.utils.StringUtils; -import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRechargeOrder; import com.xhpc.payment.mapper.XhpcRechargeOrderMapper; import com.xhpc.payment.service.IXhpcRechargeOrderService; import org.springframework.beans.factory.annotation.Autowired; @@ -131,13 +130,14 @@ public class XhpcRechargeOrderServiceImpl implements IXhpcRechargeOrderService { */ @Override @Transactional - public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber) { + public XhpcRechargeOrder addRechargeOrder(String appUserId, BigDecimal amount, String type, String orderNumber,Integer userType) { XhpcRechargeOrder xhpcRechargeOrder = new XhpcRechargeOrder(); xhpcRechargeOrder.setUserId(Long.parseLong(appUserId)); xhpcRechargeOrder.setAmount(amount); xhpcRechargeOrder.setRechargeOrderNumber(orderNumber); xhpcRechargeOrder.setType(Integer.parseInt(type)); xhpcRechargeOrder.setCreateTime(new Date()); + xhpcRechargeOrder.setSource(userType); xhpcRechargeOrderMapper.insert(xhpcRechargeOrder); return xhpcRechargeOrder; } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java index eae17c61..1c8fad74 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java @@ -3,7 +3,7 @@ package com.xhpc.payment.service.impl; import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.payment.domain.XhpcRefundAudit; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcRefundAuditMapper; import com.xhpc.payment.mapper.XhpcRefundOrderMapper; import com.xhpc.payment.service.IXhpcRefundAuditService; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java index 7f1fb66b..4551bfe4 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java @@ -8,7 +8,7 @@ import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.payment.domain.XhpcAppUser; -import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.common.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcRefundOrderMapper; import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRefundOrderService; @@ -171,8 +171,8 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { * @return 结果 */ @Override - public Map getNotRefundOrder(Long userId) { - return xhpcRefundOrderMapper.getNotRefundOrder(userId); + public Map getNotRefundOrder(Long userId,Integer userType,String tenantId) { + return xhpcRefundOrderMapper.getNotRefundOrder(userId,userType,tenantId); } /** diff --git a/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml index 339e2e7c..c399f305 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml @@ -28,7 +28,7 @@ logging: com.xhpc.order.mapper: debug ##获取微信openid地址 -WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxb14ef93e9b7901f3&secret=b5c5672141b5930c30a1abee95a2dcbf&js_code=" +WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxd0a48e00319ef8a7&secret=e26d9088b58e24af69411d5933cece47&js_code=" ##阿里云身份证验证地址 VERIFYCARD: "http://idenauthen.market.alicloudapi.com/idenAuthentication" #阿里云身份证验证地址appcode @@ -43,7 +43,7 @@ KEY: "sichuanxianghuakejiyouxiangongsi" WXPAYUNIFIEDORDER: "https://api.mch.weixin.qq.com/pay/unifiedorder" #微信支付回调地址 SERVERDOMAIN: "http://www.scxhua.cn/prod-api/xhpc-payment/wx/paymentCallback" -#微信小程序支付地址 +#向微信用户个人付款 WXTRANSFERS: "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers" #支付宝支付回调地址 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcCommonPaymentMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcCommonPaymentMapper.xml new file mode 100644 index 00000000..9f095052 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcCommonPaymentMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 0702afed..65890bde 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -22,7 +22,7 @@ - INSERT INTO xhpc_recharge_order @@ -115,7 +115,7 @@ - + UPDATE xhpc_recharge_order user_id = #{userId}, 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 9d644b08..99a16e8e 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -28,7 +28,7 @@ - INSERT INTO xhpc_refund_order @@ -127,7 +127,7 @@ - + UPDATE xhpc_refund_order refund_order_number =#{refundOrderNumber}, @@ -153,7 +153,7 @@ WHERE refund_order_id = #{refundOrderId} - + UPDATE xhpc_refund_order status = #{status}, @@ -162,7 +162,7 @@ WHERE refund_order_id = #{refundOrderId} and examine_status = 0 - + UPDATE xhpc_refund_order examine_status = #{examineStatus}, @@ -233,6 +233,9 @@ and xro.type = #{type} + + and xro.user_id = #{userId} + ORDER BY xro.create_time DESC @@ -279,15 +282,20 @@ select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber, xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount, xro.type,xro.examine_status examineStatus,xro.`status`,xro.create_time createTime, - xro.source source,xau.phone,sdd.dict_label statusName,sdds.dict_label examineStatusName + xro.source source,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 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.examine_status = 0 and xro.status = 0 - and xau.app_user_id = #{userId} + and xro.user_id = #{userId} + + + and xro.tenant_id = #{tenantId} + + + and xro.source = #{userType} ORDER BY xro.create_time DESC LIMIT 1 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml index 8e5f12d2..ce2dd28a 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml @@ -193,6 +193,6 @@ select serial_number as serialMumber from xhpc_terminal - where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and status=0 and del_flag =0 limit 1) + where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and source=#{source} and tenant_id=#{tenantId} and status=0 and del_flag =0 limit 1) \ No newline at end of file diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index 84cc89dc..146449dc 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -135,7 +135,7 @@ public class XhpcAppUserController extends BaseController { @ApiOperation("小程序用户详情") @GetMapping("/appInfo") public AjaxResult appInfo(HttpServletRequest request) { - return AjaxResult.success(iXhpcAppUserUserService.appInfo(request)); + return iXhpcAppUserUserService.appInfo(request); } /** @@ -287,7 +287,6 @@ public class XhpcAppUserController extends BaseController { @ApiOperation("注销账号") @PostMapping("/logout") public R logout(String phone, String code) { - return iXhpcAppUserUserService.logout(phone, code); } @@ -308,4 +307,22 @@ public class XhpcAppUserController extends BaseController { return R.fail(HttpStatus.ERROR_STATUS, "修改失败"); } + /** + * 设置小程序用户电池保护 + * @param + */ + @ApiOperation("设置小程序用户电池保护") + @PostMapping("/batteryProtect") + public R batteryProtect(HttpServletRequest request,@RequestBody Map map) { + if(map !=null){ + + Integer soc = Integer.parseInt(map.get("soc").toString()); + Integer socProtect = Integer.parseInt(map.get("socProtect").toString()); + Integer userType = Integer.parseInt(map.get("userType").toString()); + return iXhpcAppUserUserService.batteryProtect(request,soc,socProtect,userType); + } + return R.fail(HttpStatus.ERROR_STATUS, "修改失败"); + } + + } 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 e9f532e4..cb35e60b 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 @@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; + /** * 公共的内 * @author yuyang @@ -35,13 +37,13 @@ public class XhpcCommonController extends BaseController { if(phone !=null || "".equals(phone)){ if(!UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ //C端用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,0,serialNumber,tenantId)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.USER_TYPE,serialNumber,tenantId)); }else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2))){ //社区用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,2,serialNumber,tenantId)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.COMMUNIT_TYPE,serialNumber,tenantId)); }else if (UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ //大客户用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,3,serialNumber,tenantId)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.CUSTOMERS_TYPE,serialNumber,tenantId)); } }else{ return AjaxResult.success(xhpcCommonService.getLandUser(null,userId,userType,serialNumber,tenantId)); @@ -50,8 +52,20 @@ public class XhpcCommonController extends BaseController { } /** - * 修改用户信息 + * 根据用户类型,用户id,充值记录,增加流水 + * @param money 充值金额 + * @param userId 充值用户 + * @param userType 用户类型 + * @param tenantId 租户id + * @param type 充值渠道(1微信 2支付宝 3平台) + * @param status 1 充值 2退款 + * @param remark 备注 + * @return */ + @GetMapping(value = "/insertUserBalance") + public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type, Integer status,String remark) { + return xhpcCommonService.insertUserBalance(money,userId,userType,tenantId,type,status,remark); + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java index d38ce91f..a372f622 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java @@ -9,6 +9,8 @@ import com.xhpc.user.service.IXhpcCustomersService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -39,8 +41,8 @@ public class XhpcCustomersController extends BaseController { * @return */ @PostMapping(value = "/addCustomers") - public AjaxResult addCustomers(@RequestBody XhpcCustomers xhpcCustomers) { - return xhpcCustomersService.addCustomers(xhpcCustomers); + public AjaxResult addCustomers(HttpServletRequest request, @RequestBody XhpcCustomers xhpcCustomers) { + return xhpcCustomersService.addCustomers(request,xhpcCustomers); } /** diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java index 0108aa8d..2da36b38 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java @@ -79,6 +79,12 @@ public class XhpcAppUser extends BaseEntity { private Integer soc; + private Integer isRefund; + + private Integer socProtect; + + private String tenantId; + public Long getAppUserId() { return appUserId; } @@ -185,4 +191,29 @@ public class XhpcAppUser extends BaseEntity { this.soc = soc; } + public Integer getIsRefund() { + return isRefund; + } + + public void setIsRefund(Integer isRefund) { + this.isRefund = isRefund; + } + + public Integer getSocProtect() { + return socProtect; + } + + public void setSocProtect(Integer socProtect) { + this.socProtect = socProtect; + } + + @Override + public String getTenantId() { + return tenantId; + } + + @Override + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } } 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 5d8699f8..c1a36526 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 @@ -69,4 +69,9 @@ public class XhpcCommunityPersonnel extends BaseEntity { * 支付宝是否登录(0未登录 1已登录) */ private Integer alipayLogin; + + /** + * 充值渠道(1微信 2支付宝 3平台) + */ + private Integer rechargeType; } 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 2bf4cc10..4efaaf38 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 @@ -69,4 +69,8 @@ public class XhpcCustomersPersonnel extends BaseEntity { * 支付宝是否登录(0未登录 1已登录) */ private Integer alipayLogin; + /** + * 充值渠道(1微信 2支付宝 3平台) + */ + private Integer rechargeType; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java index b84cdff2..361e8768 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java @@ -1,5 +1,6 @@ package com.xhpc.user.mapper; +import com.xhpc.common.domain.XhpcRechargeOrder; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; @@ -73,5 +74,8 @@ public interface MechanismMapper { * @param date * @return */ - int addRechargeOrder(@Param("userId")Long userId, @Param("amount")BigDecimal amount, @Param("orderNumber")String orderNumber, @Param("type")Integer type, @Param("source")Integer source,@Param("date") String date); + int insertRechargeOrder(XhpcRechargeOrder xhpcRechargeOrder); + + + int insertUserAccount(@Param("userId")Long userId,@Param("amount")BigDecimal amount,@Param("remainingSum")BigDecimal remainingSum,@Param("chargeOrderId")Long chargeOrderId,@Param("rechargeOrderId")Long rechargeOrderId,@Param("refundOrderId")Long refundOrderId,@Param("type")Integer type,@Param("tenantId")String tenantId,@Param("source")Integer source); } 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 1b628587..6d28be21 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 @@ -75,8 +75,9 @@ public interface XhpcAppUserMapper { int updateUserIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund); - int updateCommunityIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund); + int updateCommunityIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc); + int updateCustomersSocProtect(@Param("userId")Long userId, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc); /** * 记录登录用户的最后一次数据 */ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java index 854bf4d2..c1111911 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java @@ -35,7 +35,26 @@ public interface IMechanismService { * @param userId 充值的用户 * @param source 0 C端用户 1 流量方用户 2社区用户 3B端用户 * @param amount 金额 + * @param remainingSum 剩余金额 + * @param type 充值渠道(1微信 2支付宝 3平台) * @return */ - int addRechargeOrder(Long userId,Integer source, BigDecimal amount); + Long addRechargeOrder(Long userId,Integer source, BigDecimal amount,BigDecimal remainingSum,Integer type); + + + /** + * 用户流水记录 + * @param userId 用户id + * @param amount 流水金额 + * @param remainingSum 余额 + * @param chargeOrderId 充电订单id + * @param rechargeOrderId 充值订单id + * @param refundOrderId 退款订单id + * @param type 1充值 2退款 3充电 + * @param tenantId 租户id + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + int insertUserAccount(Long userId,BigDecimal amount,BigDecimal remainingSum,Long chargeOrderId,Long rechargeOrderId,Long refundOrderId,Integer type,String tenantId,Integer source); + } 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 15814e66..37e37dbf 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 @@ -104,4 +104,10 @@ public interface IXhpcAppUserUserService { * @return */ 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 3cf0b017..0b5b0ecc 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 @@ -1,5 +1,8 @@ package com.xhpc.user.service; +import com.xhpc.common.core.web.domain.AjaxResult; + +import java.math.BigDecimal; import java.util.Map; /** @@ -12,4 +15,17 @@ public interface IXhpcCommonService { * 根据用户手机号获取用户信息 */ Map getLandUser(String phone,Long userId,Integer type,String serialNumber,String tenantId); + + /** + * 根据用户类型,用户id,充值记录,增加流水 + * @param money 充值金额 + * @param userId 充值用户 + * @param userType 用户类型 + * @param tenantId 租户id + * @param type 充值渠道(1微信 2支付宝 3平台) + * @param status 1 充值 2退款 + * @param remark 备注 + * @return + */ + AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java index 1f39401f..f1a12a81 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java @@ -90,7 +90,7 @@ public interface IXhpcCommunityService { void updateCommunityPersonnelStatus(XhpcCommunityPersonnel xhpcCommunityPersonnel); /** - * 社区人员状态改变 + * 充值 */ AjaxResult addRecharge(XhpcCommunityPersonnel xhpcCommunityPersonnel); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java index 6a6d86a3..a55526bc 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java @@ -4,6 +4,8 @@ import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.user.domain.XhpcCustomers; import com.xhpc.user.domain.XhpcCustomersPersonnel; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -27,7 +29,7 @@ public interface IXhpcCustomersService { * @param * @return */ - AjaxResult addCustomers(XhpcCustomers xhpcCustomers); + AjaxResult addCustomers(HttpServletRequest request, XhpcCustomers xhpcCustomers); /** * 删除大客户组树 diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java index f73238fd..6d81d152 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java @@ -5,6 +5,9 @@ import com.xhpc.common.core.constant.StatusConstants; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.domain.XhpcRechargeOrder; +import com.xhpc.common.domain.XhpcRefundOrder; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.user.dto.MechanismDto; import com.xhpc.user.mapper.MechanismMapper; import com.xhpc.user.service.IMechanismService; @@ -12,11 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.sql.Date; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author yuyang @@ -69,9 +68,40 @@ public class IMechanismServiceImpl implements IMechanismService { } @Override - public int addRechargeOrder(Long userId, Integer source, BigDecimal amount) { + public Long addRechargeOrder(Long userId, Integer source, BigDecimal amount,BigDecimal remainingSum,Integer type) { String orderNumber = StringUtils.numFormat(userId, 1, StatusConstants.FLOWING_WATER_RECHARGE_TYPE); - return mechanismMapper.addRechargeOrder(userId,amount,orderNumber,3,source, DateUtil.date().toString()); + + XhpcRechargeOrder xhpcRechargeOrder =new XhpcRechargeOrder(); + xhpcRechargeOrder.setUserId(userId); + xhpcRechargeOrder.setRechargeOrderNumber(orderNumber); + xhpcRechargeOrder.setAmount(amount); + if(UserTypeUtil.RECHARGE_PT.equals(type)){ + xhpcRechargeOrder.setStatus(UserTypeUtil.RECHARGE_STATUS_ONE); + }else{ + xhpcRechargeOrder.setStatus(UserTypeUtil.RECHARGE_STATUS_ZERO); + } + xhpcRechargeOrder.setType(type); + xhpcRechargeOrder.setSource(source); + xhpcRechargeOrder.setCreateTime(new Date()); + mechanismMapper.insertRechargeOrder(xhpcRechargeOrder); + return xhpcRechargeOrder.getRechargeOrderId(); + } + + /** + * 用户流水记录 + * @param amount 流水金额 + * @param remainingSum 余额 + * @param chargeOrderId 充电订单id + * @param rechargeOrderId 充值订单id + * @param refundOrderId 退款订单id + * @param type 1充值 2退款 3充电 + * @param tenantId 租户id + * @param source 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) + * @return + */ + @Override + public int insertUserAccount(Long userId,BigDecimal amount,BigDecimal remainingSum,Long chargeOrderId,Long rechargeOrderId,Long refundOrderId,Integer type,String tenantId,Integer source) { + return mechanismMapper.insertUserAccount(userId, amount, remainingSum, chargeOrderId, rechargeOrderId, refundOrderId, type, tenantId, source); } 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 becb25b4..d527c3c7 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 @@ -358,7 +358,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { //添加最后一次登录数据 xhpcAppUserMapper.addUserLoginTime(appUser.getAppUserId(),username,userType,openId,Integer.valueOf(type),UserConstants.NO_LOGIN,tenantId); } - }else if(UserTypeUtil.COMMUNIT_TYPE==userType){ + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ if (StatusConstants.OPERATION_WX_TYPE.equals(type)) { xhpcAppUserMapper.updateCommunityPersonnel(userid,null,null,UserConstants.NO_LOGIN,null); } else { @@ -366,7 +366,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { } //添加最后一次登录数据 xhpcAppUserMapper.addUserLoginTime(userid,username,userType,openId,Integer.valueOf(type),UserConstants.NO_LOGIN,tenantId); - }else if(UserTypeUtil.CUSTOMERS_TYPE==userType){ + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(userType)){ if (StatusConstants.OPERATION_WX_TYPE.equals(type)) { xhpcAppUserMapper.updateCustomersPersonnel(userid,null,null,UserConstants.NO_LOGIN,null); } else { @@ -438,6 +438,13 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { map.put("guestbook","0"); map.put("version",version); map.put("servicePhone",servicePhone); + map.put("activity",1); + map.put("activitySize",1); + map.put("activityImg","https://www.scxhua.cn/static/img/logo1.8460b7f4.png"); + map.put("socSize",98); + map.put("socUser",80); + map.put("socProtect",1); + return AjaxResult.success(map); }else{ return AjaxResult.error("请重新登录"); @@ -487,7 +494,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { return R.fail(HttpStatus.ERROR_STATUS, "修改失败"); } }else if(userType==2){ - int i = xhpcAppUserMapper.updateCommunityIsRefund(userId, isRefund); + int i = xhpcAppUserMapper.updateCommunityIsRefund(userId, isRefund,null,null); if(i>0){ return R.ok(); }else{ @@ -496,4 +503,32 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { } return R.fail(HttpStatus.ERROR_STATUS, "参数错误"); } + + @Override + public R batteryProtect(HttpServletRequest request, Integer soc,Integer socProtect,Integer userType) { + LoginUser loginUser = logUserUtils.getLogUser(request); + Object version = redisService.getCacheObject("global:version"); + Object servicePhone = redisService.getCacheObject("global:phone"); + //根据不同的用户类型查询不同的信息 + Long userid = loginUser.getUserid(); + + R user = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null,loginUser.getTenantId()); + if(user !=null && user.getData() !=null){ + Map map = (Map)user.getData(); + if(UserTypeUtil.USER_TYPE.equals(userType)){ + XhpcAppUser appUser = xhpcAppUserMapper.getAppUserByPhone(map.get("phone").toString()); + appUser.setSocProtect(socProtect); + appUser.setSoc(soc); + xhpcAppUserMapper.update(appUser); + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ + xhpcAppUserMapper.updateCommunityIsRefund(userid, null,socProtect,soc); + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(userType)){ + xhpcAppUserMapper.updateCustomersSocProtect(userid,socProtect,soc); + } + return R.fail(HttpStatus.ERROR_STATUS, "设置失败"); + } + return R.fail(HttpStatus.ERROR_STATUS, "设置失败"); + } + + } 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 01555ce1..86b3fac0 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 @@ -1,11 +1,18 @@ package com.xhpc.user.service.impl; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.user.domain.XhpcCommunityPersonnel; +import com.xhpc.user.domain.XhpcCustomersPersonnel; import com.xhpc.user.mapper.XhpcCommonMapper; import com.xhpc.user.service.IXhpcCommonService; +import com.xhpc.user.service.IXhpcCommunityService; +import com.xhpc.user.service.IXhpcCustomersService; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; @@ -18,16 +25,60 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { @Autowired private XhpcCommonMapper xhpcCommonMapper; + @Autowired + private IXhpcCommunityService xhpcCommunityService; + @Autowired + private IXhpcCustomersService xhpcCustomersService; + @Override public Map getLandUser(String phone,Long userId, Integer type,String serialNumber,String tenantId) { - if(type==0){ + if(UserTypeUtil.USER_TYPE.equals(type)){ return xhpcCommonMapper.getAppUser(phone,userId,tenantId); - }else if(type==2){ + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(type)){ return xhpcCommonMapper.getCommunityUser(phone,userId,serialNumber,tenantId); - }else if(type==3){ + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(type)){ return xhpcCommonMapper.getCustomersUser(phone,userId,serialNumber,tenantId); } return new HashMap<>(); } + + @Override + public AjaxResult insertUserBalance(BigDecimal money, Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark) { + if(UserTypeUtil.USER_TYPE.equals(userType)){ + Map appUser = xhpcCommonMapper.getAppUser(null, userId, tenantId); + //增加用户余额 + if(appUser!=null){ + + } + + }else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){ + Map communityUser = xhpcCommonMapper.getCommunityUser(null, userId, null, tenantId); + if(communityUser!=null){ + if(UserTypeUtil.INSERT_BALANCE.equals(status)){ + XhpcCommunityPersonnel xhpcCommunityPersonnel=new XhpcCommunityPersonnel(); + xhpcCommunityPersonnel.setCommunityPersonnelId(Long.valueOf(communityUser.get("communityUser").toString())); + xhpcCommunityPersonnel.setRechargeMoney(money); + xhpcCommunityPersonnel.setRemark(remark); + xhpcCommunityPersonnel.setRechargeType(type); + xhpcCommunityPersonnel.setTenantId(tenantId); + return xhpcCommunityService.addRecharge(xhpcCommunityPersonnel); + } + } + }else if(UserTypeUtil.CUSTOMERS_TYPE.equals(userType)){ + Map customersUser = xhpcCommonMapper.getCustomersUser(null, userId, null, tenantId); + if(customersUser!=null){ + if(UserTypeUtil.INSERT_BALANCE.equals(status)){ + XhpcCustomersPersonnel xhpcCustomersPersonnel =new XhpcCustomersPersonnel(); + xhpcCustomersPersonnel.setCustomersPersonnelId(Long.valueOf(customersUser.get("communityUser").toString())); + xhpcCustomersPersonnel.setRechargeMoney(money); + xhpcCustomersPersonnel.setRemark(remark); + xhpcCustomersPersonnel.setRechargeType(type); + xhpcCustomersPersonnel.setTenantId(tenantId); + return xhpcCustomersService.addRecharge(xhpcCustomersPersonnel); + } + } + } + return AjaxResult.error(); + } } 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 70bb2fac..2fe781fc 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 @@ -2,6 +2,7 @@ package com.xhpc.user.service.impl; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.user.domain.XhpcCommunity; import com.xhpc.user.domain.XhpcCommunityPersonnel; import com.xhpc.user.mapper.XhpcCommunityMapper; @@ -136,7 +137,7 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { xhpcCommunityMapper.addCommunityPersonnel(xhpcCommunityPersonnel); //增加一条充值记录 if(new BigDecimal(0).compareTo(rechargeMoney)==-1){ - mechanismService.addRechargeOrder(xhpcCommunityPersonnel.getCommunityPersonnelId(),2,rechargeMoney); + mechanismService.addRechargeOrder(xhpcCommunityPersonnel.getCommunityPersonnelId(),UserTypeUtil.COMMUNIT_TYPE,rechargeMoney,rechargeMoney,UserTypeUtil.RECHARGE_PT); } return AjaxResult.success(); } @@ -197,14 +198,17 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { XhpcCommunityPersonnel xhpcCommunityPersonnel1=new XhpcCommunityPersonnel(); xhpcCommunityPersonnel1.setCommunityPersonnelId(communityPersonnelId); - xhpcCommunityPersonnel1.setSurplusMoney(surplusMoney.add(rechargeMoney)); + BigDecimal remainingSum = surplusMoney.add(rechargeMoney); + xhpcCommunityPersonnel1.setSurplusMoney(remainingSum); xhpcCommunityPersonnel1.setRechargeMoney(rechargeMoney1.add(rechargeMoney)); xhpcCommunityMapper.updateCommunityPersonnel(xhpcCommunityPersonnel1); //增加充值记录 - mechanismService.addRechargeOrder(communityPersonnelId,2,rechargeMoney); + Long rechargeOrderId = mechanismService.addRechargeOrder(communityPersonnelId, UserTypeUtil.COMMUNIT_TYPE, rechargeMoney, remainingSum, xhpcCommunityPersonnel1.getRechargeType()); + //增加用户流水 + mechanismService.insertUserAccount(communityPersonnelId,rechargeMoney,remainingSum,null,rechargeOrderId,null,UserTypeUtil.INSERT_BALANCE,xhpcCommunityPersonnel1.getTenantId(),UserTypeUtil.COMMUNIT_TYPE); return AjaxResult.success(); } } - return AjaxResult.error("充值金额大于0"); + return AjaxResult.error("充值金额必需大于0"); } } 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 d97e025e..64023412 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 @@ -2,6 +2,9 @@ package com.xhpc.user.service.impl; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.system.api.model.LoginUser; import com.xhpc.user.domain.XhpcCustomers; import com.xhpc.user.domain.XhpcCustomersPersonnel; import com.xhpc.user.mapper.XhpcCustomersMapper; @@ -10,6 +13,8 @@ import com.xhpc.user.service.IXhpcCustomersService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; @@ -27,7 +32,8 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { private XhpcCustomersMapper xhpcCustomersMapper; @Autowired private IMechanismService mechanismService; - + @Autowired + private TokenService tokenService; @Override public List> list(String name) { Long userId = SecurityUtils.getUserId(); @@ -46,7 +52,7 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { } @Override - public AjaxResult addCustomers(XhpcCustomers xhpcCustomers) { + public AjaxResult addCustomers(HttpServletRequest request, XhpcCustomers xhpcCustomers) { //名称重复不能入库 Map communityById = xhpcCustomersMapper.getCustomersById(null, xhpcCustomers.getName(), null); @@ -55,7 +61,8 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { } Long userId = SecurityUtils.getUserId(); if(userId !=null){ - Map landUser = xhpcCustomersMapper.getLandUser(userId); + LoginUser loginUser = tokenService.getLoginUser(request); + Map landUser = xhpcCustomersMapper.getLandUser(loginUser.getUserid()); if(landUser !=null && landUser.get("userType") !=null){ if("00".equals(landUser.get("userType").toString()) ){ xhpcCustomers.setType(1); @@ -147,7 +154,7 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { xhpcCustomersMapper.addCustomersPersonnel(xhpcCustomersPersonnel); //增加一条充值记录 if(new BigDecimal(0).compareTo(rechargeMoney)==-1){ - mechanismService.addRechargeOrder(xhpcCustomersPersonnel.getCustomersPersonnelId(),3,rechargeMoney); + mechanismService.addRechargeOrder(xhpcCustomersPersonnel.getCustomersPersonnelId(),UserTypeUtil.CUSTOMERS_TYPE,rechargeMoney,rechargeMoney,UserTypeUtil.RECHARGE_PT); } return AjaxResult.success(); } @@ -201,11 +208,14 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService { XhpcCustomersPersonnel xhpcCustomersPersonnel1=new XhpcCustomersPersonnel(); xhpcCustomersPersonnel1.setCustomersPersonnelId(customersPersonnelId); - xhpcCustomersPersonnel1.setSurplusMoney(surplusMoney.add(rechargeMoney)); + BigDecimal remainingSum = surplusMoney.add(rechargeMoney); + xhpcCustomersPersonnel1.setSurplusMoney(remainingSum); xhpcCustomersPersonnel1.setRechargeMoney(rechargeMoney1.add(rechargeMoney)); xhpcCustomersMapper.updateCustomersPersonnel(xhpcCustomersPersonnel1); //增加充值记录 - mechanismService.addRechargeOrder(customersPersonnelId,3,rechargeMoney); + Long rechargeOrderId =mechanismService.addRechargeOrder(customersPersonnelId, UserTypeUtil.CUSTOMERS_TYPE,rechargeMoney,remainingSum,xhpcCustomersPersonnel1.getRechargeType()); + //增加用户流水 + 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/bootstrap.yml b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml index c570dc4f..b8d77722 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml @@ -23,6 +23,9 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.xhpc.user.mapper: debug #获取微信openid地址 WXGETJSCODE: "https://api.weixin.qq.com/sns/jscode2session?appid=wxd0a48e00319ef8a7&secret=e26d9088b58e24af69411d5933cece47&js_code=" #支付宝公钥 diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml index a651dab8..fae76807 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml @@ -139,7 +139,162 @@ - - INSERT INTO xhpc_recharge_order(user_id,recharge_order_number,amount,type,status,source,create_time) values (#{userId},#{orderNumber},#{amount},#{type},1,#{source},#{date}) + + INSERT INTO xhpc_recharge_order + + + user_id, + + + recharge_order_number, + + + prepay_id, + + + alipay_number, + + + amount, + + + type, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + source + + + + + #{userId}, + + + #{rechargeOrderNumber}, + + + #{prepayId}, + + + #{alipayNumber}, + + + #{amount}, + + + #{type}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{source} + + + + + + + + + insert into xhpc_user_account_statement + + + user_id, + + + amount, + + + remaining_sum, + + + charge_order_id, + + + recharge_order_id, + + + refund_order_id, + + + type, + + + tenant_id, + + + source, + + + + + #{userId}, + + + #{amount}, + + + #{remainingSum}, + + + #{chargeOrderId}, + + + #{rechargeOrderId}, + + + #{refundOrderId}, + + + #{type}, + + + #{tenantId}, + + + #{source}, + + += 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 d7baa72b..77f5dadb 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml @@ -167,7 +167,9 @@ update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, - soc = #{soc} + soc = #{soc} + is_refund = #{isRefund} + soc_protect = #{socProtect} WHERE app_user_id = #{appUserId} @@ -235,7 +237,22 @@ - update xhpc_community_personnel set is_refund=#{isRefund} where community_personnel_id=#{userId} + UPDATE xhpc_community_personnel + + is_refund = #{isRefund}, + soc_protect = #{socProtect}, + soc = #{soc}, + + WHERE community_personnel_id = #{userId} + + + + UPDATE xhpc_customers_personnel + + soc_protect = #{socProtect}, + soc = #{soc}, + + WHERE customers_personnel_id = #{userId} diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml index e94e67f7..c5849223 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml @@ -219,7 +219,7 @@ and status=#{status} - order by create_time desc. + order by create_time desc