|
|
|
@@ -271,6 +271,83 @@ public class WxOrderController extends BaseController { |
|
|
|
return new ResultData(wxOrderCVo); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("订单详情接口") |
|
|
|
@GetMapping("detail_v1") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true) |
|
|
|
}) |
|
|
|
public ResultData detail_v1(String orderId) { |
|
|
|
if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); |
|
|
|
} |
|
|
|
// c端用户应该只能看到自己的订单细节 |
|
|
|
WxOrder wxOrder = new WxOrder(); |
|
|
|
Long id = 0L; |
|
|
|
try { |
|
|
|
id = Long.valueOf(orderId); |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
logger.error("parse orderId failed"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "订单ID转换异常:"+orderId); |
|
|
|
} |
|
|
|
wxOrder.setId(id); |
|
|
|
Long memberId; |
|
|
|
try { |
|
|
|
memberId = getMemberId(); |
|
|
|
} catch (Exception e) { |
|
|
|
return new ResultData(Result.ERROR,e.getMessage()); |
|
|
|
} |
|
|
|
wxOrder.setCUserId(memberId); |
|
|
|
WxOrderCouponVo wxOrderCVo = wxOrderService.detailCUserVo(wxOrder); |
|
|
|
if (wxOrderCVo == null){ |
|
|
|
wxOrderCVo = new WxOrderCouponVo(); |
|
|
|
wxOrderCVo.setLevel(1); |
|
|
|
|
|
|
|
wxOrder.setComposeOrderId(wxOrder.getId()); |
|
|
|
wxOrder.setId(null); |
|
|
|
List<WxOrderCouponVo> wxOrders = wxOrderService.goodsDetailCUserVo(wxOrder); |
|
|
|
if(wxOrders != null && wxOrders.size() > 0){ |
|
|
|
wxOrderCVo.setOrderCouponVoList(wxOrders); |
|
|
|
|
|
|
|
WxOrderCouponVo wxOrderCouponVo = wxOrders.get(0); |
|
|
|
wxOrderCVo.setComposeOrderType(wxOrderCouponVo.getComposeOrderType()); |
|
|
|
wxOrderCVo.setComposeOrderId(wxOrderCouponVo.getCouponOrderId()); |
|
|
|
wxOrderCVo.setOrderStatus(wxOrderCouponVo.getOrderStatus()); |
|
|
|
wxOrderCVo.setCreateDate(wxOrderCouponVo.getCreateDate()); |
|
|
|
wxOrderCVo.setPayment(wxOrders.stream().mapToInt(o -> o.getPayment()).sum()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
wxOrderCVo.setLevel(0); |
|
|
|
Date now = new Date(); |
|
|
|
if (wxOrderCVo.getValidStartDate() != null && wxOrderCVo.getValidEndDate() != null |
|
|
|
&& !wxOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) { |
|
|
|
if (wxOrderCVo.getValidStartDate().getTime() > now.getTime()) { |
|
|
|
wxOrderCVo.setValidStatus(EnumCouponOrderValidStatus.PREPARED.getCode()); |
|
|
|
} else if (wxOrderCVo.getValidEndDate().getTime() < now.getTime()) { |
|
|
|
wxOrderCVo.setValidStatus(EnumCouponOrderValidStatus.ENDED.getCode()); |
|
|
|
} else { |
|
|
|
wxOrderCVo.setValidStatus(EnumCouponChannelActivityStatus.STARTED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(wxOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode()) |
|
|
|
&& wxOrderCVo.getPickStartDate() != null && wxOrderCVo.getPickEndDate() != null){ |
|
|
|
// wxOrderCVo.setValidStartDate(wxOrderCVo.getPickStartDate()); |
|
|
|
// wxOrderCVo.setValidEndDate(wxOrderCVo.getPickEndDate()); |
|
|
|
if (wxOrderCVo.getPickStartDate().getTime() > now.getTime()) { |
|
|
|
wxOrderCVo.setValidStatus(EnumCouponOrderValidStatus.PREPARED.getCode()); |
|
|
|
} else if (wxOrderCVo.getPickEndDate().getTime() < now.getTime()) { |
|
|
|
wxOrderCVo.setValidStatus(EnumCouponOrderValidStatus.ENDED.getCode()); |
|
|
|
} else { |
|
|
|
wxOrderCVo.setValidStatus(EnumCouponChannelActivityStatus.STARTED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(wxOrderCVo); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "根据orderId查询接口", notes = "{\"orderId\":\"string\"}") |
|
|
|
@GetMapping("/findById") |
|
|
|
@ApiImplicitParams({ |
|
|
|
|