团购卷支付回调

This commit is contained in:
wangw 2024-05-20 16:15:03 +08:00
parent 7cabb2a109
commit 6991cbaa00
2 changed files with 31 additions and 18 deletions

View File

@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.chaozhanggui.system.cashierservice.interceptor.RequestWrapper;
import com.chaozhanggui.system.cashierservice.service.PayService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@ -24,32 +27,30 @@ import java.util.Random;
public class NotifyController {
@Autowired
PayService payService;
@RequestMapping("memberInCallBack")
public String memberInCallBack(HttpServletRequest request){
public String memberInCallBack(HttpServletRequest request) {
Map<String, Object> map= getParameterMap(request);
log.info("回调返回信息:{}",JSONUtil.toJsonStr(map));
if(ObjectUtil.isNotEmpty(map)&&map.containsKey("code")&&"200".equals(map.get("code")+"")){
JSONObject object=JSONUtil.parseObj(map.get("data"));
if(ObjectUtil.isNotEmpty(object)&&object.containsKey("status")&&"1".equals(object.getStr("status"))){
String orderNo=object.getStr("orderNumber");
String channelTradeNo=object.getStr("channelTradeNo");
return payService.minsuccess(orderNo,channelTradeNo);
Map<String, Object> map = getParameterMap(request);
log.info("回调返回信息:{}", JSONUtil.toJsonStr(map));
if (ObjectUtil.isNotEmpty(map) && map.containsKey("code") && "200".equals(map.get("code") + "")) {
JSONObject object = JSONUtil.parseObj(map.get("data"));
if (ObjectUtil.isNotEmpty(object) && object.containsKey("status") && "1".equals(object.getStr("status"))) {
String orderNo = object.getStr("orderNumber");
String channelTradeNo = object.getStr("channelTradeNo");
return payService.minsuccess(orderNo, channelTradeNo);
}
}
return null;
}
@RequestMapping("fstmemberInCallBack")
public String fstmemberInCallBack(HttpServletRequest request){
Map<String, Object> map= getParameterMap(request);
log.info("fstmemberInCallBack回调返回信息:{}",JSONUtil.toJsonStr(map));
public String fstmemberInCallBack(HttpServletRequest request) {
Map<String, Object> map = getParameterMap(request);
log.info("fstmemberInCallBack回调返回信息:{}", JSONUtil.toJsonStr(map));
return null;
@ -72,8 +73,8 @@ public class NotifyController {
return null;
}
@RequestMapping("notifyCallBackGroup")
public String notifyCallBackGroup(HttpServletRequest request){
@RequestMapping("notifyCallBackGroupYsk")
public String notifyCallBackGroupYsk(HttpServletRequest request){
Map<String, Object> map= getParameterMap(request);
log.info("团购卷回调返回信息:{}",JSONUtil.toJsonStr(map));
if(ObjectUtil.isNotEmpty(map)&&map.containsKey("code")&&"200".equals(map.get("code")+"")){
@ -83,10 +84,22 @@ public class NotifyController {
return payService.callBackGroupPay(orderNo);
}
}
return null;
}
@RequestMapping("notifyCallBackGroup")
public String notifyCallBackGroup(HttpServletRequest request) {
Map<String, Object> map = getParameterMap(request);
log.info("团购卷回调返回信息:{}", JSONUtil.toJsonStr(map));
if (ObjectUtil.isNotEmpty(map) && map.containsKey("code") && "000000".equals(map.get("code") + "")) {
JSONObject object = JSONUtil.parseObj(map.get("bizData"));
if (ObjectUtil.isNotEmpty(object) && object.containsKey("state") && "TRADE_SUCCESS".equals(object.getStr("state"))) {
String orderNo = object.getStr("payOrderId");
return payService.callBackGroupPay(orderNo);
}
}
return null;
}
private Map<String, Object> getParameterMap(HttpServletRequest request) {

View File

@ -340,7 +340,7 @@ public class PayService {
req.setTimestamp(System.currentTimeMillis());
req.setIp(ip);
req.setMercOrderNo(orderInfo.getOrderNo());
req.setNotifyUrl(callBackGroupurl);
req.setNotifyUrl(callBackGroupurl+"Ysk");
req.setPayAmt(payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
if (payType.equals("wechatPay")) {
req.setPayType("03");