添加汇付支付

This commit is contained in:
韩鹏辉 2024-01-17 17:18:25 +08:00
parent ad88ec4da3
commit 6dc546e727
20 changed files with 787 additions and 65 deletions

View File

@ -123,6 +123,8 @@
<configuration>
<mainClass>cn.pluss.platform.ApiApplication</mainClass>
<outputDirectory>./</outputDirectory>
<fork>true</fork>
<includeSystemScope>true</includeSystemScope>
</configuration>
<executions>
<execution>

View File

@ -23,6 +23,9 @@ public class MercAppletController {
@Resource
private AppletStoreUserService appletStoreUserService;
@GetMapping("/list")
public Result<Object> menuList(Integer userId){
List<AppletStoreVO> list = appletStoreService.getList(userId);

View File

@ -5,9 +5,9 @@ spring:
# password: CZGmysqlroot@123
# driver-class-name: com.mysql.jdbc.Driver
datasource:
url: jdbc:mysql://rm-bp19ib8x213kh9t450o.rwlb.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: prodCZGmysqlroot@123
url: jdbc:mysql://101.37.12.135:3306/ysk_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: ysk_test
password: mysqlroot@123
driver-class-name: com.mysql.jdbc.Driver
# datasource:
# url: jdbc:mysql://101.37.12.135:3306/ysk_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
@ -16,7 +16,7 @@ spring:
# driver-class-name: com.mysql.jdbc.Driver
parameter:
### 这个根据自己的情况配置
domain: https://ky.sxczgkj.cn
domain: https://admintestapi.sxczgkj.cn
swagger:
### 生产环境不允许访问swagger
@ -24,3 +24,6 @@ swagger:
logging:
config: classpath:log4j2-dev.xml
hf:
pay:
callBack: https://admintestapi.sxczgkj.cn/wap/notify/hfCallBack

View File

@ -0,0 +1,13 @@
package cn.pluss.platform.mapper;
import cn.pluss.platform.entity.MmerchantHfInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
public interface MerchantHfInfoMapper extends BaseMapper<MmerchantHfInfo> {
@Select("SELECT * FROM tb_pluss_merchant_hf_info WHERE merchant_code = #{merchantCode}")
MmerchantHfInfo selectByMerchantCode(String merchantCode);
}

View File

@ -0,0 +1,43 @@
package cn.pluss.platform.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("tb_pluss_merchant_hf_info")
public class MmerchantHfInfo {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("merchant_code")
private String merchantCode;
@TableField("status")
private String status;
@TableField("test_api_key")
private String test_api_key;
@TableField("live_api_key")
private String live_api_key;
@TableField("app_id_list")
private String app_id_list;
@TableField("app_id")
private String app_id;
@TableField("app_name")
private String app_name;
@TableField("login_pwd")
private String login_pwd;
@TableField("puc_key")
private String puc_key;
@TableField("priv_key")
private String priv_key;
@TableField("create_time")
private Date create_time;
@TableField("update_time")
private Date update_time;
}

View File

@ -89,6 +89,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.huifu.adapay</groupId>
<artifactId>adapay-java-sdk</artifactId>
<version>1.2.10</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -0,0 +1,490 @@
package cn.pluss.platform.hf.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.dto.MemberScanPayDTO;
import cn.pluss.platform.dto.MerChantOrderDTO;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.mapper.MerchantHfInfoMapper;
import cn.pluss.platform.merchantOrder.MerchantOrderService;
import cn.pluss.platform.pay.PayService;
import cn.pluss.platform.util.DateUtils;
import cn.pluss.platform.util.SnowFlakeUtil;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.ys.YsConfig;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.base.Strings;
import com.huifu.adapay.Adapay;
import com.huifu.adapay.model.AdapayCommon;
import com.huifu.adapay.model.MerConfig;
import com.huifu.adapay.model.Payment;
import com.huifu.adapay.model.Refund;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service("hfPayService")
@Slf4j
public class HfPayServiceImpl implements PayService {
@Autowired
MerchantHfInfoMapper merchantHfInfoMapper;
@Value("${hf.pay.callBack}")
private String callBack;
@Setter(onMethod_ = {@Autowired, @Lazy})
private MerchantOrderService merchantOrderService;
private static String changeY2F(double price) {
DecimalFormat df = new DecimalFormat("#0.00");
return df.format(price);
}
private void init(String apiKey, String mockApiKey, String rsaPrivateKey) throws Exception {
/**
* debug 模式开启后有详细的日志
*/
Adapay.debug = false;
/**
* prodMode 模式默认为生产模式false可以使用mock模式
*/
Adapay.prodMode = true;
/**
* 初始化商户配置服务器启动前必须通过该方式初始化商户配置完成
* apiKey为prod模式的API KEY
* mockApiKey为mock模式的API KEY
* rsaPrivateKey为商户发起请求时用于请求参数加签所需要的RSA私钥
*/
if (Strings.isNullOrEmpty(apiKey)) {
apiKey = "api_live_c5fbe553-0680-436a-a457-3252fc841697";
}
if (Strings.isNullOrEmpty(mockApiKey)) {
mockApiKey = "api_test_ecb5e50f-c1bc-4854-af2d-eee4b98bcf6f";
}
if (Strings.isNullOrEmpty(rsaPrivateKey)) {
rsaPrivateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAImujrgtJxw2Qm5TXNiRF4WuoYmyr37vpFX/LK4VUb0Qp7darJbNqNGvGBxbYmUccsKrAGyAJPwra71BtBEfTDsg4w0RO/6Wk4qx32ZHEaxpqYTLuOujUMvorL5AVr/SAlUtRlzwz82q4yQZxchYRGXlj3OP8iq1FzdXUxv+UeyjAgMBAAECgYAk7R04Blwr892DS3ZmWxus7fZDQRpSeCFiMysfkXY3uATTZ01MsOHrQwO7b0MHjUa2MTjO4NuKina97qZFxVgjSuByVrxkib+QY4vdqCL2I+tKH6qMSYlom0g8ybGWZrqQm2CzMFzf+ub4bpkJxINQ+7zjDsrRa5Lgk9B2xHkvoQJBAMG4hH7GWS67gYdpsTFtxbQiTrlreLAYJjwbaOhvpPiH3JaooPRcdceALe42eMZDAn5Mrg1jaA7/eM1iVMDXljMCQQC18fY9c1dHmLyOF3yaeVM+0kLrAyf//67xDV0QROYXo998vsIhpbeFm0cRTsjp4uXIq4W1KBAkBw0aqtEK/3/RAkBdl7czxMKrqF3BPZglSGK/T9/3B2xsr44xdhCuU9pBVOqHQ3tX9B/XPh9yupCJQTDAMm3Y/BD3RghoOjy2WrIvAkAGN0kBWnJt6MLwW88O+/wjFk3g94+jSFnytFEsoB34Ssn02hOJ0L6PWvm3lqh4jR7qlymPQdojUPZapeFUbdwxAkEAo+UYAbvDe1ewHpVtnbxMpWmtJeLRg8PlNhFfQjwfuaTOyyiuZU1pPtwUXjHsb4zqoA1QMR5vu0C0s2IpP8dljQ==";
}
MerConfig merConfig = new MerConfig();
merConfig.setApiKey(apiKey);
merConfig.setApiMockKey(mockApiKey);
merConfig.setRSAPrivateKey(rsaPrivateKey);
try {
Adapay.initWithMerConfig(merConfig);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public JSONObject tradePay(MerchantOrder order, MerchantChannelStatus channel, MerchantBaseInfo merchant) {
String account_type = "WECHAT";
if (StringUtil.isNotEmpty(order.getScanType()) && "01".equals(order.getScanType())) {
account_type = "wechatPay".equals(order.getPayTypeCode()) ? "WECHAT" : "aliPay".equals(order.getPayTypeCode()) ? "ALIPAY" : "UQRCODEPAY";
} else {
account_type = "wechatPay".equals(order.getPayTypeCode()) ? "WECHAT" : "aliPay".equals(order.getPayTypeCode()) ? "ALIPAY" : "UQRCODEPAY";
}
String transType = account_type.equals("WECHAT") ? "wx_lite" : account_type.equals("ALIPAY") ? "alipay_qr" : "union_qr";
Map<String, Object> paymentParams = new HashMap<>();
Map<String, String> deviceInfo = new HashMap<>();
Map expendParams = new HashMap();
if ("wx_lite".equals(transType)) {
expendParams.put("open_id", order.getMercUserId());
expendParams.put("wx_app_id", order.getAppletsAppid());
} else {
expendParams.put("buyer_id", order.getMercUserId());
}
MmerchantHfInfo hfInfo = merchantHfInfoMapper.selectByMerchantCode(merchant.getMerchantCode());
MsgException.checkNull(hfInfo, "商户进件信息不存在");
Boolean flag = false;
if ("3".equals(hfInfo.getStatus()) || "4".equals(hfInfo.getStatus())) {
flag = true;
}
if (!flag) {
MsgException.check(true, "商户信息不完整");
}
String order_amt = changeY2F(order.getConsumeFee());
deviceInfo.put("device_ip", order.getIp());
paymentParams.put("app_id", hfInfo.getApp_id());
paymentParams.put("order_no", order.getOrderNumber());
paymentParams.put("pay_channel", transType);
paymentParams.put("pay_amt", order_amt);
paymentParams.put("goods_title", "收款码收款");
paymentParams.put("goods_desc", "收款码收款");
paymentParams.put("device_info", deviceInfo);
//异步通知地址url为http/https路径服务器POST回调URL 上请勿附带参数
paymentParams.put("notify_url", callBack);
paymentParams.put("expend", expendParams);
log.info(paymentParams.toString());
JSONObject resp = new JSONObject();
Map<String, Object> adapay = null;
JSONObject payData = new JSONObject();
try {
this.init(hfInfo.getLive_api_key(), hfInfo.getTest_api_key(), hfInfo.getPriv_key());
adapay = Payment.create(paymentParams);
log.info("payment result=" + JSON.toJSONString(adapay));
if ("succeeded".equals(adapay.get("status"))) {
if (!(StringUtil.isNotEmpty(order.getScanType()) && "01".equals(order.getScanType()))) {
cn.hutool.json.JSONObject expend = JSONUtil.parseObj(adapay.get("expend")).getJSONObject("pay_info");
if (Constant.PAY_TYPE_ALIPAY.equals(order.getPayTypeCode())) {
payData.put("source", JSONUtil.parseObj(adapay.get("expend")).get("qrcode_url"));
} else if (Constant.PAY_TYPE_WECHAT.equals(order.getPayTypeCode())) {
payData.put("payAppId", expend.get("appId"));
payData.put("payTimeStamp", expend.get("timeStamp"));
payData.put("paynonceStr", expend.get("nonceStr"));
payData.put("payPackage", expend.get("package"));
payData.put("paySignType", expend.get("signType"));
payData.put("paySign", expend.get("paySign"));
} else {
payData.put("redirectUrl", JSONUtil.parseObj(adapay.get("expend")).get("qrcode_url"));
}
} else {
payData.put("payUrl", adapay.get("code"));
payData.put("orderNumber", order.getOrderNumber());
payData.put("mercOrderNo", order.getMercOrderNo());
}
resp.put("code", ResultCode.SUCCESS.code());
payData.put("channel", channel.getChannel());
order.setTransNo((adapay.get("id").toString()));
resp.put("payData", payData);
return resp;
} else if ("pending".equals(adapay.get("status"))) {
resp.put("code", ResultCode.FAIL.code());
resp.put("msg", adapay.get("msg"));
return resp;
} else if ("failed".equals(adapay.get("status"))) {
resp.put("code", ResultCode.FAIL.code());
resp.put("msg", adapay.get("msg"));
return resp;
}
} catch (Exception e) {
log.error("adapay支付指令调用失败", e);
e.printStackTrace();
}
return resp;
}
@Override
public JSONObject tradePay(MerChantOrderDTO merchantOrderDTO, MerchantOrder order) {
JSONObject obj = new JSONObject(6);
String account_type = "WECHAT";
if (StringUtil.isNotEmpty(order.getScanType()) && "01".equals(order.getScanType())) {
account_type = "wechatPay".equals(order.getPayTypeCode()) ? "WECHAT" : "aliPay".equals(order.getPayTypeCode()) ? "ALIPAY" : "UQRCODEPAY";
} else {
account_type = "wechatPay".equals(order.getPayTypeCode()) ? "WECHAT" : "aliPay".equals(order.getPayTypeCode()) ? "ALIPAY" : "UQRCODEPAY";
}
String transType = account_type.equals("WECHAT") ? "wx_scan" : account_type.equals("ALIPAY") ? "alipay_scan" : "union_qr";
Map<String, Object> paymentParams = new HashMap<>();
Map<String, String> deviceInfo = new HashMap<>();
Map expendParams = new HashMap();
expendParams.put("auth_code", merchantOrderDTO.getAuthCode());
// if("wx_lite".equals(transType)){
// expendParams.put("auth_code",order.getMercUserId());
//// expendParams.put("wx_app_id",order.getAppletsAppid());
// }else {
// expendParams.put("buyer_id",order.getMercUserId());
// }
MmerchantHfInfo hfInfo = merchantHfInfoMapper.selectByMerchantCode(order.getMerchantCode());
MsgException.checkNull(hfInfo, "商户进件信息不存在");
Boolean flag = false;
if ("3".equals(hfInfo.getStatus()) || "4".equals(hfInfo.getStatus())) {
flag = true;
}
if (!flag) {
MsgException.check(true, "商户信息不完整");
}
String order_amt = changeY2F(order.getConsumeFee());
deviceInfo.put("device_ip", order.getIp());
paymentParams.put("app_id", hfInfo.getApp_id());
paymentParams.put("order_no", order.getOrderNumber());
paymentParams.put("pay_channel", transType);
paymentParams.put("pay_amt", order_amt);
paymentParams.put("goods_title", "付款码收款");
paymentParams.put("goods_desc", "付款码收款");
paymentParams.put("device_info", deviceInfo);
//异步通知地址url为http/https路径服务器POST回调URL 上请勿附带参数
paymentParams.put("notify_url", callBack);
paymentParams.put("expend", expendParams);
log.info(paymentParams.toString());
JSONObject resp = new JSONObject();
Map<String, Object> adapay = null;
JSONObject payData = new JSONObject();
try {
this.init(hfInfo.getLive_api_key(), hfInfo.getTest_api_key(), hfInfo.getPriv_key());
adapay = Payment.create(paymentParams);
log.info("payment result=" + JSON.toJSONString(adapay));
if ("succeeded".equals(adapay.get("status"))) {
JSONObject object = JSON.parseObject(adapay.toString());
if (object.containsKey("code") && "BBS10000".equals(object.get("code"))) {
obj.put("code", ResultCode.TRANSUNKNOW.code());
obj.put("msg", "用户支付中");
obj.put("channelOrderNo", object.getJSONObject("resp_data").get("trade_no"));
obj.put("transNo", object.getJSONObject("resp_data").get("log_no"));
obj.put("payStatus", "7");
return obj;
} else if (object.containsKey("code") && "BBS00000".equals(object.get("code"))) {
obj.put("code", ResultCode.SUCCESS.code());
obj.put("msg", "成功");
obj.put("channelOrderNo", object.getJSONObject("resp_data").get("trade_no"));
obj.put("transNo", object.getJSONObject("resp_data").get("log_no"));
obj.put("payStatus", "1");
obj.put("payTime", DateUtils.convertDate(object.getJSONObject("resp_data").getString("trade_time")));
return obj;
} else {
obj.put("code", ResultCode.FAIL.code());
obj.put("msg", object.get("msg"));
return obj;
}
}
} catch (Exception e) {
e.printStackTrace();
}
obj.put("code", ResultCode.FAIL.code());
obj.put("msg", "失败");
return obj;
}
@Override
public Map<String, Object> refundPay(MerchantOrder order, String mchNo) {
MmerchantHfInfo hfInfo = merchantHfInfoMapper.selectByMerchantCode(order.getMerchantCode());
MsgException.checkNull(hfInfo, "商户进件信息不存在");
Boolean flag = false;
if ("3".equals(hfInfo.getStatus()) || "4".equals(hfInfo.getStatus())) {
flag = true;
}
if (!flag) {
MsgException.check(true, "商户信息不完整");
}
Map<String, Object> refundParams = new HashMap<String, Object>();
String refundNo = "adapay_refund_order_" + SnowFlakeUtil.nextId();
refundParams.put("refund_amt", order.getConsumeFee());
refundParams.put("refund_order_no", refundNo);
refundParams.put("notify_url", callBack);
Map<String, Object> adapay = null;
Map<String, Object> result = new HashMap<>(4);
result.put("refundNo", refundNo);
result.put("status", "3");
result.put("code", ResultCode.FAIL.code());
try {
init(hfInfo.getLive_api_key(), hfInfo.getTest_api_key(), hfInfo.getPriv_key());
adapay = Refund.create(order.getTransNo(), refundParams);
log.info("payment result=" + JSON.toJSONString(adapay));
if ("pending".equals(adapay.get("status"))) {
result.put("msg", "退款成功!");
result.put("data", adapay.get("id"));
result.put("status", "1");
result.put("code", ResultCode.SUCCESS.code());
return result;
} else if ("failed".equals(adapay.get("status"))) {
result.put("msg", adapay.get("msg"));
return result;
}
} catch (Exception e) {
e.printStackTrace();
}
result.put("msg", "退款失败!");
return result;
}
@Override
public JSONObject tradeQuery(MerchantOrder order, String mchId) {
return null;
}
@Override
public JSONObject refundQuery(MerchantRefundOrder refundOrder) {
return null;
}
@Override
public Map<String, Object> closeOrder(String orderNumber, String channelNo) {
return null;
}
@Override
public Map<String, Object> getWxOpenId(MemberScanPayDTO memberScanPayDTO, MerchantChannelStatus channel) throws Exception {
return null;
}
@Override
public Map<String, Object> getUnionInfo(String userAuthCode, String paymentApp, String merchantId) throws Exception {
MmerchantHfInfo hfInfo = merchantHfInfoMapper.selectByMerchantCode(merchantId);
MsgException.checkNull(hfInfo, "商户进件信息不存在");
Boolean flag = false;
if ("3".equals(hfInfo.getStatus()) || "4".equals(hfInfo.getStatus())) {
flag = true;
}
if (!flag) {
MsgException.check(true, "商户信息不完整");
}
Map<String, Object> wxParam = new HashMap<String, Object>(4);
wxParam.put("order_no", "query".equals(SnowFlakeUtil.nextId().toString()));
wxParam.put("app_id", hfInfo.getApp_id());
wxParam.put("auth_code", userAuthCode);
Map<String, Object> result = AdapayCommon.queryAdapay(wxParam, "yifuyun");
if (ObjectUtil.isNotEmpty(result) && result.containsKey("data")) {
JSONObject object = JSON.parseObject(result.get("data").toString());
if (ObjectUtil.isNotEmpty(object) && "succeeded".equals(object.getString("status"))) {
JSONObject reqData = new JSONObject(2);
reqData.put("data", object.getString("open_id"));
reqData.put("userAuthCode", userAuthCode);
reqData.put("appUpIdentifier", paymentApp);
result.put("data", reqData);
result.put("code", "1");
result.put("msg", "获取成功");
}
}
result.put("code", "0");
result.put("msg", "获取失败");
return result;
}
@Override
public Object payNotifyCallBack(Map<String, String> params) {
Map<String, String> result = new HashMap<>(2);
result.put("code", "fail");
result.put("msg", "失败");
String type = params.get("type");
switch (type) {
case "payment.succeeded":
Map data = JSON.parseObject(params.get("data"), Map.class);
String orderNo = data.get("order_no").toString();
QueryWrapper<MerchantOrder> queryWrapper = new QueryWrapper<MerchantOrder>().eq("orderNumber", orderNo);
MerchantOrder order = merchantOrderService.getOne(queryWrapper);
if (order == null) {
log.error("====================>【汇付】支付成功回调订单号查询,查询的订单为空:订单号:{}<====================", orderNo);
return YsConfig.RESULT_SUCCESS_CODE;
}
Date payDate = new Date(Long.valueOf(data.get("created_time").toString()) * 1000);
order.setTransDt(payDate);
order.setTransNo(data.get("id").toString());
order.setThirdTransNo(data.get("id").toString());
merchantOrderService.updateOrderAndCreateProfit(order);
result.put("code", "success");
result.put("msg", "成功");
break;
case "payment.failed":
data = JSON.parseObject(params.get("data"), Map.class);
orderNo = data.get("order_no").toString();
queryWrapper = new QueryWrapper<MerchantOrder>().eq("orderNumber", orderNo);
order = merchantOrderService.getOne(queryWrapper);
if (order == null) {
log.error("====================>【汇付】支付成功回调订单号查询,查询的订单为空:订单号:{}<====================", orderNo);
return YsConfig.RESULT_SUCCESS_CODE;
}
payDate = new Date(Long.valueOf(data.get("created_time").toString()) * 1000);
order.setTransDt(payDate);
order.setStatus("0");
order.setTransNo(data.get("id").toString());
order.setThirdTransNo(data.get("id").toString());
merchantOrderService.update(order,queryWrapper);
result.put("code", "success");
result.put("msg", "成功");
break;
case "payment.close.succeeded":
break;
case "payment.close.failed":
break;
case "refund.succeeded":
break;
case "refund.failed":
break;
}
return result;
}
@Override
public String tradePayWap(MerchantOrder order, MerchantChannelStatus channel) {
return null;
}
@Override
public JSONObject getUnionAccountUrl(JSONObject reqData) {
return null;
}
@Override
public JSONObject jftPay(JftReceiptOrder order, JftMercBaseInfo jftMerc, JftMercPaymentChannel jftChannel) {
return null;
}
}

View File

@ -124,9 +124,7 @@ public class LkLPayServiceImpl implements PayService {
"}";
}
String response = lklPayService.req(body, "api/v3/labs/trans/preorder");
JSONObject resp = new JSONObject();
if (ObjectUtil.isNotEmpty(response)) {
JSONObject payData = new JSONObject();
@ -171,7 +169,6 @@ public class LkLPayServiceImpl implements PayService {
resp.put("code", ResultCode.FAIL.code());
resp.put("msg", "失败");
return resp;
}
@Override

View File

@ -2,7 +2,6 @@ package cn.pluss.platform.klk.service;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.dto.MerChantOrderDTO;
import cn.pluss.platform.entity.MerchantBackLkl;
import cn.pluss.platform.entity.MerchantBaseInfo;
import cn.pluss.platform.entity.MerchantChannelStatus;
@ -13,7 +12,6 @@ import cn.pluss.platform.mapper.MerchantBackLklMapper;
import cn.pluss.platform.util.DateUtils;
import cn.pluss.platform.util.SnowFlakeUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.io.IOUtils;
@ -140,7 +138,6 @@ public class LklPayService {
if (ObjectUtil.isNotEmpty(response)) {
JSONObject object = JSONObject.parseObject(response);
if (object.containsKey("retCode") && "000000".equals(object.getString("retCode"))) {
return true;
} else {
@ -193,8 +190,6 @@ public class LklPayService {
"}";
}
String resp= req(body,"api/v2/mms/openApi/querySubMerInfo");
log.info("resp:{}",resp);
return resp;

View File

@ -233,6 +233,15 @@ public class MerchantRateNewServiceImpl extends ServiceImpl<MerchantRateNewMappe
merchantRateNew.setBankRateLarge(61);
result = ysChangeRateService.getDefaultRate();
break;
case 7:
merchantRateNew = new MerchantRateNew();
merchantRateNew.setChannel(7);
merchantRateNew.setWxRate(38);
merchantRateNew.setAliRate(38);
merchantRateNew.setBankRate(61);
merchantRateNew.setBankRateLarge(61);
result=merchantRateNew;
break;
default:
MsgException.throwException("通道异常!");
}

View File

@ -151,6 +151,12 @@ public class MerchantServiceImpl implements MerchantService {
LkLPayServiceImpl lkLPayServiceImpl;
@Setter(onMethod_ = {@Autowired, @Qualifier("hfPayService")})
private PayService hfPayService;
@Override
public String appRefundCallback(HttpServletRequest request) {
log.info("=========================jinruleshua huidiao =====================");
@ -431,7 +437,10 @@ public class MerchantServiceImpl implements MerchantService {
result=lkLPayServiceImpl.tradePay(order,channel,merchant);
} else if (channel.getChannel() == 6) {
result = ysPayOldService.tradePay(order, channel,merchant);
}else {
}else if(channel.getChannel()==7){
result= hfPayService.tradePay(order,channel,merchant);
}
else {
MsgException.throwException("未知通道");
}
if (ResultCode.SUCCESS.code() != result.getInteger("code")) {

View File

@ -21,6 +21,7 @@ import cn.pluss.platform.entitiy.SettleTypeEnum;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.enums.UserRoleEnum;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.hf.service.HfPayServiceImpl;
import cn.pluss.platform.klk.service.LkLPayServiceImpl;
import cn.pluss.platform.klk.service.LklPayService;
import cn.pluss.platform.klk.service.impl.LaKalaInterfaceImpl;
@ -140,6 +141,11 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
@Setter(onMethod_ = {@Autowired})
private LkLPayServiceImpl lkLPayServiceImpl;
@Setter(onMethod_ = {@Autowired, @Qualifier("hfPayService")})
private PayService hfPayService ;
@Setter(onMethod_ = {@Autowired, @Qualifier("ysPayOldService")})
private PayService ysPayOldService;
@ -951,6 +957,9 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
} else if("6".equals(order.getAisleSwitch())){
JSONObject object = ysPayOldService.tradePay(dto, order);
return scanPay(object, order);
} else if ("7".equals(order.getAisleSwitch())){
JSONObject object = hfPayService.tradePay(dto,order);
return scanPay(object, order);
}else{
throw new MsgException("未知通道!");
}
@ -1479,6 +1488,11 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
merchantOrderDTO.setAisleSwitch("5");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_WECHAT);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_WECHAT);
}else if(channelStatus.getChannel()==7){
orderPrefix = "HF_Y_";
merchantOrderDTO.setAisleSwitch("7");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
}
break;
case "2":
@ -1503,31 +1517,37 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
merchantOrderDTO.setAisleSwitch("5");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_ALIPAY);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_ALIPAY);
}else if(channelStatus.getChannel()==7){
orderPrefix = "HF_Y_";
merchantOrderDTO.setAisleSwitch("7");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_ALIPAY);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_ALIPAY);
}
break;
case "6":
if (channelStatus.getChannel() == 1) {
orderPrefix = "SXF_Y_";
merchantOrderDTO.setAisleSwitch("2");
merchantOrderDTO.setPayTypeCode("sxfPay2");
merchantOrderDTO.setPayTypeName("随行云闪付支付");
} else if (channelStatus.getChannel() == 3) {
orderPrefix = "RYX_Y_";
merchantOrderDTO.setAisleSwitch("3");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
} else if (channelStatus.getChannel() == 4) {
orderPrefix = "YS_Y_";
merchantOrderDTO.setAisleSwitch("4");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
}else if (channelStatus.getChannel()==5){
orderPrefix = "LKL_Y_";
merchantOrderDTO.setAisleSwitch("5");
merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
}
break;
// case "6":
// if (channelStatus.getChannel() == 1) {
// orderPrefix = "SXF_Y_";
// merchantOrderDTO.setAisleSwitch("2");
// merchantOrderDTO.setPayTypeCode("sxfPay2");
// merchantOrderDTO.setPayTypeName("随行云闪付支付");
// } else if (channelStatus.getChannel() == 3) {
// orderPrefix = "RYX_Y_";
// merchantOrderDTO.setAisleSwitch("3");
// merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
// merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
// } else if (channelStatus.getChannel() == 4) {
// orderPrefix = "YS_Y_";
// merchantOrderDTO.setAisleSwitch("4");
// merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
// merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
// }else if (channelStatus.getChannel()==5){
// orderPrefix = "LKL_Y_";
// merchantOrderDTO.setAisleSwitch("5");
// merchantOrderDTO.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
// merchantOrderDTO.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
// }
// break;
default:
throw new MsgException("请扫微信、支付宝或云闪付的付款码!");
}
@ -1587,6 +1607,8 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
resultMap = ysPayOldService.refundPay(order, channel.getMerchantId());
}else if(channel.getChannel()==5){
resultMap = lkLPayServiceImpl.refundPay(order,channel.getMerchantCode());
}else if(channel.getChannel()==7){
resultMap= hfPayService.refundPay(order,channel.getMerchantCode());
}
else {
@ -2649,6 +2671,39 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
order.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
}
}
break;
case 7 :
order.setAisleSwitch("7");
if(!"D1".equals(channel.getVirChannelFlag()) &&YsBusinessCodeEnum.D0.getName().equals(channel.getSettlementType())){
order.setSettlementType(SettleTypeEnum.D0.getValue());
}else{
order.setSettlementType(SettleTypeEnum.D1.getValue());
}
order.setChannelRate(new BigDecimal(0.0038).multiply(new BigDecimal(10000)));
order.setChannelFee(new BigDecimal(order.getConsumeFee().toString()).multiply(new BigDecimal(0.0038)).setScale(2,BigDecimal.ROUND_HALF_UP));
if(params.get("payWay") == null){
orderPrefix = "HF_";
}else{
if("WXZF".equalsIgnoreCase((String) params.get("payWay"))){
orderPrefix = "HF_W_";
order.setPayTypeCode(Constant.PAY_TYPE_WECHAT);
order.setPayTypeName(Constant.PAY_TYPE_NAME_WECHAT);
}else if("ZFBZF".equalsIgnoreCase((String)params.get("payWay"))){
orderPrefix = "HF_Z_";
order.setPayTypeCode(Constant.PAY_TYPE_ALIPAY);
order.setPayTypeName(Constant.PAY_TYPE_NAME_ALIPAY);
}else if("UNIONPAY".equalsIgnoreCase((String)params.get("payWay"))){
if(order.getConsumeFee() > 1000.0d){
order.setChannelRate(YsOldConstants.CREDIT_DEBIT_CARD_BANK_RATE_LARGE.multiply(new BigDecimal(10000)));
order.setChannelFee(new BigDecimal(order.getConsumeFee().toString()).multiply(YsOldConstants.CREDIT_DEBIT_CARD_BANK_RATE_LARGE).setScale(2,BigDecimal.ROUND_HALF_UP));
}
orderPrefix = "HF_Y_";
order.setPayTypeCode(Constant.PAY_TYPE_YSFPAY);
order.setPayTypeName(Constant.PAY_TYPE_NAME_YSFPAY);
}
}
break;
default:
throw new MsgException("无效的通道");

View File

@ -102,6 +102,11 @@ public class ApiPayServiceImpl implements ApiPayService {
@Setter(onMethod_ = {@Autowired, @Qualifier("ysPayOldService")})
private PayService ysPayOldService;
@Setter(onMethod_ = {@Autowired, @Qualifier("hfPayService")})
private PayService hfPayService;
@Resource
private MerchantRateNewService merchantRateNewService;
@ -445,6 +450,9 @@ public class ApiPayServiceImpl implements ApiPayService {
}else if (channel.getChannel() == 6){
JSONObject res = ysPayOldService.tradePay(order, channel,merchant);
return assemblePayRresultParam(res, order);
}else if(channel.getChannel()==7){
JSONObject res=hfPayService.tradePay(order,channel,merchant);
return assemblePayRresultParam(res, order);
}
return ResultGenerator.genFailJsonResult("未知的通道!");
} catch (Exception e) {
@ -460,6 +468,7 @@ public class ApiPayServiceImpl implements ApiPayService {
if (ResultCode.SUCCESS.code() != result.getInteger("code")) {
return ResultGenerator.genFailJsonResult(result.getString("msg"));
}
JSONObject payData = result.getJSONObject("payData");
order.setPayData(payData.toJSONString());
merchantOrderService.save(order);

Binary file not shown.

Binary file not shown.

View File

@ -89,6 +89,24 @@
<version>1.9.22</version>
</dependency>
<dependency>
<groupId>com.huifu.adapay</groupId>
<artifactId>adapay-core-sdk</artifactId>
<version>1.2.10</version>
<systemPath>${project.basedir}/lib/adapay-core-sdk-1.2.10.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.huifu.adapay</groupId>
<artifactId>adapay-java-sdk</artifactId>
<version>1.2.10</version>
<systemPath>${project.basedir}/lib/adapay-java-sdk-1.2.10.jar</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
<!-- <dependencyManagement>-->
@ -120,6 +138,8 @@
<configuration>
<mainClass>cn.pluss.platform.WapApplication</mainClass>
<outputDirectory>./</outputDirectory>
<fork>true</fork>
<includeSystemScope>true</includeSystemScope>
</configuration>
<executions>
<execution>

View File

@ -186,6 +186,11 @@ public class MerchantController {
@Setter(onMethod_ = {@Autowired})
private RyxPayService ryxPayService;
@Setter(onMethod_ = {@Autowired, @Qualifier("hfPayService")})
private PayService hfPayService;
@Autowired
private UserIpRecordService ipRecordService;
@ -1752,7 +1757,11 @@ public class MerchantController {
unionInfo=lkLPayService.getUnionInfo(userAuthCode,payMentApp,channel.getMerchantCode());
} else if (channel.getChannel() == 6) {
unionInfo = ysPayOldService.getUnionInfo(userAuthCode, payMentApp, null);
} else {
}else if(channel.getChannel()==7){
unionInfo=hfPayService.getUnionInfo(userAuthCode,payMentApp,channel.getMerchantCode());
}
else {
view.addObject("error", "未知通道类型");
return view;
}

View File

@ -1,10 +1,14 @@
package cn.pluss.platform.controller.home;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.pluss.platform.klk.service.LkLPayServiceImpl;
import cn.pluss.platform.pay.PayService;
import cn.pluss.platform.ryx.pay.RyxPayService;
import cn.pluss.platform.sxf.pay.SxfPayService;
import com.alibaba.fastjson.JSONObject;
import com.huifu.adapay.core.AdapayCore;
import com.huifu.adapay.core.util.AdapaySign;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@ -13,6 +17,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@ -35,6 +40,14 @@ public class PayNotifyController {
@Setter(onMethod_ = {@Autowired, @Qualifier("lkLPayService")})
private PayService lklPayService;
@Setter(onMethod_ = {@Autowired, @Qualifier("hfPayService")})
private PayService hfPayService;
@Setter(onMethod_ = {@Autowired, @Lazy})
private SxfPayService sxfPayService;
@ -79,6 +92,46 @@ public class PayNotifyController {
@PostMapping("hfCallBack")
public String hfCallBack(HttpServletRequest request){
log.info("回调返回信息:{}", JSONUtil.toJsonStr(request.getParameterMap()));
Map<String,String> map=new HashMap<>();
try {
//验签请参data
String data = request.getParameter("data");
//验签请参sign
String sign = request.getParameter("sign");
String type=request.getParameter("type");
//验签标记
boolean checkSign;
//验签请参publicKey
String publicKey = AdapayCore.PUBLIC_KEY;
log.info("验签请参data={}sign={}");
//验签
checkSign = AdapaySign.verifySign(data, sign, publicKey);
if(checkSign){
map.put("type",type);
map.put("data",data);
Map object=(Map)hfPayService.payNotifyCallBack(map);
if(ObjectUtil.isNotEmpty(object)&&object.containsKey("code")&&"success".equals(object.get("code"))){
return "SUCCESS";
}
//验签成功逻辑
}else {
return "FAIL";
//验签失败逻辑
}
}catch (Exception e){
log.info("异步回调开始参数request={}");
}
return "FAIL";
}
}

View File

@ -1,12 +1,12 @@
spring:
# datasource:
# druid:
# url: jdbc:mysql://101.37.12.135:3306/ysk_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
# username: ysk_test
# password: CZGmysqlroot@123
# driver-class-name: com.mysql.jdbc.Driver
datasource:
url: jdbc:mysql://rm-bp19ib8x213kh9t450o.rwlb.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: prodCZGmysqlroot@123
druid:
url: jdbc:mysql://101.37.12.135:3306/ysk_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: ysk_test
password: mysqlroot@123
driver-class-name: com.mysql.jdbc.Driver
# datasource:
# url: jdbc:mysql://rm-bp19ib8x213kh9t450o.rwlb.rds.aliyuncs.com:3306/chaozhanggui?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
# username: root
# password: prodCZGmysqlroot@123
# driver-class-name: com.mysql.jdbc.Driver

View File

@ -9,11 +9,11 @@ spring:
allow-bean-definition-overriding: true
profiles:
include: common, ryx, ys
active: prod
active: dev
datasource:
url: jdbc:mysql://60.205.224.68:3306/chaozhanggui?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: CZGmysqlroot@123
password: sqlroot@123
driver-class-name: com.mysql.jdbc.Driver
# mvc:
@ -39,3 +39,9 @@ jpush:
environment:
# 极光推送开发环境还是线上环境。暂未使用
develop: true
filepath: E:\\project\\chaozhanggui\\v1.0.3\\files\\
hf:
pay:
callBack: https://admintestapi.sxczgkj.cn/wap/notify/hfCallBack
environment: