package com.stylefeng.guns.modular.smallLogistics.controller; import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; import com.stylefeng.guns.modular.system.model.Region; import com.stylefeng.guns.modular.system.service.IUserInfoService; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; 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.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.List; import java.util.Map; /** * 小件物流控制器 */ @Api @RestController @RequestMapping("") public class OrderLogisticsController { @Autowired private IOrderLogisticsService orderLogisticsService; @Autowired private IUserInfoService userInfoService; /** * 根据起点和终点坐标判断是不是同一个市内 * @param startLonLat * @param endAddress * @return */ @ResponseBody @PostMapping("/base/orderLogistics/judgingTheCity") @ApiOperation(value = "根据起点和终点坐标判断是不是同一个市内", tags = {"用户端-小件物流"}, notes = "只有在选择了同城小件物流的时候调用") @ApiImplicitParams({ @ApiImplicitParam(value = "起点经纬度(103.23265,30.2312)", name = "startLonLat", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "终点详细地址", name = "endAddress", required = true, paramType = "query", dataType = "string") }) public ResultUtil judgingTheCity(String startLonLat, String endAddress){ try { return orderLogisticsService.judgingTheCity(startLonLat, endAddress); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/orderLogistics/queryLogisticsUnitPrice") @ApiOperation(value = "获取小件物流的单价数据", tags = {"用户端-小件物流"}, notes = "ordinary(普通物品),precious(贵重物品),first=0(首次下单)") @ApiImplicitParams({ @ApiImplicitParam(value = "业务类型(4=同城小件物流,5=跨城小件物流)", name = "type", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "起点经纬度(103.23265,30.2312)", name = "startLonLat", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "终点详细地址", name = "endAddress", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryLogisticsUnitPrice(Integer type, String startLonLat, String endAddress, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return orderLogisticsService.queryLogisticsUnitPrice(type, startLonLat, endAddress, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/base/orderLogistics/queryPayMoney") @ApiOperation(value = "获取支付金额", tags = {"用户端-小件物流"}, notes = "ordinary(普通物品),precious(贵重物品)") @ApiImplicitParams({ @ApiImplicitParam(value = "货物数量", name = "number", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "业务类型(4=同城小件物流,5=跨城小件物流)", name = "type", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "起点经纬度(103.23265,30.2312)", name = "startLonLat", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "终点详细地址", name = "endAddress", required = true, paramType = "query", dataType = "string") }) public ResultUtil queryPayMoney(Integer number, Integer type, String startLonLat, String endAddress){ try { return orderLogisticsService.queryPayMoney(number, type, startLonLat, endAddress); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 小件物流下单操作 * @param type * @param cargoType * @param cargoNumber * @param remark * @param placementLon * @param placementLat * @param startLon * @param startLat * @param startAddress * @param recipient * @param recipientPhone * @param endAddress * @param travelTime * @param orderSource * @param request * @return */ @ResponseBody @PostMapping("/api/orderLogistics/smallLogistics") @ApiOperation(value = "小件物流下单操作(同城/跨城)", tags = {"用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "业务类型(4=同城小件物流,5=跨城小件物流)", name = "type", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "货物类型(1=普通货物,2=贵重货物)", name = "cargoType", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "货物数量", name = "cargoNumber", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "备注", name = "remark", required = false, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "下单点经度(103.23265,30.2312)", name = "placementLon", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "下单点纬度(103.23265,30.2312)", name = "placementLat", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "预约取货点经度(103.23265,30.2312)", name = "startLon", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "预约取货点纬度(103.23265,30.2312)", name = "startLat", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "预约取货点详细地址", name = "startAddress", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "收货人姓名", name = "recipient", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "收货人电话", name = "recipientPhone", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "收货详细地址", name = "endAddress", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "是否加急(1=否,2=是)", name = "urgent", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(value = "加急费用", name = "tipMoney", required = true, paramType = "query", dataType = "double"), @ApiImplicitParam(value = "预约收货时间(2020-09-17 21:00:00)", name = "travelTime", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(value = "下单方式(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)", name = "orderSource", required = true, paramType = "query", dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil smallLogistics(Integer type, Integer cargoType, Integer cargoNumber, String remark, String placementLon, String placementLat, String startLon, String startLat, String startAddress, String recipient, String recipientPhone, String endAddress, Integer urgent, Double tipMoney, Date travelTime, Integer orderSource, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return orderLogisticsService.smallLogistics(type, cargoType, cargoNumber, remark, placementLon, placementLat, startLon, startLat, startAddress, recipient, recipientPhone, endAddress, urgent, tipMoney, travelTime, orderSource, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/orderLogistics/queryLogisticsNumber") @ApiOperation(value = "获取首页小件物流订单数量", tags = {"用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryLogisticsNumber(HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } int i = orderLogisticsService.queryLogisticsNumber(uid); BaseWarpper baseWarppe = new BaseWarpper(); baseWarppe.setNumber(i); return ResultUtil.success(baseWarppe); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } @ResponseBody @PostMapping("/api/orderLogistics/payOrderLogisticsSpread") @ApiOperation(value = "小件物流补差价支付", tags = {"用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = true, dataType = "int"), @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil payOrderLogisticsSpread(Integer orderId, Integer payType, Integer type, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return orderLogisticsService.payLogisticsOrder_(payType, orderId, type); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 获取行政区域数据(小程序) * @return */ @ResponseBody @PostMapping("/api/orderLogistics/queryRegion") public Map queryRegion(){ try { Map map = orderLogisticsService.queryRegion(); return map; }catch (Exception e){ e.printStackTrace(); } return null; } @ResponseBody @PostMapping("/base/orderLogistics/queryRegions") @ApiOperation(value = "获取行政区域三级联动数据", tags = {"用户端-小件物流"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "上级id。第一层传0", name = "parentId", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil queryRegions(Integer parentId){ try { List regions = orderLogisticsService.queryRegions(parentId); return ResultUtil.success(regions); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }