网上订票系统第四天
前面我们实现了 前台搜索 出发站 到终点站的票务功能,并且实现了选票了,
接下来我们实现,预定之后的功能:
今日任务:
1,实现预定
2,代替联系人预定
3,确认订单
4,我的订单功能 (查看我的订单,取消订单,退票,改签,我的常用联系人添加/删除,我的基本信息)
5,留言功能
首先第一个,选择某一个车次进行预定:
点击预定------接下来应该是 添加 需要购票人的信息
点击提交----------进入 订单确认:
点击确认, 就可以插入数据了,这里没有做支付;
贴一点 主要的代码:
var train_num; var f_time; var t_time; var train_id; var t_price; var banciid; var a = new Object(); a.cityname1 = startpoint; a.cityname2 = endPoint; a.day1 = startDate; a.day2=startDate; a.trainid=1; console.log(a.day1); $.ajax({ url:"http://localhost:8989/myticket/user/piao/fresta", dataType:"json", type:"post", contentType:"application/json;charset=UTF-8", data:JSON.stringify(a), success:function (data) { va.trainInfos = data; },error:function (e) { alert("查询失败"); } }) var va = new Vue({ el:"#info-box", data: { trainId:{}, trainInfos:[], },methods:{ getInfos:function (index) { num = this.trainInfos[index].frenumber; time = this.trainInfos[index].frebegintime; t_time = this.trainInfos[index].freendtime; id = this.trainInfos[index].frecarid; price = this.trainInfos[index].freprice; id1 = this.trainInfos[index].stbegin; id2 = this.trainInfos[index].stend; banciid=this.trainInfos[index].freid;
var a = new Object();
a.userid = userid;
$.ajax({
url:"http://localhost:8989/myticket/car/user/getuserinfo",
dataType:"json",
type:"post",
contentType:"application/json;charset=UTF-8",
data:JSON.stringify(a),
success:function (data) {
va.name = data.username;
va.idnumber = data.usernumber;
va.phone = data.usertelephone;
vp.name = data.username;
vp.idnumber = data.usernumber;
vp.phone = data.usertelephone;
}
,error:function (error) {
alert("请先登陆!")
}
})
//常用联系人
var contentId;
var ao = new Object();
ao.userid = userid;
$.ajax({
url:"http://localhost:8989/myticket/car/user/getCotactByUserid",
dataType:"json",
type:"post",
contentType:"application/json;charset=UTF-8",
data:JSON.stringify(ao),
success:function (data) {
va.contanct = data;
contentId = data[0].userid;
}
public class StationController { @Autowired IStationService stationService; @RequestMapping(value = "/all", method = RequestMethod.GET) @ResponseBody private Map<String, Object> listAll() { List<Station> stations = stationService.getlist(); //System.out.println("dd"); Map<String, Object> map = new HashMap<String, Object>(); map.put("data", stations); return map; } @RequestMapping(value = "", method = RequestMethod.POST) @ResponseBody private Map<String, Object> add(@RequestBody Station station) { int result = stationService.add(station); Map<String, Object> map = new HashMap<String, Object>(); if (result > 0) { map.put("status", 1); } else { map.put("status", 0); } return map; } @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody private Map<String, Object> deleteById(@PathVariable("id") int id) { int result = stationService.delete(id); Map<String, Object> map = new HashMap<String, Object>(); if (result > 0) { map.put("status", 1); } else { map.put("status", 0); } return map; } @RequestMapping(value = "", method = RequestMethod.PUT) @ResponseBody private Map<String, Object> update(@RequestBody Station station) { int result = stationService.update(station); // System.out.println(result); Map<String, Object> map = new HashMap<String, Object>(); if (result > 0) { map.put("status", 1); } else { map.put("status", 0); } return map; } }
接下来实现 我的订单功能:
常用联系人:
留言功能:
<mapper namespace="com.hp.mapper.OrderinfoMapper"> <select id="getcountbyfreid"> select COUNT(*) from orderinfo where orderfreid =#{orderfreid} </select> <select id="getseat" resultType="java.lang.Integer"> SELECT Isnull(MAX(orderseat),0) from orderinfo where orderfreid=#{orderid}; </select> <insert id="add" parameterType="com.hp.entity.Orderinfo"> insert into orderinfo values(#{orderseat},#{orderfreid},#{orderuserid},#{orderprice},#{orderissue},#{orderdate},#{orderplaydate},#{orderstatus},#{orderremark}); </insert> <select id="userweizhifu" resultType="com.hp.entity.Orderinfo"> select *from orderinfo where orderuserid=#{orderuserid} and orderstatus=1; </select> <select id="yizhifu" resultType="com.hp.entity.Orderinfo"> select *from orderinfo where orderuserid=#{orderuserid} and orderstatus=2; </select> <select id="getbyuserid" resultType="com.hp.entity.Orderinfo"> select *from orderinfo where orderuserid=#{orderuserid}; </select> <delete id="delete" parameterType="_int"> delete from orderinfo where orderid=#{id}; </delete> <update id="update" parameterType="com.hp.entity.Orderinfo"> update orderinfo set orderseat=#{orderseat},orderfreid=#{orderfreid},orderuserid=#{orderuserid},orderprice=#{orderprice},orderdate=#{orderdate},orderplaydate=#{orderplaydate},orderstatus=#{orderstatus},orderremark=#{orderremark} where orderid=#{orderid}; </update> <update id="updatequorder" parameterType="com.hp.entity.Orderinfo"> update orderinfo set orderseat=0,orderstatus=3,orderremark='订单取消' where orderid=#{orderid}; </update> <update id="updatetuipiao" parameterType="com.hp.entity.Orderinfo"> update orderinfo set orderseat=0,orderstatus=4,orderremark='退票' where orderid=#{orderid}; </update> <select id="getlistadmin" resultType="com.hp.entity.Orderinfo"> select orderid,orderseat,orderfreid,orderuserid,orderprice,orderdate,orderplaydate,orderremark, (case orderstatus when '1' then '未支付' when '2' then '已支付' end) as orderstatus from orderinfo; </select> </mapper>
<mapper namespace="com.hp.mapper.MessageMapper">
<insert id="add">
insert into message values(#{messagecontenttitle},#{messagecontent},#{messagetime},#{messageuserid},#{messageremark});
</insert>
<select id="getlist" resultType="com.hp.entity.Message">
select top 5 * from message
</select>
<select id="getlistadmin" resultType="com.hp.entity.Message2">
select m.messageid,m.messagecontenttitle,substring(m.messagecontent,0,6) as messagecontent,m.messagetime,m.messageremark,u.userrealname from message m , userticket u where m.messageuserid=u.userid
</select>
<delete id="delete" parameterType="_int">
delete from message where messageid=#{id};
</delete>
<update id="update" parameterType="com.hp.entity.Message2">
update message set messagecontenttitle=#{messagecontenttitle},messagecontent=#{messagecontent},messagetime=#{messagetime},messageremark=#{messageremark} where messageid=#{messageid};
</update>
</mapper>
未解决的问题: 某一个用户购票后 座位号 已经生成,该用户随后选择退票,那么他的座位号如何给下一个订票的客户?