行业交易系统->预下单->开发者发起下单

This commit is contained in:
353259576 2024-10-17 11:31:34 +08:00
parent 6b9230671b
commit c97a0e4287
12 changed files with 891 additions and 0 deletions

View File

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

View File

@ -234,4 +234,12 @@ public interface IndustryTransactionClient {
*/
@Post(value = "${queryTradeOrder}", interceptor = ClientTokenInterceptor.class)
DySimpleResult<QueryTradeOrderVo> queryTradeOrder(@JSONBody QueryTradeOrderQuery body);
/**
* 行业交易系统->预下单->开发者发起下单
* @param body 开发者发起下单
* @return
*/
@Post(value = "${createTradeOrder}", interceptor = ClientTokenInterceptor.class)
DySimpleResult<PreCreateIndustryOrderVo> createTradeOrder(@JSONBody CreateTradeOrderQuery body);
}

View File

@ -0,0 +1,197 @@
package com.dyj.applet.domain;
/**
* 商品信息
*/
public class TradeOrderGoodsInfo {
/**
* 商品图片链接长度 <= 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 TradeOrderGoodsInfo goods_book_info;
/**
* 开发者自定义收款商户号须申请白名单
* 选填
*/
private String merchant_uid;
public String getGoods_image() {
return goods_image;
}
public TradeOrderGoodsInfo setGoods_image(String goods_image) {
this.goods_image = goods_image;
return this;
}
public String getGoods_title() {
return goods_title;
}
public TradeOrderGoodsInfo setGoods_title(String goods_title) {
this.goods_title = goods_title;
return this;
}
public String getLabels() {
return labels;
}
public TradeOrderGoodsInfo setLabels(String labels) {
this.labels = labels;
return this;
}
public String getDate_rule() {
return date_rule;
}
public TradeOrderGoodsInfo setDate_rule(String date_rule) {
this.date_rule = date_rule;
return this;
}
public Long getPrice() {
return price;
}
public TradeOrderGoodsInfo setPrice(Long price) {
this.price = price;
return this;
}
public Integer getQuantity() {
return quantity;
}
public TradeOrderGoodsInfo setQuantity(Integer quantity) {
this.quantity = quantity;
return this;
}
public String getGoods_id() {
return goods_id;
}
public TradeOrderGoodsInfo setGoods_id(String goods_id) {
this.goods_id = goods_id;
return this;
}
public Integer getGoods_id_type() {
return goods_id_type;
}
public TradeOrderGoodsInfo setGoods_id_type(Integer goods_id_type) {
this.goods_id_type = goods_id_type;
return this;
}
public IndustryOrderGoodsPage getGoods_page() {
return goods_page;
}
public TradeOrderGoodsInfo setGoods_page(IndustryOrderGoodsPage goods_page) {
this.goods_page = goods_page;
return this;
}
public IndustryOrderValidTime getOrder_valid_time() {
return order_valid_time;
}
public TradeOrderGoodsInfo setOrder_valid_time(IndustryOrderValidTime order_valid_time) {
this.order_valid_time = order_valid_time;
return this;
}
public Long getDiscount_amount() {
return discount_amount;
}
public TradeOrderGoodsInfo setDiscount_amount(Long discount_amount) {
this.discount_amount = discount_amount;
return this;
}
public TradeOrderGoodsInfo getGoods_book_info() {
return goods_book_info;
}
public TradeOrderGoodsInfo setGoods_book_info(TradeOrderGoodsInfo goods_book_info) {
this.goods_book_info = goods_book_info;
return this;
}
public String getMerchant_uid() {
return merchant_uid;
}
public TradeOrderGoodsInfo setMerchant_uid(String merchant_uid) {
this.merchant_uid = merchant_uid;
return this;
}
}

View File

@ -0,0 +1,304 @@
package com.dyj.applet.domain.query;
import com.dyj.applet.domain.IndustryOrderOrderEntrySchema;
import com.dyj.applet.domain.TradeOrderGoodsInfo;
import com.dyj.applet.domain.vo.PriceCalculationDetail;
import com.dyj.common.domain.query.UserInfoQuery;
import java.util.List;
/**
* 行业交易系统->预下单->开发者发起下单
*/
public class CreateTradeOrderQuery extends UserInfoQuery {
/**
* 商品信息
*/
private List<TradeOrderGoodsInfo> 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;
/**
* 营销算价结果信息
* 选填
*/
private PriceCalculationDetail price_calculation_detail;
public List<TradeOrderGoodsInfo> getGoods_list() {
return goods_list;
}
public CreateTradeOrderQuery setGoods_list(List<TradeOrderGoodsInfo> goods_list) {
this.goods_list = goods_list;
return this;
}
public Long getTotal_amount() {
return total_amount;
}
public CreateTradeOrderQuery setTotal_amount(Long total_amount) {
this.total_amount = total_amount;
return this;
}
public String getPhone_num() {
return phone_num;
}
public CreateTradeOrderQuery setPhone_num(String phone_num) {
this.phone_num = phone_num;
return this;
}
public String getContact_name() {
return contact_name;
}
public CreateTradeOrderQuery setContact_name(String contact_name) {
this.contact_name = contact_name;
return this;
}
public String getExtra() {
return extra;
}
public CreateTradeOrderQuery setExtra(String extra) {
this.extra = extra;
return this;
}
public String getPay_notify_url() {
return pay_notify_url;
}
public CreateTradeOrderQuery 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 CreateTradeOrderQuery 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 CreateTradeOrderQuery 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 CreateTradeOrderQuery setOrder_entry_schema(IndustryOrderOrderEntrySchema order_entry_schema) {
this.order_entry_schema = order_entry_schema;
return this;
}
public String getCp_extra() {
return cp_extra;
}
public CreateTradeOrderQuery setCp_extra(String cp_extra) {
this.cp_extra = cp_extra;
return this;
}
public Long getDiscount_amount() {
return discount_amount;
}
public CreateTradeOrderQuery setDiscount_amount(Long discount_amount) {
this.discount_amount = discount_amount;
return this;
}
public PriceCalculationDetail getPrice_calculation_detail() {
return price_calculation_detail;
}
public CreateTradeOrderQuery setPrice_calculation_detail(PriceCalculationDetail price_calculation_detail) {
this.price_calculation_detail = price_calculation_detail;
return this;
}
public static CreateTradeOrderQueryBuilder builder() {
return new CreateTradeOrderQueryBuilder();
}
public static final class CreateTradeOrderQueryBuilder {
private List<TradeOrderGoodsInfo> 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 PriceCalculationDetail price_calculation_detail;
private String open_id;
private Integer tenantId;
private String clientKey;
private CreateTradeOrderQueryBuilder() {
}
public CreateTradeOrderQueryBuilder goodsList(List<TradeOrderGoodsInfo> goodsList) {
this.goods_list = goodsList;
return this;
}
public CreateTradeOrderQueryBuilder totalAmount(Long totalAmount) {
this.total_amount = totalAmount;
return this;
}
public CreateTradeOrderQueryBuilder phoneNum(String phoneNum) {
this.phone_num = phoneNum;
return this;
}
public CreateTradeOrderQueryBuilder contactName(String contactName) {
this.contact_name = contactName;
return this;
}
public CreateTradeOrderQueryBuilder extra(String extra) {
this.extra = extra;
return this;
}
public CreateTradeOrderQueryBuilder payNotifyUrl(String payNotifyUrl) {
this.pay_notify_url = payNotifyUrl;
return this;
}
public CreateTradeOrderQueryBuilder outOrderNo(String outOrderNo) {
this.out_order_no = outOrderNo;
return this;
}
public CreateTradeOrderQueryBuilder payExpireSeconds(Long payExpireSeconds) {
this.pay_expire_seconds = payExpireSeconds;
return this;
}
public CreateTradeOrderQueryBuilder orderEntrySchema(IndustryOrderOrderEntrySchema orderEntrySchema) {
this.order_entry_schema = orderEntrySchema;
return this;
}
public CreateTradeOrderQueryBuilder cpExtra(String cpExtra) {
this.cp_extra = cpExtra;
return this;
}
public CreateTradeOrderQueryBuilder discountAmount(Long discountAmount) {
this.discount_amount = discountAmount;
return this;
}
public CreateTradeOrderQueryBuilder priceCalculationDetail(PriceCalculationDetail priceCalculationDetail) {
this.price_calculation_detail = priceCalculationDetail;
return this;
}
public CreateTradeOrderQueryBuilder openId(String openId) {
this.open_id = openId;
return this;
}
public CreateTradeOrderQueryBuilder tenantId(Integer tenantId) {
this.tenantId = tenantId;
return this;
}
public CreateTradeOrderQueryBuilder clientKey(String clientKey) {
this.clientKey = clientKey;
return this;
}
public CreateTradeOrderQuery build() {
CreateTradeOrderQuery createTradeOrderQuery = new CreateTradeOrderQuery();
createTradeOrderQuery.setGoods_list(goods_list);
createTradeOrderQuery.setTotal_amount(total_amount);
createTradeOrderQuery.setPhone_num(phone_num);
createTradeOrderQuery.setContact_name(contact_name);
createTradeOrderQuery.setExtra(extra);
createTradeOrderQuery.setPay_notify_url(pay_notify_url);
createTradeOrderQuery.setOut_order_no(out_order_no);
createTradeOrderQuery.setPay_expire_seconds(pay_expire_seconds);
createTradeOrderQuery.setOrder_entry_schema(order_entry_schema);
createTradeOrderQuery.setCp_extra(cp_extra);
createTradeOrderQuery.setDiscount_amount(discount_amount);
createTradeOrderQuery.setPrice_calculation_detail(price_calculation_detail);
createTradeOrderQuery.setOpen_id(open_id);
createTradeOrderQuery.setTenantId(tenantId);
createTradeOrderQuery.setClientKey(clientKey);
return createTradeOrderQuery;
}
}
}

View File

@ -0,0 +1,77 @@
package com.dyj.applet.domain.vo;
import java.util.List;
public class GoodsDiscountDetail {
/**
* 商品 id此处为课程 id注意这里是 string 类型
*/
private String goods_id;
/**
* 购买数量
*/
private Integer quantity;
/**
* 商品总价单位分
*/
private Integer total_amount;
/**
* 该商品总优惠金额该商品的实付金额 = total_amount - total_discount_amount
*/
private Integer total_discount_amount;
/**
* 营销明细
* 选填
*/
private List<MarketingDetailInfo> marketing_detail_info;
public String getGoods_id() {
return goods_id;
}
public GoodsDiscountDetail setGoods_id(String goods_id) {
this.goods_id = goods_id;
return this;
}
public Integer getQuantity() {
return quantity;
}
public GoodsDiscountDetail setQuantity(Integer quantity) {
this.quantity = quantity;
return this;
}
public Integer getTotal_amount() {
return total_amount;
}
public GoodsDiscountDetail setTotal_amount(Integer total_amount) {
this.total_amount = total_amount;
return this;
}
public Integer getTotal_discount_amount() {
return total_discount_amount;
}
public GoodsDiscountDetail setTotal_discount_amount(Integer total_discount_amount) {
this.total_discount_amount = total_discount_amount;
return this;
}
public List<MarketingDetailInfo> getMarketing_detail_info() {
return marketing_detail_info;
}
public GoodsDiscountDetail setMarketing_detail_info(List<MarketingDetailInfo> marketing_detail_info) {
this.marketing_detail_info = marketing_detail_info;
return this;
}
}

View File

@ -0,0 +1,64 @@
package com.dyj.applet.domain.vo;
import java.util.List;
public class ItemDiscountDetail {
/**
* 商品 id
*/
private String goods_id;
/**
* 商品总价单位分
*/
private Integer total_amount;
/**
* 该商品总优惠金额
* 该商品的实付金额 = total_amount - total_discount_amount
*/
private Integer total_discount_amount;
/**
* 营销明细
* 选填
*/
private List<MarketingDetailInfo> marketing_detail_info;
public String getGoods_id() {
return goods_id;
}
public ItemDiscountDetail setGoods_id(String goods_id) {
this.goods_id = goods_id;
return this;
}
public Integer getTotal_amount() {
return total_amount;
}
public ItemDiscountDetail setTotal_amount(Integer total_amount) {
this.total_amount = total_amount;
return this;
}
public Integer getTotal_discount_amount() {
return total_discount_amount;
}
public ItemDiscountDetail setTotal_discount_amount(Integer total_discount_amount) {
this.total_discount_amount = total_discount_amount;
return this;
}
public List<MarketingDetailInfo> getMarketing_detail_info() {
return marketing_detail_info;
}
public ItemDiscountDetail setMarketing_detail_info(List<MarketingDetailInfo> marketing_detail_info) {
this.marketing_detail_info = marketing_detail_info;
return this;
}
}

View File

@ -0,0 +1,121 @@
package com.dyj.applet.domain.vo;
public class MarketingDetailInfo {
/**
* 营销 id用户身份 id优惠券 id积分 id 或者活动 id
*/
private String id;
/**
* 营销类型:
* 1用户身份
* 2优惠券
* 3: 积分
* 4活动
*/
private Integer type;
/**
* 该营销策略优惠金额单位分
*/
private Integer discount_amount;
/**
* 营销名称
*/
private String title;
/**
* 营销备注
* 选填
*/
private String note;
/**
* 优惠范围
*/
private Integer discount_range;
/**
* 营销子类型
*/
private String subtype;
/**
* 不同 type 含义不同 type = 3value 则为积分值
*/
private Long value;
public String getId() {
return id;
}
public MarketingDetailInfo setId(String id) {
this.id = id;
return this;
}
public Integer getType() {
return type;
}
public MarketingDetailInfo setType(Integer type) {
this.type = type;
return this;
}
public Integer getDiscount_amount() {
return discount_amount;
}
public MarketingDetailInfo setDiscount_amount(Integer discount_amount) {
this.discount_amount = discount_amount;
return this;
}
public String getTitle() {
return title;
}
public MarketingDetailInfo setTitle(String title) {
this.title = title;
return this;
}
public String getNote() {
return note;
}
public MarketingDetailInfo setNote(String note) {
this.note = note;
return this;
}
public Integer getDiscount_range() {
return discount_range;
}
public MarketingDetailInfo setDiscount_range(Integer discount_range) {
this.discount_range = discount_range;
return this;
}
public String getSubtype() {
return subtype;
}
public MarketingDetailInfo setSubtype(String subtype) {
this.subtype = subtype;
return this;
}
public Long getValue() {
return value;
}
public MarketingDetailInfo setValue(Long value) {
this.value = value;
return this;
}
}

View File

@ -0,0 +1,49 @@
package com.dyj.applet.domain.vo;
import java.util.List;
public class OrderDiscountDetail {
/**
* 订单维度总优惠金额单位分
*/
private Integer order_total_discount_amount;
/**
* 商品SKU维度总优惠金额单位分
*/
private Integer goods_total_discount_amount;
/**
* 营销明细
* 选填
*/
private List<ItemDiscountDetail> marketing_detail_info;
public Integer getOrder_total_discount_amount() {
return order_total_discount_amount;
}
public OrderDiscountDetail setOrder_total_discount_amount(Integer order_total_discount_amount) {
this.order_total_discount_amount = order_total_discount_amount;
return this;
}
public Integer getGoods_total_discount_amount() {
return goods_total_discount_amount;
}
public OrderDiscountDetail setGoods_total_discount_amount(Integer goods_total_discount_amount) {
this.goods_total_discount_amount = goods_total_discount_amount;
return this;
}
public List<ItemDiscountDetail> getMarketing_detail_info() {
return marketing_detail_info;
}
public OrderDiscountDetail setMarketing_detail_info(List<ItemDiscountDetail> marketing_detail_info) {
this.marketing_detail_info = marketing_detail_info;
return this;
}
}

View File

@ -0,0 +1,32 @@
package com.dyj.applet.domain.vo;
import java.util.List;
public class PriceCalculationDetail {
/**
* 算价类型
* 1商户单维度item 单价格按分摊比例计算
* 2item 单维度item 单价格由开发者计算
*/
private Integer calculation_type;
/**
* 商品算价结果
* 选填
*/
private List<GoodsDiscountDetail> goods_discount_detail;
/**
* 订单算价结果
* 选填
*/
private OrderDiscountDetail order_discount_detail;
/**
* 单商品算价结果
* 选填
*/
private List<ItemDiscountDetail> item_discount_detail;
}

View File

@ -294,4 +294,15 @@ public class IndustryTransactionHandler extends AbstractAppletHandler{
baseQuery(body);
return getIndustryOpenTransactionClient().queryTradeOrder(body);
}
/**
* 行业交易系统->预下单->开发者发起下单
* @param body 开发者发起下单
* @return
*/
public DySimpleResult<PreCreateIndustryOrderVo> createTradeOrder(CreateTradeOrderQuery body) {
baseQuery(body);
return getIndustryOpenTransactionClient().createTradeOrder(body);
}
}

View File

@ -606,6 +606,12 @@ public enum DyAppletUrlPathEnum {
* 行业交易系统->预下单->查询订单信息
*/
QUERY_TRADE_ORDER("queryTradeOrder","/api/apps/trade/v2/query_order"),
/**
* https://developer.toutiao.com
* 行业交易系统->预下单->开发者发起下单
*/
CREATE_TRADE_ORDER("createTradeOrder","/api/apps/trade/v2/create_order"),
;

View File

@ -713,4 +713,17 @@ public class TransactionTest {
)
);
}
/**
* 行业交易系统->预下单->开发者发起下单
*/
@Test
public void createTradeOrder(){
DyAppletClient dyAppletClient = new DyAppletClient();
System.out.println(
JSON.toJSONString(
dyAppletClient.createTradeOrder(CreateTradeOrderQuery.builder().build())
)
);
}
}