This commit is contained in:
parent
7e79d3fc35
commit
5bcf7b788a
|
|
@ -10,10 +10,7 @@ import com.sqx.modules.orders.entity.Orders;
|
|||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.wuyou.BaseResp;
|
||||
import com.sqx.modules.pay.wuyou.Encrypt;
|
||||
import com.sqx.modules.pay.wuyou.NotifyDto;
|
||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||
import com.sqx.modules.pay.wuyou.*;
|
||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -21,7 +18,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.PathParam;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
|
@ -87,9 +83,28 @@ public class WuyouController {
|
|||
return Result.success().put("data", baseResp.getData());
|
||||
}
|
||||
|
||||
@PostMapping("/extractNotify")
|
||||
public String extractNotify(HttpServletRequest request, @RequestBody NotifyDto notifyDto) {
|
||||
log.info("无忧支付提现回调, {}", notifyDto);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("callbacks", notifyDto.getCallbacks());
|
||||
params.put("total", notifyDto.getTotal());
|
||||
params.put("out_trade_no", notifyDto.getOutTradeNo());
|
||||
params.put("status", notifyDto.getStatus());
|
||||
params.put("msg", notifyDto.getMsg());
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
if (!sign.equals(notifyDto.getSign())) {
|
||||
log.error("无忧支付提现回调签名错误, 参数: {},签名结果:{}", JSONObject.toJSONString(notifyDto), sign);
|
||||
return "签名错误";
|
||||
}
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
@PostMapping("/notify")
|
||||
public String notify(HttpServletRequest request, @RequestBody NotifyDto notifyDto) {
|
||||
log.info("无忧支付回调");
|
||||
log.info("无忧支付回调, {}", notifyDto);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("callbacks", notifyDto.getCallbacks());
|
||||
params.put("total", notifyDto.getTotal());
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ import lombok.Data;
|
|||
@Data
|
||||
public class BaseResp {
|
||||
private Integer code;
|
||||
// 提现:(交易状态 0:未处理 1:处理中 2:已打款 3:已退款),
|
||||
private Integer status;
|
||||
private String msg;
|
||||
private OrderResp data;
|
||||
|
||||
// 只有 SUCCESS 是成功的
|
||||
// 支付 只有 SUCCESS 是成功的
|
||||
@JSONField(name = "pay_status")
|
||||
private String payStatus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ public class Constants {
|
|||
final static String PAY_URL = BASE_URL + "/api/order";
|
||||
final static String QUERY_URL = BASE_URL + "/api/queryOrder";
|
||||
|
||||
final static String EXTRACT_URL = BASE_URL + "/api/salary";
|
||||
final static String EXTRACT_QUERY_URL = BASE_URL + "/api/querySalary";
|
||||
|
||||
final static String NOTIFY_URL = "https://video.hnsiyao.cn/sqx_fast/app/wuyou/notify";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,9 @@ public class NotifyDto {
|
|||
@JSONField(name = "pay_time")
|
||||
private String payTime;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String status;
|
||||
|
||||
private String sign;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,12 @@ public class OrderResp {
|
|||
|
||||
@JSONField(name = "h5_url")
|
||||
private String h5Url;
|
||||
|
||||
// CODE_SUCCESS 为成功
|
||||
private String callbacks;
|
||||
|
||||
private String msg;
|
||||
|
||||
@JSONField(name = "error_msg")
|
||||
private String errorMsg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ public class WuyouPay {
|
|||
|
||||
public static BaseResp payOrder(String orderNo, String amount, String userAgent) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
params.put("type", "6001");
|
||||
params.put("is_code", "1");
|
||||
params.put("out_trade_no", orderNo);
|
||||
params.put("total", amount);
|
||||
params.put("notify_url", Constants.NOTIFY_URL);
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
params.put("sign", sign);
|
||||
|
|
@ -27,7 +30,7 @@ public class WuyouPay {
|
|||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
private static BaseResp queryOrder(String orderNo, String amount, String userAgent) {
|
||||
public static BaseResp queryOrder(String orderNo, String amount, String userAgent) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
params.put("out_trade_no", orderNo);
|
||||
params.put("total", amount);
|
||||
|
|
@ -39,13 +42,46 @@ public class WuyouPay {
|
|||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
public static BaseResp extractOrder(String outOrderNo, String amount, String account, String userName) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
|
||||
params.put("out_trade_no", outOrderNo);
|
||||
params.put("total", amount);
|
||||
params.put("bank_card", account);
|
||||
params.put("bank_account_name", userName);
|
||||
params.put("bank_name", "1");
|
||||
params.put("bank_branch", "1");
|
||||
params.put("province", "1");
|
||||
params.put("city", "1");
|
||||
params.put("notify_url", "1");
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
params.put("sign", sign);
|
||||
|
||||
params.put("business_type", 0);
|
||||
params.put("business_attr", "alipay");
|
||||
|
||||
String body = request(Constants.EXTRACT_URL, params, "");
|
||||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
public static BaseResp queryExtractOrder(String outOrderNo, String amount) {
|
||||
Map<String, Object> params = getBaseParams();
|
||||
params.put("out_trade_no", outOrderNo);
|
||||
params.put("total", amount);
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
params.put("sign", sign);
|
||||
|
||||
String body = request(Constants.EXTRACT_QUERY_URL, params, "");
|
||||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
private static Map<String, Object> getBaseParams() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("mch_id", Constants.MERCHANT_ID);
|
||||
params.put("timestamp", System.currentTimeMillis() / 1000);
|
||||
params.put("type", "6001");
|
||||
params.put("notify_url", Constants.NOTIFY_URL);
|
||||
params.put("is_code", "1");
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +100,9 @@ public class WuyouPay {
|
|||
|
||||
public static void main(String[] args) {
|
||||
// payOrder("20221118123456791", "0.1", "Mozilla/5.0");
|
||||
queryOrder("20221118123456791", "0.1", "Mozilla/5.0");
|
||||
// queryOrder("20221118123456791", "0.1", "Mozilla/5.0");
|
||||
|
||||
// extractOrder("20221118123456793", "1", "1157756119@qq.com", "巩奕杰");
|
||||
queryExtractOrder("20221118123456793", "1");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue