| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.ZonedDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | public class WxDeliveryGoodService { |
| | | |
| | | public JSONObject wxDeliveryGood(String orderId, String openid, String transactionId, |
| | | String itemDesc, String merchantId,String accessToken) throws Exception { |
| | | String itemDesc, String merchantId,String accessToken, Long partnerID,String deliveryNo) throws Exception { |
| | | String requestPath = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token="+accessToken; |
| | | Map<String, Object> headers = new HashMap<>(); |
| | | headers.put("Accept", MediaType.APPLICATION_JSON.getValue()); |
| | |
| | | orderKey.put("mchid",merchantId);//支付下单商户的商户号,由微信支付生成并下发。 |
| | | orderKey.put("out_trade_no",orderId);//商户系统内部订单号 |
| | | body.put("order_key",orderKey); |
| | | body.put("logistics_type",4);//物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 |
| | | body.put("delivery_mode",1);//发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) 示例值: UNIFIED_DELIVERY |
| | | if (StringUtils.isEmpty(partnerID) && !StringUtils.isEmpty(deliveryNo)) { |
| | | // 如果是散户的情况下保存订单号 |
| | | body.put("logistics_type", 1);//物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 |
| | | } else { |
| | | body.put("logistics_type", 2);//物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 |
| | | } |
| | | |
| | | |
| | | |
| | | //商品信息 |
| | | List<Map<String,Object>> shippingList = new ArrayList<>(); |
| | | Map<String,Object> itemMap = new HashMap<>(); |
| | | itemMap.put("item_desc",itemDesc);//商品描述 |
| | | if (StringUtils.isEmpty(partnerID) && !StringUtils.isEmpty(deliveryNo)) { |
| | | itemMap.put("tracking_no", deliveryNo);//物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128] |
| | | } |
| | | shippingList.add(itemMap); |
| | | body.put("shipping_list",shippingList); |
| | | |