|
| 1 | +package me.chanjar.weixin.channel.api.impl; |
| 2 | + |
| 3 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.ADD_SUB_ORDER_URL; |
| 4 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.BATCH_PRINT_ORDER_URL; |
| 5 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.CANCEL_ORDER_URL; |
| 6 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.CREATE_ORDER_URL; |
| 7 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.CREATE_TEMPLATE_URL; |
| 8 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.DELETE_TEMPLATE_URL; |
| 9 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_ACCOUNT_URL; |
| 10 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_DELIVERY_LIST_URL; |
| 11 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_ORDER_URL; |
| 12 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_PRINT_CONTENT_URL; |
| 13 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_TEMPLATE_BY_ID_URL; |
| 14 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_TEMPLATE_CONFIG_URL; |
| 15 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.GET_TEMPLATE_URL; |
| 16 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.PRE_CREATE_ORDER_URL; |
| 17 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.PRINT_ORDER_URL; |
| 18 | +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Ewaybill.UPDATE_TEMPLATE_URL; |
| 19 | + |
| 20 | +import java.util.List; |
| 21 | +import me.chanjar.weixin.channel.api.WxChannelEwaybillService; |
| 22 | +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; |
| 23 | +import me.chanjar.weixin.channel.bean.ewaybill.AccountInfoResponse; |
| 24 | +import me.chanjar.weixin.channel.bean.ewaybill.AddSubOrderRequest; |
| 25 | +import me.chanjar.weixin.channel.bean.ewaybill.CreateOrderRequest; |
| 26 | +import me.chanjar.weixin.channel.bean.ewaybill.CreateOrderResponse; |
| 27 | +import me.chanjar.weixin.channel.bean.ewaybill.DeliveryListResponse; |
| 28 | +import me.chanjar.weixin.channel.bean.ewaybill.OrderDetailResponse; |
| 29 | +import me.chanjar.weixin.channel.bean.ewaybill.PreCreateRequest; |
| 30 | +import me.chanjar.weixin.channel.bean.ewaybill.PreCreateResponse; |
| 31 | +import me.chanjar.weixin.channel.bean.ewaybill.PrintContentResponse; |
| 32 | +import me.chanjar.weixin.channel.bean.ewaybill.TemplateConfigResponse; |
| 33 | +import me.chanjar.weixin.channel.bean.ewaybill.TemplateCreateRequest; |
| 34 | +import me.chanjar.weixin.channel.bean.ewaybill.TemplateIdParam; |
| 35 | +import me.chanjar.weixin.channel.bean.ewaybill.TemplateIdResponse; |
| 36 | +import me.chanjar.weixin.channel.bean.ewaybill.TemplateInfoResponse; |
| 37 | +import me.chanjar.weixin.channel.bean.ewaybill.TemplateUpdateRequest; |
| 38 | +import me.chanjar.weixin.channel.bean.ewaybill.WaybillIdParam; |
| 39 | +import me.chanjar.weixin.channel.bean.ewaybill.WaybillIdsParam; |
| 40 | +import me.chanjar.weixin.channel.util.ResponseUtils; |
| 41 | +import me.chanjar.weixin.common.error.WxErrorException; |
| 42 | + |
| 43 | +/** |
| 44 | + * 视频号小店电子面单服务实现。 |
| 45 | + * |
| 46 | + * @author GitHub Copilot |
| 47 | + */ |
| 48 | +public class WxChannelEwaybillServiceImpl implements WxChannelEwaybillService { |
| 49 | + |
| 50 | + /** 微信商店服务 */ |
| 51 | + private final BaseWxChannelServiceImpl<?, ?> shopService; |
| 52 | + |
| 53 | + public WxChannelEwaybillServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) { |
| 54 | + this.shopService = shopService; |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public TemplateConfigResponse getTemplateConfig() throws WxErrorException { |
| 59 | + String resJson = shopService.post(GET_TEMPLATE_CONFIG_URL, "{}"); |
| 60 | + return ResponseUtils.decode(resJson, TemplateConfigResponse.class); |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + public TemplateIdResponse createTemplate(TemplateCreateRequest req) throws WxErrorException { |
| 65 | + String resJson = shopService.post(CREATE_TEMPLATE_URL, req); |
| 66 | + return ResponseUtils.decode(resJson, TemplateIdResponse.class); |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public WxChannelBaseResponse deleteTemplate(String templateId) throws WxErrorException { |
| 71 | + String resJson = shopService.post(DELETE_TEMPLATE_URL, new TemplateIdParam(templateId)); |
| 72 | + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public WxChannelBaseResponse updateTemplate(TemplateUpdateRequest req) throws WxErrorException { |
| 77 | + String resJson = shopService.post(UPDATE_TEMPLATE_URL, req); |
| 78 | + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + public TemplateInfoResponse getTemplate(String templateId) throws WxErrorException { |
| 83 | + String resJson = shopService.post(GET_TEMPLATE_URL, new TemplateIdParam(templateId)); |
| 84 | + return ResponseUtils.decode(resJson, TemplateInfoResponse.class); |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public TemplateInfoResponse getTemplateById(String templateId) throws WxErrorException { |
| 89 | + String resJson = shopService.post(GET_TEMPLATE_BY_ID_URL, new TemplateIdParam(templateId)); |
| 90 | + return ResponseUtils.decode(resJson, TemplateInfoResponse.class); |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + public AccountInfoResponse getAccount() throws WxErrorException { |
| 95 | + String resJson = shopService.post(GET_ACCOUNT_URL, "{}"); |
| 96 | + return ResponseUtils.decode(resJson, AccountInfoResponse.class); |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public DeliveryListResponse getDeliveryList() throws WxErrorException { |
| 101 | + String resJson = shopService.post(GET_DELIVERY_LIST_URL, "{}"); |
| 102 | + return ResponseUtils.decode(resJson, DeliveryListResponse.class); |
| 103 | + } |
| 104 | + |
| 105 | + @Override |
| 106 | + public PreCreateResponse preCreateOrder(PreCreateRequest req) throws WxErrorException { |
| 107 | + String resJson = shopService.post(PRE_CREATE_ORDER_URL, req); |
| 108 | + return ResponseUtils.decode(resJson, PreCreateResponse.class); |
| 109 | + } |
| 110 | + |
| 111 | + @Override |
| 112 | + public CreateOrderResponse createOrder(CreateOrderRequest req) throws WxErrorException { |
| 113 | + String resJson = shopService.post(CREATE_ORDER_URL, req); |
| 114 | + return ResponseUtils.decode(resJson, CreateOrderResponse.class); |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public WxChannelBaseResponse addSubOrder(AddSubOrderRequest req) throws WxErrorException { |
| 119 | + String resJson = shopService.post(ADD_SUB_ORDER_URL, req); |
| 120 | + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + public WxChannelBaseResponse cancelOrder(String waybillId) throws WxErrorException { |
| 125 | + String resJson = shopService.post(CANCEL_ORDER_URL, new WaybillIdParam(waybillId)); |
| 126 | + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| 127 | + } |
| 128 | + |
| 129 | + @Override |
| 130 | + public OrderDetailResponse getOrder(String waybillId) throws WxErrorException { |
| 131 | + String resJson = shopService.post(GET_ORDER_URL, new WaybillIdParam(waybillId)); |
| 132 | + return ResponseUtils.decode(resJson, OrderDetailResponse.class); |
| 133 | + } |
| 134 | + |
| 135 | + @Override |
| 136 | + public PrintContentResponse getPrintContent(String waybillId) throws WxErrorException { |
| 137 | + String resJson = shopService.post(GET_PRINT_CONTENT_URL, new WaybillIdParam(waybillId)); |
| 138 | + return ResponseUtils.decode(resJson, PrintContentResponse.class); |
| 139 | + } |
| 140 | + |
| 141 | + @Override |
| 142 | + public WxChannelBaseResponse printOrder(String waybillId) throws WxErrorException { |
| 143 | + String resJson = shopService.post(PRINT_ORDER_URL, new WaybillIdParam(waybillId)); |
| 144 | + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public WxChannelBaseResponse batchPrintOrder(List<String> waybillIds) throws WxErrorException { |
| 149 | + String resJson = shopService.post(BATCH_PRINT_ORDER_URL, new WaybillIdsParam(waybillIds)); |
| 150 | + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); |
| 151 | + } |
| 152 | +} |
0 commit comments