|
@@ -1,12 +1,9 @@
|
|
package com.qs.mp.pay.service.impl;
|
|
package com.qs.mp.pay.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
import com.qs.mp.channel.service.IChannelOrderService;
|
|
import com.qs.mp.channel.service.IChannelOrderService;
|
|
import com.qs.mp.common.enums.BizTypeEnum;
|
|
import com.qs.mp.common.enums.BizTypeEnum;
|
|
import com.qs.mp.common.enums.MqTopicType;
|
|
import com.qs.mp.common.enums.MqTopicType;
|
|
-import com.qs.mp.common.enums.PayOrderStatusEnum;
|
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
import com.qs.mp.common.pulsar.PulsarClientService;
|
|
import com.qs.mp.common.pulsar.PulsarClientService;
|
|
import com.qs.mp.common.utils.DateUtils;
|
|
import com.qs.mp.common.utils.DateUtils;
|
|
@@ -19,15 +16,12 @@ import com.qs.mp.pay.service.IWalletService;
|
|
import com.qs.mp.system.service.id.BizIdGenerator;
|
|
import com.qs.mp.system.service.id.BizIdGenerator;
|
|
import com.qs.mp.user.service.IUserDeliverOrderService;
|
|
import com.qs.mp.user.service.IUserDeliverOrderService;
|
|
import com.qs.mp.user.service.IUserTicketOrderService;
|
|
import com.qs.mp.user.service.IUserTicketOrderService;
|
|
-import java.util.List;
|
|
|
|
import org.apache.pulsar.client.api.PulsarClientException;
|
|
import org.apache.pulsar.client.api.PulsarClientException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @auther duota
|
|
* @auther duota
|
|
@@ -83,7 +77,8 @@ public class WalletServiceImpl implements IWalletService {
|
|
private static final String PAY_RESOURCE_TYPE = "1017"; //2:微信小程序
|
|
private static final String PAY_RESOURCE_TYPE = "1017"; //2:微信小程序
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public JSONObject pay(BizTypeEnum bizType, String bizId, String openId, int money) {
|
|
|
|
|
|
+ public JSONObject pay(BizTypeEnum bizType, String bizId, String openId, int money,
|
|
|
|
+ String orderRemark) {
|
|
String reqUrl = baseUrl + "/pay/payMoneyCTB";
|
|
String reqUrl = baseUrl + "/pay/payMoneyCTB";
|
|
String appId = channelAppId;
|
|
String appId = channelAppId;
|
|
String payShopNo = channelPayShopNo;
|
|
String payShopNo = channelPayShopNo;
|
|
@@ -93,7 +88,7 @@ public class WalletServiceImpl implements IWalletService {
|
|
payShopNo = userPayShopNo;
|
|
payShopNo = userPayShopNo;
|
|
paySign = userPaySign;
|
|
paySign = userPaySign;
|
|
}
|
|
}
|
|
- JSONObject params = buildPayOrderReqData(payShopNo, paySign, money, openId, appId);
|
|
|
|
|
|
+ JSONObject params = buildPayOrderReqData(payShopNo, paySign, money, openId, appId, orderRemark);
|
|
String result = OkHttpUtil.postJsonParams(reqUrl, params.toJSONString());
|
|
String result = OkHttpUtil.postJsonParams(reqUrl, params.toJSONString());
|
|
logger.info("request params:" + params.toJSONString() + " result:" + result);
|
|
logger.info("request params:" + params.toJSONString() + " result:" + result);
|
|
if (StringUtils.isBlank(result)) {
|
|
if (StringUtils.isBlank(result)) {
|
|
@@ -127,7 +122,7 @@ public class WalletServiceImpl implements IWalletService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean refund(String orderNo, Integer refundAmount) {
|
|
|
|
|
|
+ public boolean refundByUser(String orderNo, Integer refundAmount, String remark) {
|
|
|
|
|
|
String reqUrl = baseUrl + "/pay/refundOrder";
|
|
String reqUrl = baseUrl + "/pay/refundOrder";
|
|
|
|
|
|
@@ -136,13 +131,41 @@ public class WalletServiceImpl implements IWalletService {
|
|
sendData.put("timestamp",System.currentTimeMillis());
|
|
sendData.put("timestamp",System.currentTimeMillis());
|
|
sendData.put("order_no",orderNo);
|
|
sendData.put("order_no",orderNo);
|
|
sendData.put("refund_amount", refundAmount);
|
|
sendData.put("refund_amount", refundAmount);
|
|
- sendData.put("order_remark", "测试退款");
|
|
|
|
|
|
+ sendData.put("order_remark", remark);
|
|
sendData.put("type","sno");
|
|
sendData.put("type","sno");
|
|
sendData.put("sign",userPaySign);
|
|
sendData.put("sign",userPaySign);
|
|
- System.err.println(sendData.toJSONString());
|
|
|
|
String result = OkHttpUtil.postJsonParams(reqUrl, sendData.toJSONString());
|
|
String result = OkHttpUtil.postJsonParams(reqUrl, sendData.toJSONString());
|
|
- System.err.println(result);
|
|
|
|
- return true;
|
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
|
+ logger.info("用户订单退款 -> request params:" + sendData.toJSONString() + " result:" + result);
|
|
|
|
+ if ("R0001".equals(code)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ throw new ServiceException(jsonObject.getString("result"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean refundByChannel(String orderNo, Integer refundAmount, String remark) {
|
|
|
|
+
|
|
|
|
+ String reqUrl = baseUrl + "/pay/refundOrder";
|
|
|
|
+
|
|
|
|
+ JSONObject sendData = new JSONObject();
|
|
|
|
+ sendData.put("shop_no", channelPayShopNo);
|
|
|
|
+ sendData.put("timestamp",System.currentTimeMillis());
|
|
|
|
+ sendData.put("order_no",orderNo);
|
|
|
|
+ sendData.put("refund_amount", refundAmount);
|
|
|
|
+ sendData.put("order_remark", remark);
|
|
|
|
+ sendData.put("type","sno");
|
|
|
|
+ sendData.put("sign",channelPaySign);
|
|
|
|
+ String result = OkHttpUtil.postJsonParams(reqUrl, sendData.toJSONString());
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
|
+ logger.info("经销商订单退款 -> request params:" + sendData.toJSONString() + " result:" + result);
|
|
|
|
+ if ("R0001".equals(code)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ throw new ServiceException(jsonObject.getString("result"));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -199,7 +222,7 @@ public class WalletServiceImpl implements IWalletService {
|
|
return payOrder;
|
|
return payOrder;
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject buildPayOrderReqData(String shopNo, String sign, int money, String openId, String appId) {
|
|
|
|
|
|
+ private JSONObject buildPayOrderReqData(String shopNo, String sign, int money, String openId, String appId, String orderRemark) {
|
|
|
|
|
|
JSONObject sendData = new JSONObject();
|
|
JSONObject sendData = new JSONObject();
|
|
sendData.put("shop_no" , shopNo);
|
|
sendData.put("shop_no" , shopNo);
|
|
@@ -208,7 +231,7 @@ public class WalletServiceImpl implements IWalletService {
|
|
sendData.put("pay_resource" , PAY_RESOURCE); //支付来源 1:支付宝 2:微信支付 5:云闪付
|
|
sendData.put("pay_resource" , PAY_RESOURCE); //支付来源 1:支付宝 2:微信支付 5:云闪付
|
|
sendData.put("trans_type_code" , PAY_RESOURCE_TYPE); //1017:微信小程序
|
|
sendData.put("trans_type_code" , PAY_RESOURCE_TYPE); //1017:微信小程序
|
|
sendData.put("transaction_amount" , money);
|
|
sendData.put("transaction_amount" , money);
|
|
- sendData.put("order_remark" , "");
|
|
|
|
|
|
+ sendData.put("order_remark" , orderRemark);
|
|
sendData.put("timestamp" , System.currentTimeMillis());
|
|
sendData.put("timestamp" , System.currentTimeMillis());
|
|
sendData.put("callback_url" , callbackUrl);
|
|
sendData.put("callback_url" , callbackUrl);
|
|
|
|
|