1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| package club.zby.express.Controller;
import club.zby.express.Config.Result; import club.zby.express.Config.StatusCode; import club.zby.express.Entity.Express; import club.zby.express.Untlis.ExpressUntlis; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;
import java.util.HashMap; import java.util.Map;
@RestController @RequestMapping(value = "Express") @Api(value = "物流追踪接口") public class ExpressController {
@Autowired private ExpressUntlis expressUntlis; @Autowired private Express express;
@ApiOperation(value = "根据物流单号和快递公司编码查询物流信息", notes = "根据物流单号和快递公司编码查询物流信息", httpMethod = "GET") @ApiImplicitParams({ @ApiImplicitParam(paramType="query",name = "shipChannel",required = true, value = "快递公司编码",dataType = "String"), @ApiImplicitParam(paramType="query",name = "shipSn",required = true, value = "物流单号", dataType = "String" ) }) @ResponseBody @GetMapping("getOrderTracesByJson") public Result getOrderTracesByJson(@RequestParam("shipChannel") String shipChannel, @RequestParam("shipSn") String shipSn) throws Exception{ String requestData= "{'OrderCode':'','ShipperCode':'" + shipChannel + "','LogisticCode':'" + shipSn + "'}"; System.out.println("请求报文:" + requestData); Map<String, String> params = new HashMap<String, String>(); params.put("RequestData", expressUntlis.urlEncoder(requestData, "UTF-8")); params.put("EBusinessID", express.getEBusinessID()); params.put("RequestType", "1002"); String dataSign=expressUntlis.encrypt(requestData, express.getAppKey(), "UTF-8"); params.put("DataSign", expressUntlis.urlEncoder(dataSign, "UTF-8")); params.put("DataType", "2");
String result=expressUntlis.sendPost(express.getReqURL(), params); System.out.println("返回报文:" + result); return new Result(true, StatusCode.OK,"查询结果集",result); }
@ApiOperation(value = "根据物流单号查询快递公司编码", notes = "根据物流单号查询快递公司编码", httpMethod = "GET") @ApiImplicitParams({ @ApiImplicitParam(paramType="query",name = "shipSn",required = true, value = "物流单号", dataType = "String" ) }) @ResponseBody @GetMapping("/getOrderShipperCode") public Result getOrderShipperCode(@RequestParam("shipSn") String shipSn) throws Exception{ String requestData= "{'LogisticCode':'" + shipSn + "'}"; System.out.println("请求报文:" + requestData); Map<String, String> params = new HashMap<String, String>(); params.put("RequestData", expressUntlis.urlEncoder(requestData, "UTF-8")); params.put("EBusinessID", express.getEBusinessID()); params.put("RequestType", "2002"); String dataSign=expressUntlis.encrypt(requestData, express.getAppKey(), "UTF-8"); params.put("DataSign", expressUntlis.urlEncoder(dataSign, "UTF-8")); params.put("DataType", "2");
String result=expressUntlis.sendPost(express.getReqURL(), params); return new Result(true, StatusCode.OK,"查询结果集",result); } }
|