Commit dc985e34 by Wangmin

完善 开始服务

parent 4c486c26
...@@ -6,11 +6,16 @@ import com.pz.common.core.domain.PageQuery; ...@@ -6,11 +6,16 @@ import com.pz.common.core.domain.PageQuery;
import com.pz.common.core.domain.R; import com.pz.common.core.domain.R;
import com.pz.common.core.page.TableDataInfo; import com.pz.common.core.page.TableDataInfo;
import com.pz.common.core.validate.EditGroup; import com.pz.common.core.validate.EditGroup;
import com.pz.common.exception.ServiceException;
import com.pz.merchant.domain.bo.OrderBo; import com.pz.merchant.domain.bo.OrderBo;
import com.pz.merchant.domain.vo.OrderInfoVO; import com.pz.merchant.domain.vo.OrderInfoVO;
import com.pz.merchant.service.IEmployeesService; import com.pz.merchant.service.IEmployeesService;
import com.pz.merchant.service.ISonOrderService;
import com.pz.merchant.service.impl.SonOrderServiceBuilder;
import com.pz.system.domain.bo.AccompanyAddressBo; import com.pz.system.domain.bo.AccompanyAddressBo;
import com.pz.system.domain.bo.OrderCommonBo;
import com.pz.system.domain.vo.AccompanyDemandVo; import com.pz.system.domain.vo.AccompanyDemandVo;
import com.pz.system.domain.vo.OrderCommonVo;
import com.pz.system.service.IDbmyOrderService; import com.pz.system.service.IDbmyOrderService;
import com.pz.system.service.ITotalOrderService; import com.pz.system.service.ITotalOrderService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -31,7 +36,7 @@ import javax.validation.constraints.NotNull; ...@@ -31,7 +36,7 @@ import javax.validation.constraints.NotNull;
@RestController @RestController
@RequestMapping("app/accompany") @RequestMapping("app/accompany")
@SaIgnore @SaIgnore
public class AccompanyEmployeesAccompanyController extends BaseController { public class AccompanyController extends BaseController {
private final ITotalOrderService totalOrderService; private final ITotalOrderService totalOrderService;
...@@ -39,6 +44,8 @@ public class AccompanyEmployeesAccompanyController extends BaseController { ...@@ -39,6 +44,8 @@ public class AccompanyEmployeesAccompanyController extends BaseController {
private final IDbmyOrderService dbmyOrderService; private final IDbmyOrderService dbmyOrderService;
private final SonOrderServiceBuilder sonOrderServiceBuilder;
/** /**
* 需求广场 列表 * 需求广场 列表
...@@ -85,9 +92,34 @@ public class AccompanyEmployeesAccompanyController extends BaseController { ...@@ -85,9 +92,34 @@ public class AccompanyEmployeesAccompanyController extends BaseController {
return employeesService.queryAllOrder(bo, pageQuery); return employeesService.queryAllOrder(bo, pageQuery);
} }
/**
* 陪诊员取消订单
*
* @param bo 订单参数
* @return 操作结果
*/
@PutMapping("/cancel") @PutMapping("/cancel")
public R<Boolean> cancelOrder() { public R<Boolean> cancelOrder(@Validated(EditGroup.class) @RequestBody OrderCommonBo bo) {
return null; ISonOrderService orderService = sonOrderServiceBuilder.getSonOrderService(bo.getBusinessId());
if (orderService == null) {
throw new ServiceException("业务异常");
}
return R.ok(orderService.accompanyCancellationOfOrder(bo.getOrderId()));
}
/**
* 陪诊员取消订单
*
* @param bo 订单参数
* @return 操作结果
*/
@PutMapping("/startService")
public R<Boolean> startOrderService(@Validated(EditGroup.class) @RequestBody OrderCommonBo bo) {
ISonOrderService orderService = sonOrderServiceBuilder.getSonOrderService(bo.getBusinessId());
if (orderService == null) {
throw new ServiceException("业务异常");
}
return R.ok(orderService.accompanyStartService(bo.getOrderId()));
} }
/** /**
......
...@@ -51,4 +51,23 @@ public interface ISonOrderService { ...@@ -51,4 +51,23 @@ public interface ISonOrderService {
*/ */
boolean accompanyCancellationOfOrder(Integer totalId); boolean accompanyCancellationOfOrder(Integer totalId);
/**
* 陪诊员开始服务
*
* @param totalId 主订单ID
* @return 操作结果
*/
default boolean accompanyStartService(Integer totalId){
throw new UnsupportedOperationException("不支持该操作");
}
/**
* 陪诊员完成服务
* @param totalId 主订单ID
* @return 操作结果
*/
default boolean finishedService(Integer totalId) {
throw new UnsupportedOperationException("不支持该操作");
}
} }
package com.pz.system.domain.bo;
import com.pz.common.core.validate.EditGroup;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* <p>created in 2023/9/15 9:31
*
* @author WangMin
* @version 1.0
*/
@Data
public class OrderCommonBo {
/**
* 业务ID
*/
@NotNull(groups = EditGroup.class,message = "业务ID不能为空")
private Integer businessId;
/**
* 主订单ID
*/
@NotNull(groups = EditGroup.class,message = "主订单ID不能为空")
private Integer orderId;
}
package com.pz.system.domain.bo;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 订单已完成实体
* <p>created in 2023/9/15 11:43
*
* @author WangMin
* @version 1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OrderFinishedBo extends OrderCommonBo {
/**
* 凭证
*/
private String voucher;
/**
* 备注
*/
private String remark;
/**
* 主治医师
*/
private String doctor;
}
...@@ -57,4 +57,14 @@ public class ZyphOrderItemVo extends OrderCommonVo { ...@@ -57,4 +57,14 @@ public class ZyphOrderItemVo extends OrderCommonVo {
* 凭证 * 凭证
*/ */
private String voucher; private String voucher;
/**
* 评价
*/
private String evaluationContent;
/**
* 是否好评,0-未评价,1-好评,2-差评
*/
private Integer evaluationFlag;
} }
...@@ -181,7 +181,6 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService ...@@ -181,7 +181,6 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean accompanyCancellationOfOrder(Integer totalId) { public boolean accompanyCancellationOfOrder(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId); TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在"); Objects.requireNonNull(totalOrder, "主订单不存在");
Integer emId = totalOrder.getEmId(); Integer emId = totalOrder.getEmId();
...@@ -233,4 +232,9 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService ...@@ -233,4 +232,9 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService
} }
return true; return true;
} }
@Override
public boolean accompanyStartService(Integer totalId) {
throw new UnsupportedOperationException("此类业务订单不支持该操作");
}
} }
...@@ -207,21 +207,7 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService ...@@ -207,21 +207,7 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService
} }
DbmyOrder dbmyOrder = baseMapper.selectOne(Wrappers.<DbmyOrder>lambdaQuery().eq(DbmyOrder::getOrderId, totalId)); DbmyOrder dbmyOrder = baseMapper.selectOne(Wrappers.<DbmyOrder>lambdaQuery().eq(DbmyOrder::getOrderId, totalId));
Objects.requireNonNull(dbmyOrder, "子订单与主订单不一致!"); Objects.requireNonNull(dbmyOrder, "子订单与主订单不一致!");
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前 // 代办买药,取消时间判定操作
// 取消次数
Integer cancel = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
if (dbmyOrder.getOverTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(dbmyOrder.getOverTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
// 若缓存为空,则查询数据表
if (cancel == null) {
cancel = Optional.ofNullable(employeesMapper.selectById(emId).getKillOrder()).orElse(0);
}
// 若在18小时前取消订单,需记录取消次数
if (visitTime.isBefore(currentDate) || ChronoUnit.HOURS.between(visitTime, currentDate) <= 18) {
cancel++;
}
}
// 更新主订单数据 // 更新主订单数据
totalOrder.setEmId(0); totalOrder.setEmId(0);
totalOrder.setSuborderStatus(0); totalOrder.setSuborderStatus(0);
...@@ -233,18 +219,37 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService ...@@ -233,18 +219,37 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService
if (baseMapper.updateById(dbmyOrder) < 0) { if (baseMapper.updateById(dbmyOrder) < 0) {
throw new ServiceException("子订单更新失败"); throw new ServiceException("子订单更新失败");
} }
// 若取消次数大于3,则冻结用户账号 return true;
if (cancel != null && cancel > 3) {
if (employeesMapper.update(null,
Wrappers.<Employees>lambdaUpdate()
.set(Employees::getStatus, 2)
.set(Employees::getKillOrder, cancel)
.eq(Employees::getId, emId)) < 0) {
throw new ServiceException("用户冻结失败");
} }
/**
* 陪诊员开始服务代办买药订单
*
* @param totalId 主订单ID
* @return 操作结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean accompanyStartService(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
if (totalOrder.getStatus() != 1 || totalOrder.getEmId() == 0) { // 用户已付款
throw new ServiceException("主订单不符合开始服务要求");
}
DbmyOrder suborder = baseMapper.selectOne(Wrappers.<DbmyOrder>lambdaQuery().eq(DbmyOrder::getOrderId, totalId));
Objects.requireNonNull(suborder, "子订单不存在");
if (suborder.getStatus() != 1) { // 订单已接单
throw new ServiceException("子订单不符合开始服务要求");
} }
if (cancel != null) { // 代办买药,取消时间判定操作
RedisUtils.setCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId), cancel); // 修改子订单状态为开始服务
suborder.setStatus(6);
totalOrder.setSuborderStatus(6);
if (baseMapper.updateById(suborder) < 0) {
throw new ServiceException("操作失败,子订单异常");
}
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("操作失败,主订单异常");
} }
return true; return true;
} }
......
...@@ -195,8 +195,8 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService ...@@ -195,8 +195,8 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前 // 若设置了就诊时间,在取消订单时需要检查是否在18小时之前
// 取消次数 // 取消次数
Integer cancel = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId)); Integer cancel = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
if (dbwzOrder.getOverTime() != null) { if (dbwzOrder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(dbwzOrder.getOverTime().toInstant(), ZoneId.systemDefault()); LocalDateTime visitTime = LocalDateTime.ofInstant(dbwzOrder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault()); LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
// 若缓存为空,则查询数据表 // 若缓存为空,则查询数据表
if (cancel == null) { if (cancel == null) {
...@@ -233,4 +233,43 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService ...@@ -233,4 +233,43 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService
} }
return true; return true;
} }
/**
* 陪诊员开始服务待办问诊订单
*
* @param totalId 主订单ID
* @return 操作结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean accompanyStartService(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
if (totalOrder.getStatus() != 1 || totalOrder.getEmId() == 0) { // 用户已付款
throw new ServiceException("主订单不符合开始服务要求");
}
DbwzOrder suborder = baseMapper.selectOne(Wrappers.<DbwzOrder>lambdaQuery().eq(DbwzOrder::getOrderId, totalId));
Objects.requireNonNull(suborder, "子订单不存在");
if (suborder.getStatus() != 1) { // 订单已接单
throw new ServiceException("子订单不符合开始服务要求");
}
// 操作时间若未到达开始时间,则拒绝该操作
if (suborder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(suborder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
if (currentDate.isBefore(visitTime)) {
throw new ServiceException("请在到达陪诊时间后再点击开始服务");
}
}
// 修改子订单状态为开始服务
suborder.setStatus(6);
totalOrder.setSuborderStatus(6);
if (baseMapper.updateById(suborder) < 0) {
throw new ServiceException("操作失败,子订单异常");
}
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("操作失败,主订单异常");
}
return true;
}
} }
...@@ -87,46 +87,46 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -87,46 +87,46 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
@Override @Override
public TotalOrderVo queryByAppId(Integer id) { public TotalOrderVo queryByAppId(Integer id) {
TotalOrderVo totalOrderVo = baseMapper.selectByOrderId(id); TotalOrderVo totalOrderVo = baseMapper.selectByOrderId(id);
if(totalOrderVo.getBusinessId() == 1){//预约陪诊 if (totalOrderVo.getBusinessId() == 1) {// 预约陪诊
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId, totalOrderVo.getId())).getStatus() yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId, totalOrderVo.getId())).getStatus()
); );
}else if(totalOrderVo.getBusinessId() == 2){//代办挂号 } else if (totalOrderVo.getBusinessId() == 2) {// 代办挂号
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
dbghOrderMapper.selectOne(new LambdaQueryWrapper<DbghOrder>().eq(DbghOrder::getOrderId, totalOrderVo.getId())).getStatus() dbghOrderMapper.selectOne(new LambdaQueryWrapper<DbghOrder>().eq(DbghOrder::getOrderId, totalOrderVo.getId())).getStatus()
); );
}else if(totalOrderVo.getBusinessId() == 3){//代办问诊 } else if (totalOrderVo.getBusinessId() == 3) {// 代办问诊
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
dbwzOrderMapper.selectOne(new LambdaQueryWrapper<DbwzOrder>().eq(DbwzOrder::getOrderId, totalOrderVo.getId())).getStatus() dbwzOrderMapper.selectOne(new LambdaQueryWrapper<DbwzOrder>().eq(DbwzOrder::getOrderId, totalOrderVo.getId())).getStatus()
); );
}else if(totalOrderVo.getBusinessId() == 4){//住院陪护 } else if (totalOrderVo.getBusinessId() == 4) {// 住院陪护
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
zyphOrderMapper.selectOne(new LambdaQueryWrapper<ZyphOrder>().eq(ZyphOrder::getOrderId, totalOrderVo.getId())).getStatus() zyphOrderMapper.selectOne(new LambdaQueryWrapper<ZyphOrder>().eq(ZyphOrder::getOrderId, totalOrderVo.getId())).getStatus()
); );
}else if(totalOrderVo.getBusinessId() == 5){//代办买药 } else if (totalOrderVo.getBusinessId() == 5) {// 代办买药
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
dbmyOrderMapper.selectOne(new LambdaQueryWrapper<DbmyOrder>().eq(DbmyOrder::getOrderId, totalOrderVo.getId())).getStatus() dbmyOrderMapper.selectOne(new LambdaQueryWrapper<DbmyOrder>().eq(DbmyOrder::getOrderId, totalOrderVo.getId())).getStatus()
); );
}else if(totalOrderVo.getBusinessId() == 6){//诊前挂号 } else if (totalOrderVo.getBusinessId() == 6) {// 诊前挂号
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
zqghOrderMapper.selectOne(new LambdaQueryWrapper<ZqghOrder>().eq(ZqghOrder::getOrderId, totalOrderVo.getId())).getStatus() zqghOrderMapper.selectOne(new LambdaQueryWrapper<ZqghOrder>().eq(ZqghOrder::getOrderId, totalOrderVo.getId())).getStatus()
); );
}else if(totalOrderVo.getBusinessId() == 0){//商城订单 } else if (totalOrderVo.getBusinessId() == 0) {// 商城订单
StoreOrder storeOrder = storeOrderMapper.selectOne(new LambdaQueryWrapper<StoreOrder>().eq(StoreOrder::getOrderId, totalOrderVo.getId())); StoreOrder storeOrder = storeOrderMapper.selectOne(new LambdaQueryWrapper<StoreOrder>().eq(StoreOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus( totalOrderVo.setServiceStatus(
...@@ -278,7 +278,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -278,7 +278,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
baseMapper.insert(totalOrder); baseMapper.insert(totalOrder);
bo.setOrderId(totalOrder.getId().intValue()); bo.setOrderId(totalOrder.getId().intValue());
totalOrderVo.setOrderSn(totalOrder.getId()+""); totalOrderVo.setOrderSn(totalOrder.getId() + "");
totalOrderVo.setPayMoney(bo.getPayMoney()); totalOrderVo.setPayMoney(bo.getPayMoney());
if (bo.getBusinessId() == 1) {// 预约陪诊 if (bo.getBusinessId() == 1) {// 预约陪诊
...@@ -341,11 +341,11 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -341,11 +341,11 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
@Override @Override
public Boolean cancelOrder(TotalOrderBo bo) { public Boolean cancelOrder(TotalOrderBo bo) {
TotalOrder totalOrder = baseMapper.selectById(bo.getId()); TotalOrder totalOrder = baseMapper.selectById(bo.getId());
if(null != totalOrder.getEmId() && totalOrder.getEmId() != 0){//预约陪诊 if (null != totalOrder.getEmId() && totalOrder.getEmId() != 0) {// 预约陪诊
//yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId,totalOrder)); // yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId,totalOrder));
totalOrder.setStatus(TotalOrderStatus.CANCEL.getCode()); totalOrder.setStatus(TotalOrderStatus.CANCEL.getCode());
return baseMapper.updateById(totalOrder) > 0; return baseMapper.updateById(totalOrder) > 0;
}else { } else {
throw new ServiceException("该订单已分配给陪诊员,不允许取消订单!"); throw new ServiceException("该订单已分配给陪诊员,不允许取消订单!");
} }
} }
...@@ -360,7 +360,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -360,7 +360,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest(); WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
orderRequest.setBody(bo.getOrderTitle()); orderRequest.setBody(bo.getOrderTitle());
orderRequest.setOutTradeNo(totalOrder.getOrderSn()); orderRequest.setOutTradeNo(totalOrder.getOrderSn());
orderRequest.setTotalFee(money);//元转成分 orderRequest.setTotalFee(money);// 元转成分
orderRequest.setOpenid(sysUserMapper.selectById(loginUser.getUserId()).getOpenId()); orderRequest.setOpenid(sysUserMapper.selectById(loginUser.getUserId()).getOpenId());
orderRequest.setSpbillCreateIp("127.0.0.1"); orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl("http://127.0.0.1:8089/applet/totalOrder/orderPayCallBack"); orderRequest.setNotifyUrl("http://127.0.0.1:8089/applet/totalOrder/orderPayCallBack");
...@@ -541,15 +541,22 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -541,15 +541,22 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
} }
ISonOrderService orderService = serviceBuilder.getSonOrderService(totalOrder.getBusinessId()); ISonOrderService orderService = serviceBuilder.getSonOrderService(totalOrder.getBusinessId());
Objects.requireNonNull(orderService, "订单业务属性出错"); Objects.requireNonNull(orderService, "订单业务属性出错");
// 修改子订单状态为已接单 // 已接单状态
boolean sonOrderFlag = orderService.switchSonOrderStatus(totalOrder.getId(), 1); int target = 1;
// 代办挂号需额外处理
if (totalOrder.getBusinessId() == 2 && totalOrder.getStatus() == 1) {
// 若接单(待办挂号)时,订单已支付,则子订单状态应该修改为6(进行中)
target = 6;
}
// 修改子订单状态
boolean sonOrderFlag = orderService.switchSonOrderStatus(totalOrder.getId(), target);
if (!sonOrderFlag) { if (!sonOrderFlag) {
throw new ServiceException("子订单状态修改出错,接单失败"); throw new ServiceException("子订单状态修改出错,接单失败");
} }
// 绑定主订单陪诊员 // 绑定主订单陪诊员
totalOrder.setEmId(emId); totalOrder.setEmId(emId);
// 设置主订单中子订单状态为已接单 // 设置主订单中子订单状态为已接单
totalOrder.setSuborderStatus(1); totalOrder.setSuborderStatus(target);
boolean flag = baseMapper.updateById(totalOrder) > 0; boolean flag = baseMapper.updateById(totalOrder) > 0;
if (!flag) { if (!flag) {
throw new ServiceException("接单失败"); throw new ServiceException("接单失败");
......
...@@ -197,8 +197,8 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService ...@@ -197,8 +197,8 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前 // 若设置了就诊时间,在取消订单时需要检查是否在18小时之前
// 取消次数 // 取消次数
Integer cancel = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId)); Integer cancel = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
if (yypzOrder.getOverTime() != null) { if (yypzOrder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(yypzOrder.getOverTime().toInstant(), ZoneId.systemDefault()); LocalDateTime visitTime = LocalDateTime.ofInstant(yypzOrder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault()); LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
// 若缓存为空,则查询数据表 // 若缓存为空,则查询数据表
if (cancel == null) { if (cancel == null) {
...@@ -235,4 +235,43 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService ...@@ -235,4 +235,43 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService
} }
return true; return true;
} }
/**
* 陪诊员预约陪诊开始服务
*
* @param totalId 主订单ID
* @return 操作结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean accompanyStartService(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
if (totalOrder.getStatus() != 1 || totalOrder.getEmId() == 0) { // 用户已付款
throw new ServiceException("主订单不符合开始服务要求");
}
YypzOrder suborder = baseMapper.selectOne(Wrappers.<YypzOrder>lambdaQuery().eq(YypzOrder::getOrderId, totalId));
Objects.requireNonNull(suborder, "子订单不存在");
if (suborder.getStatus() != 1) { // 订单已接单
throw new ServiceException("子订单不符合开始服务要求");
}
// 操作时间若未到达开始时间,则拒绝该操作
if (suborder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(suborder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
if (currentDate.isBefore(visitTime)) {
throw new ServiceException("请在到达陪诊时间后再点击开始服务");
}
}
// 修改子订单状态为开始服务
suborder.setStatus(6);
totalOrder.setSuborderStatus(6);
if (baseMapper.updateById(suborder) < 0) {
throw new ServiceException("操作失败,子订单异常");
}
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("操作失败,主订单异常");
}
return true;
}
} }
...@@ -239,4 +239,50 @@ public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService ...@@ -239,4 +239,50 @@ public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService
} }
return true; return true;
} }
/**
* 陪诊员开始服务住院陪护订单
*
* @param totalId 主订单ID
* @return 操作结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean accompanyStartService(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
if (totalOrder.getStatus() != 1 || totalOrder.getEmId() == 0) { // 用户已付款
throw new ServiceException("主订单不符合开始服务要求");
}
ZyphOrder suborder = baseMapper.selectOne(Wrappers.<ZyphOrder>lambdaQuery().eq(ZyphOrder::getOrderId, totalId));
Objects.requireNonNull(suborder, "子订单不存在");
if (suborder.getStatus() != 1) { // 订单已接单
throw new ServiceException("子订单不符合开始服务要求");
}
String dateTimeStr = suborder.getStartDay() + " " + suborder.getEndTime();
Date paseDateTime = null;
try {
paseDateTime = DATETIME_FORMAT.parse(dateTimeStr);
} catch (ParseException e) {
log.error("时间解析失败");
}
// 操作时间若未到达开始时间,则拒绝该操作
if (paseDateTime != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(paseDateTime.toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
if (currentDate.isBefore(visitTime)) {
throw new ServiceException("请在到达陪诊时间后再点击开始服务");
}
}
// 修改子订单状态为开始服务
suborder.setStatus(6);
totalOrder.setSuborderStatus(6);
if (baseMapper.updateById(suborder) < 0) {
throw new ServiceException("操作失败,子订单异常");
}
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("操作失败,主订单异常");
}
return true;
}
} }
...@@ -86,7 +86,9 @@ ...@@ -86,7 +86,9 @@
zyph_order.remark, zyph_order.remark,
concat(zyph_order.start_day, ' ~ ', zyph_order.end_day) as visitDate, concat(zyph_order.start_day, ' ~ ', zyph_order.end_day) as visitDate,
concat(zyph_order.start_time, ' ~ ', zyph_order.end_time) as visitTime, concat(zyph_order.start_time, ' ~ ', zyph_order.end_time) as visitTime,
zyph_order.voucher zyph_order.voucher,
total_order.evaluation_content,
total_order.is_satisfaction as evaluation_flag
from total_order from total_order
left join zyph_order on zyph_order.order_id = total_order.id left join zyph_order on zyph_order.order_id = total_order.id
left join services on total_order.service_id = services.id left join services on total_order.service_id = services.id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment