yuhaitao14 7 years ago
parent
commit
6bd02f371f

+ 6 - 2
shop/src/main/java/com/zskk/shop/controller/GlobalErrorController.java

@@ -65,7 +65,8 @@ public class GlobalErrorController {
 			//为登录 跳转到登录页面
 			if (e instanceof ZSKKException){
 				if (((ZSKKException)e).getError().getCode() == ErrorConstant.NO_LOGIN_ERROR.getCode()){
-					return new ModelAndView("redirect:" + uccenter + "/login/authorize?redirect=" + this.getRequestUrl());
+					String redirect = this.getRequestUrl();
+					return new ModelAndView("redirect:" + uccenter + "/login/authorize?redirect=" + redirect);
 				}
 			}
 			
@@ -80,7 +81,10 @@ public class GlobalErrorController {
 		try{
 			ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
 			HttpServletRequest request = requestAttributes.getRequest();
-			return URLEncoder.encode(myhost + request.getQueryString(), "UTF-8");
+			String path = request.getRequestURI();
+			String query = request.getQueryString();
+			String url = myhost + path + (query != null? "?" + query: "");
+			return URLEncoder.encode(url, "UTF-8");
 		}catch (Exception e) {
 			LogUtil.sysError(e.getMessage(), e);
 			return "";

+ 53 - 3
shop/src/main/java/com/zskk/shop/controller/web/AppointmentController.java

@@ -24,10 +24,12 @@ import com.zskk.shop.controller.AbstractController;
 import com.zskk.shop.controller.bean.BuyOrderBean;
 import com.zskk.shop.controller.bean.ControllerResult;
 import com.zskk.shop.controller.bean.UserBean;
+import com.zskk.shop.dao.entry.Appointment;
 import com.zskk.shop.dao.entry.BuyOrder;
 import com.zskk.shop.dao.entry.BuyOrderItem;
 import com.zskk.shop.dao.entry.FamilyPeople;
 import com.zskk.shop.dao.entry.FamilyPeopleAppointment;
+import com.zskk.shop.dao.entry.GoodBase;
 import com.zskk.shop.exception.ErrorConstant;
 import com.zskk.shop.exception.ZSKKException;
 import com.zskk.shop.service.BuyOrderService;
@@ -62,10 +64,9 @@ public class AppointmentController extends AbstractController {
 		if (!item.getBid().equals(bid)){
 			throw new ZSKKException(ErrorConstant.PARAM_ERROR);
 		}
-		
-		List<String> tjCheckList	= tjCenterService.getDJDetail("49");
+		GoodBase good = goodService.queryOneGoodBase(item.getGid());
+		List<String> tjCheckList	= tjCenterService.getDJDetail(good.getPackageid());
 		List<FamilyPeople> peoples	= familyPeopleService.queryMyPeoples(userBean.getUserid());
-
 		
 		model.addAttribute("good", goodService.queryOneGoodBase(item.getGid()));
 		model.addAttribute("checklist", tjCheckList);
@@ -114,4 +115,53 @@ public class AppointmentController extends AbstractController {
 		return new ControllerResult(people);
 	}
 	
+	@RequestMapping("/gochangeappointment/{id}")
+	public String gochangeappointment(Model model, @PathVariable("id") Integer id){
+		UserBean userBean = this.getUser();
+		Appointment appointment = familyPeopleService.queryAppointment(id);
+		if (appointment == null){
+			throw new ZSKKException(ErrorConstant.PARAM_ERROR);
+		}
+		BuyOrderItem item			= buyOrderService.queryItem(appointment.getItemid());
+		List<FamilyPeople> peoples	= familyPeopleService.queryMyPeoples(userBean.getUserid());
+		FamilyPeople people			= familyPeopleService.queryMyPeople(appointment.getFid());
+		
+		model.addAttribute("good", goodService.queryOneGoodBase(item.getGid()));
+		model.addAttribute("appointment", appointment);
+		model.addAttribute("item", item);
+		model.addAttribute("peoples", peoples);
+		model.addAttribute("peoplesJSON", JSON.toJSONString(peoples));
+		model.addAttribute("people", people);
+		
+		this.initUser(model);
+		return "/changeappointment";
+	}
+	
+	@RequestMapping("change")
+	public String change(Model model, @RequestParam("id") Integer id,
+			@RequestParam("fid") Integer fid, @RequestParam("idcard") String idcard, @RequestParam("name") String name, @RequestParam("sex") Integer sex,
+			@RequestParam("phone") String phone, @RequestParam("atime") String atime){
+		UserBean userBean = this.getUser();
+		Appointment appointment = familyPeopleService.queryAppointment(id);
+		if (appointment == null){
+			throw new ZSKKException(ErrorConstant.PARAM_ERROR);
+		}
+		
+		FamilyPeople people = this.familyPeopleService.queryMyPeople(fid);
+		if (people == null){
+			throw new ZSKKException(ErrorConstant.PARAM_ERROR);
+		}
+		
+		appointment.setFid(fid);
+		appointment.setAtime(atime);
+		
+		people.setIdcard(idcard);
+		people.setName(name);
+		people.setPhone(phone);
+		people.setSex(sex);
+		
+		familyPeopleService.change(userBean, people, appointment);
+		
+		return "redirect:/mypayedorders";
+	}
 }

+ 2 - 0
shop/src/main/java/com/zskk/shop/dao/FamilyPeopleMapper.java

@@ -30,4 +30,6 @@ public interface FamilyPeopleMapper {
 	
 	void insertAppointment(Appointment appointment);
 	FamilyPeopleAppointment queryAppointmentFamily(@Param("bid") Long bid, @Param("itemid") Long itemid);
+	Appointment queryAppointment(Integer id);
+	int updateAppointment(Appointment appointment);
 }

+ 7 - 0
shop/src/main/java/com/zskk/shop/dao/entry/Appointment.java

@@ -15,6 +15,7 @@ public class Appointment {
 	private Integer fid;
 	private String atime;
 	private String extend;
+	private String tjaid;
 	private Integer ctime;
 	public Integer getId() {
 		return id;
@@ -58,4 +59,10 @@ public class Appointment {
 	public void setBid(Long bid) {
 		this.bid = bid;
 	}
+	public String getTjaid() {
+		return tjaid;
+	}
+	public void setTjaid(String tjaid) {
+		this.tjaid = tjaid;
+	}
 }

+ 24 - 1
shop/src/main/java/com/zskk/shop/service/FamilyPeopleService.java

@@ -160,7 +160,21 @@ public class FamilyPeopleService {
 		}
 
 		//向体检系统 发起体检请求
-		//tjCenterService.appointment(people, order, atime, extend);
+		tjCenterService.appointment(people, order, atime, extend);
+	}
+	
+	@Transactional
+	public Appointment change(UserBean userBean, FamilyPeople people, Appointment appointment){
+		familyPeopleMapper.updateMyPeople(people);
+		
+		//TODO 取消原有订单
+		
+		//重新预约
+		BuyOrder order = buyOrderService.queryBuyOrder(appointment.getBid());
+		String tjid = tjCenterService.appointment(people, order, appointment.getAtime(), appointment.getExtend());
+		appointment.setTjaid(tjid);
+		familyPeopleMapper.updateAppointment(appointment);
+		return appointment;
 	}
 	
 	/**
@@ -172,6 +186,15 @@ public class FamilyPeopleService {
 		return familyPeopleMapper.queryAppointmentFamily(bid, itemid);
 	}
 	
+	/**
+	 * 查询预约信息
+	 * @param id
+	 * @return
+	 */
+	public Appointment queryAppointment(Integer id){
+		return familyPeopleMapper.queryAppointment(id);
+	}
+	
 	/**
 	 * 类型 转换
 	 * @param people

+ 9 - 3
shop/src/main/java/com/zskk/shop/service/TJCenterService.java

@@ -62,7 +62,7 @@ public class TJCenterService {
 		}
 	}
 
-	public void appointment(FamilyPeople people, BuyOrder order, String atime, String extend) {
+	public String appointment(FamilyPeople people, BuyOrder order, String atime, String extend) {
 		// 调用体检系统 预约
 		Map<String, String> data = new HashMap<>();
 		data.put("name", people.getName());
@@ -89,9 +89,15 @@ public class TJCenterService {
 		Map<String, String> params = new HashMap<>();
 		params.put("main", main);
 		
-		String url = tjcenter + "public/index.php/api/shop/add";
+		String url = tjcenter + "public/api.php/shop/addSubscribe";
 		try{
-			HttpClient.doPost(url, params, headers);
+			String content = HttpClient.doPost(url, params, headers);
+			JSONObject obj = JSON.parseObject(content);
+			if (obj.containsKey("code") && obj.getInteger("code").equals(0)){
+				return obj.getJSONObject("data").getString("id");
+			}else{
+				throw new ZSKKException(ErrorConstant.SERVER_ERROR);
+			}
 		}catch (Exception e) {
 			LogUtil.sysError(e.getMessage(), e);
 			throw new ZSKKException(ErrorConstant.NET_ERROR);

+ 9 - 0
shop/src/main/resource/mapper/FamilyPeopleMapper.xml

@@ -36,4 +36,13 @@
 		where a.bid=#{bid} and a.itemid=${itemid}
 		limit 1
 	</select>
+	<select id="queryAppointment" resultType="com.zskk.shop.dao.entry.Appointment">
+		select id, bid, itemid, fid,atime, extend, tjaid, ctime
+		from appointment
+		where id=#{id}
+	</select>
+	<update id="updateAppointment" parameterType="com.zskk.shop.dao.entry.Appointment">
+		upadte appointment set fid=#{fid},atime=#{atime},extend=#{extend},tjaid=#{tjaid}
+		where id=#{id}
+	</update>
 </mapper>

+ 154 - 0
shop/src/main/resource/templates/changeappointment.html

@@ -0,0 +1,154 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>黑龙江昆仑盛和安体检中心</title>
+<link rel="stylesheet" type="text/css" href="/style/common.css" />
+<link rel="stylesheet" type="text/css" href="/style/user.css" />
+<!--[if lt IE 9]> 
+<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script> 
+<![endif]-->
+<!--窗口自适应适配低端IE-->
+<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
+<style type="text/css">
+	.show {
+		display: block;
+	}
+	.showtable {
+		display: table;
+	}
+	.hidden {
+		display: none;
+	}
+</style>
+</head>
+
+<body>
+	<div th:include="fragments :: header"></div>
+	<div class="wp">
+		<div class="main bgFF">
+			<ul class="subnav l mt20">
+				<li class="u2"><a href="/mypayedorders" class="ca">预约体检</a></li>
+				<li class="u3"><a href="####">报告查询</a></li>
+				<li class="u4"><a href="####">商城订单</a></li>
+				<li class="u6"><a href="####">常见问题</a></li>
+				<li class="u7"><a href="#">修改密码</a></li>
+				<li class="u8"><a href="#">退出登录</a></li>
+			</ul>
+			<form action="/appointment/change" method="post" id="form1">
+			<input type="hidden" name="id" th:attr="value=${appointment.id}"/>
+			<div class="l" style="width: 80%;">
+				<div id="step2Content">
+					<div class="u-form" >
+	                    <dl>
+	                    	<dt>选择体检人:</dt>
+	                    	<dd>
+                            <label class="label">
+                                <input class="radio" type="radio" name="fid" value="0"/>
+                                <span class="radioInput"></span>
+                                <span>新建体检人</span>
+                            </label>
+                        	</dd>
+	                    	<dd th:each="people:${peoples}">
+	                        	<label class="label">
+	                        		<input class="radio" type="radio" name="fid" th:attr="value=${people.id}" th:if="${people.id != appointment.fid}"/>
+	                        		<input class="radio" type="radio" name="fid" th:attr="value=${people.id}" th:if="${people.id eq appointment.fid}" checked="checked"/>
+	                        		
+	                        		<span class="radioInput"></span>
+	                        		<span th:text="${people.name}"></span>
+	                        	</label>
+	                        </dd>
+	                    </dl><!--已做过体检则有记录,选择某人后自动填充-->
+	                    <div style="width:100%; height:1px; background-color:#EEE; font-size:0; "></div>
+	                  	<dl>
+	                  		<dt>体检人证件号:</dt>
+	                  		<dd>
+	                  			<select class="slt">
+	                  				<option>身份证</option>
+	                  			</select>
+	                  			<input id="idcard" name="idcard" type="text" class="txt ml5" style="width:231px; " placeholder="请输入身份证号码" maxlength="19" th:attr="value=${people.idcard}"/>
+	                  		</dd>
+	                  	</dl>
+	                    <dl>
+	                    	<dt>姓名:</dt>
+	                    	<dd>
+	                    		<input id="name" name="name" type="text" class="txt" placeholder="请输入与证件上一致的体检人姓名" style="width:300px; " maxlength="32" th:attr="value=${people.name}"/>
+	                    	</dd>
+	                    </dl>
+	                    <dl>
+	                    	<dt>性别:</dt>
+	                    	<dd>
+	                            <label class="label" th:if="${people.sex eq 1}">
+	                            	<input id="sex1" class="radio" type="radio" name="sex" value="1" checked="checked"/><span class="radioInput"></span>男
+	                            </label>
+	                            <label class="label" th:if="${people.sex != 1}">
+	                            	<input id="sex1" class="radio" type="radio" name="sex" value="1"/><span class="radioInput"></span>男
+	                            </label>
+	                        </dd>
+	                    	<dd>
+	                        	<label class="label" th:if="${people.sex eq 0}"><input id="sex0" class="radio" type="radio" name="sex" value="0" checked="checked"/><span class="radioInput"></span>女</label>
+	                        	<label class="label" th:if="${people.sex != 0}"><input id="sex0" class="radio" type="radio" name="sex" value="0"/><span class="radioInput"></span>女</label>
+	                        </dd>
+	                    </dl>
+	                    <dl>
+	                    	<dt>手机号码:</dt>
+	                    	<dd>
+	                    		<input id="phone" name="phone" type="text" class="txt" style="width:300px; " placeholder="此手机号用于接收体检报告及预约信息" maxlength="32" th:attr="value=${people.phone}"/>
+	                    	</dd>
+	                    </dl>
+	                    <div style="width:100%; height:1px; background-color:#EEE; font-size:0; "></div>
+	                    <dl>
+	                    	<dt>预约体检日期:</dt>
+	                    	<dd>
+	                    		<input id="atime" name="atime" type="text" class="txt" style="width:160px;" th:attr="value=${appointment.atime}"/>
+	                    		<select name="" class="slt" style="width:130px; ">
+	                    			<option>预约时间</option>
+	                    			<option>8:00 - 8:30</option>
+	                    			<option>8:30 - 9:00</option>
+	                    		</select>
+	                    	</dd>
+	                    </dl>
+	                </div>
+	                <div class="user_speed_nextBar">
+						<a href="javascript:save();" class="nextBtn" >保存</a>
+					</div>
+                </div>
+			</div>
+			</form>
+		</div>
+	</div>
+	
+	<div th:replace="fragments :: footer"></div>
+
+	<script th:inline="javascript">
+		/* <![CDATA[ */
+		var peoples = JSON.parse([[${peoplesJSON}]])
+		var bid		= [[${bid}]]
+		var itemid	= [[${itemid}]]
+		$("input[name=people]").click(function(){
+			var id = $(this).val();
+			if (id == "0"){
+				$("#idcard").val("");
+				$("#name").val("");
+				$("#sex1").attr("checked","checked")
+				$("#phone").val("")
+			}else{
+				for (var i = 0; i < peoples.length; ++i){
+					var obj = peoples[i]
+					if (obj.id==id){
+						$("#idcard").val(obj.idcard);
+						$("#name").val(obj.name);
+						$("#sex" + obj.sex).attr("checked","checked")
+						$("#phone").val(obj.phone)
+					}
+				}
+			}
+		});
+		
+		function save(){
+			$("#form1").submit();
+		}
+		/* ]]> */
+	</script>
+</body>
+</html>

+ 1 - 1
shop/src/main/resource/templates/fragments.html

@@ -113,7 +113,7 @@
 				</td>
 				<td width="140">
 					<div class="wx">
-						<img src="../images/qrcode.png" />
+						<img src="/images/qrcode.png" />
 						<p>官方微信</p>
 					</div>
 				</td>