From 9a12f02fa3854f626f1813d47e0d892fe00858d4 Mon Sep 17 00:00:00 2001 From: keivn <shinelonddpro@outlook.com> Date: Sun, 12 Dec 2021 09:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../carpool/controller/PCommonController.java | 49 +++++++++ .../carpool/controller/PDriverController.java | 25 ++++- .../carpool/controller/POrderController.java | 2 - .../controller/PPassengerController.java | 24 ++-- .../com/ruoyi/carpool/domain/CommonVO.java | 57 ++++++++++ .../com/ruoyi/carpool/domain/PDriver.java | 13 +++ .../com/ruoyi/carpool/domain/PPassenger.java | 13 +++ .../ruoyi/carpool/mapper/PCommonMapper.java | 67 +++++++++++ .../ruoyi/carpool/mapper/PDriverMapper.java | 17 +++ .../ruoyi/carpool/mapper/POrderMapper.java | 17 +++ .../carpool/mapper/PPassengerMapper.java | 7 ++ .../carpool/service/IPCommonService.java | 23 ++++ .../carpool/service/IPDriverService.java | 16 +++ .../carpool/service/IPPassengerService.java | 8 ++ .../service/impl/IPCommonServiceImpl.java | 104 ++++++++++++++++++ .../service/impl/PDriverServiceImpl.java | 15 +++ .../service/impl/POrderServiceImpl.java | 5 + .../service/impl/PPassengerServiceImpl.java | 5 + .../mapper/carpool/PCommonMapper.xml | 55 +++++++++ .../mapper/carpool/PDriverMapper.xml | 33 +++++- .../resources/mapper/carpool/POrderMapper.xml | 18 ++- .../mapper/carpool/PPassengerMapper.xml | 26 ++++- .../controller/system/SysLoginController.java | 3 +- .../web/service/SysLoginService.java | 3 +- 24 files changed, 585 insertions(+), 20 deletions(-) create mode 100644 ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PCommonController.java create mode 100644 ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/CommonVO.java create mode 100644 ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PCommonMapper.java create mode 100644 ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPCommonService.java create mode 100644 ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/IPCommonServiceImpl.java create mode 100644 ruiyi-carpool/src/main/resources/mapper/carpool/PCommonMapper.xml diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PCommonController.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PCommonController.java new file mode 100644 index 000000000..325a17834 --- /dev/null +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PCommonController.java @@ -0,0 +1,49 @@ +package com.ruoyi.carpool.controller; + + +import com.ruoyi.carpool.domain.CommonVO; +import com.ruoyi.carpool.service.IPCommonService; +import com.ruoyi.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/carpool/common") +public class PCommonController { + + + @Autowired + private IPCommonService ipCommonService; + + + /** + * 乘客或者司机关闭订单 + * @param commonVO + * @return + */ + @PostMapping(value = "/cancelOrder") + public AjaxResult getDriverInfo(@RequestBody CommonVO commonVO) + { + return ipCommonService.cancelOrder(commonVO); + } + + + + /** + * 乘客申请加入拼单 + * @param commonVO + * @return + */ + @PostMapping(value = "/joinOrderList") + public AjaxResult joinOrderList(@RequestBody CommonVO commonVO) + { + return ipCommonService.joinOrderList(commonVO); + } + + + + + + + +} diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PDriverController.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PDriverController.java index 0c1be9e9b..13e9b4344 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PDriverController.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PDriverController.java @@ -72,6 +72,17 @@ public class PDriverController extends BaseController return AjaxResult.success(pDriverService.selectPDriverById(id)); } + + /** + * 获取司机信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('carpool:driver:query')") + @PostMapping(value = "/queryUserInfo") + public AjaxResult getDriverInfo(@RequestBody PDriver pDriver) + { + return AjaxResult.success(pDriverService.getDriverInfo(pDriver)); + } + /** * 新增司机信息 */ @@ -80,10 +91,22 @@ public class PDriverController extends BaseController @PostMapping public AjaxResult add(@RequestBody PDriver pDriver) { - pDriver.setDriverId(IdUtils.randomUUID()); return toAjax(pDriverService.insertPDriver(pDriver)); } + /** + * 通过审核 + * @param pDriver + * @return + */ + @PostMapping("/agree") + public AjaxResult agree(@RequestBody PDriver pDriver) + { + return toAjax(pDriverService.agreePDriver(pDriver)); + } + + + /** * 修改司机信息 */ diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/POrderController.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/POrderController.java index fe0cdfa8c..8c9c0d1c1 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/POrderController.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/POrderController.java @@ -79,8 +79,6 @@ public class POrderController extends BaseController @PostMapping public AjaxResult add(@RequestBody POrder pOrder) { - String orderNum = DateUtils.dateTimeNow(); - pOrder.setOrderNum("carpool_"+orderNum); return toAjax(pOrderService.insertPOrder(pOrder)); } /** diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PPassengerController.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PPassengerController.java index 136ff6048..74286be87 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PPassengerController.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/controller/PPassengerController.java @@ -6,14 +6,7 @@ import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.utils.uuid.IdUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -79,7 +72,7 @@ public class PPassengerController extends BaseController @PostMapping public AjaxResult add(@RequestBody PPassenger pPassenger) { - pPassenger.setCustId(IdUtils.randomUUID()); + pPassenger.setCustId("passenger_"+IdUtils.randomUUID()); return toAjax(pPassengerService.insertPPassenger(pPassenger)); } @@ -104,4 +97,17 @@ public class PPassengerController extends BaseController { return toAjax(pPassengerService.deletePPassengerByIds(ids)); } + + + /** + * 获取乘客信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('carpool:passenger:query')") + @PostMapping(value = "/queryUserInfo") + public AjaxResult queryUserInfo(@RequestBody PPassenger pPassenger) + { + return AjaxResult.success(pPassengerService.queryUserInfo(pPassenger)); + } + + } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/CommonVO.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/CommonVO.java new file mode 100644 index 000000000..4544e7aab --- /dev/null +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/CommonVO.java @@ -0,0 +1,57 @@ +package com.ruoyi.carpool.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +public class CommonVO { + /** + * 订单流水号 + */ + private String orderNum ; + + /** + * 平台用户唯一ID + */ + private String userID; + + + /** + * 申请拼单的人数 + */ + private Integer num; + + + + public String getOrderNum() { + return orderNum; + } + + public void setOrderNum(String orderNum) { + this.orderNum = orderNum; + } + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("orderNum", getOrderNum()) + .append("userID", getUserID()) + .append("num", getNum()) + .toString(); + } +} diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PDriver.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PDriver.java index 7c646d813..01415b488 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PDriver.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PDriver.java @@ -58,6 +58,10 @@ public class PDriver extends BaseEntity @Excel(name = "是否黑名单用户:0否,1是") private String isBlacklist; + /** 当前状态 */ + @Excel(name = "用户当前的状态:0:审核中,1:审核通过,2:禁用") + private Integer state ; + public void setId(Long id) { this.id = id; @@ -158,6 +162,14 @@ public class PDriver extends BaseEntity return isBlacklist; } + public Integer getState() { + return state; + } + + public void setState(Integer state) { + this.state = state; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -174,6 +186,7 @@ public class PDriver extends BaseEntity .append("isBlacklist", getIsBlacklist()) .append("createTime", getCreateTime()) .append("updateTime", getUpdateTime()) + .append("state", getState()) .toString(); } } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PPassenger.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PPassenger.java index 0b689695b..81a052b4b 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PPassenger.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/domain/PPassenger.java @@ -45,6 +45,10 @@ public class PPassenger extends BaseEntity @Excel(name = "性别:1男性,0女性") private String sex; + /** 身份证号码 */ + @Excel(name = "身份证号码") + private String idCard; + /** 生日 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd") @@ -174,6 +178,14 @@ public class PPassenger extends BaseEntity this.age = age; } + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -191,6 +203,7 @@ public class PPassenger extends BaseEntity .append("createTime", getCreateTime()) .append("updateTime", getUpdateTime()) .append("age", getAge()) + .append("idCard", getIdCard()) .toString(); } } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PCommonMapper.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PCommonMapper.java new file mode 100644 index 000000000..b47d3e92a --- /dev/null +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PCommonMapper.java @@ -0,0 +1,67 @@ +package com.ruoyi.carpool.mapper; + + +import com.ruoyi.carpool.domain.CommonVO; +import com.ruoyi.carpool.domain.PDriver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public interface PCommonMapper { + + /** + * 查询订单是有司机接单 + * @param orderNum + * @return + */ + public String queryIsTake(String orderNum); + + /** + * 查询乘客下单的状态 + * @param commonVO + * @return + */ + public Map queryOrderMemberState(CommonVO commonVO); + + /** + * 乘客取消订单 + * @param commonVO + * @return + */ + public int updateOrderMenber(CommonVO commonVO); + + + /** + * 查询订单乘客详情 + * @param orderNum + * @return + */ + public int queryOrderMemberCount(String orderNum); + + + /** + * 司机取消订单-取消拼单 + * @param orderNum + * @return + */ + public int updateOrderState(String orderNum); + + /** + * 司机取消订单-取消拼单 + * @param orderNum + * @return + */ + public int updateOrderIsTake(String orderNum); + + + /** + * 添加一条拼单记录 + * @param orderNum + * @return + */ + public int insertOrderMemberInfo(Map<String,Object> orderMember); + + + +} diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PDriverMapper.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PDriverMapper.java index 4d35ac50b..1df510fd2 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PDriverMapper.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PDriverMapper.java @@ -58,4 +58,21 @@ public interface PDriverMapper * @return 结果 */ public int deletePDriverByIds(Long[] ids); + + + /** + * 通过电话号码和用户名查询司机的详情 + * @param pDriver + * @return + */ + public PDriver getDriverInfo(PDriver pDriver); + + /** + * 修改司机信息 + * + * @param pDriver 司机信息 + * @return 结果 + */ + public int agreePDriver(PDriver pDriver); + } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/POrderMapper.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/POrderMapper.java index b3d97596e..79fa680a4 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/POrderMapper.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/POrderMapper.java @@ -66,4 +66,21 @@ public interface POrderMapper * @return 结果 */ public int takeOrderById (POrder pOrder); + + /** + * 通过orderNum查询订单信息 + * @param orderNum + * @return + */ + public POrder selectPOrderByOrderNum(String orderNum); + + + /** + * 更新订单当前的人数 + * @param pOrder + * @return + */ + public int updateOrderMemberNum(POrder pOrder); + + } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PPassengerMapper.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PPassengerMapper.java index 461995d7b..56b1533ed 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PPassengerMapper.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/mapper/PPassengerMapper.java @@ -58,4 +58,11 @@ public interface PPassengerMapper * @return 结果 */ public int deletePPassengerByIds(Long[] ids); + + /** + * 查询乘客详情 + * @param pPassenger + * @return + */ + public PPassenger queryUserInfo(PPassenger pPassenger); } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPCommonService.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPCommonService.java new file mode 100644 index 000000000..1ea223a84 --- /dev/null +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPCommonService.java @@ -0,0 +1,23 @@ +package com.ruoyi.carpool.service; + +import com.ruoyi.carpool.domain.CommonVO; +import com.ruoyi.common.core.domain.AjaxResult; + +public interface IPCommonService { + + /** + * 取消订单 + * @param orderNum + * @return + */ + public AjaxResult cancelOrder(CommonVO commonVO); + + + /** + * 审查拼单 + * @param commonVO + * @return + */ + public AjaxResult joinOrderList(CommonVO commonVO); + +} diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPDriverService.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPDriverService.java index cc9a5982b..e3b0bf644 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPDriverService.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPDriverService.java @@ -58,4 +58,20 @@ public interface IPDriverService * @return 结果 */ public int deletePDriverById(Long id); + + + + /** + * 查询司机信息 + * @return 司机信息 + */ + public PDriver getDriverInfo(PDriver pDriver); + + + /** + * 同意审核 + * @param pDriver + * @return + */ + public int agreePDriver(PDriver pDriver); } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPPassengerService.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPPassengerService.java index 57b6b79ae..55c9c2295 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPPassengerService.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/IPPassengerService.java @@ -58,4 +58,12 @@ public interface IPPassengerService * @return 结果 */ public int deletePPassengerById(Long id); + + + /** + * 查询乘客详细信息 + * @param pPassenger + * @return + */ + public PPassenger queryUserInfo(PPassenger pPassenger); } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/IPCommonServiceImpl.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/IPCommonServiceImpl.java new file mode 100644 index 000000000..6db2f8023 --- /dev/null +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/IPCommonServiceImpl.java @@ -0,0 +1,104 @@ +package com.ruoyi.carpool.service.impl; + +import com.ruoyi.carpool.domain.CommonVO; +import com.ruoyi.carpool.domain.POrder; +import com.ruoyi.carpool.mapper.PCommonMapper; +import com.ruoyi.carpool.mapper.PDriverMapper; +import com.ruoyi.carpool.mapper.POrderMapper; +import com.ruoyi.carpool.service.IPCommonService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import jdk.nashorn.api.scripting.AbstractJSObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Service +public class IPCommonServiceImpl implements IPCommonService { + private static Logger logger = LoggerFactory.getLogger(IPCommonServiceImpl.class); + + + @Autowired + private PCommonMapper pCommonMapper; + + @Autowired + private POrderMapper pOrderMapper; + + + @Override + public AjaxResult cancelOrder(CommonVO commonVO) { + String orderNum = commonVO.getOrderNum(); + String userId = commonVO.getUserID(); + if (StringUtils.isEmpty(orderNum) && StringUtils.isEmpty(userId) ){ + return AjaxResult.error("请求参数错误!"); + } + /*乘客取消订单*/ + if(userId.contains("passenger_")){ + /*是否接单:1:已接单,0:未接单*/ + String state = pCommonMapper.queryIsTake(orderNum); + if("1".equals(state)){ + logger.info("订单:" + orderNum+" 已经有司机接单,请联系司机。"); + return AjaxResult.error("订单已经有司机接单,请联系司机。"); + }else { + /*校验是否可以取消*/ + Map<String , Integer> info = pCommonMapper.queryOrderMemberState(commonVO); + if(info.isEmpty() && info.get("state") == 0){ + /*查询订单详情*/ + POrder pOrder = pOrderMapper.selectPOrderByOrderNum(orderNum); + Integer currnt = pOrder.getMember()-info.get("num"); + pOrder.setMember(currnt); + /*更新当前人数表*/ + pOrderMapper.updateOrderMemberNum(pOrder); + /*更新订单成员信息表*/ + pCommonMapper.updateOrderMenber(commonVO); + return AjaxResult.success(); + } + return AjaxResult.error(); + } + } + /*司机取消订单*/ + if(userId.contains("driver_")){ + Integer count = pCommonMapper.queryOrderMemberCount(orderNum); + if( count > 0 ){ + logger.info("订单:" + orderNum+" 已经有乘客,请联系乘客。"); + pCommonMapper.updateOrderIsTake(orderNum); + return AjaxResult.success("订单已经取消,请及时联系乘客。"); + }else { + pCommonMapper.updateOrderState(orderNum); + return AjaxResult.success(); + } + } + return AjaxResult.error(); + } + + + @Override + public AjaxResult joinOrderList(CommonVO commonVO) { + String orderNum = commonVO.getOrderNum(); + String userId = commonVO.getUserID(); + Integer num = commonVO.getNum(); + if (StringUtils.isEmpty(orderNum) && StringUtils.isEmpty(userId) ){ + return AjaxResult.error("请求参数错误!"); + } + Integer count = pCommonMapper.queryOrderMemberCount(orderNum); + Integer menberNum = count + num; + if(menberNum >= 4){ + return AjaxResult.error("订单人数大于4人"); + } + Map<String , Object> data = new HashMap<>(); + data.put("orderNum",orderNum); + data.put("custId" ,userId); + data.put("num" ,num); + data.put("state" ,0); + data.put("createTime" , DateUtils.dateTimeNow()); + pCommonMapper.insertOrderMemberInfo(data); + return AjaxResult.success(); + } +} diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PDriverServiceImpl.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PDriverServiceImpl.java index e5a86ddc6..122fbe753 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PDriverServiceImpl.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PDriverServiceImpl.java @@ -2,6 +2,8 @@ package com.ruoyi.carpool.service.impl; import java.util.List; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.uuid.IdUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.carpool.mapper.PDriverMapper; @@ -54,6 +56,9 @@ public class PDriverServiceImpl implements IPDriverService public int insertPDriver(PDriver pDriver) { pDriver.setCreateTime(DateUtils.getNowDate()); + pDriver.setDriverId("driver_"+ IdUtils.randomUUID()); + pDriver.setState(0); + pDriver.setIsBlacklist("0"); return pDriverMapper.insertPDriver(pDriver); } @@ -93,4 +98,14 @@ public class PDriverServiceImpl implements IPDriverService { return pDriverMapper.deletePDriverById(id); } + + @Override + public PDriver getDriverInfo(PDriver pDriver) { + return pDriverMapper.getDriverInfo(pDriver); + } + + @Override + public int agreePDriver(PDriver pDriver) { + return pDriverMapper.agreePDriver(pDriver); + } } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/POrderServiceImpl.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/POrderServiceImpl.java index 548ff0d86..a63a2ce0b 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/POrderServiceImpl.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/POrderServiceImpl.java @@ -53,6 +53,11 @@ public class POrderServiceImpl implements IPOrderService @Override public int insertPOrder(POrder pOrder) { + String orderNum = DateUtils.dateTimeNow(); + pOrder.setOrderNum("carpool_"+orderNum); + pOrder.setIsTake("0"); + pOrder.setState("0"); + pOrder.setMember(0); pOrder.setCreateTime(DateUtils.getNowDate()); return pOrderMapper.insertPOrder(pOrder); } diff --git a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PPassengerServiceImpl.java b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PPassengerServiceImpl.java index eb0bc5cfa..7cd308786 100644 --- a/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PPassengerServiceImpl.java +++ b/ruiyi-carpool/src/main/java/com/ruoyi/carpool/service/impl/PPassengerServiceImpl.java @@ -93,4 +93,9 @@ public class PPassengerServiceImpl implements IPPassengerService { return pPassengerMapper.deletePPassengerById(id); } + + @Override + public PPassenger queryUserInfo(PPassenger pPassenger) { + return pPassengerMapper.queryUserInfo(pPassenger); + } } diff --git a/ruiyi-carpool/src/main/resources/mapper/carpool/PCommonMapper.xml b/ruiyi-carpool/src/main/resources/mapper/carpool/PCommonMapper.xml new file mode 100644 index 000000000..dadda2d0b --- /dev/null +++ b/ruiyi-carpool/src/main/resources/mapper/carpool/PCommonMapper.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.carpool.mapper.PCommonMapper"> + + + + <select id="queryIsTake" parameterType="String" resultType="String"> + SELECT is_take FROM p_order WHERE order_num = #{orderNum} + </select> + + + <select id="queryOrderMemberState" parameterType="CommonVO" resultType="hashmap" > + SELECT state,num FROM p_order_member WHERE order_num = #{orderNum} AND cust_id = #{userID} + </select> + + + <update id="updateOrderMenber" parameterType="CommonVO" > + UPDATE p_order_member SET state = 1 WHERE order_num = #{orderNum} AND cust_id = #{userID} + </update> + + <select id="queryOrderMemberCount" parameterType="String" resultType="integer" > + SELECT COUNT(1) as count FROM p_order_member WHERE order_num = #{orderNum} AND state = 0 + </select> + + <update id="updateOrderState" parameterType="String" > + UPDATE p_order SET state = '2' WHERE order_num = #{orderNum} + </update> + + <update id="updateOrderIsTake" parameterType="String" > + UPDATE p_order SET is_take = '0' , driver_id = '' WHERE order_num = #{orderNum} + </update> + + + <insert id="insertOrderMemberInfo" parameterType="hashmap" > + insert into p_order_member + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="orderNum != null">order_num,</if> + <if test="custId != null">cust_id,</if> + <if test="num != null">num,</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="custId != null">#{custId},</if> + <if test="num != null">#{num},</if> + <if test="state != null">#{state},</if> + <if test="createTime != null">#{createTime},</if> + </trim> + </insert> + + +</mapper> \ No newline at end of file diff --git a/ruiyi-carpool/src/main/resources/mapper/carpool/PDriverMapper.xml b/ruiyi-carpool/src/main/resources/mapper/carpool/PDriverMapper.xml index 9aeb791a8..5d83f73fa 100644 --- a/ruiyi-carpool/src/main/resources/mapper/carpool/PDriverMapper.xml +++ b/ruiyi-carpool/src/main/resources/mapper/carpool/PDriverMapper.xml @@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <result property="sex" column="sex" /> <result property="idCard" column="id_card" /> <result property="age" column="age" /> + <result property="state" column="state" /> <result property="phone" column="phone" /> <result property="city" column="city" /> <result property="province" column="province" /> @@ -21,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" </resultMap> <sql id="selectPDriverVo"> - select id, driver_id, name, sex, id_card, age, phone, city, province, country, is_blacklist, create_time, update_time from p_driver + select id, driver_id, name, sex, id_card, age, phone, city,state, province, country, is_blacklist, create_time, update_time from p_driver </sql> <select id="selectPDriverList" parameterType="PDriver" resultMap="PDriverResult"> @@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="driverId != null and driverId != ''"> and driver_id = #{driverId}</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="sex != null "> and sex = #{sex}</if> + <if test="state != null "> and state = #{state}</if> <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if> <if test="age != null "> and age = #{age}</if> <if test="phone != null and phone != ''"> and phone = #{phone}</if> @@ -54,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="sex != null">sex,</if> <if test="idCard != null">id_card,</if> <if test="age != null">age,</if> + <if test="state != null">state,</if> <if test="phone != null">phone,</if> <if test="city != null">city,</if> <if test="province != null">province,</if> @@ -67,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="driverId != null">#{driverId},</if> <if test="name != null">#{name},</if> <if test="sex != null">#{sex},</if> + <if test="state != null">#{state},</if> <if test="idCard != null">#{idCard},</if> <if test="age != null">#{age},</if> <if test="phone != null">#{phone},</if> @@ -85,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="driverId != null">driver_id = #{driverId},</if> <if test="name != null">name = #{name},</if> <if test="sex != null">sex = #{sex},</if> + <if test="state != null">state = #{state},</if> <if test="idCard != null">id_card = #{idCard},</if> <if test="age != null">age = #{age},</if> <if test="phone != null">phone = #{phone},</if> @@ -108,4 +113,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} </foreach> </delete> + + + <select id="getDriverInfo" parameterType="PDriver" resultMap="PDriverResult"> + <include refid="selectPDriverVo"/> + <where> + <if test="driverId != null and driverId != ''"> and driver_id = #{driverId}</if> + <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> + <if test="sex != null "> and sex = #{sex}</if> + <if test="state != null "> and state = #{state}</if> + <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if> + <if test="age != null "> and age = #{age}</if> + <if test="phone != null and phone != ''"> and phone = #{phone}</if> + <if test="city != null and city != ''"> and city = #{city}</if> + <if test="province != null and province != ''"> and province = #{province}</if> + <if test="country != null and country != ''"> and country = #{country}</if> + <if test="isBlacklist != null "> and is_blacklist = #{isBlacklist}</if> + </where> + </select> + + + + + <update id="agreePDriver" parameterType="PDriver"> + update p_driver SET state = 1 where driver_id = #{driverId} + </update> + </mapper> \ No newline at end of file diff --git a/ruiyi-carpool/src/main/resources/mapper/carpool/POrderMapper.xml b/ruiyi-carpool/src/main/resources/mapper/carpool/POrderMapper.xml index 08dca15f9..d2c30be4a 100644 --- a/ruiyi-carpool/src/main/resources/mapper/carpool/POrderMapper.xml +++ b/ruiyi-carpool/src/main/resources/mapper/carpool/POrderMapper.xml @@ -70,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="departureTime != null">departure_time,</if> <if test="member != null">member,</if> <if test="state != null">state,</if> + <if test="isTake != null ">is_take,</if> <if test="isdelete != null">isDelete,</if> <if test="createUser != null">create_user,</if> <if test="createTime != null">create_time,</if> @@ -83,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="departureTime != null">#{departureTime},</if> <if test="member != null">#{member},</if> <if test="state != null">#{state},</if> + <if test="isTake != null ">#{isTake},</if> <if test="isdelete != null">#{isdelete},</if> <if test="createUser != null">#{createUser},</if> <if test="createTime != null">#{createTime},</if> @@ -91,7 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" </trim> </insert> - <update id="updatePOrder" parameterType="POrder"> + <update id="updatePOrder" parameterType="POrder" > update p_order <trim prefix="SET" suffixOverrides=","> <if test="orderNum != null">order_num = #{orderNum},</if> @@ -127,7 +129,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="isTake != null">is_take = #{isTake},</if> <if test="driverId != null">driver_id = #{driverId},</if> </trim> - where orderNum = #{orderNum} + where order_num = #{orderNum} </update> + <select id="selectPOrderByOrderNum" parameterType="String" resultMap="POrderResult"> + <include refid="selectPOrderVo"/> + where order_num = #{orderNum} + </select> + + + <update id="updateOrderMemberNum" parameterType="POrder" > + update p_order set member = #{member} where order_num = #{orderNum} + </update> + + + </mapper> \ No newline at end of file diff --git a/ruiyi-carpool/src/main/resources/mapper/carpool/PPassengerMapper.xml b/ruiyi-carpool/src/main/resources/mapper/carpool/PPassengerMapper.xml index b6cab07ad..c89ccfc3e 100644 --- a/ruiyi-carpool/src/main/resources/mapper/carpool/PPassengerMapper.xml +++ b/ruiyi-carpool/src/main/resources/mapper/carpool/PPassengerMapper.xml @@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <result property="openId" column="open_id" /> <result property="custPhone" column="cust_phone" /> <result property="sex" column="sex" /> + <result property="idCard" column="id_card" /> <result property="age" column="age" /> <result property="birthday" column="birthday" /> <result property="city" column="city" /> @@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" </resultMap> <sql id="selectPPassengerVo"> - select id, cust_id, cust_name, nick_name, open_id, cust_phone, sex, birthday, city, province, is_blacklist, create_time, update_time from p_passenger + select id, cust_id, cust_name, nick_name, open_id, cust_phone, sex, id_card, birthday, city, province, is_blacklist, create_time, update_time from p_passenger </sql> <select id="selectPPassengerList" parameterType="PPassenger" resultMap="PPassengerResult"> @@ -34,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="openId != null and openId != ''"> and open_id = #{openId}</if> <if test="custPhone != null and custPhone != ''"> and cust_phone = #{custPhone}</if> <if test="sex != null "> and sex = #{sex}</if> + <if test="idCard != null and idCard != '' "> and id_card = #{idCard}</if> <if test="birthday != null "> and birthday = #{birthday}</if> <if test="city != null and city != ''"> and city = #{city}</if> <if test="province != null and province != ''"> and province = #{province}</if> @@ -56,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="openId != null">open_id,</if> <if test="custPhone != null">cust_phone,</if> <if test="sex != null">sex,</if> + <if test="idCard != null "> and id_card = #{idCard}</if> <if test="birthday != null">birthday,</if> <if test="city != null">city,</if> <if test="province != null">province,</if> @@ -71,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="openId != null">#{openId},</if> <if test="custPhone != null">#{custPhone},</if> <if test="sex != null">#{sex},</if> + <if test="idCard != null "> and id_card = #{idCard}</if> <if test="birthday != null">#{birthday},</if> <if test="city != null">#{city},</if> <if test="province != null">#{province},</if> @@ -89,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="openId != null">open_id = #{openId},</if> <if test="custPhone != null">cust_phone = #{custPhone},</if> <if test="sex != null">sex = #{sex},</if> + <if test="idCard != null "> and id_card = #{idCard}</if> <if test="birthday != null">birthday = #{birthday},</if> <if test="city != null">city = #{city},</if> <if test="province != null">province = #{province},</if> @@ -109,4 +114,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} </foreach> </delete> + + + + <select id="queryUserInfo" parameterType="PPassenger" resultMap="PPassengerResult"> + <include refid="selectPPassengerVo"/> + <where> + <if test="custId != null and custId != ''"> and cust_id = #{custId}</if> + <if test="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if> + <if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if> + <if test="openId != null and openId != ''"> and open_id = #{openId}</if> + <if test="custPhone != null and custPhone != ''"> and cust_phone = #{custPhone}</if> + <if test="sex != null "> and sex = #{sex}</if> + <if test="idCard != null and idCard != '' "> and id_card = #{idCard}</if> + <if test="birthday != null "> and birthday = #{birthday}</if> + <if test="city != null and city != ''"> and city = #{city}</if> + <if test="province != null and province != ''"> and province = #{province}</if> + <if test="isBlacklist != null "> and is_blacklist = #{isBlacklist}</if> + </where> + </select> </mapper> \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index dab2bf879..e94ae78e6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -45,8 +45,7 @@ public class SysLoginController { AjaxResult ajax = AjaxResult.success(); // 生成令牌 - String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), - loginBody.getUuid()); + String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid()); ajax.put(Constants.TOKEN, token); return ajax; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 2b5474327..f52f8748a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -69,8 +69,7 @@ public class SysLoginService try { // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername - authentication = authenticationManager - .authenticate(new UsernamePasswordAuthenticationToken(username, password)); + authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); } catch (Exception e) {