mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-02 20:02:37 +08:00
🆕 #2692【企业微信】增加家校应用-班级收款接口支持
This commit is contained in:
parent
a9fe0b29d4
commit
1f3f133772
@ -4,7 +4,7 @@ import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.HttpRequest;
|
||||
import jodd.http.HttpResponse;
|
||||
import jodd.http.ProxyInfo;
|
||||
import jodd.http.up.ByteArrayUploadable;
|
||||
import jodd.http.upload.ByteArrayUploadable;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
|
@ -2,7 +2,9 @@ package me.chanjar.weixin.cp.api;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpPaymentResult;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpResultList;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpTrade;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
@ -57,4 +59,27 @@ public interface WxCpSchoolService {
|
||||
*/
|
||||
WxCpResultList getHealthQrCode(@NotNull List<String> userIds, @NotNull Integer type) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取学生付款结果
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/get_payment_result?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param paymentId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpPaymentResult getPaymentResult(@NotNull String paymentId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/get_trade?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param paymentId
|
||||
* @param tradeNo
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpTrade getTrade(@NotNull String paymentId, @NotNull String tradeNo) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.WxCpSchoolService;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpPaymentResult;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpResultList;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpTrade;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
@ -64,4 +66,23 @@ public class WxCpSchoolServiceImpl implements WxCpSchoolService {
|
||||
return WxCpResultList.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpPaymentResult getPaymentResult(@NotNull String paymentId) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_PAYMENT_RESULT);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("payment_id", paymentId);
|
||||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
|
||||
return WxCpPaymentResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTrade getTrade(@NotNull String paymentId, @NotNull String tradeNo) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_TRADE);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("payment_id", paymentId);
|
||||
jsonObject.addProperty("trade_no", tradeNo);
|
||||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
|
||||
return WxCpTrade.fromJson(responseContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
package me.chanjar.weixin.cp.bean.school;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取学生付款结果.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
*/
|
||||
@Data
|
||||
public class WxCpPaymentResult extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625142879581L;
|
||||
|
||||
@SerializedName("project_name")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName("amount")
|
||||
private Integer amount;
|
||||
|
||||
@SerializedName("payment_result")
|
||||
private List<PaymentResult> paymentResult;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class PaymentResult{
|
||||
|
||||
@SerializedName("student_userid")
|
||||
private String studentUserId;
|
||||
|
||||
@SerializedName("trade_no")
|
||||
private String tradeNo;
|
||||
|
||||
@SerializedName("payer_parent_userid")
|
||||
private String payerParentUserId;
|
||||
|
||||
@SerializedName("trade_state")
|
||||
private Integer tradeState;
|
||||
|
||||
public static PaymentResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, PaymentResult.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpPaymentResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpPaymentResult.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.cp.bean.school;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 获取订单详情.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
*/
|
||||
@Data
|
||||
public class WxCpTrade extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625142879581L;
|
||||
|
||||
/**
|
||||
* 微信交易单号
|
||||
*/
|
||||
@SerializedName("transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* 交易时间
|
||||
*/
|
||||
@SerializedName("pay_time")
|
||||
private Long payTime;
|
||||
|
||||
public static WxCpTrade fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTrade.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -182,6 +182,9 @@ public interface WxCpApiPathConsts {
|
||||
String GET_TEACHER_CUSTOMIZE_HEALTH_INFO = "/cgi-bin/school/user/get_teacher_customize_health_info";
|
||||
String GET_STUDENT_CUSTOMIZE_HEALTH_INFO = "/cgi-bin/school/user/get_student_customize_health_info";
|
||||
String GET_HEALTH_QRCODE = "/cgi-bin/school/user/get_health_qrcode";
|
||||
|
||||
String GET_PAYMENT_RESULT = "/cgi-bin/school/get_payment_result";
|
||||
String GET_TRADE = "/cgi-bin/school/get_trade";
|
||||
}
|
||||
|
||||
interface Living {
|
||||
|
@ -5,7 +5,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpPaymentResult;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpResultList;
|
||||
import me.chanjar.weixin.cp.bean.school.WxCpTrade;
|
||||
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
|
||||
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
|
||||
import org.testng.annotations.Test;
|
||||
@ -44,6 +46,34 @@ public class WxCpSchoolTest {
|
||||
String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
|
||||
|
||||
/**
|
||||
* 获取学生付款结果
|
||||
* https://developer.work.weixin.qq.com/document/path/94553
|
||||
*/
|
||||
String paymentResultStr = "{\"errcode\":0,\"errmsg\":\"ok\",\"project_name\":\"学费\",\"amount\":998,\"payment_result\":[{\"student_userid\":\"xxxx\",\"trade_state\":1,\"trade_no\":\"xxxxx\",\"payer_parent_userid\":\"zhangshan\"}]}";
|
||||
WxCpPaymentResult cpPaymentResult = WxCpPaymentResult.fromJson(paymentResultStr);
|
||||
log.info("cpPaymentResult:{}", cpPaymentResult.toJson());
|
||||
|
||||
WxCpPaymentResult paymentResult = cpService.getSchoolService().getPaymentResult("");
|
||||
log.info("paymentResult:{}", paymentResult.toJson());
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* https://developer.work.weixin.qq.com/document/path/94554
|
||||
*/
|
||||
String tradeStr = "{\n" +
|
||||
"\t\"errcode\":0,\n" +
|
||||
"\t\"errmsg\":\"ok\",\n" +
|
||||
"\t\"transaction_id\":\"xxxxx\", \t \n" +
|
||||
"\t\"pay_time\":12345\n" +
|
||||
"}";
|
||||
WxCpTrade wxCpTrade = WxCpTrade.fromJson(tradeStr);
|
||||
log.info("wxCpTrade:{}", wxCpTrade.toJson());
|
||||
|
||||
WxCpTrade trade = cpService.getSchoolService().getTrade("", "");
|
||||
log.info("trade:{}", trade.toJson());
|
||||
|
||||
|
||||
/**
|
||||
* 获取老师健康信息
|
||||
* https://developer.work.weixin.qq.com/document/path/93744
|
||||
|
Loading…
Reference in New Issue
Block a user