交易系统生活服务交易系统:预下单开发者发起下单

This commit is contained in:
353259576 2024-07-09 16:42:59 +08:00
parent 4f337be866
commit 5222ad895d
14 changed files with 875 additions and 0 deletions

View File

@ -2076,6 +2076,15 @@ public class DyAppletClient extends BaseClient {
return new IndustryTransactionHandler(configuration().getAgentByTenantId(tenantId, clientKey)).queryIndustryOrderCps(body);
}
/**
* 生活服务交易系统->预下单->开发者发起下单
* @param body
* @return
*/
public DySimpleResult<PreCreateIndustryOrderVo> preCreateIndustryOrder(PreCreateIndustryOrderQuery body){
return new IndustryTransactionHandler(configuration().getAgentByTenantId(tenantId, clientKey)).preCreateIndustryOrder(body);
}
/**
* 获取抖音号绑定所需的资质模版列表
*

View File

@ -3,13 +3,16 @@ package com.dyj.applet.client;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.JSONBody;
import com.dtflys.forest.annotation.Post;
import com.dyj.applet.domain.query.PreCreateIndustryOrderQuery;
import com.dyj.applet.domain.query.QueryIndustryOrderCpsQuery;
import com.dyj.applet.domain.query.QueryIndustryOrderQuery;
import com.dyj.applet.domain.query.QueryIndustryItemOrderInfoQuery;
import com.dyj.applet.domain.vo.PreCreateIndustryOrderVo;
import com.dyj.applet.domain.vo.QueryIndustryCpsVo;
import com.dyj.applet.domain.vo.QueryIndustryOrderVo;
import com.dyj.applet.domain.vo.QueryIndustryItemOrderInfoVo;
import com.dyj.common.domain.DataAndExtraVo;
import com.dyj.common.domain.DySimpleResult;
import com.dyj.common.interceptor.ClientTokenInterceptor;
/**
@ -42,4 +45,12 @@ public interface IndustryTransactionClient {
*/
@Post(value = "${queryIndustryOrderCps}", interceptor = ClientTokenInterceptor.class)
DataAndExtraVo<QueryIndustryCpsVo> queryIndustryOrderCps(@JSONBody QueryIndustryOrderCpsQuery body);
/**
* 生活服务交易系统->预下单->开发者发起下单
* @param body
* @return
*/
@Post(value = "${preCreateIndustryOrder}", interceptor = ClientTokenInterceptor.class)
DySimpleResult<PreCreateIndustryOrderVo> preCreateIndustryOrder(@JSONBody PreCreateIndustryOrderQuery body);
}

View File

@ -0,0 +1,56 @@
package com.dyj.applet.domain;
/**
* 预约信息
*/
public class IndustryOrderGoodsBookInfo {
/**
* 预约类型
* 1不需要预约
* 2在线预约
*/
private Integer book_type;
/**
* 取消政策
* 1预约后不可取消
* 2预约后可取消
* 3预约中可取消预约成功须提前 x 小时取消
* 选填
*/
private Integer cancel_policy;
/**
* 提前取消的小时限制
* 选填
*/
private Integer cancel_advance_hour;
public Integer getBook_type() {
return book_type;
}
public IndustryOrderGoodsBookInfo setBook_type(Integer book_type) {
this.book_type = book_type;
return this;
}
public Integer getCancel_policy() {
return cancel_policy;
}
public IndustryOrderGoodsBookInfo setCancel_policy(Integer cancel_policy) {
this.cancel_policy = cancel_policy;
return this;
}
public Integer getCancel_advance_hour() {
return cancel_advance_hour;
}
public IndustryOrderGoodsBookInfo setCancel_advance_hour(Integer cancel_advance_hour) {
this.cancel_advance_hour = cancel_advance_hour;
return this;
}
}

View File

@ -0,0 +1,181 @@
package com.dyj.applet.domain;
/**
* 商品信息
*/
public class IndustryOrderGoodsInfo {
/**
* 商品图片链接长度 <= 512 byte
* 注意 POI 商品必传
*/
private String goods_image;
/**
* 商品标题/商品名称长度 <= 256 byte
* 注意 POI 商品必传
*/
private String goods_title;
/**
* 商品标签最多设置三个标签例如随时退免预约提前3日预约是中文类型详见 pay-button 支付 type 的合法值 部分注意不是 good-type 的合法值
* 注意 POI 商品必传
*/
private String labels;
/**
* 使用规则 周一至周日可用周一至周五可用非节假日可用默认周一至周日可用
*/
private String date_rule;
/**
* 商品价格单位
* 注意 POI 商品必传
*/
private Long price;
/**
* 商品数量
*/
private Integer quantity;
/**
* 商品 id
*/
private String goods_id;
/**
* 商品 id 类别
* POI 商品传 1
* POI 商品传 2
*/
private Integer goods_id_type;
/**
* 商品详情页
*/
private IndustryOrderGoodsPage goods_page;
/**
* 券的有效期
*/
private IndustryOrderValidTime order_valid_time;
/**
* 折扣金额单位分
*/
private Long discount_amount;
/**
* 预约信息
*/
private IndustryOrderGoodsBookInfo goods_book_info;
public String getGoods_image() {
return goods_image;
}
public IndustryOrderGoodsInfo setGoods_image(String goods_image) {
this.goods_image = goods_image;
return this;
}
public String getGoods_title() {
return goods_title;
}
public IndustryOrderGoodsInfo setGoods_title(String goods_title) {
this.goods_title = goods_title;
return this;
}
public String getLabels() {
return labels;
}
public IndustryOrderGoodsInfo setLabels(String labels) {
this.labels = labels;
return this;
}
public String getDate_rule() {
return date_rule;
}
public IndustryOrderGoodsInfo setDate_rule(String date_rule) {
this.date_rule = date_rule;
return this;
}
public Long getPrice() {
return price;
}
public IndustryOrderGoodsInfo setPrice(Long price) {
this.price = price;
return this;
}
public Integer getQuantity() {
return quantity;
}
public IndustryOrderGoodsInfo setQuantity(Integer quantity) {
this.quantity = quantity;
return this;
}
public String getGoods_id() {
return goods_id;
}
public IndustryOrderGoodsInfo setGoods_id(String goods_id) {
this.goods_id = goods_id;
return this;
}
public Integer getGoods_id_type() {
return goods_id_type;
}
public IndustryOrderGoodsInfo setGoods_id_type(Integer goods_id_type) {
this.goods_id_type = goods_id_type;
return this;
}
public IndustryOrderGoodsPage getGoods_page() {
return goods_page;
}
public IndustryOrderGoodsInfo setGoods_page(IndustryOrderGoodsPage goods_page) {
this.goods_page = goods_page;
return this;
}
public IndustryOrderValidTime getOrder_valid_time() {
return order_valid_time;
}
public IndustryOrderGoodsInfo setOrder_valid_time(IndustryOrderValidTime order_valid_time) {
this.order_valid_time = order_valid_time;
return this;
}
public Long getDiscount_amount() {
return discount_amount;
}
public IndustryOrderGoodsInfo setDiscount_amount(Long discount_amount) {
this.discount_amount = discount_amount;
return this;
}
public IndustryOrderGoodsBookInfo getGoods_book_info() {
return goods_book_info;
}
public IndustryOrderGoodsInfo setGoods_book_info(IndustryOrderGoodsBookInfo goods_book_info) {
this.goods_book_info = goods_book_info;
return this;
}
}

View File

@ -0,0 +1,39 @@
package com.dyj.applet.domain;
/**
* 商品详情页
*/
public class IndustryOrderGoodsPage {
/**
* 订单详情页跳转路径没有前导的/长度 <= 512byte
*/
private String path;
/**
* 订单详情页路径参数自定义的 json 结构
* 序列化成字符串存入该字段平台不限制
* 但是写入的内容需要能够保证生成访问订单详情的 schema 能正确跳转到小程序内部的订单详情页
* 长度 <= 512byte
* 选填
*/
private String params;
public String getPath() {
return path;
}
public IndustryOrderGoodsPage setPath(String path) {
this.path = path;
return this;
}
public String getParams() {
return params;
}
public IndustryOrderGoodsPage setParams(String params) {
this.params = params;
return this;
}
}

View File

@ -0,0 +1,35 @@
package com.dyj.applet.domain;
/**
* 商品 item_order 详细信息
*/
public class IndustryOrderItemOrderDetail {
/**
* item id
*/
private String item_order_id;
/**
* 商品优惠后价格
*/
private Long price;
public String getItem_order_id() {
return item_order_id;
}
public IndustryOrderItemOrderDetail setItem_order_id(String item_order_id) {
this.item_order_id = item_order_id;
return this;
}
public Long getPrice() {
return price;
}
public IndustryOrderItemOrderDetail setPrice(Long price) {
this.price = price;
return this;
}
}

View File

@ -0,0 +1,51 @@
package com.dyj.applet.domain;
import java.util.List;
/**
* 商品 item_order 信息
*/
public class IndustryOrderItemOrderInfo {
/**
* 商品 id
*/
private String goods_id;
/**
* item_order_id 列表id 个数与下单时对应 goods_id quantity 一致
*/
private List<String> item_order_id_list;
/**
* 商品 item_order 详细信息
*/
private List<IndustryOrderItemOrderDetail> item_order_detail;
public String getGoods_id() {
return goods_id;
}
public IndustryOrderItemOrderInfo setGoods_id(String goods_id) {
this.goods_id = goods_id;
return this;
}
public List<String> getItem_order_id_list() {
return item_order_id_list;
}
public IndustryOrderItemOrderInfo setItem_order_id_list(List<String> item_order_id_list) {
this.item_order_id_list = item_order_id_list;
return this;
}
public List<IndustryOrderItemOrderDetail> getItem_order_detail() {
return item_order_detail;
}
public IndustryOrderItemOrderInfo setItem_order_detail(List<IndustryOrderItemOrderDetail> item_order_detail) {
this.item_order_detail = item_order_detail;
return this;
}
}

View File

@ -0,0 +1,40 @@
package com.dyj.applet.domain;
/**
* 订单详情页信息
*/
public class IndustryOrderOrderEntrySchema {
/**
* 订单详情页跳转路径没有前导的/长度 <= 512byte
*/
private String path;
/**
* 订单详情页路径参数自定义的 json 结构
* 序列化成字符串存入该字段
* 平台不限制
* 但是写入的内容需要能够保证生成访问订单详情的 schema 能正确跳转到小程序内部的订单详情页
* 长度 <= 512byte
* 选填
*/
private String params;
public String getPath() {
return path;
}
public IndustryOrderOrderEntrySchema setPath(String path) {
this.path = path;
return this;
}
public String getParams() {
return params;
}
public IndustryOrderOrderEntrySchema setParams(String params) {
this.params = params;
return this;
}
}

View File

@ -0,0 +1,55 @@
package com.dyj.applet.domain;
/**
* 券的有效期
*/
public class IndustryOrderValidTime {
/**
* 券的有效期开始时间单位毫秒须大于 0 选填
*/
private Long valid_start_time;
/**
* 券的有效期结束时间单位毫秒须大于 0且须大于 valid_start_time 和当前时间 选填
*/
private Long valid_end_time;
/**
* a.券的相对有效时间单位毫秒须大于 0
* b. valid_start_timevalid_end_time 组合至少回传一个否则会下单失败
* c.都合法优先使用 valid_start_timevalid_end_time 组合
* d. valid_duration 有效时
* 券的有效期开始时间 S = 订单支付完成时间
* 券的有效期结束时间 E = 1 + 向下按天截断S + valid_duration)
* 选填
*/
private Long valid_duration;
public Long getValid_start_time() {
return valid_start_time;
}
public IndustryOrderValidTime setValid_start_time(Long valid_start_time) {
this.valid_start_time = valid_start_time;
return this;
}
public Long getValid_end_time() {
return valid_end_time;
}
public IndustryOrderValidTime setValid_end_time(Long valid_end_time) {
this.valid_end_time = valid_end_time;
return this;
}
public Long getValid_duration() {
return valid_duration;
}
public IndustryOrderValidTime setValid_duration(Long valid_duration) {
this.valid_duration = valid_duration;
return this;
}
}

View File

@ -0,0 +1,281 @@
package com.dyj.applet.domain.query;
import com.dyj.applet.domain.IndustryOrderGoodsInfo;
import com.dyj.applet.domain.IndustryOrderOrderEntrySchema;
import com.dyj.common.domain.query.UserInfoQuery;
import java.util.List;
/**
* 生活服务交易系统->预下单->开发者发起下单查询值
*/
public class PreCreateIndustryOrderQuery extends UserInfoQuery {
/**
* 商品信息
*/
private List<IndustryOrderGoodsInfo> goods_list;
/**
* 订单总价单位分
*/
private Long total_amount;
/**
* 用户手机号长度 <= 128 byte
*/
private String phone_num;
/**
* 用户姓名长度 <= 64 byte
*/
private String contact_name;
/**
* 下单备注信息长度 <= 2048byte
*/
private String extra;
/**
* 支付结果通知地址必须是 HTTPS 类型
* 若不填默认使用在行业模板配置-消息通知的支付结果通知地址
*/
private String pay_notify_url;
/**
* 开发者的单号长度 <= 64 byte
*/
private String out_order_no;
/**
* 支付超时时间单位秒例如 300 表示 300 秒后过期不传或传 0 会使用默认值 300
*/
private Long pay_expire_seconds;
/**
* 订单详情页信息
*/
private IndustryOrderOrderEntrySchema order_entry_schema;
/**
* 开发者自定义透传字段不支持二进制长度 <= 2048 byte
*/
private String cp_extra;
/**
* 折扣金额单位分
*/
private Long discount_amount;
public List<IndustryOrderGoodsInfo> getGoods_list() {
return goods_list;
}
public PreCreateIndustryOrderQuery setGoods_list(List<IndustryOrderGoodsInfo> goods_list) {
this.goods_list = goods_list;
return this;
}
public Long getTotal_amount() {
return total_amount;
}
public PreCreateIndustryOrderQuery setTotal_amount(Long total_amount) {
this.total_amount = total_amount;
return this;
}
public String getPhone_num() {
return phone_num;
}
public PreCreateIndustryOrderQuery setPhone_num(String phone_num) {
this.phone_num = phone_num;
return this;
}
public String getContact_name() {
return contact_name;
}
public PreCreateIndustryOrderQuery setContact_name(String contact_name) {
this.contact_name = contact_name;
return this;
}
public String getExtra() {
return extra;
}
public PreCreateIndustryOrderQuery setExtra(String extra) {
this.extra = extra;
return this;
}
public String getPay_notify_url() {
return pay_notify_url;
}
public PreCreateIndustryOrderQuery setPay_notify_url(String pay_notify_url) {
this.pay_notify_url = pay_notify_url;
return this;
}
public String getOut_order_no() {
return out_order_no;
}
public PreCreateIndustryOrderQuery setOut_order_no(String out_order_no) {
this.out_order_no = out_order_no;
return this;
}
public Long getPay_expire_seconds() {
return pay_expire_seconds;
}
public PreCreateIndustryOrderQuery setPay_expire_seconds(Long pay_expire_seconds) {
this.pay_expire_seconds = pay_expire_seconds;
return this;
}
public IndustryOrderOrderEntrySchema getOrder_entry_schema() {
return order_entry_schema;
}
public PreCreateIndustryOrderQuery setOrder_entry_schema(IndustryOrderOrderEntrySchema order_entry_schema) {
this.order_entry_schema = order_entry_schema;
return this;
}
public String getCp_extra() {
return cp_extra;
}
public PreCreateIndustryOrderQuery setCp_extra(String cp_extra) {
this.cp_extra = cp_extra;
return this;
}
public Long getDiscount_amount() {
return discount_amount;
}
public PreCreateIndustryOrderQuery setDiscount_amount(Long discount_amount) {
this.discount_amount = discount_amount;
return this;
}
public static PreCreateIndustryOrderQueryBuilder builder() {
return new PreCreateIndustryOrderQueryBuilder();
}
public static final class PreCreateIndustryOrderQueryBuilder {
private List<IndustryOrderGoodsInfo> goods_list;
private Long total_amount;
private String phone_num;
private String contact_name;
private String extra;
private String pay_notify_url;
private String out_order_no;
private Long pay_expire_seconds;
private IndustryOrderOrderEntrySchema order_entry_schema;
private String cp_extra;
private Long discount_amount;
private String open_id;
private Integer tenantId;
private String clientKey;
private PreCreateIndustryOrderQueryBuilder() {
}
public PreCreateIndustryOrderQueryBuilder goodsList(List<IndustryOrderGoodsInfo> goodsList) {
this.goods_list = goodsList;
return this;
}
public PreCreateIndustryOrderQueryBuilder totalAmount(Long totalAmount) {
this.total_amount = totalAmount;
return this;
}
public PreCreateIndustryOrderQueryBuilder phoneNum(String phoneNum) {
this.phone_num = phoneNum;
return this;
}
public PreCreateIndustryOrderQueryBuilder contactName(String contactName) {
this.contact_name = contactName;
return this;
}
public PreCreateIndustryOrderQueryBuilder extra(String extra) {
this.extra = extra;
return this;
}
public PreCreateIndustryOrderQueryBuilder pay_notify_url(String pay_notify_url) {
this.pay_notify_url = pay_notify_url;
return this;
}
public PreCreateIndustryOrderQueryBuilder outOrderNo(String outOrderNo) {
this.out_order_no = outOrderNo;
return this;
}
public PreCreateIndustryOrderQueryBuilder payExpireSeconds(Long payExpireSeconds) {
this.pay_expire_seconds = payExpireSeconds;
return this;
}
public PreCreateIndustryOrderQueryBuilder orderEntrySchema(IndustryOrderOrderEntrySchema orderEntrySchema) {
this.order_entry_schema = orderEntrySchema;
return this;
}
public PreCreateIndustryOrderQueryBuilder cpExtra(String cpExtra) {
this.cp_extra = cpExtra;
return this;
}
public PreCreateIndustryOrderQueryBuilder discountAmount(Long discountAmount) {
this.discount_amount = discountAmount;
return this;
}
public PreCreateIndustryOrderQueryBuilder openId(String openId) {
this.open_id = openId;
return this;
}
public PreCreateIndustryOrderQueryBuilder tenantId(Integer tenantId) {
this.tenantId = tenantId;
return this;
}
public PreCreateIndustryOrderQueryBuilder clientKey(String clientKey) {
this.clientKey = clientKey;
return this;
}
public PreCreateIndustryOrderQuery build() {
PreCreateIndustryOrderQuery preCreateIndustryOrderQuery = new PreCreateIndustryOrderQuery();
preCreateIndustryOrderQuery.setGoods_list(goods_list);
preCreateIndustryOrderQuery.setTotal_amount(total_amount);
preCreateIndustryOrderQuery.setPhone_num(phone_num);
preCreateIndustryOrderQuery.setContact_name(contact_name);
preCreateIndustryOrderQuery.setExtra(extra);
preCreateIndustryOrderQuery.setPay_notify_url(pay_notify_url);
preCreateIndustryOrderQuery.setOut_order_no(out_order_no);
preCreateIndustryOrderQuery.setPay_expire_seconds(pay_expire_seconds);
preCreateIndustryOrderQuery.setOrder_entry_schema(order_entry_schema);
preCreateIndustryOrderQuery.setCp_extra(cp_extra);
preCreateIndustryOrderQuery.setDiscount_amount(discount_amount);
preCreateIndustryOrderQuery.setOpen_id(open_id);
preCreateIndustryOrderQuery.setTenantId(tenantId);
preCreateIndustryOrderQuery.setClientKey(clientKey);
return preCreateIndustryOrderQuery;
}
}
}

View File

@ -0,0 +1,83 @@
package com.dyj.applet.domain.vo;
import com.dyj.applet.domain.IndustryOrderItemOrderDetail;
import com.dyj.applet.domain.IndustryOrderItemOrderInfo;
import com.dyj.common.domain.vo.BaseVo;
import java.util.List;
/**
* 生活服务交易系统->预下单->开发者发起下单返回值
*/
public class PreCreateIndustryOrderVo extends BaseVo {
/**
* 抖音开平侧生成的订单号
*/
private String order_id;
/**
* 开发者系统生成的订单号
*/
private String out_order_no;
/**
* 调起收银台的支付订单号
*/
private String pay_order_id;
/**
* 调起收银台的 token
*/
private String pay_order_token;
/**
* 商品 item_order 信息
*/
private List<IndustryOrderItemOrderInfo> item_order_info_list;
public String getOrder_id() {
return order_id;
}
public PreCreateIndustryOrderVo setOrder_id(String order_id) {
this.order_id = order_id;
return this;
}
public String getOut_order_no() {
return out_order_no;
}
public PreCreateIndustryOrderVo setOut_order_no(String out_order_no) {
this.out_order_no = out_order_no;
return this;
}
public String getPay_order_id() {
return pay_order_id;
}
public PreCreateIndustryOrderVo setPay_order_id(String pay_order_id) {
this.pay_order_id = pay_order_id;
return this;
}
public String getPay_order_token() {
return pay_order_token;
}
public PreCreateIndustryOrderVo setPay_order_token(String pay_order_token) {
this.pay_order_token = pay_order_token;
return this;
}
public List<IndustryOrderItemOrderInfo> getItem_order_info_list() {
return item_order_info_list;
}
public PreCreateIndustryOrderVo setItem_order_info_list(List<IndustryOrderItemOrderInfo> item_order_info_list) {
this.item_order_info_list = item_order_info_list;
return this;
}
}

View File

@ -1,14 +1,19 @@
package com.dyj.applet.handler;
import com.dtflys.forest.annotation.JSONBody;
import com.dtflys.forest.annotation.Post;
import com.dyj.applet.domain.query.PreCreateIndustryOrderQuery;
import com.dyj.applet.domain.query.QueryIndustryOrderCpsQuery;
import com.dyj.applet.domain.query.QueryIndustryOrderQuery;
import com.dyj.applet.domain.query.QueryIndustryItemOrderInfoQuery;
import com.dyj.applet.domain.vo.PreCreateIndustryOrderVo;
import com.dyj.applet.domain.vo.QueryIndustryCpsVo;
import com.dyj.applet.domain.vo.QueryIndustryOrderVo;
import com.dyj.applet.domain.vo.QueryIndustryItemOrderInfoVo;
import com.dyj.common.config.AgentConfiguration;
import com.dyj.common.domain.DataAndExtraVo;
import com.dyj.common.domain.DySimpleResult;
import com.dyj.common.interceptor.ClientTokenInterceptor;
/**
* 交易系统 生活服务交易系统
@ -48,4 +53,15 @@ public class IndustryTransactionHandler extends AbstractAppletHandler{
baseQuery(body);
return getIndustryOpenTransactionClient().queryIndustryOrderCps(body);
}
/**
* 生活服务交易系统->预下单->开发者发起下单
* @param body
* @return
*/
public DySimpleResult<PreCreateIndustryOrderVo> preCreateIndustryOrder(PreCreateIndustryOrderQuery body){
baseQuery(body);
return getIndustryOpenTransactionClient().preCreateIndustryOrder(body);
}
}

View File

@ -480,6 +480,11 @@ public enum DyAppletUrlPathEnum {
* 生活服务交易系统->查询 CPS 信息
*/
QUERY_INDUSTRY_ORDER_CPS("queryIndustryOrderCps", "/api/apps/trade/v2/order/query_cps"),
/**
* 生活服务交易系统->预下单->开发者发起下单
*/
PRE_CREATE_INDUSTRY_ORDER("preCreateIndustryOrder", "/api/apps/trade/v2/order/create_order"),
;

View File

@ -388,4 +388,17 @@ public class TransactionTest {
);
}
/**
* 生活服务交易系统->预下单->开发者发起下单
*/
@Test
public void preCreateIndustryOrder(){
DyAppletClient dyAppletClient = new DyAppletClient();
System.out.println(
JSON.toJSONString(
dyAppletClient.preCreateIndustryOrder(PreCreateIndustryOrderQuery.builder().build())
)
);
}
}