@@ -0,0 +1,36 @@ | |||
package cn.com.taiji.core.entity.dict.basic; | |||
/** | |||
* @Author weicailin | |||
* @Date 2023/3/22 17:39 | |||
* @Email 13079168756@163.com | |||
*/ | |||
public enum AccountType { | |||
ENTERPRISE("企业会员", 2), | |||
PERSONAL("个人会员", 1), | |||
UNDEFINED("未知", 3), | |||
; | |||
private final String value; | |||
private final Integer code; | |||
AccountType(String value, Integer code) { | |||
this.value = value; | |||
this.code = code; | |||
} | |||
public String getValue() { | |||
return value; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public static AccountType fromCode(Integer code) { | |||
AccountType[] values = AccountType.values(); | |||
for (AccountType value : values) { | |||
if (value.code == code) return value; | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package cn.com.taiji.core.entity.dict.basic; | |||
/** | |||
* @Author weicailin | |||
* @Date 2023/3/22 17:38 | |||
* @Email 13079168756@163.com | |||
*/ | |||
public enum Gender { | |||
MALE("男") {}, | |||
FEMALE("女") {}, | |||
UNKOWN("未知") {}, | |||
; | |||
private final String value; | |||
Gender(String value) { | |||
this.value = value; | |||
} | |||
public static Gender getGender(String value){ | |||
for (Gender gender : Gender.values()){ | |||
if(value.equals(gender.getValue())){ | |||
return gender; | |||
} | |||
} | |||
return Gender.UNKOWN; | |||
} | |||
public String getValue() { | |||
return value; | |||
} | |||
} |
@@ -2,8 +2,7 @@ package cn.com.taiji.core.entity.user; | |||
import cn.com.taiji.core.entity.AbstractStringPropertyUUIDEntity; | |||
import cn.com.taiji.core.entity.dict.basic.IdType; | |||
import cn.com.taiji.core.entity.dict.basic.SourceType; | |||
import cn.com.taiji.core.entity.dict.basic.*; | |||
import javax.persistence.*; | |||
import java.time.LocalDateTime; | |||
@@ -62,11 +61,11 @@ public class AccountInfo extends AbstractStringPropertyUUIDEntity { | |||
private IdType idType; | |||
/** | |||
* 会员类型: | |||
* 会员类型:原来是USER_TYPE | |||
* 1、个人会员 | |||
* 2、企业会员 | |||
*/ | |||
private UserType userType; | |||
private AccountType accountType; | |||
/** | |||
* 登录方来源 | |||
@@ -188,9 +187,9 @@ public class AccountInfo extends AbstractStringPropertyUUIDEntity { | |||
} | |||
@Enumerated(EnumType.STRING) | |||
@Column(name = "USER_TYPE") | |||
public UserType getUserType() { | |||
return userType; | |||
@Column(name = "ACCOUNT_TYPE") | |||
public AccountType getAccountType() { | |||
return accountType; | |||
} | |||
@Enumerated(EnumType.STRING) | |||
@@ -276,8 +275,8 @@ public class AccountInfo extends AbstractStringPropertyUUIDEntity { | |||
this.idType = idType; | |||
} | |||
public void setUserType(UserType userType) { | |||
this.userType = userType; | |||
public void setAccountType(AccountType accountType) { | |||
this.accountType = accountType; | |||
} | |||
public void setLoginSource(SourceType loginSource) { |
@@ -1,10 +1,14 @@ | |||
package cn.com.taiji.core.model.comm.protocol.ats.weiXin; | |||
import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsRequest; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.IntegerConstant; | |||
import cn.com.taiji.core.model.comm.protocol.valid.ErrorMsgBuilder; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/17 11:30 | |||
@@ -18,8 +22,32 @@ public class AtsQueryPayResultV2Request extends AbstractAtsRequest<AtsQueryPayRe | |||
public AtsQueryPayResultV2Request() { | |||
super(WeiXinServiceCmd.QUERYPAYRESULTV2); | |||
} | |||
/** | |||
* 1单独下单url-普通商户下单 | |||
* 2服务商下单 | |||
* 3合并下单url | |||
* 目前只提供单独下单和服务商下单 | |||
*/ | |||
@IntegerConstant(values = "1,2") | |||
@NotNull | |||
private Integer createType; | |||
@NotBlank | |||
private String outTradeNo; //商户订单号 | |||
@NotBlank | |||
private String appId;//服务商的APPID | |||
@NotBlank | |||
private String mchId; | |||
private String subAppId; | |||
private String subMchId; | |||
@NotBlank | |||
private String mchKey; | |||
@Override | |||
protected void validate(ErrorMsgBuilder builder) { | |||
if (createType == 2){ | |||
builder.validFieldNotBlank("subMchId", subMchId); | |||
} | |||
} | |||
} |
@@ -1,5 +1,7 @@ | |||
package cn.com.taiji.core.model.comm.protocol.ats.weiXin; | |||
import cn.com.taiji.core.entity.dict.pay.TradeState; | |||
import cn.com.taiji.core.entity.dict.pay.TradeType; | |||
import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsResponse; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@@ -13,4 +15,34 @@ import lombok.Setter; | |||
@Getter | |||
@Setter | |||
public class AtsQueryPayResultV2Response extends AbstractAtsResponse { | |||
private String openid; //是 | |||
private String subOpenid; //否 | |||
private TradeType tradetype;//交易类型 否 | |||
private TradeState tradeState;//交易状态 是 | |||
private String bankType; //付款银行 是 | |||
private String detail;//商品详情 否 | |||
private Integer totalFee;//标价金额 单位分 是 | |||
private String feeType;//标价币种,默认CNY //否 | |||
private Integer settlementTotalFee;//应结订单金额 否 | |||
private Integer cashFee;//现金支付金额 是 | |||
private String cashFeeType;//现金支付货币类型 否 | |||
private String transactionId;//微信支付订单号 是 | |||
private String outTradeNo; //商户订单号 是 | |||
private String timeEnd;//支付完成时间 是 | |||
private String tradeStateDesc;// 交易状态描述 是 | |||
} |
@@ -1,16 +1,16 @@ | |||
package cn.com.taiji.core.repo.jpa.user; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.dict.basic.AccountType; | |||
import cn.com.taiji.core.entity.user.AccountInfo; | |||
import org.springframework.data.jpa.repository.Query; | |||
import java.util.List; | |||
public interface AccountInfoRepo extends AbstractJpaRepo<AccountInfo, String> { | |||
@Query("FROM AccountInfo WHERE openId=?1") | |||
AccountInfo findByOpenId(String openId); | |||
AccountInfo findByIdNumAndUserType(String idNum, UserType userType); | |||
AccountInfo findByIdNumAndAccountType(String idNum, AccountType accountType); | |||
} |
@@ -4,8 +4,10 @@ package cn.com.taiji.iaw.tools; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.core.entity.basic.QtkCustomerInfo; | |||
import cn.com.taiji.core.entity.dict.basic.UserType; | |||
import cn.com.taiji.core.entity.dict.basic.AccountType; | |||
import cn.com.taiji.core.entity.user.AccountInfo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkCustomerInfoRepo; | |||
import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
@@ -27,7 +29,7 @@ public class WxLoginUserUtil extends AbstractManager { | |||
throw new ManagerException("身份认证信息错误"); | |||
} | |||
return customerInfoRepo.findByCustomerIdNumAndCustomerIdTypeAndUserType(accountInfo.getIdNum(), | |||
accountInfo.getIdType().getCode(), accountInfo.getUserType().getCode()); | |||
accountInfo.getIdType().getCode(), accountInfo.getAccountType().getCode()); | |||
} | |||
/** | |||
@@ -59,19 +61,19 @@ public class WxLoginUserUtil extends AbstractManager { | |||
*/ | |||
public AccountInfo getAccountInfoFromCustomerId(String customerId) throws ManagerException { | |||
QtkCustomerInfo customer = customerInfoRepo.findByCustomerId(customerId); | |||
AccountInfo accountInfo = accountInfoRepo.findByIdNumAndUserType(customer.getCustomerIdNum(), UserType.fromCode(customer.getUserType())); | |||
AccountInfo accountInfo = accountInfoRepo.findByIdNumAndAccountType(customer.getCustomerIdNum(), AccountType.fromCode(customer.getUserType().getCode())); | |||
if (accountInfo == null) { | |||
throw new ManagerException("身份认证信息错误"); | |||
} | |||
return accountInfo; | |||
} | |||
/* | |||
/** | |||
* 通过AccountInfo获得QtkCustomerInfo信息 | |||
*/ | |||
public QtkCustomerInfo getCustomerInfoFromAccountInfo(AccountInfo accountInfo) throws ManagerException { | |||
QtkCustomerInfo customer = customerInfoRepo.findByCustomerIdNumAndCustomerIdTypeAndUserType(accountInfo.getIdNum(), | |||
accountInfo.getIdType().getCode(), accountInfo.getUserType().getCode()); | |||
accountInfo.getIdType().getCode(), accountInfo.getAccountType().getCode()); | |||
if (customer == null) { | |||
throw new ManagerException("身份认证信息错误"); | |||
} |
@@ -17,7 +17,7 @@ public class WechatConfig { | |||
} | |||
//配置V2信息 | |||
public WxPayConfig initV2Config(String appId,String mchId,String mchKey,String subAppId,String subMchId,String notifyUrl) { | |||
public WxPayConfig initV2Config(String appId,String mchId,String mchKey,String subAppId,String subMchId) { | |||
WxPayConfig wxPayConfig = new WxPayConfig(); | |||
wxPayConfig.setAppId(appId); | |||
wxPayConfig.setMchId(mchId); | |||
@@ -25,7 +25,7 @@ public class WechatConfig { | |||
wxPayConfig.setSubAppId(subAppId); | |||
wxPayConfig.setSubMchId(subMchId); | |||
wxPayConfig.setSignType(HMAC_SHA256); | |||
wxPayConfig.setNotifyUrl(notifyUrl); | |||
// wxPayConfig.setNotifyUrl(notifyUrl); | |||
return wxPayConfig; | |||
} | |||
@@ -1,12 +1,9 @@ | |||
package cn.com.taiji.ats.manager.handler; | |||
import cn.com.taiji.ats.manager.handler.wx.WxMessageManager; | |||
import cn.com.taiji.ats.manager.weixin.CreatePayOrderV2Manager; | |||
import cn.com.taiji.ats.manager.weixin.CreatePayOrderV3Manager; | |||
import cn.com.taiji.ats.manager.weixin.QueryPayResultV3Manager; | |||
import cn.com.taiji.ats.manager.weixin.*; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.model.file.FileProtocolSystemError; | |||
import cn.com.taiji.ats.manager.weixin.VehicleUserStateManager; | |||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest; | |||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeResponse; | |||
import cn.com.taiji.core.model.comm.protocol.SignJsonRequest; | |||
@@ -35,6 +32,8 @@ public class WinXinServiceHandler extends AbstractAtsServiceHandler<WeiXinServic | |||
@Autowired | |||
private CreatePayOrderV2Manager createPayOrderV2Manager; | |||
@Autowired | |||
private QueryPayResultV2Manager queryPayResultV2Manager; | |||
@Autowired | |||
private CreatePayOrderV3Manager createPayOrderV3Manager; | |||
@Autowired | |||
private QueryPayResultV3Manager queryPayResultV3Manager; | |||
@@ -50,6 +49,8 @@ public class WinXinServiceHandler extends AbstractAtsServiceHandler<WeiXinServic | |||
switch (cmd) { | |||
case CREATEPAYORDERV2: | |||
return createPayOrderV2Manager.serviceHandle((AtsCreatPayOrderV2Request) request); | |||
case QUERYPAYRESULTV2: | |||
return queryPayResultV2Manager.serviceHandle((AtsQueryPayResultV2Request) request); | |||
case CREATEPAYORDERV3: | |||
return createPayOrderV3Manager.serviceHandle((AtsCreatPayOrderV3Request) request); | |||
case QUERYPAYRESULTV3: |
@@ -31,12 +31,12 @@ public class CreatePayOrderV2Manager extends AbstractManager { | |||
private WechatConfig wechatConfig; | |||
public AtsCreatPayOrderV2Response serviceHandle(AtsCreatPayOrderV2Request req) throws ServiceHandleException{ | |||
logger.info("微信支付V2下单请求参数{}",req.toJson()); | |||
//格式校验 | |||
req.validate(); | |||
logger.info("微信支付下单请求参数:{}", req.toJson()); | |||
//初始化配置信息 | |||
WxPayConfig wxPayConfig = wechatConfig.initV2Config(req.getAppId(), req.getMchId(), req.getMchKey(), | |||
req.getSubAppId(), req.getSubMchId(), req.getNotifyUrl()); | |||
req.getSubAppId(), req.getSubMchId()); | |||
//配置信息 | |||
wxPayService.setConfig(wxPayConfig); | |||
WxPayUnifiedOrderRequest wxRequest = copyProperties(req, new WxPayUnifiedOrderRequest()); |
@@ -28,7 +28,7 @@ public class CreatePayOrderV3Manager extends AbstractManager { | |||
@Autowired | |||
private WechatConfig wechatConfig; | |||
public AtsCreatPayOrderV3Response serviceHandle(AtsCreatPayOrderV3Request req) throws ServiceHandleException { | |||
logger.info("微信支付下单{}",req.toJson()); | |||
logger.info("微信支付V3下单请求参数{}",req.toJson()); | |||
//格式校验 | |||
req.validate(); | |||
//初始化配置信息 |
@@ -0,0 +1,53 @@ | |||
package cn.com.taiji.ats.manager.weixin; | |||
import cn.com.taiji.ats.config.WechatConfig; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.core.entity.dict.pay.TradeState; | |||
import cn.com.taiji.core.entity.dict.pay.TradeType; | |||
import cn.com.taiji.core.model.comm.protocol.ats.weiXin.AtsQueryPayResultV2Request; | |||
import cn.com.taiji.core.model.comm.protocol.ats.weiXin.AtsQueryPayResultV2Response; | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryRequest; | |||
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; | |||
import com.github.binarywang.wxpay.config.WxPayConfig; | |||
import com.github.binarywang.wxpay.exception.WxPayException; | |||
import com.github.binarywang.wxpay.service.WxPayService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/17 11:48 | |||
* @Filename:QueryPayResultV2Manager | |||
* @description: | |||
*/ | |||
@Service | |||
public class QueryPayResultV2Manager extends AbstractManager { | |||
@Autowired | |||
private WxPayService wxPayService; | |||
@Autowired | |||
private WechatConfig wechatConfig; | |||
public AtsQueryPayResultV2Response serviceHandle(AtsQueryPayResultV2Request req) throws ServiceHandleException { | |||
logger.info("微信支付V2查询支付结果请求参数{}",req.toJson()); | |||
WxPayConfig wxPayConfig = wechatConfig.initV2Config(req.getAppId(), req.getMchId(), req.getMchKey(), req.getSubAppId(), req.getSubMchId()); | |||
wxPayService.setConfig(wxPayConfig); | |||
WxPayOrderQueryRequest request = copyProperties(req, new WxPayOrderQueryRequest()); | |||
WxPayOrderQueryResult wxPayOrderQueryResult = null; | |||
try { | |||
wxPayOrderQueryResult = wxPayService.queryOrder(request); | |||
} catch (WxPayException e) { | |||
logger.error("微信支付结果V2查询失败:{}", e.getMessage()); | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException(e.getMessage()); | |||
} | |||
AtsQueryPayResultV2Response response = copyProperties(wxPayOrderQueryResult, new AtsQueryPayResultV2Response()); | |||
response.setTradeState(TradeState.valueOf(wxPayOrderQueryResult.getTradeState())); | |||
if (hasText(wxPayOrderQueryResult.getTradeType())) { | |||
response.setTradetype(TradeType.valueOf(wxPayOrderQueryResult.getTradeType())); | |||
} | |||
return response; | |||
} | |||
} |
@@ -26,6 +26,7 @@ public class QueryPayResultV3Manager extends AbstractManager { | |||
@Autowired | |||
private WechatConfig wechatConfig; | |||
public AtsQueryPayResultV3Response serviceHandle(AtsQueryPayResultV3Request req) throws ServiceHandleException { | |||
logger.info("微信支付V3查询支付结果请求参数{}",req.toJson()); | |||
//格式 | |||
req.validate(); | |||
//配置支付信息 |
@@ -27,6 +27,7 @@ public class VehicleUserStateManager extends AbstractManager { | |||
private static final String baseUrl = "https://api.mch.weixin.qq.com/vehicle/partnerpay/querystate"; | |||
public AtsVehicleUserStateResponse serviceHandle(AtsVehicleUserStateRequest request) throws ServiceHandleException { | |||
logger.info("微信支付车主签约状态查询请求参数{}",request.toJson()); | |||
//生成xml字符串 | |||
String reqXml = getXmlString(request); | |||
String resXml = postData(baseUrl, reqXml, "text/xml"); |
@@ -99,6 +99,7 @@ public class TestController { | |||
} | |||
//服务商 codeUrl = weixin://wxpay/bizpayurl?pr=14g4kOez1 | |||
//v2 普通商户 codeUrl = weixin://wxpay/bizpayurl?pr=SNBYt2Kz3 | |||
//V2 普通商户weixin://wxpay/bizpayurl?pr=Ne0lOJSz3 | |||
@GetMapping("qrCode") | |||
public void qrcode(HttpServletResponse response,@RequestBody TestModel model) throws Exception { | |||
String data = "weixin://wxpay/bizpayurl?pr=OeLKIGGz1"; |