新增支付配置表,支付宝、微信支付已修改,待测试

This commit is contained in:
yuyang 2022-01-09 21:04:08 +08:00
parent 38b2455c35
commit e70cc61941
50 changed files with 951 additions and 173 deletions

View File

@ -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
;

View File

@ -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}
</select>

View File

@ -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);
}

View File

@ -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<UserTypeService>
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());
}
};
}
}

View File

@ -1,4 +1,4 @@
package com.xhpc.payment.domain;
package com.xhpc.common.domain;
import com.xhpc.common.core.web.domain.BaseEntity;

View File

@ -1,4 +1,4 @@
package com.xhpc.payment.domain;
package com.xhpc.common.domain;
import com.xhpc.common.core.web.domain.BaseEntity;

View File

@ -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;
}

View File

@ -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<String, Object> refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId));
LoginUser loginUser = tokenService.getLoginUser(servletRequest);
Long userid = loginUser.getUserid();
Integer userType = loginUser.getUserType();
String tenantId = loginUser.getTenantId();
Map<String, Object> 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<String, String> params = convertRequestParamsToMap(request);
// 将异步通知中收到的待验证所有参数都存放到map中
logger.info("<<<<<<<<<<<<params>>>>>>>>>"+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>>>>>>>>>"+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<String, Object> 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<String, Object> map = (Map<String, Object>)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);
}
}

View File

@ -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<String, Object> refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId));
LoginUser loginUser = tokenService.getLoginUser(servletRequest);
Long userid = loginUser.getUserid();
Integer userType = loginUser.getUserType();
String tenantId = loginUser.getTenantId();
Map<String, Object> 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<String, Object> 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<String, Object> map = (Map<String, Object>)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) {

View File

@ -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<String, Object> map) {
public AjaxResult cancelExamine(HttpServletRequest request, @RequestBody Map<String, Object> map) {
String userId = StringUtils.valueOf(map.get("userId"));
if (StringUtils.isEmpty(userId)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空");
}
Map<String, Object> refundOrder = iXhpcRefundOrderService.getNotRefundOrder(Long.parseLong(userId));
LoginUser loginUser = tokenService.getLoginUser(request);
Long userid = loginUser.getUserid();
Integer userType = loginUser.getUserType();
String tenantId = loginUser.getTenantId();
Map<String, Object> refundOrder = iXhpcRefundOrderService.getNotRefundOrder(userid,userType,tenantId);
if (StringUtils.isNull(refundOrder)) {
return AjaxResult.error(HttpStatus.DATA_ERROR, "退款订单不存在");
}

View File

@ -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));
}
/**

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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<String, Object> getNotRefundOrder(@Param("userId") Long userId);
public Map<String, Object> getNotRefundOrder(@Param("userId") Long userId,@Param("userType")Integer userType,@Param("tenantId")String tenantId);
/**

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
/**
* 修改订单状态 充值订单

View File

@ -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<String, Object> getNotRefundOrder(Long userId);
public Map<String, Object> getNotRefundOrder(Long userId,Integer userType,String tenantId);
/**
* 修改退款订单信息

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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<String, Object> getNotRefundOrder(Long userId) {
return xhpcRefundOrderMapper.getNotRefundOrder(userId);
public Map<String, Object> getNotRefundOrder(Long userId,Integer userType,String tenantId) {
return xhpcRefundOrderMapper.getNotRefundOrder(userId,userType,tenantId);
}
/**

View File

@ -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"
#支付宝支付回调地址

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.payment.mapper.XhpcCommonPaymentMapper">
<resultMap type="com.xhpc.payment.domain.XhpcSettingConfig" id="XhpcSettingConfigResult">
<result column="setting_config_id" property="settingConfigId"/>
<result column="wx_app_id" property="wxAppId"/>
<result column="wx_app_secret" property="wxAppSecret"/>
<result column="wx_mch_id" property="wxMchId"/>
<result column="wx_mch_key" property="wxMchKey"/>
<result column="wx_payment_url" property="wxPaymentUrl"/>
<result column="wx_callback_url" property="wxCallbackUrl"/>
<result column="wx_transfers_url" property="wxTransfersUrl"/>
<result column="wx_apiclient_cert_pem" property="wxApiclientCertPem"/>
<result column="wx_apiclient_key_pem" property="wxApiclientKeyPem"/>
<result column="wx_app_cert_public_key" property="wxAppCertPublicKey"/>
<result column="zfb_app_id" property="zfbAppId"/>
<result column="zfb_private_key" property="zfbPrivateKey"/>
<result column="zfb_callback_url" property="zfbCallbackUrl"/>
<result column="zfb_app_cert_public_key" property="zfbAppCertPublicKey"/>
<result column="zfb_app_cert_public_key" property="zfbAlipayCertPublicKeyRsa"/>
<result column="zfb_alipay_root_cert" property="zfbAlipayRootCert"/>
<result column="zhb_server_url" property="zhbServerUrl"/>
<result column="status" property="status"/>
<result column="del_flag" property="delFlag"/>
<result column="create_time" property="createTime"/>
<result column="create_by" property="createBy"/>
<result column="update_time" property="updateTime"/>
<result column="update_by" property="updateBy"/>
<result column="remark" property="remark"/>
<result column="tenant_id" property="tenantId"/>
</resultMap>
<select id="getXhpcSettingConfigTenantId" resultMap="XhpcSettingConfigResult">
select * from xhpc_setting_config where del_flag =0 and status=#{status} and tenant_id=#{tenantId} limit 1
</select>
</mapper>

View File

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.payment.mapper.XhpcRechargeOrderMapper">
<resultMap type="com.xhpc.payment.domain.XhpcRechargeOrder" id="XhpcRechargeOrderResult">
<resultMap type="com.xhpc.common.domain.XhpcRechargeOrder" id="XhpcRechargeOrderResult">
<result column="recharge_order_id" property="rechargeOrderId" />
<result column="user_id" property="userId" />
<result column="recharge_order_number" property="rechargeOrderNumber"/>
@ -22,7 +22,7 @@
<result column="source" property="source" />
</resultMap>
<insert id="insert" parameterType="com.xhpc.payment.domain.XhpcRechargeOrder" useGeneratedKeys="true"
<insert id="insert" parameterType="com.xhpc.common.domain.XhpcRechargeOrder" useGeneratedKeys="true"
keyProperty="rechargeOrderId">
INSERT INTO xhpc_recharge_order
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -115,7 +115,7 @@
</trim>
</insert>
<update id="update" parameterType="com.xhpc.payment.domain.XhpcRechargeOrder">
<update id="update" parameterType="com.xhpc.common.domain.XhpcRechargeOrder">
UPDATE xhpc_recharge_order
<set>
<if test="null != userId and '' != userId">user_id = #{userId},</if>

View File

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.payment.mapper.XhpcRefundOrderMapper">
<resultMap type="com.xhpc.payment.domain.XhpcRefundOrder" id="XhpcRefundOrderResult">
<resultMap type="com.xhpc.common.domain.XhpcRefundOrder" id="XhpcRefundOrderResult">
<result column="refund_order_id" property="refundOrderId"/>
<result column="refund_order_number" property="refundOrderNumber"/>
<result column="user_id" property="userId"/>
@ -28,7 +28,7 @@
<result column="trans_pay_time" property="transPayTime" />
</resultMap>
<insert id="insert" parameterType="com.xhpc.payment.domain.XhpcRefundOrder" useGeneratedKeys="true"
<insert id="insert" parameterType="com.xhpc.common.domain.XhpcRefundOrder" useGeneratedKeys="true"
keyProperty="refundOrderId">
INSERT INTO xhpc_refund_order
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -127,7 +127,7 @@
</trim>
</insert>
<update id="update" parameterType="com.xhpc.payment.domain.XhpcRefundOrder">
<update id="update" parameterType="com.xhpc.common.domain.XhpcRefundOrder">
UPDATE xhpc_refund_order
<set>
<if test="null != refundOrderNumber and '' != refundOrderNumber">refund_order_number =#{refundOrderNumber},</if>
@ -153,7 +153,7 @@
WHERE refund_order_id = #{refundOrderId}
</update>
<update id="updateStatus" parameterType="com.xhpc.payment.domain.XhpcRefundOrder">
<update id="updateStatus" parameterType="com.xhpc.common.domain.XhpcRefundOrder">
UPDATE xhpc_refund_order
<set>
<if test="null != status">status = #{status},</if>
@ -162,7 +162,7 @@
WHERE refund_order_id = #{refundOrderId} and examine_status = 0
</update>
<update id="updateExamineStatus" parameterType="com.xhpc.payment.domain.XhpcRefundOrder">
<update id="updateExamineStatus" parameterType="com.xhpc.common.domain.XhpcRefundOrder">
UPDATE xhpc_refund_order
<set>
<if test="null != status">examine_status = #{examineStatus},</if>
@ -233,6 +233,9 @@
<if test="type != null ">
and xro.type = #{type}
</if>
<if test="userId != null ">
and xro.user_id = #{userId}
</if>
ORDER BY xro.create_time DESC
</select>
@ -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
<if test="userId != null and userId != ''">
and xau.app_user_id = #{userId}
and xro.user_id = #{userId}
</if>
<if test="tenantId != null and tenantId != ''">
and xro.tenant_id = #{tenantId}
</if>
<if test="userType != null">
and xro.source = #{userType}
</if>
ORDER BY xro.create_time DESC LIMIT 1
</select>

View File

@ -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)
</select>
</mapper>

View File

@ -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<String, Object> 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, "修改失败");
}
}

View File

@ -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);
}
}

View File

@ -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);
}
/**

View File

@ -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;
}
}

View File

@ -69,4 +69,9 @@ public class XhpcCommunityPersonnel extends BaseEntity {
* 支付宝是否登录0未登录 1已登录
*/
private Integer alipayLogin;
/**
* 充值渠道1微信 2支付宝 3平台)
*/
private Integer rechargeType;
}

View File

@ -69,4 +69,8 @@ public class XhpcCustomersPersonnel extends BaseEntity {
* 支付宝是否登录0未登录 1已登录
*/
private Integer alipayLogin;
/**
* 充值渠道1微信 2支付宝 3平台)
*/
private Integer rechargeType;
}

View File

@ -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);
}

View File

@ -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);
/**
* 记录登录用户的最后一次数据
*/

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<String, Object> 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);
}

View File

@ -90,7 +90,7 @@ public interface IXhpcCommunityService {
void updateCommunityPersonnelStatus(XhpcCommunityPersonnel xhpcCommunityPersonnel);
/**
* 社区人员状态改变
* 充值
*/
AjaxResult addRecharge(XhpcCommunityPersonnel xhpcCommunityPersonnel);

View File

@ -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);
/**
* 删除大客户组树

View File

@ -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);
}

View File

@ -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<String, Object> map = (Map<String, Object>)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, "设置失败");
}
}

View File

@ -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<String, Object> 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<String, Object> appUser = xhpcCommonMapper.getAppUser(null, userId, tenantId);
//增加用户余额
if(appUser!=null){
}
}else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){
Map<String, Object> 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<String, Object> 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();
}
}

View File

@ -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");
}
}

View File

@ -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<Map<String, Object>> 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<String, Object> communityById = xhpcCustomersMapper.getCustomersById(null, xhpcCustomers.getName(), null);
@ -55,7 +61,8 @@ public class XhpcCustomersServiceImpl implements IXhpcCustomersService {
}
Long userId = SecurityUtils.getUserId();
if(userId !=null){
Map<String, Object> landUser = xhpcCustomersMapper.getLandUser(userId);
LoginUser loginUser = tokenService.getLoginUser(request);
Map<String, Object> 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();
}
}

View File

@ -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="
#支付宝公钥

View File

@ -139,7 +139,162 @@
</foreach>
</insert>
<insert id="addRechargeOrder">
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 id="insertRechargeOrder" parameterType="com.xhpc.common.domain.XhpcRechargeOrder" useGeneratedKeys="true"
keyProperty="rechargeOrderId">
INSERT INTO xhpc_recharge_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != userId and '' != userId">
user_id,
</if>
<if test="null != rechargeOrderNumber and '' != rechargeOrderNumber">
recharge_order_number,
</if>
<if test="null != prepayId and '' != prepayId">
prepay_id,
</if>
<if test="null != alipayNumber and '' != alipayNumber">
alipay_number,
</if>
<if test="null != amount and '' != amount">
amount,
</if>
<if test="null != type and '' != type">
type,
</if>
<if test="null != status and '' != status">
status,
</if>
<if test="null != delFlag and '' != delFlag">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != source">
source
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != userId and '' != userId">
#{userId},
</if>
<if test="null != rechargeOrderNumber and '' != rechargeOrderNumber">
#{rechargeOrderNumber},
</if>
<if test="null != prepayId and '' != prepayId">
#{prepayId},
</if>
<if test="null != alipayNumber and '' != alipayNumber">
#{alipayNumber},
</if>
<if test="null != amount and '' != amount">
#{amount},
</if>
<if test="null != type and '' != type">
#{type},
</if>
<if test="null != status and '' != status">
#{status},
</if>
<if test="null != delFlag and '' != delFlag">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != source">
#{source}
</if>
</trim>
</insert>
<insert id="insertUserAccount">
insert into xhpc_user_account_statement
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != userId">
user_id,
</if>
<if test="null != amount">
amount,
</if>
<if test="null != remainingSum">
remaining_sum,
</if>
<if test="null != chargeOrderId">
charge_order_id,
</if>
<if test="null != rechargeOrderId">
recharge_order_id,
</if>
<if test="null != refundOrderId">
refund_order_id,
</if>
<if test="null != type">
type,
</if>
<if test="null != tenantId and tenantId !=''">
tenant_id,
</if>
<if test="null != source">
source,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != userId">
#{userId},
</if>
<if test="null != amount">
#{amount},
</if>
<if test="null != remainingSum">
#{remainingSum},
</if>
<if test="null != chargeOrderId">
#{chargeOrderId},
</if>
<if test="null != rechargeOrderId">
#{rechargeOrderId},
</if>
<if test="null != refundOrderId">
#{refundOrderId},
</if>
<if test="null != type">
#{type},
</if>
<if test="null != tenantId and tenantId !=''">
#{tenantId},
</if>
<if test="null != source">
#{source},
</if>
</trim>
= </insert>
</mapper>

View File

@ -167,7 +167,9 @@
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
<if test="null != updateTime ">update_time = #{updateTime},</if>
<if test="null != remark and '' != remark">remark = #{remark},</if>
<if test="null != soc and '' != soc">soc = #{soc}</if>
<if test="null != soc">soc = #{soc}</if>
<if test="null != isRefund">is_refund = #{isRefund}</if>
<if test="null != socProtect">soc_protect = #{socProtect}</if>
</set>
WHERE app_user_id = #{appUserId}
</update>
@ -235,7 +237,22 @@
</update>
<update id="updateCommunityIsRefund">
update xhpc_community_personnel set is_refund=#{isRefund} where community_personnel_id=#{userId}
UPDATE xhpc_community_personnel
<set>
<if test="null != isRefund">is_refund = #{isRefund},</if>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
<if test="null != soc ">soc = #{soc},</if>
</set>
WHERE community_personnel_id = #{userId}
</update>
<update id="updateCustomersSocProtect">
UPDATE xhpc_customers_personnel
<set>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
<if test="null != soc ">soc = #{soc},</if>
</set>
WHERE customers_personnel_id = #{userId}
</update>
<insert id="addUserLoginTime">

View File

@ -219,7 +219,7 @@
<if test="status !=null">
and status=#{status}
</if>
order by create_time desc.
order by create_time desc
</select>
<insert id="addCommunityPersonnel" parameterType="com.xhpc.user.domain.XhpcCommunityPersonnel" useGeneratedKeys="true" keyProperty="communityPersonnelId">