修改退款接口和多appId 支付

This commit is contained in:
韩鹏辉
2023-08-21 15:58:08 +08:00
parent f788f3fb23
commit f40f33263b
10 changed files with 73 additions and 22 deletions

Binary file not shown.

View File

@@ -47,6 +47,8 @@ public class MerchantOrder {
@TableId(type = IdType.AUTO)
private Long id;
private String appletsAppid;
private String orderNumber;
private String userImg;
private String nickName;

View File

@@ -3,7 +3,6 @@ package cn.pluss.platform.klk.service;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.device.MercOrderNewService;
import cn.pluss.platform.dto.MemberScanPayDTO;
import cn.pluss.platform.dto.MerChantOrderDTO;
import cn.pluss.platform.entity.*;
@@ -16,7 +15,6 @@ import cn.pluss.platform.merchantOrder.MerchantOrderService;
import cn.pluss.platform.pay.PayService;
import cn.pluss.platform.util.DateUtils;
import cn.pluss.platform.util.ParametersUtil;
import cn.pluss.platform.util.SnowFlakeUtil;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.ys.YsConfig;
import com.alibaba.fastjson.JSON;
@@ -27,11 +25,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.spring.web.json.Json;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
@@ -86,7 +81,7 @@ public class LkLPayServiceImpl implements PayService {
"\t\"req_data\": {\n" +
"\t\t\"acc_busi_fields\": {\n" +
"\t\t\t\"user_id\": \""+order.getMercUserId()+"\",\n" +
"\t\t\t\"sub_appid\": \""+ParametersUtil.APPLETS_APPID+"\"\n" +
"\t\t\t\"sub_appid\": \""+order.getAppletsAppid()+"\"\n" +
"\t\t},\n" +
"\t\t\"account_type\": \""+account_type+"\",\n" +
"\t\t\"location_info\": {\n" +
@@ -268,7 +263,15 @@ public class LkLPayServiceImpl implements PayService {
String req_time = DateUtils.getSdfTimes();
Long order_amt = changeY2F(order.getPayReturnAmount().doubleValue());
Long order_amt = 0L;
if(ObjectUtil.isNotEmpty(order.getPayReturnAmount())){
order_amt= changeY2F(order.getPayReturnAmount().doubleValue());
} else if(StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ){
order_amt= changeY2F(order.getRefundAmt().doubleValue());
} else {
order_amt= changeY2F(order.getConsumeFee().doubleValue());
}
String refundNo = "LKLR" + StringUtil.getBillno();

View File

@@ -1811,20 +1811,21 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
BigDecimal returnAmount=merchantRefundOrderMapper.selectOrderByOrderNumber(orderNumber);
if(N.egt(returnAmount,new BigDecimal(queryMerchantOrder.getConsumeFee()))){
BigDecimal trueAmount= new BigDecimal(queryMerchantOrder.getConsumeFee()).setScale(2,BigDecimal.ROUND_HALF_UP);
if(N.egt(returnAmount,trueAmount)){
MsgException.check(true, "订单已全额退款,请勿重复操作!");
}
if(N.gt(returnAmount.add(amount),new BigDecimal(queryMerchantOrder.getConsumeFee()))){
if(N.gt(returnAmount.add(amount),trueAmount)){
MsgException.check(true, "退款金额超限,请输入正确的退款金额!");
}
if(N.eq(returnAmount.add(amount),new BigDecimal(queryMerchantOrder.getConsumeFee()))){
if(N.eq(returnAmount.add(amount),trueAmount)){
queryMerchantOrder.setRefundType(2);
queryMerchantOrder.setRefundAmt(new BigDecimal(queryMerchantOrder.getConsumeFee()));
queryMerchantOrder.setRefundAmt(trueAmount);
}
if(N.gt(new BigDecimal(queryMerchantOrder.getConsumeFee()),returnAmount.add(amount))){
if(N.gt(trueAmount,returnAmount.add(amount))){
queryMerchantOrder.setRefundType(6);
queryMerchantOrder.setRefundAmt(returnAmount.add(amount));
}

View File

@@ -1,6 +1,7 @@
package cn.pluss.platform.pay.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSON;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultCode;
@@ -426,6 +427,7 @@ public class ApiPayServiceImpl implements ApiPayService {
return ResultGenerator.genSuccessJsonResult("下单成功", result);
}
if (channel.getChannel() == 1) {
JSONObject res = sxfPayService.tradePay(order, channel,merchant);
return assemblePayRresultParam(res, order);
@@ -565,6 +567,11 @@ public class ApiPayServiceImpl implements ApiPayService {
//获取商户费率
BigDecimal rate = merchantRateNewService.getMchRate(baseInfo.getMerchantCode(),merchantOrder.getPayTypeCode(), merchantOrder.getConsumeFee());
merchantOrder.calcRateAndFee(rate);
// if("WXZF".equals(jsonObject.getString("payWay"))){
// MsgException.checkNull(jsonObject.getString("appletsAppid"),"APPID 不允许为空");
// }
merchantOrder.setAppletsAppid((!jsonObject.containsKey("appletsAppid")||ObjectUtil.isEmpty(jsonObject.getString("appletsAppid")))?ParametersUtil.APPLETS_APPID:jsonObject.getString("appletsAppid"));
if("trans_wap_pay".equals(jsonObject.getString("method"))){
merchantOrderService.save(merchantOrder);
}
@@ -826,11 +833,13 @@ public class ApiPayServiceImpl implements ApiPayService {
*/
@Override
public Result<JSONObject> apiRefund(JSONObject params) {
checkRefundCommonParam(params);
Optional.ofNullable(params.getString("method")).orElseThrow(() -> new MsgException("请求接口名称method不能为空"));
String method = params.getString("method");
JSONObject result = new JSONObject();
switch (method){
case "syb.refund.pay":
checkRefundCommonParam(params);
MsgException.checkBlank(params.getString("mercOrderNo"),"原交易商户交易订单号不能为空!");
MsgException.checkBlank(params.getString("notifyUrl"),"异步通知地址不能为空!");
MsgException.checkBlank(params.getString("refundAmt"),"退款金额不能为空");
@@ -1016,7 +1025,10 @@ public class ApiPayServiceImpl implements ApiPayService {
}else if (channel.getChannel() == 4) {
JSONObject result = ysPayOldService.tradePay(order, channel,merchant);
return assemblePayRresultParam(result, order);
}else{
}else if(channel.getChannel()==5){
JSONObject result =lklPayService.tradePay(order,channel,merchant);
return assemblePayRresultParam(result, order);
}else {
MsgException.throwException("未知通道");
}
return null;

View File

@@ -167,7 +167,7 @@ public class MerchantRefundOrderServiceImpl extends ServiceImpl<MerchantRefundOr
@Override
public MerchantRefundOrder apiRefundQuery(JSONObject params) {
String mercRefundNo = params.getString("mercRefundNo");
QueryWrapper<MerchantRefundOrder> queryWrapper = new QueryWrapper<MerchantRefundOrder>().eq("mercRefundNo",mercRefundNo);
QueryWrapper<MerchantRefundOrder> queryWrapper = new QueryWrapper<MerchantRefundOrder>().eq("refundNo",mercRefundNo);
MerchantRefundOrder refundOrder = baseMapper.selectOne(queryWrapper);
MsgException.checkNull(refundOrder,"退款单号有误!");
if(!"1".equals(refundOrder.getStatus())){

View File

@@ -1,6 +1,7 @@
package cn.pluss.platform.ryx.pay.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.dto.MemberScanPayDTO;
@@ -292,7 +293,13 @@ public class RyxPayServiceimpl implements RyxPayService {
reqData.put("merchantCode",mchNo);
reqData.put("oriReqDate",DateUtils.formatDateDefault(order.getCreateDt(),"yyyyMMdd"));
reqData.put("oriReqMsgId",order.getOrderNumber());
reqData.put("refundAmount",StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ? order.getPayReturnAmount() : order.getConsumeFee());
if(ObjectUtil.isNotEmpty(order.getPayReturnAmount())){
reqData.put("refundAmount", order.getPayReturnAmount());
}else if(StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ){
reqData.put("refundAmount", order.getRefundAmt());
} else {
reqData.put("refundAmount", order.getConsumeFee());
}
reqData.put("refundReason",order.getRemark());
JSONObject respMap = ryxService.analysisCommonPayParams(RyxConfig.refundUrl,RyxConfig.barCodePayRefund,reqData);
log.info("==============>【瑞银信】交易订单退款接口,退款返回参数报文解析成功:{}<==================",respMap);

View File

@@ -1,5 +1,6 @@
package cn.pluss.platform.sxf.pay.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.channel.MerchantAuditService;
import cn.pluss.platform.config.ParameterConfig;
@@ -279,7 +280,15 @@ public class SxfPayServiceImpl implements SxfPayService {
reqRefundData.put("ordNo", refundNo);
reqRefundData.put("mno", mchNo);//随行付测试商户号
reqRefundData.put("origOrderNo", order.getOrderNumber());
reqRefundData.put("amt", StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ? order.getPayReturnAmount() : order.getConsumeFee());
if(ObjectUtil.isNotEmpty(order.getPayReturnAmount())){
reqRefundData.put("amt", order.getPayReturnAmount());
}else if(StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ){
reqRefundData.put("amt", order.getRefundAmt());
} else {
reqRefundData.put("amt", order.getConsumeFee());
}
reqRefundData.put("notifyUrl", ParametersUtil.domain + "/wap/notify/sxfCallBack");
if (StringUtil.isNotEmpty(order.getRemark())) {
reqRefundData.put("refundReason", order.getRemark());
@@ -501,7 +510,7 @@ public class SxfPayServiceImpl implements SxfPayService {
if (!(StringUtil.isNotEmpty(order.getScanType()) && "01".equals(order.getScanType()))) {
if (("9".equals(order.getOrderType()) || "3".equals(order.getOrderType()) || "10".equals(order.getOrderType())) &&
"WECHAT".equals(reqData.getString("payType"))) {
String defaultSupAppId = ParametersUtil.APPLETS_APPID;
String defaultSupAppId = order.getAppletsAppid();
if (StringUtil.isNotEmpty(merchant.getSubAppId())) {
defaultSupAppId = merchant.getSubAppId();
}

View File

@@ -1,6 +1,7 @@
package cn.pluss.platform.ys.pay;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.device.MercOrderNewService;
@@ -349,7 +350,13 @@ public class YsPayOldServiceImpl extends YsPayServiceImpl{
reqData.put("out_trade_no",order.getOrderNumber());
reqData.put("shopdate",DateUtils.formatDateDefault(new Date(),"yyyyMMdd"));
reqData.put("trade_no",order.getTransNo());
reqData.put("refund_amount",StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ? order.getRefundAmt() : order.getConsumeFee());
if(ObjectUtil.isNotEmpty(order.getPayReturnAmount())){
reqData.put("refundAmount", order.getPayReturnAmount());
}else if(StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ){
reqData.put("refundAmount", order.getRefundAmt());
} else {
reqData.put("refundAmount", order.getConsumeFee());
}
reqData.put("refund_reason",StringUtil.isEmpty(order.getRemark()) ? "申请退款" : order.getRemark());
reqData.put("out_request_no",refundNo);

View File

@@ -1,5 +1,6 @@
package cn.pluss.platform.ys.pay;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.channel.MakeMoneyService;
import cn.pluss.platform.constants.Constant;
@@ -206,13 +207,22 @@ public class YsPayServiceImpl implements PayService {
Map<String,Object> result = new HashMap<>(4);
JSONObject reqData = new JSONObject();
Double amt = order.getPayReturnAmount().setScale(2).doubleValue();
BigDecimal amt =BigDecimal.ZERO;
if(ObjectUtil.isNotEmpty(order.getPayReturnAmount())){
amt= order.getPayReturnAmount();
} else if(StringUtil.isNotEmpty(order.getRefundType()) && order.getRefundType() == 2 ){
amt=order.getRefundAmt();
}else {
amt= new BigDecimal(order.getConsumeFee());
}
String refundNo = "YSR"+StringUtil.getBillno();
reqData.put("merchantNo",mchNo);
reqData.put("origMerchantOrderNo",order.getOrderNumber());
reqData.put("origAmount",amt);
reqData.put("origAmount",amt.setScale(2,BigDecimal.ROUND_DOWN));
reqData.put("refundOrderNo",refundNo);
reqData.put("refundAmount",amt);
reqData.put("refundAmount",amt.setScale(2,BigDecimal.ROUND_DOWN));
JSONObject respones = ysService.requestApi(ysConfig.REFUND_PAY, reqData, YsService.TYPE_PAY);