Commit ed6444ac by Wangmin

新增 取消订单

parent 52c7c471
...@@ -5,17 +5,17 @@ import com.pz.common.core.controller.BaseController; ...@@ -5,17 +5,17 @@ import com.pz.common.core.controller.BaseController;
import com.pz.common.core.domain.PageQuery; 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.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.system.domain.bo.AccompanyAddressBo;
import com.pz.system.domain.vo.AccompanyDemandVo; import com.pz.system.domain.vo.AccompanyDemandVo;
import com.pz.system.service.IDbmyOrderService;
import com.pz.system.service.ITotalOrderService; import com.pz.system.service.ITotalOrderService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -37,6 +37,8 @@ public class EmployeesAccompanyController extends BaseController { ...@@ -37,6 +37,8 @@ public class EmployeesAccompanyController extends BaseController {
private final IEmployeesService employeesService; private final IEmployeesService employeesService;
private final IDbmyOrderService dbmyOrderService;
/** /**
* 需求广场 列表 * 需求广场 列表
...@@ -83,4 +85,20 @@ public class EmployeesAccompanyController extends BaseController { ...@@ -83,4 +85,20 @@ public class EmployeesAccompanyController extends BaseController {
return employeesService.queryAllOrder(bo, pageQuery); return employeesService.queryAllOrder(bo, pageQuery);
} }
@PutMapping("/cancel")
public R<Boolean> cancelOrder() {
return null;
}
/**
* 设置代办买药 陪诊员地址
*
* @param bo 地址
* @return 操作结果
*/
@PutMapping("/setAddress")
public R<Boolean> updateAccompanyAddress(@Validated(EditGroup.class) @RequestBody AccompanyAddressBo bo) {
return R.ok(dbmyOrderService.updateAccompanyAddress(bo));
}
} }
...@@ -27,7 +27,7 @@ captcha: ...@@ -27,7 +27,7 @@ captcha:
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口,默认为8080 # 服务器的HTTP端口,默认为8080
port: 8089 port: 9524
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
......
...@@ -14,6 +14,7 @@ import com.pz.merchant.domain.vo.CompanyAppVo; ...@@ -14,6 +14,7 @@ import com.pz.merchant.domain.vo.CompanyAppVo;
import com.pz.merchant.domain.vo.CompanyBalanceVo; import com.pz.merchant.domain.vo.CompanyBalanceVo;
import com.pz.merchant.domain.vo.FinanceStatisticVo; import com.pz.merchant.domain.vo.FinanceStatisticVo;
import com.pz.merchant.service.ICompanyService; import com.pz.merchant.service.ICompanyService;
import com.pz.system.domain.bo.WithdrawDepositBo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -83,4 +84,13 @@ public class CompanyController extends BaseController { ...@@ -83,4 +84,13 @@ public class CompanyController extends BaseController {
return R.ok(companyService.queryCompanyBalance(bo, page)); return R.ok(companyService.queryCompanyBalance(bo, page));
} }
/**
* 提现
*/
@PutMapping("/withdraw")
public R<Boolean> withdrawDeposit(@RequestBody WithdrawDepositBo bo) {
// TODO: 2023/9/14 提现暂时搁置
return R.ok(true);
}
} }
...@@ -9,6 +9,7 @@ import com.pz.merchant.service.impl.SonOrderServiceBuilder; ...@@ -9,6 +9,7 @@ import com.pz.merchant.service.impl.SonOrderServiceBuilder;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
......
...@@ -10,6 +10,10 @@ import com.pz.merchant.domain.vo.SonOrderVo; ...@@ -10,6 +10,10 @@ import com.pz.merchant.domain.vo.SonOrderVo;
* @version 1.0 * @version 1.0
*/ */
public interface ISonOrderService { public interface ISonOrderService {
/**
* 取消订单Redis前缀
*/
String ORDER_CANCEL_CACHE_PREFIX = "order_cancel_hash";
/** /**
* 根据主订单ID查询子订单相关信息 * 根据主订单ID查询子订单相关信息
...@@ -39,4 +43,13 @@ public interface ISonOrderService { ...@@ -39,4 +43,13 @@ public interface ISonOrderService {
throw new UnsupportedOperationException("不支持该操作"); throw new UnsupportedOperationException("不支持该操作");
} }
/**
* 陪诊员取消订单
*
* @param totalId 取消订单
* @return 操作结果
*/
default boolean accompanyCancellationOfOrder(Integer totalId){
return true;}
} }
...@@ -41,7 +41,7 @@ public class DbghOrder extends BaseEntity { ...@@ -41,7 +41,7 @@ public class DbghOrder extends BaseEntity {
/** /**
* 期望就诊时间 * 期望就诊时间
*/ */
private String visitTime; private Date visitTime;
/** /**
* 科室 * 科室
*/ */
......
...@@ -37,7 +37,7 @@ public class DbwzOrder extends BaseEntity { ...@@ -37,7 +37,7 @@ public class DbwzOrder extends BaseEntity {
/** /**
* 期望就诊时间 * 期望就诊时间
*/ */
private String visitTime; private Date visitTime;
/** /**
* 科室 * 科室
*/ */
......
...@@ -45,7 +45,7 @@ public class YypzOrder extends BaseEntity { ...@@ -45,7 +45,7 @@ public class YypzOrder extends BaseEntity {
/** /**
* 就诊时间 * 就诊时间
*/ */
private String visitTime; private Date visitTime;
/** /**
* 预约电话 * 预约电话
*/ */
......
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/14 18:17
*
* @author WangMin
* @version 1.0
*/
@Data
public class AccompanyAddressBo {
/**
* 订单ID
*/
@NotNull(message = "订单ID不能为空", groups = EditGroup.class)
private Integer sonOrderId;
/**
* 陪诊员姓名
*/
private String accompanyName;
/**
* 收货地址
*/
private String address;
/**
* 收货电话
*/
private String phone;
/**
* 备注
*/
private String remark;
}
package com.pz.system.domain.bo;
import com.pz.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>created in 2023/9/14 17:41
*
* @author WangMin
* @version 1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class WithdrawDepositBo extends BaseEntity {
/**
* 唯一标识ID
*/
private Integer id;
/**
* 是否是商户
*/
private Boolean isMerchant;
/**
* 提现金额
*/
private Float amount;
}
...@@ -62,7 +62,6 @@ public class AccompanyDemandVo { ...@@ -62,7 +62,6 @@ public class AccompanyDemandVo {
/** /**
* 订单所属业务 * 订单所属业务
*/ */
@JsonIgnore private Integer businessId;
private Integer bid;
} }
...@@ -49,4 +49,9 @@ public class DbghOrderItemVo extends OrderCommonVo { ...@@ -49,4 +49,9 @@ public class DbghOrderItemVo extends OrderCommonVo {
*/ */
private Float commission; private Float commission;
/**
* 凭证
*/
private String voucher;
} }
...@@ -74,7 +74,17 @@ public class DbmyOrderItemVo extends OrderCommonVo { ...@@ -74,7 +74,17 @@ public class DbmyOrderItemVo extends OrderCommonVo {
private String remark; private String remark;
/** /**
* 主订单备注
*/
private String description;
/**
* 订单佣金 * 订单佣金
*/ */
private Float commission; private Float commission;
/**
* 凭证
*/
private String voucher;
} }
...@@ -70,4 +70,24 @@ public class DbwzOrderItemVo extends OrderCommonVo { ...@@ -70,4 +70,24 @@ public class DbwzOrderItemVo extends OrderCommonVo {
*/ */
private String remark; private String remark;
/**
* 主订单备注
*/
private String description;
/**
* 凭证
*/
private String voucher;
/**
* 上次就医情况
*/
private String lastMedicalTreatmentSituation;
/**
* 治疗后情况
*/
private String postTreatmentCondition;
} }
...@@ -42,4 +42,19 @@ public class ZyphOrderItemVo extends OrderCommonVo { ...@@ -42,4 +42,19 @@ public class ZyphOrderItemVo extends OrderCommonVo {
* 其他需求 * 其他需求
*/ */
private String description; private String description;
/**
* 陪护日期
*/
private String visitDate;
/**
* 陪护时间
*/
private String visitTime;
/**
* 凭证
*/
private String voucher;
} }
package com.pz.system.service; package com.pz.system.service;
import com.pz.system.domain.DbmyOrder; import com.pz.system.domain.DbmyOrder;
import com.pz.system.domain.bo.AccompanyAddressBo;
import com.pz.system.domain.vo.DbmyOrderVo; import com.pz.system.domain.vo.DbmyOrderVo;
import com.pz.system.domain.bo.DbmyOrderBo; import com.pz.system.domain.bo.DbmyOrderBo;
import com.pz.common.core.page.TableDataInfo; import com.pz.common.core.page.TableDataInfo;
...@@ -46,4 +47,12 @@ public interface IDbmyOrderService { ...@@ -46,4 +47,12 @@ public interface IDbmyOrderService {
* 校验并批量删除代办买药订单信息 * 校验并批量删除代办买药订单信息
*/ */
Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid);
/**
* 修改订单陪诊员收货地址
* @param bo 地址
* @return 操作结果
*/
boolean updateAccompanyAddress(AccompanyAddressBo bo);
} }
...@@ -27,6 +27,7 @@ public interface ITotalOrderService { ...@@ -27,6 +27,7 @@ public interface ITotalOrderService {
/** /**
* 查询用户订单详情 * 查询用户订单详情
*
* @param id * @param id
* @return * @return
*/ */
...@@ -62,6 +63,7 @@ public interface ITotalOrderService { ...@@ -62,6 +63,7 @@ public interface ITotalOrderService {
/** /**
* 用户取消订单 * 用户取消订单
*
* @param bo * @param bo
* @return * @return
*/ */
...@@ -69,6 +71,7 @@ public interface ITotalOrderService { ...@@ -69,6 +71,7 @@ public interface ITotalOrderService {
/** /**
* 用户主动退款 * 用户主动退款
*
* @param bo * @param bo
* @return * @return
*/ */
......
...@@ -7,9 +7,16 @@ import com.pz.common.core.domain.PageQuery; ...@@ -7,9 +7,16 @@ import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.common.exception.ServiceException;
import com.pz.common.utils.redis.RedisUtils;
import com.pz.merchant.domain.Employees;
import com.pz.merchant.domain.vo.SonOrderVo; import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService; import com.pz.merchant.service.ISonOrderService;
import com.pz.system.domain.DbwzOrder; import com.pz.system.domain.DbwzOrder;
import com.pz.system.domain.TotalOrder;
import com.pz.system.domain.YypzOrder;
import com.pz.system.mapper.TotalOrderMapper;
import com.pz.system.mapper.UserVsitorMapper; import com.pz.system.mapper.UserVsitorMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -20,6 +27,9 @@ import com.pz.system.mapper.DbghOrderMapper; ...@@ -20,6 +27,9 @@ import com.pz.system.mapper.DbghOrderMapper;
import com.pz.system.service.IDbghOrderService; import com.pz.system.service.IDbghOrderService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
/** /**
...@@ -34,8 +44,12 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService ...@@ -34,8 +44,12 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService
private final DbghOrderMapper baseMapper; private final DbghOrderMapper baseMapper;
private final TotalOrderMapper totalOrderMapper;
private final UserVsitorMapper userVsitorMapper; private final UserVsitorMapper userVsitorMapper;
private final EmployeesMapper employeesMapper;
/** /**
* 查询代办挂号订单 * 查询代办挂号订单
*/ */
...@@ -157,4 +171,56 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService ...@@ -157,4 +171,56 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService
public Object getSonOrderDetailDataByTotalId(Integer totalId) { public Object getSonOrderDetailDataByTotalId(Integer totalId) {
return baseMapper.selectDbghOrderDetailDateByTotalId(totalId); return baseMapper.selectDbghOrderDetailDateByTotalId(totalId);
} }
/**
* 陪诊员取消代办挂号订单
*
* @param totalId 取消订单
* @return 操作结果
*/
@Override
public boolean accompanyCancellationOfOrder(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
Integer emId = totalOrder.getEmId();
if (emId == 0) {
throw new ServiceException("订单暂未分配陪诊员,拒绝该操作");
}
DbghOrder dbghOrder = baseMapper.selectOne(Wrappers.<DbghOrder>lambdaQuery().eq(DbghOrder::getOrderId, totalId));
Objects.requireNonNull(dbghOrder, "子订单与主订单不一致!");
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前
int cancel = 0;
if (dbghOrder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(dbghOrder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
// 若在18小时前取消订单,需记录取消次数
if (visitTime.isBefore(currentDate) || ChronoUnit.HOURS.between(visitTime, currentDate) <= 18) {
// 取消次数
Integer cancelCount = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
cancel = cancelCount == null ? 1 : cancelCount + 1;
}
}
// 更新主订单数据
totalOrder.setEmId(0);
totalOrder.setSuborderStatus(0);
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("更新主订单失败");
}
// 更新子订单
dbghOrder.setStatus(0);
if (baseMapper.updateById(dbghOrder) < 0) {
throw new ServiceException("子订单更新失败");
}
// 若取消次数大于3,则冻结用户账号
if (cancel > 3) {
if (employeesMapper.update(null,
Wrappers.<Employees>lambdaUpdate().set(Employees::getStatus, 2)
.eq(Employees::getId, emId)) < 0) {
throw new ServiceException("用户冻结失败");
}
}
RedisUtils.setCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId), cancel);
return true;
}
} }
package com.pz.system.service.impl; package com.pz.system.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.pz.common.core.page.TableDataInfo; import com.pz.common.core.page.TableDataInfo;
import com.pz.common.core.domain.PageQuery; import com.pz.common.core.domain.PageQuery;
...@@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.merchant.domain.vo.SonOrderVo; import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.service.ISonOrderService; import com.pz.merchant.service.ISonOrderService;
import com.pz.system.domain.DbwzOrder; import com.pz.system.domain.DbwzOrder;
import com.pz.system.domain.bo.AccompanyAddressBo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.pz.system.domain.bo.DbmyOrderBo; import com.pz.system.domain.bo.DbmyOrderBo;
...@@ -128,6 +130,25 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService ...@@ -128,6 +130,25 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService
return baseMapper.deleteBatchIds(ids) > 0; return baseMapper.deleteBatchIds(ids) > 0;
} }
/**
* 修改订单陪诊员收货地址
*
* @param bo 地址
* @return 操作结果
*/
@Override
public boolean updateAccompanyAddress(AccompanyAddressBo bo) {
DbmyOrder dbmyOrder = baseMapper.selectById(bo.getSonOrderId());
Objects.requireNonNull(dbmyOrder, "订单不存在");
LambdaUpdateWrapper<DbmyOrder> wrapper = Wrappers.lambdaUpdate();
wrapper.set(StringUtils.isNotEmpty(bo.getAccompanyName()), DbmyOrder::getPzShr, bo.getAccompanyName())
.set(StringUtils.isNotEmpty(bo.getAddress()), DbmyOrder::getPzAddress, bo.getAddress())
.set(StringUtils.isNotEmpty(bo.getPhone()), DbmyOrder::getPzShPhone, bo.getPhone())
.set(StringUtils.isNotEmpty(bo.getRemark()), DbmyOrder::getPzShRemake, bo.getRemark())
.eq(DbmyOrder::getId, bo.getSonOrderId());
return baseMapper.update(null, wrapper) > 0;
}
@Override @Override
public SonOrderVo getSonOrderSimpleDataByTotalId(Integer totalId) { public SonOrderVo getSonOrderSimpleDataByTotalId(Integer totalId) {
return baseMapper.selectSonOrderInfoByTotalId(totalId); return baseMapper.selectSonOrderInfoByTotalId(totalId);
......
...@@ -7,8 +7,15 @@ import com.pz.common.core.domain.PageQuery; ...@@ -7,8 +7,15 @@ import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.common.exception.ServiceException;
import com.pz.common.utils.redis.RedisUtils;
import com.pz.merchant.domain.Employees;
import com.pz.merchant.domain.vo.SonOrderVo; import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService; import com.pz.merchant.service.ISonOrderService;
import com.pz.system.domain.TotalOrder;
import com.pz.system.domain.YypzOrder;
import com.pz.system.mapper.TotalOrderMapper;
import com.pz.system.mapper.UserVsitorMapper; import com.pz.system.mapper.UserVsitorMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -19,6 +26,9 @@ import com.pz.system.mapper.DbwzOrderMapper; ...@@ -19,6 +26,9 @@ import com.pz.system.mapper.DbwzOrderMapper;
import com.pz.system.service.IDbwzOrderService; import com.pz.system.service.IDbwzOrderService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
/** /**
...@@ -32,8 +42,9 @@ import java.util.*; ...@@ -32,8 +42,9 @@ import java.util.*;
public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService { public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService {
private final DbwzOrderMapper baseMapper; private final DbwzOrderMapper baseMapper;
private final UserVsitorMapper userVsitorMapper; private final UserVsitorMapper userVsitorMapper;
private final TotalOrderMapper totalOrderMapper;
private final EmployeesMapper employeesMapper;
/** /**
* 查询代办问诊订单 * 查询代办问诊订单
...@@ -163,4 +174,55 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService ...@@ -163,4 +174,55 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService
public Object getSonOrderDetailDataByTotalId(Integer totalId) { public Object getSonOrderDetailDataByTotalId(Integer totalId) {
return baseMapper.selectDbwzOrderDetailDataByTotalId(totalId); return baseMapper.selectDbwzOrderDetailDataByTotalId(totalId);
} }
/**
* 陪诊员取消代办问诊订单
*
* @param totalId 取消订单
* @return 操作结果
*/
@Override
public boolean accompanyCancellationOfOrder(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
Integer emId = totalOrder.getEmId();
if (emId == 0) {
throw new ServiceException("订单暂未分配陪诊员,拒绝该操作");
}
DbwzOrder dbwzOrder = baseMapper.selectOne(Wrappers.<DbwzOrder>lambdaQuery().eq(DbwzOrder::getOrderId, totalId));
Objects.requireNonNull(dbwzOrder, "子订单与主订单不一致!");
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前
int cancel = 0;
if (dbwzOrder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(dbwzOrder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
// 若在18小时前取消订单,需记录取消次数
if (visitTime.isBefore(currentDate) || ChronoUnit.HOURS.between(visitTime, currentDate) <= 18) {
// 取消次数
Integer cancelCount = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
cancel = cancelCount == null ? 1 : cancelCount + 1;
}
}
// 更新主订单数据
totalOrder.setEmId(0);
totalOrder.setSuborderStatus(0);
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("更新主订单失败");
}
// 更新子订单
dbwzOrder.setStatus(0);
if (baseMapper.updateById(dbwzOrder) < 0) {
throw new ServiceException("子订单更新失败");
}
// 若取消次数大于3,则冻结用户账号
if (cancel > 3) {
if (employeesMapper.update(null,
Wrappers.<Employees>lambdaUpdate().set(Employees::getStatus, 2)
.eq(Employees::getId, emId)) < 0) {
throw new ServiceException("用户冻结失败");
}
}
RedisUtils.setCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId), cancel);
return true;
}
} }
...@@ -40,7 +40,6 @@ import java.util.*; ...@@ -40,7 +40,6 @@ import java.util.*;
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TotalOrderServiceImpl implements ITotalOrderService { public class TotalOrderServiceImpl implements ITotalOrderService {
private final TotalOrderMapper baseMapper; private final TotalOrderMapper baseMapper;
private final SonOrderServiceBuilder serviceBuilder; private final SonOrderServiceBuilder serviceBuilder;
...@@ -412,13 +411,13 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -412,13 +411,13 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
public TableDataInfo<AccompanyDemandVo> queryUndistributedOrder(PageQuery page) { public TableDataInfo<AccompanyDemandVo> queryUndistributedOrder(PageQuery page) {
QueryWrapper<TotalOrder> wrapper = Wrappers.query(); QueryWrapper<TotalOrder> wrapper = Wrappers.query();
// 筛选未分配订单 // 筛选未分配订单
wrapper.apply("total_order.em_id = 0") wrapper.apply("total_order.em_id = 0") // 未分配陪诊员订单
.eq("total_order.status", 1) .in("total_order.status", 0, 1) // 待支付、已支付
.between("total_order.business_id", 1, 5); .between("total_order.business_id", 1, 5);
IPage<AccompanyDemandVo> result = baseMapper.selectUndistributedTotalOrder(page.build(), wrapper); IPage<AccompanyDemandVo> result = baseMapper.selectUndistributedTotalOrder(page.build(), wrapper);
// 装载子订单信息 // 装载子订单信息
result.getRecords().forEach(order -> { result.getRecords().forEach(order -> {
ISonOrderService orderService = serviceBuilder.getSonOrderService(order.getBid()); ISonOrderService orderService = serviceBuilder.getSonOrderService(order.getBusinessId());
SonOrderVo sonOrder; SonOrderVo sonOrder;
if (orderService != null && (sonOrder = orderService.getSonOrderSimpleDataByTotalId(order.getOrderId())) != null) { if (orderService != null && (sonOrder = orderService.getSonOrderSimpleDataByTotalId(order.getOrderId())) != null) {
order.setAvatar(sonOrder.getAvatar()); order.setAvatar(sonOrder.getAvatar());
...@@ -475,7 +474,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -475,7 +474,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
AccompanyDemandVo order = baseMapper.selectTotalOrderById(id); AccompanyDemandVo order = baseMapper.selectTotalOrderById(id);
Objects.requireNonNull(order, "未查询到订单信息"); Objects.requireNonNull(order, "未查询到订单信息");
// 装载子订单数据 // 装载子订单数据
ISonOrderService orderService = serviceBuilder.getSonOrderService(order.getBid()); ISonOrderService orderService = serviceBuilder.getSonOrderService(order.getBusinessId());
SonOrderVo sonOrder; SonOrderVo sonOrder;
if (orderService != null && (sonOrder = orderService.getSonOrderSimpleDataByTotalId(order.getOrderId())) != null) { if (orderService != null && (sonOrder = orderService.getSonOrderSimpleDataByTotalId(order.getOrderId())) != null) {
order.setSonOrderStatus(sonOrder.getOrderStatus()); order.setSonOrderStatus(sonOrder.getOrderStatus());
......
...@@ -7,9 +7,14 @@ import com.pz.common.core.domain.PageQuery; ...@@ -7,9 +7,14 @@ import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.common.exception.ServiceException;
import com.pz.common.utils.redis.RedisUtils;
import com.pz.merchant.domain.Employees;
import com.pz.merchant.domain.vo.SonOrderVo; import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService; import com.pz.merchant.service.ISonOrderService;
import com.pz.system.domain.DbwzOrder; import com.pz.system.domain.DbwzOrder;
import com.pz.system.domain.TotalOrder;
import com.pz.system.mapper.CityMapper; import com.pz.system.mapper.CityMapper;
import com.pz.system.mapper.TotalOrderMapper; import com.pz.system.mapper.TotalOrderMapper;
import com.pz.system.mapper.UserVsitorMapper; import com.pz.system.mapper.UserVsitorMapper;
...@@ -23,6 +28,10 @@ import com.pz.system.service.IYypzOrderService; ...@@ -23,6 +28,10 @@ import com.pz.system.service.IYypzOrderService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
/** /**
...@@ -36,7 +45,9 @@ import java.util.*; ...@@ -36,7 +45,9 @@ import java.util.*;
public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService { public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService {
private final YypzOrderMapper baseMapper; private final YypzOrderMapper baseMapper;
private final TotalOrderMapper totalOrderMapper;
private final UserVsitorMapper userVsitorMapper; private final UserVsitorMapper userVsitorMapper;
private final EmployeesMapper employeesMapper;
/** /**
* 查询预约陪诊订单 * 查询预约陪诊订单
...@@ -165,4 +176,56 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService ...@@ -165,4 +176,56 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService
public Object getSonOrderDetailDataByTotalId(Integer totalId) { public Object getSonOrderDetailDataByTotalId(Integer totalId) {
return baseMapper.selectYypzOrderDetailDataByTotalId(totalId); return baseMapper.selectYypzOrderDetailDataByTotalId(totalId);
} }
/**
* 陪诊员取消预约陪诊订单
*
* @param totalId 取消订单
* @return 操作结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean accompanyCancellationOfOrder(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
Integer emId = totalOrder.getEmId();
if (emId == 0) {
throw new ServiceException("订单暂未分配陪诊员,拒绝该操作");
}
YypzOrder yypzOrder = baseMapper.selectOne(Wrappers.<YypzOrder>lambdaQuery().eq(YypzOrder::getOrderId, totalId));
Objects.requireNonNull(yypzOrder, "子订单与主订单不一致!");
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前
int cancel = 0;
if (yypzOrder.getVisitTime() != null) {
LocalDateTime visitTime = LocalDateTime.ofInstant(yypzOrder.getVisitTime().toInstant(), ZoneId.systemDefault());
LocalDateTime currentDate = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
// 若在18小时前取消订单,需记录取消次数
if (visitTime.isBefore(currentDate) || ChronoUnit.HOURS.between(visitTime, currentDate) <= 18) {
// 取消次数
Integer cancelCount = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
cancel = cancelCount == null ? 1 : cancelCount + 1;
}
}
// 更新主订单数据
totalOrder.setEmId(0);
totalOrder.setSuborderStatus(0);
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("更新主订单失败");
}
// 更新子订单
yypzOrder.setStatus(0);
if (baseMapper.updateById(yypzOrder) < 0) {
throw new ServiceException("子订单更新失败");
}
// 若取消次数大于3,则冻结用户账号
if (cancel > 3) {
if (employeesMapper.update(null,
Wrappers.<Employees>lambdaUpdate().set(Employees::getStatus, 2)
.eq(Employees::getId, emId)) < 0) {
throw new ServiceException("用户冻结失败");
}
}
RedisUtils.setCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId), cancel);
return true;
}
} }
...@@ -7,10 +7,18 @@ import com.pz.common.core.domain.PageQuery; ...@@ -7,10 +7,18 @@ import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.common.exception.ServiceException;
import com.pz.common.utils.redis.RedisUtils;
import com.pz.merchant.domain.Employees;
import com.pz.merchant.domain.vo.SonOrderVo; import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService; import com.pz.merchant.service.ISonOrderService;
import com.pz.system.domain.DbwzOrder; import com.pz.system.domain.DbwzOrder;
import com.pz.system.domain.TotalOrder;
import com.pz.system.domain.YypzOrder;
import com.pz.system.mapper.TotalOrderMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.pz.system.domain.bo.ZyphOrderBo; import com.pz.system.domain.bo.ZyphOrderBo;
import com.pz.system.domain.vo.ZyphOrderVo; import com.pz.system.domain.vo.ZyphOrderVo;
...@@ -19,10 +27,12 @@ import com.pz.system.mapper.ZyphOrderMapper; ...@@ -19,10 +27,12 @@ import com.pz.system.mapper.ZyphOrderMapper;
import com.pz.system.service.IZyphOrderService; import com.pz.system.service.IZyphOrderService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.text.ParseException;
import java.util.Map; import java.text.SimpleDateFormat;
import java.util.Collection; import java.time.LocalDateTime;
import java.util.Objects; import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
/** /**
* 住院陪诊订单Service业务层处理 * 住院陪诊订单Service业务层处理
...@@ -32,9 +42,14 @@ import java.util.Objects; ...@@ -32,9 +42,14 @@ import java.util.Objects;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
@Slf4j
public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService { public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService {
private final ZyphOrderMapper baseMapper; private final ZyphOrderMapper baseMapper;
private final TotalOrderMapper totalOrderMapper;
private final EmployeesMapper employeesMapper;
private static final SimpleDateFormat DATETIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/** /**
* 查询住院陪诊订单 * 查询住院陪诊订单
...@@ -158,4 +173,63 @@ public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService ...@@ -158,4 +173,63 @@ public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService
public Object getSonOrderDetailDataByTotalId(Integer totalId) { public Object getSonOrderDetailDataByTotalId(Integer totalId) {
return baseMapper.selectZyphOrderDetailDataByTotalId(totalId); return baseMapper.selectZyphOrderDetailDataByTotalId(totalId);
} }
/**
* 陪诊员取消住院陪护订单
*
* @param totalId 取消订单
* @return 操作结果
*/
@Override
public boolean accompanyCancellationOfOrder(Integer totalId) {
TotalOrder totalOrder = totalOrderMapper.selectById(totalId);
Objects.requireNonNull(totalOrder, "主订单不存在");
Integer emId = totalOrder.getEmId();
if (emId == 0) {
throw new ServiceException("订单暂未分配陪诊员,拒绝该操作");
}
ZyphOrder zyphOrder = baseMapper.selectOne(Wrappers.<ZyphOrder>lambdaQuery().eq(ZyphOrder::getOrderId, totalId));
Objects.requireNonNull(zyphOrder, "子订单与主订单不一致!");
// 若设置了就诊时间,在取消订单时需要检查是否在18小时之前
int cancel = 0;
String dateTimeStr = zyphOrder.getStartDay() + " " + zyphOrder.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());
// 若在18小时前取消订单,需记录取消次数
if (visitTime.isBefore(currentDate) || ChronoUnit.HOURS.between(visitTime, currentDate) <= 18) {
// 取消次数
Integer cancelCount = RedisUtils.<Integer>getCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId));
cancel = cancelCount == null ? 1 : cancelCount + 1;
}
}
// 更新主订单数据
totalOrder.setEmId(0);
totalOrder.setSuborderStatus(0);
if (totalOrderMapper.updateById(totalOrder) < 0) {
throw new ServiceException("更新主订单失败");
}
// 更新子订单
zyphOrder.setStatus(0);
if (baseMapper.updateById(zyphOrder) < 0) {
throw new ServiceException("子订单更新失败");
}
// 若取消次数大于3,则冻结用户账号
if (cancel > 3) {
if (employeesMapper.update(null,
Wrappers.<Employees>lambdaUpdate().set(Employees::getStatus, 2)
.eq(Employees::getId, emId)) < 0) {
throw new ServiceException("用户冻结失败");
}
}
RedisUtils.setCacheMapValue(ISonOrderService.ORDER_CANCEL_CACHE_PREFIX, String.valueOf(emId), cancel);
return true;
}
} }
...@@ -77,7 +77,9 @@ ...@@ -77,7 +77,9 @@
hospital.name as hospital, hospital.name as hospital,
department.title as department, department.title as department,
dbgh_order.visit_time, dbgh_order.visit_time,
total_order.remark as description total_order.remark as description,
dbgh_order.remark,
dbgh_order.voucher
from total_order from total_order
left join dbgh_order on dbgh_order.order_id = total_order.id left join dbgh_order on dbgh_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
......
...@@ -84,7 +84,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -84,7 +84,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dbmy_order.adress as address, dbmy_order.adress as address,
dbmy_order.address_info, dbmy_order.address_info,
dbmy_order.is_refrigerate, dbmy_order.is_refrigerate,
total_order.remark total_order.remark as description,
dbmy_order.remark,
dbmy_order.voucher
from total_order from total_order
left join dbmy_order on dbmy_order.order_id = total_order.id left join dbmy_order on dbmy_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
......
...@@ -83,7 +83,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -83,7 +83,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dbwz_order.past_history, dbwz_order.past_history,
dbwz_order.related_reports, dbwz_order.related_reports,
dbwz_order.service_requirements, dbwz_order.service_requirements,
total_order.remark dbwz_order.last_medical_treatment_situation,
dbwz_order.post_treatment_condition,
total_order.remark as description,
dbwz_order.remark,
dbwz_order.voucher
from total_order from total_order
left join dbwz_order on dbwz_order.order_id = total_order.id left join dbwz_order on dbwz_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
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
services.name as project, services.name as project,
CONVERT((1 - services.fenmo / 100), decimal(10, 2)) * CONVERT((1 - services.fenmo / 100), decimal(10, 2)) *
CONVERT(services.price, decimal(10, 2)) as commission, CONVERT(services.price, decimal(10, 2)) as commission,
services.bid, total_order.business_id,
total_order.remark as description total_order.remark as description
from total_order from total_order
left join services on total_order.service_id = services.id left join services on total_order.service_id = services.id
......
...@@ -71,18 +71,22 @@ ...@@ -71,18 +71,22 @@
</select> </select>
<select id="selectZyphOrderDetailDataByTotalId" resultType="com.pz.system.domain.vo.ZyphOrderItemVo"> <select id="selectZyphOrderDetailDataByTotalId" resultType="com.pz.system.domain.vo.ZyphOrderItemVo">
select total_order.id as orderId, select total_order.id as orderId,
zyph_order.id as serviceOrderId, zyph_order.id as serviceOrderId,
total_order.business_id, total_order.business_id,
total_order.status as orderStatus, total_order.status as orderStatus,
zyph_order.status as serviceStatus, zyph_order.status as serviceStatus,
services.name as project, services.name as project,
CONVERT((1 - services.fenmo / 100), decimal(10, 2)) * CONVERT((1 - services.fenmo / 100), decimal(10, 2)) *
CONVERT(services.price, decimal(10, 2)) as commission, CONVERT(services.price, decimal(10, 2)) as commission,
user_vsitor.name as userName, user_vsitor.name as userName,
hospital.name as hospital, hospital.name as hospital,
department.title as department, department.title as department,
total_order.remark as description total_order.remark as description,
zyph_order.remark,
concat(zyph_order.start_day, ' ~ ', zyph_order.end_day) as visitDate,
concat(zyph_order.start_time, ' ~ ', zyph_order.end_time) as visitTime,
zyph_order.voucher
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