mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-05 13:17:46 +08:00
Merge remote-tracking branch 'wechat/develop' into develop
This commit is contained in:
commit
3fbeec4018
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WxJava - Weixin/Wechat Java SDK</name>
|
||||
<description>微信开发Java SDK</description>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -133,6 +133,7 @@ public class WxOpenStorageAutoConfiguration {
|
||||
Config config = new Config();
|
||||
config.useSingleServer()
|
||||
.setAddress("redis://" + redis.getHost() + ":" + redis.getPort())
|
||||
.setDatabase(redis.getDatabase())
|
||||
.setPassword(redis.getPassword());
|
||||
config.setTransportMode(TransportMode.NIO);
|
||||
return Redisson.create(config);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wx-java-spring-boot-starters</artifactId>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-graal</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-common</artifactId>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-cp</artifactId>
|
||||
|
@ -4,6 +4,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
|
||||
|
||||
/**
|
||||
* 消息推送接口.
|
||||
@ -24,6 +25,21 @@ public interface WxCpMessageService {
|
||||
*/
|
||||
WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 查询应用消息发送统计
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/message/get_statistics?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* 详情请见: https://work.weixin.qq.com/api/doc/90000/90135/92369
|
||||
* </pre>
|
||||
*
|
||||
* @param timeType 查询哪天的数据,0:当天;1:昨天。默认为0。
|
||||
* @return 统计结果
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 互联企业的应用支持推送文本、图片、视频、文件、图文等类型。
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.chanjar.weixin.cp.api.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.WxCpMessageService;
|
||||
@ -7,7 +8,9 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
|
||||
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 消息推送接口实现类.
|
||||
@ -27,7 +30,13 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {
|
||||
}
|
||||
|
||||
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
|
||||
.getApiUrl(WxCpApiPathConsts.Message.MESSAGE_SEND), message.toJson()));
|
||||
.getApiUrl(Message.MESSAGE_SEND), message.toJson()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException {
|
||||
return WxCpMessageSendStatistics.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(Message.GET_STATISTICS),
|
||||
WxCpGsonBuilder.create().toJson(ImmutableMap.of("time_type", timeType))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,6 +47,6 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {
|
||||
}
|
||||
|
||||
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
|
||||
.getApiUrl(WxCpApiPathConsts.Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
|
||||
.getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package me.chanjar.weixin.cp.bean.message;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用消息发送统计信息.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-09-13
|
||||
*/
|
||||
@Data
|
||||
public class WxCpMessageSendStatistics {
|
||||
public static WxCpMessageSendStatistics fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpMessageSendStatistics.class);
|
||||
}
|
||||
|
||||
private List<StatisticItem> statistics;
|
||||
|
||||
@Data
|
||||
public static class StatisticItem {
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
@SerializedName("app_name")
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
@SerializedName("agentid")
|
||||
private Integer agentId;
|
||||
|
||||
/**
|
||||
* 发消息成功人次
|
||||
*/
|
||||
@SerializedName("count")
|
||||
private Integer count;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package me.chanjar.weixin.cp.constant;
|
||||
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业微信api地址常量类
|
||||
@ -9,6 +11,7 @@ package me.chanjar.weixin.cp.constant;
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@UtilityClass
|
||||
public final class WxCpApiPathConsts {
|
||||
public static final String DEFAULT_CP_BASE_URL = "https://qyapi.weixin.qq.com";
|
||||
|
||||
@ -26,30 +29,39 @@ public final class WxCpApiPathConsts {
|
||||
* 消息推送相关接口
|
||||
* https://work.weixin.qq.com/api/doc/90000/90135/90235
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class Message {
|
||||
/**
|
||||
* 发送应用消息
|
||||
*/
|
||||
public static final String MESSAGE_SEND = "/cgi-bin/message/send";
|
||||
|
||||
/**
|
||||
* 查询应用消息发送统计
|
||||
*/
|
||||
public static final String GET_STATISTICS = "/cgi-bin/message/get_statistics";
|
||||
|
||||
/**
|
||||
* 互联企业发送应用消息
|
||||
*/
|
||||
public static final String LINKEDCORP_MESSAGE_SEND = "/cgi-bin/linkedcorp/message/send";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Agent {
|
||||
public static final String AGENT_GET = "/cgi-bin/agent/get?agentid=%d";
|
||||
public static final String AGENT_SET = "/cgi-bin/agent/set";
|
||||
public static final String AGENT_LIST = "/cgi-bin/agent/list";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class OAuth2 {
|
||||
public static final String GET_USER_INFO = "/cgi-bin/user/getuserinfo?code=%s&agentid=%d";
|
||||
public static final String GET_USER_DETAIL = "/cgi-bin/user/getuserdetail";
|
||||
public static final String URL_OAUTH2_AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Chat {
|
||||
public static final String APPCHAT_CREATE = "/cgi-bin/appchat/create";
|
||||
public static final String APPCHAT_UPDATE = "/cgi-bin/appchat/update";
|
||||
@ -57,6 +69,7 @@ public final class WxCpApiPathConsts {
|
||||
public static final String APPCHAT_SEND = "/cgi-bin/appchat/send";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Department {
|
||||
public static final String DEPARTMENT_CREATE = "/cgi-bin/department/create";
|
||||
public static final String DEPARTMENT_UPDATE = "/cgi-bin/department/update";
|
||||
@ -64,6 +77,7 @@ public final class WxCpApiPathConsts {
|
||||
public static final String DEPARTMENT_LIST = "/cgi-bin/department/list";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Media {
|
||||
public static final String MEDIA_GET = "/cgi-bin/media/get";
|
||||
public static final String MEDIA_UPLOAD = "/cgi-bin/media/upload?type=";
|
||||
@ -71,12 +85,14 @@ public final class WxCpApiPathConsts {
|
||||
public static final String JSSDK_MEDIA_GET = "/cgi-bin/media/get/jssdk";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Menu {
|
||||
public static final String MENU_CREATE = "/cgi-bin/menu/create?agentid=%d";
|
||||
public static final String MENU_DELETE = "/cgi-bin/menu/delete?agentid=%d";
|
||||
public static final String MENU_GET = "/cgi-bin/menu/get?agentid=%d";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Oa {
|
||||
public static final String GET_CHECKIN_DATA = "/cgi-bin/checkin/getcheckindata";
|
||||
public static final String GET_CHECKIN_OPTION = "/cgi-bin/checkin/getcheckinoption";
|
||||
@ -87,6 +103,7 @@ public final class WxCpApiPathConsts {
|
||||
public static final String APPLY_EVENT = "/cgi-bin/oa/applyevent";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Tag {
|
||||
public static final String TAG_CREATE = "/cgi-bin/tag/create";
|
||||
public static final String TAG_UPDATE = "/cgi-bin/tag/update";
|
||||
@ -97,10 +114,12 @@ public final class WxCpApiPathConsts {
|
||||
public static final String TAG_DEL_TAG_USERS = "/cgi-bin/tag/deltagusers";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class TaskCard {
|
||||
public static final String UPDATE_TASK_CARD = "/cgi-bin/message/update_taskcard";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class Tp {
|
||||
public static final String JSCODE_TO_SESSION = "/cgi-bin/service/miniprogram/jscode2session";
|
||||
public static final String GET_CORP_TOKEN = "/cgi-bin/service/get_corp_token";
|
||||
@ -111,6 +130,7 @@ public final class WxCpApiPathConsts {
|
||||
public static final String GET_AUTH_INFO = "/cgi-bin/service/get_auth_info";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class User {
|
||||
public static final String USER_AUTHENTICATE = "/cgi-bin/user/authsucc?userid=";
|
||||
public static final String USER_CREATE = "/cgi-bin/user/create";
|
||||
@ -127,6 +147,7 @@ public final class WxCpApiPathConsts {
|
||||
public static final String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class ExternalContact {
|
||||
@Deprecated
|
||||
public static final String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
|
||||
|
@ -1,5 +1,7 @@
|
||||
package me.chanjar.weixin.cp.constant;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业微信常量
|
||||
@ -8,11 +10,13 @@ package me.chanjar.weixin.cp.constant;
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@UtilityClass
|
||||
public class WxCpConsts {
|
||||
/**
|
||||
* 企业微信端推送过来的事件类型.
|
||||
* 参考文档:https://work.weixin.qq.com/api/doc#12974
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class EventType {
|
||||
/**
|
||||
* 成员关注事件.
|
||||
@ -105,6 +109,7 @@ public class WxCpConsts {
|
||||
/**
|
||||
* 企业外部联系人变更事件的CHANGE_TYPE
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class ExternalContactChangeType {
|
||||
/**
|
||||
* 新增外部联系人
|
||||
@ -128,6 +133,7 @@ public class WxCpConsts {
|
||||
/**
|
||||
* 企业微信通讯录变更事件.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class ContactChangeType {
|
||||
/**
|
||||
* 新增成员事件.
|
||||
@ -169,6 +175,7 @@ public class WxCpConsts {
|
||||
/**
|
||||
* 互联企业发送应用消息的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class LinkedCorpMsgType {
|
||||
/**
|
||||
* 文本消息.
|
||||
@ -213,6 +220,7 @@ public class WxCpConsts {
|
||||
/**
|
||||
* 群机器人的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class GroupRobotMsgType {
|
||||
/**
|
||||
* 文本消息.
|
||||
@ -238,6 +246,7 @@ public class WxCpConsts {
|
||||
/**
|
||||
* 应用推送消息的消息类型.
|
||||
*/
|
||||
@UtilityClass
|
||||
public static class AppChatMsgType {
|
||||
/**
|
||||
* 文本消息.
|
||||
|
@ -12,6 +12,7 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Guice;
|
||||
@ -20,6 +21,7 @@ import org.testng.annotations.Test;
|
||||
import static com.github.dreamhead.moco.Moco.file;
|
||||
import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer;
|
||||
import static me.chanjar.weixin.cp.api.ApiTestModuleWithMockServer.mockServerPort;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
@ -29,8 +31,8 @@ import static org.testng.Assert.assertNotNull;
|
||||
* @date 2020-08-30
|
||||
*/
|
||||
@Test
|
||||
@Guice(modules = ApiTestModuleWithMockServer.class)
|
||||
//@Guice(modules = ApiTestModule.class)
|
||||
//@Guice(modules = ApiTestModuleWithMockServer.class)
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxCpMessageServiceImplTest {
|
||||
@Inject
|
||||
protected WxCpService wxService;
|
||||
@ -154,11 +156,24 @@ public class WxCpMessageServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkedCorpMessageSend() throws WxErrorException {
|
||||
public void testSendLinkedCorpMessage() throws WxErrorException {
|
||||
this.wxService.getMessageService().sendLinkedCorpMessage(WxCpLinkedCorpMessage.builder()
|
||||
.msgType(WxConsts.KefuMsgType.TEXT)
|
||||
.toUsers(new String[]{configStorage.getUserId()})
|
||||
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSend() {
|
||||
// see other test methods
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStatistics() throws WxErrorException {
|
||||
final WxCpMessageSendStatistics statistics = this.wxService.getMessageService().getStatistics(1);
|
||||
assertNotNull(statistics);
|
||||
assertThat(statistics.getStatistics()).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-miniapp</artifactId>
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveGoodInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
import java.util.List;
|
||||
@ -37,7 +37,7 @@ public interface WxMaLiveGoodsService {
|
||||
* @return 返回auditId、goodsId
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxMaLiveResult addGoods(WxMaLiveInfo.Goods goods) throws WxErrorException;
|
||||
WxMaLiveResult addGoods(WxMaLiveGoodInfo goods) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 撤回审核
|
||||
@ -91,7 +91,7 @@ public interface WxMaLiveGoodsService {
|
||||
* @return 更新商品是否成功
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
boolean updateGoods(WxMaLiveInfo.Goods goods) throws WxErrorException;
|
||||
boolean updateGoods(WxMaLiveGoodInfo goods) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取商品状态
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
import java.util.List;
|
||||
@ -31,7 +31,7 @@ public interface WxMaLiveService {
|
||||
* @return .
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
Integer createRoom(WxMaLiveInfo.RoomInfo roomInfo) throws WxErrorException;
|
||||
Integer createRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取直播房间列表.(分页)
|
||||
|
@ -2,16 +2,14 @@ package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaLiveGoodsService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveGoodInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
@ -32,15 +30,9 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMaLiveResult addGoods(WxMaLiveInfo.Goods goods) throws WxErrorException {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("goodsInfo", goods);
|
||||
String responseContent = this.wxMaService.post(ADD_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaLiveResult.fromJson(jsonObject.toString());
|
||||
public WxMaLiveResult addGoods(WxMaLiveGoodInfo goods) throws WxErrorException {
|
||||
return WxMaLiveResult.fromJson(this.wxMaService.post(ADD_GOODS,
|
||||
WxMaGsonBuilder.create().toJson(ImmutableMap.of("goodsInfo", goods))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,11 +40,7 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
|
||||
Map<String, Integer> map = new HashMap<>(4);
|
||||
map.put("auditId", auditId);
|
||||
map.put("goodsId", goodsId);
|
||||
String responseContent = this.wxMaService.post(RESET_AUDIT_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
this.wxMaService.post(RESET_AUDIT_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -62,9 +50,6 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
|
||||
map.put("goodsId", goodsId);
|
||||
String responseContent = this.wxMaService.post(AUDIT_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return jsonObject.get("auditId").getAsString();
|
||||
}
|
||||
|
||||
@ -72,23 +57,15 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
|
||||
public boolean deleteGoods(Integer goodsId) throws WxErrorException {
|
||||
Map<String, Integer> map = new HashMap<>(2);
|
||||
map.put("goodsId", goodsId);
|
||||
String responseContent = this.wxMaService.post(DELETE_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
this.wxMaService.post(DELETE_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateGoods(WxMaLiveInfo.Goods goods) throws WxErrorException {
|
||||
public boolean updateGoods(WxMaLiveGoodInfo goods) throws WxErrorException {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("goodsInfo", goods);
|
||||
String responseContent = this.wxMaService.post(UPDATE_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
this.wxMaService.post(UPDATE_GOODS, WxMaGsonBuilder.create().toJson(map));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -97,11 +74,7 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("goods_ids", goodsIds);
|
||||
String responseContent = this.wxMaService.post(GET_GOODS_WARE_HOUSE, WxMaGsonBuilder.create().toJson(map));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaLiveResult.fromJson(jsonObject.toString());
|
||||
return WxMaLiveResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,9 +82,6 @@ public class WxMaLiveGoodsServiceImpl implements WxMaLiveGoodsService {
|
||||
ImmutableMap<String, ? extends Serializable> params = ImmutableMap.of("status", status, "offset", offset, "limit", limit);
|
||||
String responseContent = wxMaService.get(GET_APPROVED_GOODS, Joiner.on("&").withKeyValueSeparator("=").join(params));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
JsonArray goodsArr = jsonObject.getAsJsonArray("goods");
|
||||
if (goodsArr.size() > 0) {
|
||||
for (int i = 0; i < goodsArr.size(); i++) {
|
||||
|
@ -2,8 +2,8 @@ package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaLiveService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo;
|
||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -31,7 +31,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService {
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public Integer createRoom(WxMaLiveInfo.RoomInfo roomInfo) throws WxErrorException {
|
||||
public Integer createRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo));
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get("errcode").getAsInt() != 0) {
|
||||
|
@ -1,60 +0,0 @@
|
||||
package cn.binarywang.wx.miniapp.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 直播接口入参
|
||||
*
|
||||
* @author yjwang
|
||||
* @date 2020/4/5
|
||||
*/
|
||||
@Data
|
||||
public class WxMaLiveInfo implements Serializable {
|
||||
private static final long serialVersionUID = 7285263767524755887L;
|
||||
|
||||
/**
|
||||
* 直播列表
|
||||
*/
|
||||
@Data
|
||||
public static class RoomInfo implements Serializable {
|
||||
private static final long serialVersionUID = 7745775280267417154L;
|
||||
private String name;
|
||||
private Integer roomid;
|
||||
private String coverImg;
|
||||
private String shareImg;
|
||||
private Integer liveStatus;
|
||||
private Long startTime;
|
||||
private Long endTime;
|
||||
private String anchorName;
|
||||
private String anchorWechat;
|
||||
private String anchorImg;
|
||||
private Integer type;
|
||||
private Integer screenType;
|
||||
private Integer closeLike;
|
||||
private Integer closeGoods;
|
||||
private Integer closeComment;
|
||||
private List<Goods> goods;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@Data
|
||||
public static class Goods implements Serializable {
|
||||
private static final long serialVersionUID = 5769245932149287574L;
|
||||
private Integer goodsId;
|
||||
private String coverImgUrl;
|
||||
private String url;
|
||||
private Integer priceType;
|
||||
private String price;
|
||||
private String price2;
|
||||
private String name;
|
||||
/**
|
||||
* 1, 2:表示是为api添加商品,否则是在MP添加商品
|
||||
*/
|
||||
private String thirdPartyTag;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.binarywang.wx.miniapp.bean.live;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 直播商品信息
|
||||
*/
|
||||
@Data
|
||||
public class WxMaLiveGoodInfo implements Serializable {
|
||||
private static final long serialVersionUID = 5769245932149287574L;
|
||||
private Integer goodsId;
|
||||
private String coverImgUrl;
|
||||
private String url;
|
||||
private Integer priceType;
|
||||
private String price;
|
||||
private String price2;
|
||||
private String name;
|
||||
/**
|
||||
* 1, 2:表示是为api添加商品,否则是在MP添加商品
|
||||
*/
|
||||
private String thirdPartyTag;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.binarywang.wx.miniapp.bean;
|
||||
package cn.binarywang.wx.miniapp.bean.live;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -18,8 +18,6 @@ import java.util.List;
|
||||
@Data
|
||||
public class WxMaLiveResult implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer errcode;
|
||||
private String errmsg;
|
||||
private Integer total;
|
||||
private Integer auditId;
|
||||
private Integer goodsId;
|
@ -0,0 +1,86 @@
|
||||
package cn.binarywang.wx.miniapp.bean.live;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 直播间信息
|
||||
*/
|
||||
@Data
|
||||
public class WxMaLiveRoomInfo implements Serializable {
|
||||
private static final long serialVersionUID = 7745775280267417154L;
|
||||
|
||||
/**
|
||||
* 直播间名字,最短3个汉字,最长17个汉字,1个汉字相当于2个字符
|
||||
**/
|
||||
private String name;
|
||||
/**
|
||||
* 背景图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;直播间背景图,图片规则:建议像素1080*1920,大小不超过2M
|
||||
**/
|
||||
private String coverImg;
|
||||
/**
|
||||
* 直播计划开始时间(开播时间需要在当前时间的10分钟后 并且 开始时间不能在 6 个月后)
|
||||
**/
|
||||
private Long startTime;
|
||||
/**
|
||||
* 直播计划结束时间(开播时间和结束时间间隔不得短于30分钟,不得超过24小时)
|
||||
**/
|
||||
private Long endTime;
|
||||
/**
|
||||
* 主播昵称,最短2个汉字,最长15个汉字,1个汉字相当于2个字符
|
||||
**/
|
||||
private String anchorName;
|
||||
/**
|
||||
* 主播微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证, 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr
|
||||
**/
|
||||
private String anchorWechat;
|
||||
/**
|
||||
* 主播副号微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证, 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr
|
||||
**/
|
||||
private String subAnchorWechat;
|
||||
/**
|
||||
* 分享图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;直播间分享图,图片规则:建议像素800*640,大小不超过1M;
|
||||
**/
|
||||
private String shareImg;
|
||||
/**
|
||||
* 购物直播频道封面图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html; 购物直播频道封面图,图片规则:建议像素800*800,大小不超过100KB;
|
||||
**/
|
||||
private String feedsImg;
|
||||
/**
|
||||
* 是否开启官方收录 【1: 开启,0:关闭】,默认开启收录
|
||||
**/
|
||||
private Integer isFeedsPublic;
|
||||
/**
|
||||
* 直播间类型 【1: 推流,0:手机直播】
|
||||
**/
|
||||
private Integer type;
|
||||
/**
|
||||
* 横屏、竖屏 【1:横屏,0:竖屏】(横屏:视频宽高比为16:9、4:3、1.85:1 ;竖屏:视频宽高比为9:16、2:3)
|
||||
**/
|
||||
private Integer screenType;
|
||||
/**
|
||||
* 是否关闭点赞 【0:开启,1:关闭】(若关闭,直播开始后不允许开启)
|
||||
**/
|
||||
private Integer closeLike;
|
||||
/**
|
||||
* 是否关闭货架 【0:开启,1:关闭】(若关闭,直播开始后不允许开启)
|
||||
**/
|
||||
private Integer closeGoods;
|
||||
/**
|
||||
* 是否关闭评论 【0:开启,1:关闭】(若关闭,直播开始后不允许开启)
|
||||
**/
|
||||
private Integer closeComment;
|
||||
/**
|
||||
* 是否关闭回放 【0:开启,1:关闭】默认关闭回放
|
||||
**/
|
||||
private Integer closeReplay;
|
||||
/**
|
||||
* 是否关闭分享 【0:开启,1:关闭】默认开启分享(直播开始后不允许修改)
|
||||
**/
|
||||
private Integer loseShare;
|
||||
/**
|
||||
* closeKf Number 否 是否关闭客服 【0:开启,1:关闭】 默认关闭客服
|
||||
**/
|
||||
private Integer closeKf;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveGoodInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
@ -31,7 +31,7 @@ public class WxMaLiveGoodsServiceImplTest {
|
||||
//上传临时素材
|
||||
WxMediaUploadResult mediaUpload = this.wxService.getMediaService().uploadMedia("image", new File("E:\\1.png"));
|
||||
|
||||
WxMaLiveInfo.Goods goods = new WxMaLiveInfo.Goods();
|
||||
WxMaLiveGoodInfo goods = new WxMaLiveGoodInfo();
|
||||
goods.setCoverImgUrl(mediaUpload.getMediaId());
|
||||
goods.setName("宫廷奢华真丝四件套");
|
||||
goods.setPrice("1599");
|
||||
@ -64,7 +64,7 @@ public class WxMaLiveGoodsServiceImplTest {
|
||||
@Test
|
||||
public void updateGoods() throws Exception {
|
||||
|
||||
WxMaLiveInfo.Goods goods = new WxMaLiveInfo.Goods();
|
||||
WxMaLiveGoodInfo goods = new WxMaLiveGoodInfo();
|
||||
goods.setGoodsId(8);
|
||||
goods.setName("宫廷奢华真丝四件套");
|
||||
goods.setCoverImgUrl("http://mmbiz.qpic.cn/mmbiz_png/omYktZNGamuUQE0WPVfqdnLV61JDhluXOac7PiaoZeticFpcR7wvicC0aXUC2VXkl7r1gN0QSKosv2satn6oCFeiaQ/0");
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
|
||||
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo;
|
||||
import cn.binarywang.wx.miniapp.test.ApiTestModule;
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
@ -33,7 +33,7 @@ public class WxMaLiveServiceImplTest {
|
||||
//上传临时素材
|
||||
WxMediaUploadResult mediaUpload = this.wxService.getMediaService().uploadMedia("image", new File("E:\\1.png"));
|
||||
|
||||
WxMaLiveInfo.RoomInfo roomInfo = new WxMaLiveInfo.RoomInfo();
|
||||
WxMaLiveRoomInfo roomInfo = new WxMaLiveRoomInfo();
|
||||
roomInfo.setName("订阅通知直播间");
|
||||
roomInfo.setCoverImg(mediaUpload.getMediaId());
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>weixin-java-open</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java</artifactId>
|
||||
<version>3.9.1.B</version>
|
||||
<version>3.9.2.B</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author: f00lish
|
||||
* @date: 2020/09/12
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FundBalanceResult {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 电商平台二级商户号,由微信支付生成并下发。
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("sub_mchid")
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:可用余额
|
||||
* 变量名:available_amount
|
||||
* 是否必填:是
|
||||
* 类型:int64
|
||||
* 描述:
|
||||
* 可用余额(单位:分),此余额可做提现操作。
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("available_amount")
|
||||
private Integer availableAmount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:不可用余额
|
||||
* 变量名:pending_amount
|
||||
* 是否必填:否
|
||||
* 类型:int64
|
||||
* 描述:
|
||||
* 不可用余额(单位:分)。
|
||||
* 示例值:100
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName("pending_amount")
|
||||
private Integer pendingAmount;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 请求分账 对象
|
||||
* <pre>
|
||||
* 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_1.shtml
|
||||
* </pre>
|
||||
* @author: f00lish
|
||||
* @date: 2020/09/12
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ProfitSharingRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8662837652326828377L;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:公众账号ID
|
||||
* 变量名:appid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 微信分配的公众账号ID。
|
||||
* 示例值:wx8888888888888888
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "appid")
|
||||
private String appid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 分账出资的电商平台二级商户,填写微信支付分配的商户号。
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:微信订单号
|
||||
* 变量名:transaction_id
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 微信支付订单号。
|
||||
* 示例值:4208450740201411110007820472
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户分账单号
|
||||
* 变量名:out_order_no
|
||||
* 是否必填:是
|
||||
* 类型:string(64)
|
||||
* 描述:
|
||||
* 商户系统内部的分账单号,在商户系统内部唯一(单次分账、多次分账、完结分账应使用不同的商户分账单号),同一分账单号多次请求等同一次。
|
||||
* 示例值:P20150806125346
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "out_order_no")
|
||||
private String outOrderNo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分账接收方列表
|
||||
* 变量名:receivers
|
||||
* 是否必填:是
|
||||
* 类型:array
|
||||
* 描述:
|
||||
* 分账接收方列表,支持设置出资商户作为分账接收方,单次分账最多可有5个分账接收方
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "receivers")
|
||||
private Receiver[] receivers;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:是否分账完成
|
||||
* 变量名:finish
|
||||
* 是否必填:是
|
||||
* 类型:bool
|
||||
* 描述:
|
||||
* 是否完成分账
|
||||
* 1、如果为true,该笔订单剩余未分账的金额会解冻回电商平台二级商户;
|
||||
* 2、如果为false,该笔订单剩余未分账的金额不会解冻回电商平台二级商户,可以对该笔订单再次进行分账。
|
||||
* 示例值:true
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "finish")
|
||||
private Boolean finish;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class Receiver implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8995144356011793136L;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分账接收方类型
|
||||
* 变量名:type
|
||||
* 是否必填:否
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 分账接收方类型,枚举值:
|
||||
* MERCHANT_ID:商户
|
||||
* PERSONAL_OPENID:个人
|
||||
* 示例值:MERCHANT_ID
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分账接收方账号
|
||||
* 变量名:receiver_account
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 分账接收方账号:
|
||||
* 类型是MERCHANT_ID时,是商户ID
|
||||
* 类型是PERSONAL_OPENID时,是个人openid,openid获取方法 https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/guide/chapter2_1.shtml#menu1
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "receiver_account")
|
||||
private String receiverAccount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分账金额
|
||||
* 变量名:amount
|
||||
* 是否必填:是
|
||||
* 类型:int
|
||||
* 描述:
|
||||
* 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额。
|
||||
* 示例值:190
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "amount")
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分账描述
|
||||
* 变量名:description
|
||||
* 是否必填:是
|
||||
* 类型:string(180)
|
||||
* 描述:
|
||||
* 分账的原因描述,分账账单中需要体现。
|
||||
* 示例值:分给商户1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:分账个人姓名
|
||||
* 变量名:receiver_name
|
||||
* 是否必填:否
|
||||
* 类型:string(10240)
|
||||
* 描述:
|
||||
* 可选项,在接收方类型为个人的时可选填,若有值,会检查与 receiver_name 是否实名匹配,不匹配会拒绝分账请求
|
||||
* 1、分账接收方类型是PERSONAL_OPENID时,是个人姓名的密文(选传,传则校验) 此字段的加密方法详见:敏感信息加密说明
|
||||
* 2、使用微信支付平台证书中的公钥
|
||||
* 3、使用RSAES-OAEP算法进行加密
|
||||
* 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
|
||||
* 示例值:hu89ohu89ohu89o
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "receiver_name")
|
||||
private String receiverName;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 请求分账 结果响应
|
||||
* @author: f00lish
|
||||
* @date: 2020/09/12
|
||||
*/
|
||||
public class ProfitSharingResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9026456165403642050L;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 分账出资的电商平台二级商户,填写微信支付分配的商户号。
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:微信订单号
|
||||
* 变量名:transaction_id
|
||||
* 是否必填:是
|
||||
* 类型:string(32)
|
||||
* 描述:
|
||||
* 微信支付订单号。
|
||||
* 示例值:4208450740201411110007820472
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户分账单号
|
||||
* 变量名:out_order_no
|
||||
* 是否必填:是
|
||||
* 类型:string(64)
|
||||
* 描述:
|
||||
* 商户系统内部的分账单号,在商户系统内部唯一(单次分账、多次分账、完结分账应使用不同的商户分账单号),同一分账单号多次请求等同一次。
|
||||
* 示例值:P20150806125346
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "out_order_no")
|
||||
private String outOrderNo;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:微信分账单号
|
||||
* 变量名:order_id
|
||||
* 是否必填:是
|
||||
* 类型:string (64)
|
||||
* 描述:
|
||||
* 微信分账单号,微信系统返回的唯一标识。
|
||||
* 示例值:6754760740201411110007865434
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "order_id")
|
||||
private String orderId;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.github.binarywang.wxpay.bean.ecommerce.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 服务商账户类型
|
||||
* @author: f00lish
|
||||
* @date: 2020/09/12
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SpAccountTypeEnum {
|
||||
|
||||
/**
|
||||
* 基本账户
|
||||
*/
|
||||
BASIC("BASIC"),
|
||||
/**
|
||||
* 运营账户
|
||||
*/
|
||||
OPERATION("OPERATION"),
|
||||
/**
|
||||
* 手续费账户
|
||||
*/
|
||||
FEES("FEES");
|
||||
|
||||
/**
|
||||
* 账户类型
|
||||
*/
|
||||
private final String value;
|
||||
}
|
@ -18,38 +18,66 @@ public class PayScoreNotifyData implements Serializable {
|
||||
private static final long serialVersionUID = -8538014389773390989L;
|
||||
|
||||
/**
|
||||
* id : EV-2018022511223320873
|
||||
* create_time : 20180225112233
|
||||
* resource_type : encrypt-resource
|
||||
* event_type : PAYSCORE.USER_CONFIRM
|
||||
* resource : {"algorithm":"AEAD_AES_256_GCM","ciphertext":"...","nonce":"...","associated_data":""}
|
||||
* 通知ID
|
||||
*/
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 通知创建时间
|
||||
*/
|
||||
@SerializedName("create_time")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 通知数据类型
|
||||
*/
|
||||
@SerializedName("resource_type")
|
||||
private String resourceType;
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@SerializedName("event_type")
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* 通知数据
|
||||
*/
|
||||
@SerializedName("resource")
|
||||
private Resource resource;
|
||||
|
||||
/**
|
||||
* 回调摘要
|
||||
* summary
|
||||
*/
|
||||
@SerializedName("summary")
|
||||
private String summary;
|
||||
|
||||
@Data
|
||||
public static class Resource implements Serializable {
|
||||
private static final long serialVersionUID = 8530711804335261449L;
|
||||
/**
|
||||
* algorithm : AEAD_AES_256_GCM
|
||||
* ciphertext : ...
|
||||
* nonce : ...
|
||||
* associated_data :
|
||||
* 加密算法类型
|
||||
*/
|
||||
@SerializedName("algorithm")
|
||||
private String algorithm;
|
||||
|
||||
/**
|
||||
* 数据密文
|
||||
*/
|
||||
@SerializedName("ciphertext")
|
||||
private String cipherText;
|
||||
|
||||
/**
|
||||
* 附加数据
|
||||
*/
|
||||
@SerializedName("nonce")
|
||||
private String nonce;
|
||||
|
||||
/**
|
||||
* 随机串
|
||||
*/
|
||||
@SerializedName("associated_data")
|
||||
private String associatedData;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.binarywang.wxpay.service;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.*;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
|
||||
@ -11,7 +12,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
* </pre>
|
||||
*
|
||||
* @author cloudX
|
||||
* @date 2020/08/17
|
||||
* @date 2020 /08/17
|
||||
*/
|
||||
public interface EcommerceService {
|
||||
/**
|
||||
@ -62,8 +63,9 @@ public interface EcommerceService {
|
||||
* </pre>
|
||||
*
|
||||
* @param tradeType 支付方式
|
||||
* @param request 请求对象
|
||||
* @return 微信合单支付返回
|
||||
* @param request 请求对象
|
||||
* @return 微信合单支付返回 transactions result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
TransactionsResult combine(TradeTypeEnum tradeType, CombineTransactionsRequest request) throws WxPayException;
|
||||
|
||||
@ -74,9 +76,11 @@ public interface EcommerceService {
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/e-combine.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param <T> the type parameter
|
||||
* @param tradeType 支付方式
|
||||
* @param request 请求对象
|
||||
* @return 调起支付需要的参数
|
||||
* @param request 请求对象
|
||||
* @return 调起支付需要的参数 t
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
<T> T combineTransactions(TradeTypeEnum tradeType, CombineTransactionsRequest request) throws WxPayException;
|
||||
|
||||
@ -87,32 +91,38 @@ public interface EcommerceService {
|
||||
* </pre>
|
||||
*
|
||||
* @param notifyData 通知数据
|
||||
* @param header 通知头部数据,不传则表示不校验头
|
||||
* @return 解密后通知数据
|
||||
* @param header 通知头部数据,不传则表示不校验头
|
||||
* @return 解密后通知数据 combine transactions notify result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* <pre>
|
||||
* 服务商模式普通支付API(APP支付、JSAPI支付、H5支付、NATIVE支付).
|
||||
* 请求URL:https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/transactions_sl.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param tradeType 支付方式
|
||||
* @param request 请求对象
|
||||
* @return 调起支付需要的参数
|
||||
* @param request 请求对象
|
||||
* @return 调起支付需要的参数 transactions result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
TransactionsResult partner(TradeTypeEnum tradeType, PartnerTransactionsRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* <pre>
|
||||
* 服务商模式普通支付API(APP支付、JSAPI支付、H5支付、NATIVE支付).
|
||||
* 请求URL:https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/transactions_sl.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param <T> the type parameter
|
||||
* @param tradeType 支付方式
|
||||
* @param request 请求对象
|
||||
* @return 调起支付需要的参数
|
||||
* @param request 请求对象
|
||||
* @return 调起支付需要的参数 t
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
<T> T partnerTransactions(TradeTypeEnum tradeType, PartnerTransactionsRequest request) throws WxPayException;
|
||||
|
||||
@ -123,8 +133,72 @@ public interface EcommerceService {
|
||||
* </pre>
|
||||
*
|
||||
* @param notifyData 通知数据
|
||||
* @param header 通知头部数据,不传则表示不校验头
|
||||
* @return 解密后通知数据
|
||||
* @param header 通知头部数据,不传则表示不校验头
|
||||
* @return 解密后通知数据 partner transactions notify result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 服务商账户实时余额
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/amount.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param accountType 服务商账户类型
|
||||
* @return 返回数据 fund balance result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
FundBalanceResult spNowBalance(SpAccountTypeEnum accountType) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 服务商账户日终余额
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/amount.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param accountType 服务商账户类型
|
||||
* @param date 查询日期 2020-09-11
|
||||
* @return 返回数据 fund balance result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
FundBalanceResult spDayEndBalance(SpAccountTypeEnum accountType, String date) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 二级商户号账户实时余额
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/amount.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param subMchid 二级商户号
|
||||
* @return 返回数据 fund balance result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
FundBalanceResult subNowBalance(String subMchid) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 二级商户号账户日终余额
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/amount.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param subMchid 二级商户号
|
||||
* @param date 查询日期 2020-09-11
|
||||
* @return 返回数据 fund balance result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
FundBalanceResult subDayEndBalance(String subMchid, String date) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 请求分账API
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_1.shtml
|
||||
* </pre>
|
||||
*
|
||||
* @param request 分账请求
|
||||
* @return 返回数据 profit sharing result
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.binarywang.wxpay.service.impl;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.*;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum;
|
||||
import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.EcommerceService;
|
||||
@ -115,6 +116,45 @@ public class EcommerceServiceImpl implements EcommerceService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundBalanceResult spNowBalance(SpAccountTypeEnum accountType) throws WxPayException {
|
||||
String url = String.format("%s/v3/merchant/fund/balance/%s", this.payService.getPayBaseUrl(), accountType);
|
||||
URI uri = URI.create(url);
|
||||
String response = this.payService.getV3(uri);
|
||||
return GSON.fromJson(response, FundBalanceResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundBalanceResult spDayEndBalance(SpAccountTypeEnum accountType, String date) throws WxPayException {
|
||||
String url = String.format("%s/v3/merchant/fund/dayendbalance/%s?date=%s", this.payService.getPayBaseUrl(), accountType, date);
|
||||
URI uri = URI.create(url);
|
||||
String response = this.payService.getV3(uri);
|
||||
return GSON.fromJson(response, FundBalanceResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundBalanceResult subNowBalance(String subMchid) throws WxPayException {
|
||||
String url = String.format("%s/v3/ecommerce/fund/balance/%s", this.payService.getPayBaseUrl(), subMchid);
|
||||
URI uri = URI.create(url);
|
||||
String response = this.payService.getV3(uri);
|
||||
return GSON.fromJson(response, FundBalanceResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundBalanceResult subDayEndBalance(String subMchid, String date) throws WxPayException {
|
||||
String url = String.format("%s/v3/ecommerce/fund/enddaybalance/%s?date=%s", this.payService.getPayBaseUrl(), subMchid, date);
|
||||
URI uri = URI.create(url);
|
||||
String response = this.payService.getV3(uri);
|
||||
return GSON.fromJson(response, FundBalanceResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException {
|
||||
String url = String.format("%s/v3/ecommerce/profitsharing/orders", this.payService.getPayBaseUrl());
|
||||
String response = this.payService.postV3(url, GSON.toJson(request));
|
||||
return GSON.fromJson(response, ProfitSharingResult.class);
|
||||
}
|
||||
|
||||
private boolean verifyNotifySign(SignatureHeader header, String data) {
|
||||
String beforeSign = String.format("%s\n%s\n%s\n",
|
||||
header.getTimeStamp(),
|
||||
|
Loading…
Reference in New Issue
Block a user