修改发起拼单的逻辑
This commit is contained in:
parent
863a8fe190
commit
4120705ad8
@ -24,6 +24,16 @@ public interface PCommonMapper {
|
||||
*/
|
||||
public Map queryOrderMemberState(CommonVO commonVO);
|
||||
|
||||
|
||||
/**
|
||||
* 查询乘客下单的状态
|
||||
* @param commonVO
|
||||
* @return
|
||||
*/
|
||||
public Map queryOrderMemberStateByOpenId(CommonVO commonVO);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 乘客取消订单
|
||||
* @param commonVO
|
||||
|
@ -44,6 +44,15 @@ public interface POrderMapper
|
||||
*/
|
||||
public int insertPOrder(POrder pOrder);
|
||||
|
||||
|
||||
/**
|
||||
* 新增订单成员信息
|
||||
*
|
||||
* @param pOrderMember 订单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPOrderMember(POrderMember pOrderMember);
|
||||
|
||||
/**
|
||||
* 修改订单信息
|
||||
*
|
||||
|
@ -51,8 +51,8 @@ public class IPCommonServiceImpl implements IPCommonService {
|
||||
return AjaxResult.error("订单已经有司机接单,请联系司机。");
|
||||
}else {
|
||||
/*校验是否可以取消*/
|
||||
Map<String , Integer> info = pCommonMapper.queryOrderMemberState(commonVO);
|
||||
if(info.isEmpty() && info.get("state") == 0){
|
||||
Map<String , Integer> info = pCommonMapper.queryOrderMemberStateByOpenId(commonVO);
|
||||
if(info != null && info.get("state") == 0){
|
||||
/*查询订单详情*/
|
||||
POrder pOrder = pOrderMapper.selectPOrderByOrderNum(orderNum);
|
||||
Integer currnt = pOrder.getMember()-info.get("num");
|
||||
@ -63,7 +63,7 @@ public class IPCommonServiceImpl implements IPCommonService {
|
||||
pCommonMapper.updateOrderMenber(commonVO);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error();
|
||||
return AjaxResult.error(999 , "请求参数有误");
|
||||
}
|
||||
}
|
||||
/*司机取消订单*/
|
||||
@ -78,7 +78,7 @@ public class IPCommonServiceImpl implements IPCommonService {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
return AjaxResult.error(200 , "请求参数有误");
|
||||
return AjaxResult.error(999 , "请求参数有误");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ public class POrderServiceImpl implements IPOrderService
|
||||
@Autowired
|
||||
private POrderMapper pOrderMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private PPassengerMapper pPassengerMapper;
|
||||
|
||||
@ -98,24 +99,40 @@ public class POrderServiceImpl implements IPOrderService
|
||||
@Override
|
||||
public AjaxResult insertPOrderWx(POrder pOrder)
|
||||
{
|
||||
/*校验当前用户是否存在未完成的订单*/
|
||||
String openId = pOrder.getCreaterOpenId();
|
||||
if(StringUtils.isEmpty(openId)) return AjaxResult.error("openId 必传");
|
||||
/*判断当前用户是否是黑名单*/
|
||||
PPassenger pPassenger = pPassengerMapper.selectPPassengerByOpenId(openId);
|
||||
if("1".equals(pPassenger.getIsBlacklist())) return AjaxResult.error("您现在处于系统黑名单,请联系管理员。");
|
||||
/*查询当前用户是否存在拼单中的订单*/
|
||||
List<POrder> pOrders = pOrderMapper.queryOrderInfoByOpenIdAndState(openId);
|
||||
if(pOrders.size() > 0){
|
||||
return AjaxResult.error("您在系统中存在拼单中的订单。");
|
||||
try {
|
||||
/*校验当前用户是否存在未完成的订单*/
|
||||
String openId = pOrder.getCreaterOpenId();
|
||||
if(StringUtils.isEmpty(openId)) return AjaxResult.error("createrOpenId 必传");
|
||||
/*判断当前用户是否是黑名单*/
|
||||
PPassenger pPassenger = pPassengerMapper.selectPPassengerByOpenId(openId);
|
||||
if("1".equals(pPassenger.getIsBlacklist())) return AjaxResult.error("您现在处于系统黑名单,请联系管理员。");
|
||||
/*查询当前用户是否存在拼单中的订单*/
|
||||
List<POrder> pOrders = pOrderMapper.queryOrderInfoByOpenIdAndState(openId);
|
||||
if(pOrders.size() > 0){
|
||||
return AjaxResult.error("您在系统中存在拼单中的订单。");
|
||||
}
|
||||
String orderNum = DateUtils.dateTimeNow();
|
||||
pOrder.setOrderNum("carpool_"+orderNum);
|
||||
pOrder.setIsTake("0");
|
||||
pOrder.setState("0");
|
||||
pOrder.setCreateTime(DateUtils.getNowDate());
|
||||
/*订单成员表中添加一条成员信息*/
|
||||
POrderMember pOrderMember = new POrderMember();
|
||||
pOrderMember.setOrderNum(pOrder.getOrderNum());
|
||||
pOrderMember.setOpenId(openId);
|
||||
pOrderMember.setState(0);
|
||||
pOrderMember.setCustName(pOrder.getCreaterName());
|
||||
pOrderMember.setCustPhone(pOrder.getCreaterPhone());
|
||||
pOrderMember.setCreateTime(DateUtils.getNowDate());
|
||||
pOrderMember.setIndex(1);
|
||||
pOrderMember.setNum(pOrder.getMember());
|
||||
pOrderMapper.insertPOrder(pOrder);
|
||||
pOrderMapper.insertPOrderMember(pOrderMember);
|
||||
return AjaxResult.success("发起拼单成功。");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
String orderNum = DateUtils.dateTimeNow();
|
||||
pOrder.setOrderNum("carpool_"+orderNum);
|
||||
pOrder.setIsTake("0");
|
||||
pOrder.setState("0");
|
||||
pOrder.setCreateTime(DateUtils.getNowDate());
|
||||
pOrderMapper.insertPOrder(pOrder);
|
||||
return AjaxResult.success("发起拼单成功。");
|
||||
return AjaxResult.error(999 ,"发起拼单失败.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,9 +15,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
SELECT state,num FROM p_order_member WHERE order_num = #{orderNum} AND cust_id = #{userID}
|
||||
</select>
|
||||
|
||||
<select id="queryOrderMemberStateByOpenId" parameterType="CommonVO" resultType="hashmap" >
|
||||
SELECT state,num FROM p_order_member WHERE order_num = #{orderNum} AND open_id = #{openId}
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateOrderMenber" parameterType="CommonVO" >
|
||||
UPDATE p_order_member SET state = 1 WHERE order_num = #{orderNum} AND cust_id = #{userID}
|
||||
UPDATE p_order_member SET state = 1 WHERE order_num = #{orderNum} AND open_id = #{openId}
|
||||
</update>
|
||||
|
||||
<select id="queryOrderMemberCount" parameterType="String" resultType="integer" >
|
||||
|
@ -28,13 +28,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<resultMap type="com.ruoyi.carpool.domain.POrderMember" id="POrderMemberResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="openId" column="open_id" />
|
||||
<result property="custName" column="cust_name" />
|
||||
<result property="custPhone" column="cust_phone" />
|
||||
<result property="custId" column="cust_id" />
|
||||
<result property="num" column="num" />
|
||||
<result property="index" column="index" />
|
||||
<result property="index" column="submit_index" />
|
||||
<result property="state" column="state" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPOrderVo">
|
||||
@ -201,4 +203,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
SELECT * FROM p_order_member WHERE order_num = #{orderNum} ;
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertPOrderMember" parameterType="POrderMember" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into p_order_member
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="openId != null">open_id,</if>
|
||||
<if test="custName != null">cust_name,</if>
|
||||
<if test="custPhone != null">cust_phone,</if>
|
||||
<if test="custId != null">cust_id,</if>
|
||||
<if test="num != null">num,</if>
|
||||
<if test="index != null ">submit_index,</if>
|
||||
<if test="state != null ">state,</if>
|
||||
<if test="createTime != null ">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="openId != null">#{openId},</if>
|
||||
<if test="custName != null">#{custName},</if>
|
||||
<if test="custPhone != null">#{custPhone},</if>
|
||||
<if test="custId != null">#{custId},</if>
|
||||
<if test="num != null">#{num},</if>
|
||||
<if test="index != null ">#{index},</if>
|
||||
<if test="state != null ">#{state},</if>
|
||||
<if test="createTime != null ">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user