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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| public Long saveOrder(String scheduleId, Long patientId) { Patient patient = patientFeignClient.getPatientOrder(patientId);
ScheduleOrderVo scheduleOrderVo = hospitalFeignClient.getScheduleOrderVo(scheduleId);
if(new DateTime(scheduleOrderVo.getStartTime()).isAfterNow() || new DateTime(scheduleOrderVo.getEndTime()).isBeforeNow()) { throw new YyghException(ResultCodeEnum.TIME_NO); }
SignInfoVo signInfoVo = hospitalFeignClient.getSignInfoVo(scheduleOrderVo.getHoscode());
OrderInfo orderInfo = new OrderInfo(); BeanUtils.copyProperties(scheduleOrderVo,orderInfo); String outTradeNo = System.currentTimeMillis() + ""+ new Random().nextInt(100); orderInfo.setOutTradeNo(outTradeNo); orderInfo.setScheduleId(scheduleId); orderInfo.setUserId(patient.getUserId()); orderInfo.setPatientId(patientId); orderInfo.setPatientName(patient.getName()); orderInfo.setPatientPhone(patient.getPhone()); orderInfo.setOrderStatus(OrderStatusEnum.UNPAID.getStatus()); baseMapper.insert(orderInfo);
Map<String, Object> paramMap = new HashMap<>(); paramMap.put("hoscode",orderInfo.getHoscode()); paramMap.put("depcode",orderInfo.getDepcode()); paramMap.put("hosScheduleId",orderInfo.getScheduleId()); paramMap.put("reserveDate",new DateTime(orderInfo.getReserveDate()).toString("yyyy-MM-dd")); paramMap.put("reserveTime", orderInfo.getReserveTime()); paramMap.put("amount",orderInfo.getAmount());
paramMap.put("name", patient.getName()); paramMap.put("certificatesType",patient.getCertificatesType()); paramMap.put("certificatesNo", patient.getCertificatesNo()); paramMap.put("sex",patient.getSex()); paramMap.put("birthdate", patient.getBirthdate()); paramMap.put("phone",patient.getPhone()); paramMap.put("isMarry", patient.getIsMarry()); paramMap.put("provinceCode",patient.getProvinceCode()); paramMap.put("cityCode", patient.getCityCode()); paramMap.put("districtCode",patient.getDistrictCode()); paramMap.put("address",patient.getAddress()); paramMap.put("contactsName",patient.getContactsName()); paramMap.put("contactsCertificatesType", patient.getContactsCertificatesType()); paramMap.put("contactsCertificatesNo",patient.getContactsCertificatesNo()); paramMap.put("contactsPhone",patient.getContactsPhone()); paramMap.put("timestamp", HttpRequestHelper.getTimestamp());
String sign = HttpRequestHelper.getSign(paramMap, signInfoVo.getSignKey()); paramMap.put("sign", sign);
JSONObject result = HttpRequestHelper.sendRequest(paramMap, signInfoVo.getApiUrl() + "/order/submitOrder");
if(result.getInteger("code")==200) { JSONObject jsonObject = result.getJSONObject("data"); String hosRecordId = jsonObject.getString("hosRecordId"); Integer number = jsonObject.getInteger("number");; String fetchTime = jsonObject.getString("fetchTime");; String fetchAddress = jsonObject.getString("fetchAddress");; orderInfo.setHosRecordId(hosRecordId); orderInfo.setNumber(number); orderInfo.setFetchTime(fetchTime); orderInfo.setFetchAddress(fetchAddress); baseMapper.updateById(orderInfo); Integer reservedNumber = jsonObject.getInteger("reservedNumber"); Integer availableNumber = jsonObject.getInteger("availableNumber"); OrderMqVo orderMqVo = new OrderMqVo(); orderMqVo.setScheduleId(scheduleId); orderMqVo.setReservedNumber(reservedNumber); orderMqVo.setAvailableNumber(availableNumber); 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("amount", orderInfo.getAmount()); put("reserveDate", reserveDate); put("name", orderInfo.getPatientName()); put("quitTime", new DateTime(orderInfo.getQuitTime()).toString("yyyy-MM-dd HH:mm")); }}; msmVo.setParam(param); orderMqVo.setMsmVo(msmVo);
rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_ORDER, MqConst.ROUTING_ORDER, orderMqVo); } else { throw new YyghException(result.getString("message"), ResultCodeEnum.FAIL.getCode()); } return orderInfo.getId(); }
|