用户系统---取消预约订单操作
作者:互联网
1.未支付情况下取消订单,直接通知医院取消预约
2.已支付情况下取消订单,先退款给用户,然后通知医院取消订单
步骤
(1)下载证书
(2)在application.properties中配置证书
weixin.cert=C:\\Users\\lenovo\\Desktop\\0621\\yygh_parent\\service\\service_order\\src\\main\\resources\\cert\\apiclient_cert.p12
(3)根据支付记录发起退款,添加获取支付记录的接口
controller 层:
//取消预约 @GetMapping("auth/cancelOrder/{orderId}") public Result cancelOrder(@PathVariable Long orderId) { Boolean isOrder = orderService.cancelOrder(orderId); return Result.ok(isOrder); }
service 层
//取消预约 @Override public Boolean cancelOrder(Long orderId) { //获取订单信息 OrderInfo orderInfo = baseMapper.selectById(orderId); //判断是否取消 DateTime quitTime = new DateTime(orderInfo.getQuitTime()); if(quitTime.isBeforeNow()) { throw new YyghException(ResultCodeEnum.CANCEL_ORDER_NO); } //调用医院接口实现预约取消 SignInfoVo signInfoVo = hospitalFeignClient.getSignInfoVo(orderInfo.getHoscode()); if(null == signInfoVo) { throw new YyghException(ResultCodeEnum.PARAM_ERROR); } Map<String, Object> reqMap = new HashMap<>(); reqMap.put("hoscode",orderInfo.getHoscode()); reqMap.put("hosRecordId",orderInfo.getHosRecordId()); reqMap.put("timestamp", HttpRequestHelper.getTimestamp()); String sign = HttpRequestHelper.getSign(reqMap, signInfoVo.getSignKey()); reqMap.put("sign", sign); JSONObject result = HttpRequestHelper.sendRequest(reqMap, signInfoVo.getApiUrl()+"/order/updateCancelStatus"); //根据医院接口返回数据 if(result.getInteger("code")!=200) { throw new YyghException(result.getString("message"), ResultCodeEnum.FAIL.getCode()); } else { //判断当前订单是否可以取消 if(orderInfo.getOrderStatus().intValue() == OrderStatusEnum.PAID.getStatus().intValue()) { Boolean isRefund = weixinService.refund(orderId); if(!isRefund) { throw new YyghException(ResultCodeEnum.CANCEL_ORDER_FAIL); } //更新订单状态 orderInfo.setOrderStatus(OrderStatusEnum.CANCLE.getStatus()); baseMapper.updateById(orderInfo); //发送mq更新预约数量 OrderMqVo orderMqVo = new OrderMqVo(); orderMqVo.setScheduleId(orderInfo.getScheduleId()); //短信提示 MsmVo msmVo = new MsmVo(); msmVo.setPhone(orderInfo.getPatientPhone()); String reserveDate = new DateTime(orderInfo.getReserveDate()).toString("yyyy-MM-dd") + (orderInfo.getReserveTime()==0 ? "上午": "下午"); Map<String,Object> param = new HashMap<String,Object>(){{ put("title", orderInfo.getHosname()+"|"+orderInfo.getDepname()+"|"+orderInfo.getTitle()); put("reserveDate", reserveDate); put("name", orderInfo.getPatientName()); }}; msmVo.setParam(param); orderMqVo.setMsmVo(msmVo); rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_ORDER, MqConst.ROUTING_ORDER, orderMqVo); } } return true; }
标签:orderId,orderInfo,预约,reqMap,---,订单,取消,put,new 来源: https://www.cnblogs.com/Leeyoung888/p/16096514.html