|
@ -0,0 +1,85 @@
|
|
|
package com.yihu.wlyy.web.patient.booking;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.PatientReservation;
|
|
|
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
|
|
|
import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
/**
|
|
|
* 预约挂号
|
|
|
* Created by yeshijie on 2017/2/4.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/patient/guahao")
|
|
|
@Api(description = "预约挂号接口-居民端")
|
|
|
public class PatientBookingController extends WeixinBaseController{
|
|
|
@Autowired
|
|
|
private GuahaoXMService guahaoXM;
|
|
|
@Autowired
|
|
|
private GuahaoYihuService guahaoYihu;
|
|
|
@Autowired
|
|
|
private PatientReservationService patientReservationService;
|
|
|
@Autowired
|
|
|
private PatientService patientService;
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
@ApiOperation("取消挂号单")
|
|
|
public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "48")
|
|
|
@RequestParam(value = "orderId", required = true) Long orderId) {
|
|
|
try {
|
|
|
//获取订单信息
|
|
|
PatientReservation obj = patientReservationService.findById(orderId);
|
|
|
boolean re = false;
|
|
|
if (obj != null) {
|
|
|
String type = obj.getType();
|
|
|
String code = obj.getCode();
|
|
|
if (type.equals("0")) { //医护网接口
|
|
|
re = guahaoYihu.CancelOrder(code);
|
|
|
} else if (type.equals("1")) //厦门市民健康预约接口
|
|
|
{
|
|
|
re = guahaoXM.CancelOrder(code, obj.getSsc());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (re) {
|
|
|
//更新状态
|
|
|
patientReservationService.patientCancelOrder(orderId,getUID());//"9aa5c557e06a4324911487a035195545"
|
|
|
//微信消息
|
|
|
Patient p = patientService.findByCode(obj.getPatient());
|
|
|
if (StringUtils.isNotEmpty(p.getOpenid())) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("first", "");
|
|
|
json.put("toUser", p.getCode());
|
|
|
json.put("name", obj.getName());
|
|
|
json.put("date", obj.getStartTime());
|
|
|
json.put("doctorName", obj.getDoctorName());
|
|
|
json.put("orgName", obj.getOrgName());
|
|
|
json.put("remark", obj.getName() + ",您好!\n您已取消了" + obj.getStartTime() + "的挂号!");
|
|
|
PushMsgTask.getInstance().putWxMsg(getAccessToken(), 7, p.getOpenid(), obj.getName(), json);
|
|
|
}
|
|
|
return write(200, "取消挂号单成功!");
|
|
|
} else {
|
|
|
return error(-1, "取消挂号单失败!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|