Commit d24f12b8 by sdif

用户端代码提交

parent da4b9159
......@@ -69,6 +69,6 @@ public class AppletCommonController extends BaseController {
*/
@GetMapping("/cityVoList")
public R<List<CityVo>> cityVoList(CityBo bo) {
return R.ok(iCityService.queryList(bo));
return R.ok(iCityService.queryAppList(bo));
}
}
......@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.github.binarywang.wxpay.exception.WxPayException;
......@@ -38,9 +39,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.*;
/**
* 总订单
......@@ -109,14 +108,7 @@ public class AppletTotalOrderController extends BaseController {
return toAjax(iTotalOrderService.deleteWithValidByIds(Arrays.asList(ids), true));
}
/**
* 用户主动退款
*/
@RepeatSubmit()
@PostMapping("/refundOrder")
public R<Void> refundOrder(@Validated(AddGroup.class) @RequestBody TotalOrderBo recordBo) {
return toAjax(iTotalOrderService.refundOrder(recordBo));
}
/**
* 用户评价订单
......@@ -137,6 +129,15 @@ public class AppletTotalOrderController extends BaseController {
}
/**
* 用户完成订单
*/
@RepeatSubmit()
@PostMapping("/finishOrder")
public R<Void> finishOrder(@Validated(AddGroup.class) @RequestBody TotalOrderBo recordBo) {
return toAjax(iTotalOrderService.finishOrder(recordBo));
}
/**
* 订单支付
*/
@RepeatSubmit()
......@@ -150,20 +151,66 @@ public class AppletTotalOrderController extends BaseController {
*/
@ResponseBody
@PostMapping("/orderPayCallBack")
public R<Void> orderPayCallBack(HttpServletRequest request, HttpServletResponse response) {
public Map orderPayCallBack(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> map = new HashMap();
try {
String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
WxPayOrderNotifyResult result = iPayService.parseOrderNotifyResult(xmlResult);
// 加入自己处理订单的业务逻辑,需要判断订单是否已经支付过,否则可能会重复调用
/* String orderNum = result.getOutTradeNo();
iTotalOrderService.*/
if(iTotalOrderService.orderPayCallBack(result)){
map.put("code", "SUCCESS");
map.put("message", "成功");
return map;
}
return R.ok();
} catch (Exception e) {
System.out.println("微信回调结果异常,异常原因" + e.getMessage());
return R.fail();
map.put("code", "fail");
map.put("message", "系统错误");
return map;
}
map.put("code", "fail");
map.put("message", "系统错误");
return map;
}
/**
* 用户主动退款
*/
@RepeatSubmit()
@PostMapping("/refundOrder")
public R<Void> refundOrder(@Validated(AddGroup.class) @RequestBody TotalOrderBo recordBo) {
return toAjax(iTotalOrderService.refundOrder(recordBo));
}
/**
* 退款回调
*/
@ResponseBody
@PostMapping("/orderRefundCallBack")
public Map orderRefundCallBack(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> map = new HashMap();
try {
String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
WxPayRefundNotifyResult result = iPayService.parseRefundNotifyResult(xmlResult);
// 加入自己处理订单的业务逻辑,需要判断订单是否已经支付过,否则可能会重复调用
if(iTotalOrderService.orderRefundCallBack(result)){
map.put("code", "SUCCESS");
map.put("message", "成功");
return map;
}
} catch (Exception e) {
System.out.println("微信回调结果异常,异常原因" + e.getMessage());
map.put("code", "fail");
map.put("message", "系统错误");
return map;
}
map.put("code", "fail");
map.put("message", "系统错误");
return map;
}
}
package com.pz.applet;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.pz.common.annotation.Log;
import com.pz.common.annotation.RepeatSubmit;
import com.pz.common.core.controller.BaseController;
import com.pz.common.core.domain.PageQuery;
import com.pz.common.core.domain.R;
import com.pz.common.core.page.TableDataInfo;
import com.pz.common.core.validate.AddGroup;
import com.pz.common.core.validate.EditGroup;
import com.pz.common.enums.BusinessType;
import com.pz.common.utils.poi.ExcelUtil;
import com.pz.system.domain.bo.ZqghOrderBo;
import com.pz.system.domain.vo.ZqghOrderVo;
import com.pz.system.service.IZqghOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 诊前挂号订单
*
* @author ruoyi
* @date 2023-09-12
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/applet/zqghOrder")
public class AppletZqghOrderController extends BaseController {
private final IZqghOrderService iZqghOrderService;
/**
* 查询诊前挂号订单列表
*/
@PostMapping("/list")
public R<List<ZqghOrderVo>> list(@RequestBody ZqghOrderBo bo) {
return R.ok(iZqghOrderService.queryAppList(bo));
}
}
package com.pz.system.datastructure;
import com.pz.system.domain.TotalOrder;
import com.pz.system.domain.bo.TotalOrderBo;
import com.pz.system.service.ITotalOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.concurrent.DelayQueue;
@Component
public class OrderDelayQueue {
private DelayQueue<TotalOrder> delayQueue = new DelayQueue<>();
@Autowired
private ITotalOrderService iTotalOrderService;
// 添加订单到延时队列
public void addOrder(TotalOrder order) {
delayQueue.put(order);
}
// 处理过期订单
@Scheduled(fixedDelay = 5000) // 每5秒触发一次任务
public void processExpiredOrders() {
long currentTime = System.currentTimeMillis();
while (true) {
TotalOrder order = delayQueue.peek();
if (order == null || order.getExpirationTime() > currentTime) {
break;
}
order = delayQueue.poll();
cancelOrder(order);
}
}
// 取消订单的逻辑
private void cancelOrder(TotalOrder order) {
TotalOrderBo totalOrderBo = new TotalOrderBo();
totalOrderBo.setId(order.getId());
// 执行取消订单的相关操作
iTotalOrderService.cancelOrder(totalOrderBo);
}
}
......@@ -68,4 +68,5 @@ public class DbghOrder extends BaseEntity {
*/
private String remark;
}
......@@ -39,11 +39,11 @@ public class PaymentRecord extends BaseEntity {
/**
* 金额
*/
private Long money;
private Double money;
/**
* 用户
*/
private Long uid;
private Integer uid;
/**
* 删除标志(0代表存在 2代表删除)
*/
......
......@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.annotation.*;
import com.pz.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
/**
......@@ -15,7 +19,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("total_order")
public class TotalOrder extends BaseEntity {
public class TotalOrder extends BaseEntity implements Delayed {
private static final long serialVersionUID = 1L;
......@@ -87,4 +91,19 @@ public class TotalOrder extends BaseEntity {
@TableLogic
private String delFlag;
@TableField(exist = false)
private long expirationTime; // 订单过期时间
@Override
public long getDelay(@NotNull TimeUnit unit) {
// 计算订单到期时间和当前时间的时间差,并返回以指定时间单位表示的延迟时间
long diff = expirationTime - System.currentTimeMillis();
return unit.convert(diff, TimeUnit.MILLISECONDS);
}
@Override
public int compareTo(@NotNull Delayed o) {
// 比较订单到期时间先后顺序
return Long.compare(expirationTime, ((TotalOrder) o).expirationTime);
}
}
......@@ -100,7 +100,7 @@ public class CreateOrderBo extends BaseEntity {
/**
* 相关报告(文件数组)
*/
private List<String> relatedReports;
private String relatedReports;
/**
* 开始日期
......@@ -140,7 +140,7 @@ public class CreateOrderBo extends BaseEntity {
/**
* 处方附件(文件数组)
*/
private List<String> prescriptionAttachment;
private String prescriptionAttachment;
/**
* 取药方式:0-邮寄到家,1-送货上门
......
......@@ -6,6 +6,8 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
......
......@@ -6,6 +6,8 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
......@@ -75,4 +77,10 @@ public class ZqghOrderBo extends BaseEntity {
private String remark;
private String orderSn;
/**
* 预约时间段
*/
private List<String> timeOfAppointmentArr;
}
......@@ -6,6 +6,8 @@ import com.pz.common.annotation.ExcelDictFormat;
import com.pz.common.convert.ExcelDictConvert;
import lombok.Data;
import java.util.List;
/**
* 城市视图对象 city
......@@ -43,5 +45,6 @@ public class CityVo {
@ExcelProperty(value = "")
private String sy;
private List<CityVo> cityVo;
}
......@@ -7,6 +7,7 @@ import com.pz.common.convert.ExcelDictConvert;
import com.pz.system.domain.StoreGoodsTag;
import lombok.Data;
import java.util.Date;
import java.util.List;
......@@ -181,4 +182,109 @@ public class TotalOrderVo {
*/
private String project;
/**
* 陪护日期
*/
private String phrq;
/**
* 陪护时间
*/
private String phsj;
/**
* 凭证图片
*/
private String voucher;
/**
* 服务完成状态
*/
private Date overTime;
/**
* 主诉
*/
private String chiefComplaint;
/**
* 现病史
*/
private String historyOfPresentIllness;
/**
* 上次就医情况
*/
private String pastHistory;
/**
* 治疗后情况
*/
private String postTreatmentCondition;
/**
* 相关报告
*/
private String relatedReports;
/**
* 服务要求
*/
private String serviceRequirements;
/**
* 说明
*/
private String indications;
/**
* 药品名称
*/
private String ypName;
/**
* 药店地址
*/
private String ydAddress;
/**
* 是否处方药
*/
private Integer isCf;
/**
* 处方附件
*/
private String prescriptionAttachment;
/**
* 取药方式:0-邮寄到家,1-送货上门
*/
private String way;
/**
* 收件人
*/
private String recipient;
/**
* 收货地址
*/
private String adress;
/**
* 详细地址
*/
private String addressInfo;
/**
*是否冷藏
*/
private Integer isRefrigerate;
/**
* 预约时间
*/
private String timeOfAppointment;
}
......@@ -136,4 +136,9 @@ public class ZqghOrderVo {
private String userName;
private Date createTime;
/**
* 预约数量
*/
private Integer num;
}
......@@ -5,6 +5,8 @@ import com.pz.system.domain.vo.CityVo;
import com.pz.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 城市Mapper接口
*
......@@ -13,5 +15,5 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CityMapper extends BaseMapperPlus<CityMapper, City, CityVo> {
List<CityVo> selectAppCity();
}
package com.pz.system.service;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayRefundQueryRequest;
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
......@@ -94,5 +95,5 @@ public interface IPayService {
* 微信请求的接口,要求可以公网访问,要放开token校验
* @param xmlData 微信提交的请求参数
*/
String parseRefundNotifyResult(String xmlData) throws WxPayException;
WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws WxPayException;
}
package com.pz.system.service;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.pz.system.domain.TotalOrder;
import com.pz.system.domain.bo.CreateOrderBo;
import com.pz.system.domain.vo.AccompanyDemandVo;
......@@ -68,6 +70,13 @@ public interface ITotalOrderService {
* @return
*/
Boolean cancelOrder(TotalOrderBo bo);
/**
* 用户完成订单
*
* @param bo
* @return
*/
Boolean finishOrder(TotalOrderBo bo);
/**
* 统一下单接口
......@@ -77,6 +86,13 @@ public interface ITotalOrderService {
Object payOrder(TotalOrderBo bo);
/**
* 支付回调
* @param result
* @return
*/
boolean orderPayCallBack(WxPayOrderNotifyResult result);
/**
* 用户主动退款
*
* @param bo
......@@ -84,6 +100,8 @@ public interface ITotalOrderService {
*/
Boolean refundOrder(TotalOrderBo bo);
boolean orderRefundCallBack(WxPayRefundNotifyResult wxPayRefundNotifyResult);
/**
* 校验并批量删除总订单信息
*/
......
......@@ -8,6 +8,7 @@ import com.pz.common.core.domain.PageQuery;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 诊前挂号订单Service接口
......@@ -33,6 +34,13 @@ public interface IZqghOrderService {
List<ZqghOrderVo> queryList(ZqghOrderBo bo);
/**
* 小程序诊前挂号列表
* @param bo
* @return
*/
List<ZqghOrderVo> queryAppList(ZqghOrderBo bo);
/**
* 新增诊前挂号订单
*/
Boolean insertByBo(ZqghOrderBo bo);
......
......@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.common.helper.LoginHelper;
import com.pz.common.utils.JsonUtils;
import com.pz.system.domain.ArticleComment;
import com.pz.system.domain.UserAppreciate;
import com.pz.system.domain.UserCollect;
......@@ -139,7 +140,8 @@ public class ArticleServiceImpl implements IArticleService {
LambdaQueryWrapper<Article> lqw = new LambdaQueryWrapper<>();
//Page<ArticleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
// TODO 待登录写完修改
int userId = LoginHelper.getLoginUser().getUserId().intValue();
//int userId = LoginHelper.getLoginUser().getUserId().intValue();
int userId = 1;
Page<ArticleVo> result = new Page<>();
//判断是否展示收藏文章
if(bo.getIsCollect() == 1){
......@@ -150,10 +152,14 @@ public class ArticleServiceImpl implements IArticleService {
.map(UserCollect::getAid)
.collect(Collectors.toList());
if(articleIds.size() != 0) {
//查询用户收藏的所有文章
bo.setArticleId(articleIds);
lqw = buildQueryWrapper(bo);
result = baseMapper.selectVoPage(pageQuery.build(), lqw);
}
}else if(bo.getIsCollect() == 0){
result = baseMapper.selectVoPage(pageQuery.build(), lqw);
}
......@@ -183,7 +189,7 @@ public class ArticleServiceImpl implements IArticleService {
// 设置城市名称、点赞数和收藏数
articleVos.forEach(articleVo -> {
// 去除方括号
/* // 去除方括号
String numbers = articleVo.getCover().substring(1, articleVo.getCover().length() - 1);
// 使用逗号分割字符串
......@@ -193,8 +199,9 @@ public class ArticleServiceImpl implements IArticleService {
List<String> integerList = new ArrayList<>();
for (String num : numberArray) {
integerList.add(num.trim());
}
articleVo.setCoverList(integerList);
}*/
List<String> ids = JsonUtils.parseArray(articleVo.getCover(), String.class);
articleVo.setCoverList(ids);
// 设置点赞数
articleVo.setAppreciateNum(appreciateNumMap.getOrDefault(articleVo.getId(), 0));
......@@ -221,7 +228,9 @@ public class ArticleServiceImpl implements IArticleService {
LambdaQueryWrapper<Article> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getTitle()), Article::getTitle, bo.getTitle());
lqw.eq(!Objects.isNull(bo.getCityId()), Article::getCityId, bo.getCityId());
lqw.in(CollectionUtils.isNotEmpty(bo.getArticleId()), Article::getId, bo.getArticleId());
if(null != bo.getArticleId() && bo.getArticleId().size() != 0){
lqw.in(Article::getId, bo.getArticleId());
}
return lqw;
}
......
......@@ -60,9 +60,11 @@ public class CityServiceImpl implements ICityService {
@Override
public List<CityVo> queryAppList(CityBo bo) {
LambdaQueryWrapper<City> lqw = buildQueryWrapper(bo);
List<CityVo> cityVos = baseMapper.selectVoList(lqw);
return null;
List<CityVo> cityVos = baseMapper.selectAppCity();
for (CityVo cityVo : cityVos) {
cityVo.setCityVo(baseMapper.selectVoList(new LambdaQueryWrapper<City>().eq(City::getSy,cityVo.getSy())));
}
return cityVos;
}
private LambdaQueryWrapper<City> buildQueryWrapper(CityBo bo) {
......
......@@ -118,10 +118,10 @@ public class PayServiceImpl implements IPayService {
* @throws WxPayException
*/
@Override
public String parseRefundNotifyResult(String xmlData) throws WxPayException {
public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws WxPayException {
// 参数解析
final WxPayRefundNotifyResult result = this.wxService.parseRefundNotifyResult(xmlData);
// TODO 根据自己业务场景需要构造返回对象
return WxPayNotifyResponse.success("成功");
return result;
}
}
......@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.pz.common.core.domain.model.LoginUser;
import com.pz.common.core.page.TableDataInfo;
......@@ -17,15 +19,18 @@ import com.pz.common.enums.ShopOrderStatus;
import com.pz.common.enums.TotalOrderStatus;
import com.pz.common.exception.ServiceException;
import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService;
import com.pz.merchant.service.impl.SonOrderServiceBuilder;
import com.pz.common.helper.LoginHelper;
import com.pz.system.datastructure.OrderDelayQueue;
import com.pz.system.domain.*;
import com.pz.system.domain.bo.CreateOrderBo;
import com.pz.system.domain.vo.AccompanyDemandVo;
import com.pz.system.mapper.*;
import com.pz.system.service.IPayService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pz.system.domain.bo.TotalOrderBo;
import com.pz.system.domain.vo.TotalOrderVo;
......@@ -34,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* 总订单Service业务层处理
......@@ -76,6 +82,19 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
private final SysUserMapper sysUserMapper;
private final HospitalMapper hospitalMapper;
private final DoctorMapper doctorMapper;
private final DepartmentMapper departmentMapper;
private final EmployeesMapper employeesMapper;
private final PaymentRecordMapper paymentRecordMapper;
@Autowired
private OrderDelayQueue delayQueue;
@Override
public TotalOrderVo queryById(Long id) {
return baseMapper.selectVoById(id);
......@@ -86,45 +105,73 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
*/
@Override
public TotalOrderVo queryByAppId(Integer id) {
// TODO 待优化
TotalOrderVo totalOrderVo = baseMapper.selectByOrderId(id);
if(totalOrderVo.getBusinessId() == 1){//预约陪诊
YypzOrder yypzOrder = yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus(
yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId, totalOrderVo.getId())).getStatus()
yypzOrder.getStatus()
);
totalOrderVo.setHospital(hospitalMapper.selectById(yypzOrder.getHid()).getName());
totalOrderVo.setVisitor(userVsitorMapper.selectById(yypzOrder.getVisitor()).getName());
totalOrderVo.setDepartment(departmentMapper.selectById(yypzOrder.getDid()).getTitle());
totalOrderVo.setPhone(yypzOrder.getPhone());
totalOrderVo = BeanUtil.toBean(yypzOrder, TotalOrderVo.class);
}else if(totalOrderVo.getBusinessId() == 2){//代办挂号
DbghOrder dbghOrder = dbghOrderMapper.selectOne(new LambdaQueryWrapper<DbghOrder>().eq(DbghOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus(
dbghOrderMapper.selectOne(new LambdaQueryWrapper<DbghOrder>().eq(DbghOrder::getOrderId, totalOrderVo.getId())).getStatus()
dbghOrder.getStatus()
);
totalOrderVo.setHospital(hospitalMapper.selectById(dbghOrder.getHid()).getName());
totalOrderVo.setDepartment(departmentMapper.selectById(dbghOrder.getDid()).getTitle());
totalOrderVo = BeanUtil.toBean(dbghOrder, TotalOrderVo.class);
}else if(totalOrderVo.getBusinessId() == 3){//代办问诊
DbwzOrder dbwzOrder = dbwzOrderMapper.selectOne(new LambdaQueryWrapper<DbwzOrder>().eq(DbwzOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus(
dbwzOrderMapper.selectOne(new LambdaQueryWrapper<DbwzOrder>().eq(DbwzOrder::getOrderId, totalOrderVo.getId())).getStatus()
dbwzOrder.getStatus()
);
totalOrderVo.setDepartment(departmentMapper.selectById(dbwzOrder.getDid()).getTitle());
totalOrderVo.setVisitor(userVsitorMapper.selectById(dbwzOrder.getVisitor()).getName());
totalOrderVo = BeanUtil.toBean(dbwzOrder, TotalOrderVo.class);
}else if(totalOrderVo.getBusinessId() == 4){//住院陪护
ZyphOrder zyphOrder = zyphOrderMapper.selectOne(new LambdaQueryWrapper<ZyphOrder>().eq(ZyphOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus(
zyphOrderMapper.selectOne(new LambdaQueryWrapper<ZyphOrder>().eq(ZyphOrder::getOrderId, totalOrderVo.getId())).getStatus()
zyphOrder.getStatus()
);
totalOrderVo.setHospital(hospitalMapper.selectById(zyphOrder.getHid()).getName());
totalOrderVo.setVisitor(userVsitorMapper.selectById(zyphOrder.getVisitor()).getName());
totalOrderVo.setDepartment(departmentMapper.selectById(zyphOrder.getDid()).getTitle());
totalOrderVo.setPhrq(zyphOrder.getStartDay()+"-"+zyphOrder.getEndDay());
totalOrderVo.setPhsj(zyphOrder.getStartTime()+"-"+zyphOrder.getEndTime());
totalOrderVo = BeanUtil.toBean(zyphOrder, TotalOrderVo.class);
}else if(totalOrderVo.getBusinessId() == 5){//代办买药
DbmyOrder dbmyOrder = dbmyOrderMapper.selectOne(new LambdaQueryWrapper<DbmyOrder>().eq(DbmyOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus(
dbmyOrderMapper.selectOne(new LambdaQueryWrapper<DbmyOrder>().eq(DbmyOrder::getOrderId, totalOrderVo.getId())).getStatus()
dbmyOrder.getStatus()
);
}else if(totalOrderVo.getBusinessId() == 6){//诊前挂号
ZqghOrder zqghOrder = zqghOrderMapper.selectOne(new LambdaQueryWrapper<ZqghOrder>().eq(ZqghOrder::getOrderId, totalOrderVo.getId()));
totalOrderVo.setServiceStatus(
zqghOrderMapper.selectOne(new LambdaQueryWrapper<ZqghOrder>().eq(ZqghOrder::getOrderId, totalOrderVo.getId())).getStatus()
zqghOrder.getStatus()
);
totalOrderVo.setHospital(hospitalMapper.selectById(zqghOrder.getHid()).getName());
totalOrderVo.setVisitor(doctorMapper.selectById(zqghOrder.getDoctorId()).getName());
totalOrderVo.setDepartment(departmentMapper.selectById(zqghOrder.getDid()).getTitle());
totalOrderVo.setHospital(hospitalMapper.selectById(zqghOrder.getHid()).getName());
totalOrderVo.setTimeOfAppointment(zqghOrder.getTimeOfAppointment());
}else if(totalOrderVo.getBusinessId() == 0){//商城订单
......@@ -153,7 +200,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
totalOrderVos.forEach(totalOrderVo -> {
// 陪诊人员
if (totalOrderVo.getEmId() != 0) {
Optional.ofNullable(userVsitorMapper.selectVoById(totalOrderVo.getEmId()).getName())
Optional.ofNullable(employeesMapper.selectVoById(totalOrderVo.getEmId()).getName())
.ifPresent(totalOrderVo::setEmName);
}
......@@ -163,7 +210,9 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
// 服务封面
Services services = servicesMapper.selectById(totalOrderVo.getServiceId());
if(null != services){
totalOrderVo.setCover(services.getCover());
}
if (totalOrderVo.getBusinessId() == 1) {// 预约陪诊
......@@ -215,6 +264,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, getTages(storeGoods.getTags())).select(StoreGoodsTag::getTitle));
totalOrderVo.setTags(storeGoodsTags);
totalOrderVo.setName(storeGoods.getTitle());
}
});
......@@ -246,6 +296,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
lqw.eq(StringUtils.isNotBlank(bo.getEvaluationContent()), TotalOrder::getEvaluationContent, bo.getEvaluationContent());
lqw.eq(StringUtils.isNotBlank(bo.getRefundReason()), TotalOrder::getRefundReason, bo.getRefundReason());
lqw.eq(StringUtils.isNotBlank(bo.getRefundAmount()), TotalOrder::getRefundAmount, bo.getRefundAmount());
lqw.orderByDesc(TotalOrder::getId);
return lqw;
}
......@@ -275,17 +326,25 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
TotalOrder totalOrder = BeanUtil.toBean(bo, TotalOrder.class);
totalOrder.setOrderSn(orderSn);
totalOrder.setUid(loginUser.getUserId().intValue());
baseMapper.insert(totalOrder);
bo.setOrderId(totalOrder.getId().intValue());
totalOrderVo.setOrderSn(totalOrder.getId()+"");
totalOrderVo.setPayMoney(bo.getPayMoney());
// 计算订单过期时间(当前时间加上24小时)
long expirationTime = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24);
totalOrder.setExpirationTime(expirationTime);
// 未付款的订单延迟24小时自动取消
delayQueue.addOrder(totalOrder);
if (bo.getBusinessId() == 1) {// 预约陪诊
YypzOrder yypzOrder = BeanUtil.toBean(bo, YypzOrder.class);
yypzOrder.setHid(bo.getHospitalId());
yypzOrder.setDid(bo.getDepartmentId());
yypzOrderMapper.insert(yypzOrder);
} else if (bo.getBusinessId() == 2) {// 代办挂号
......@@ -293,6 +352,8 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
DbghOrder dbghOrder = BeanUtil.toBean(bo, DbghOrder.class);
dbghOrder.setHid(bo.getHospitalId());
dbghOrder.setDid(bo.getDepartmentId());
dbghOrder.setVisitor(bo.getVisitorId());
dbghOrderMapper.insert(dbghOrder);
} else if (bo.getBusinessId() == 3) {// 代办问诊
......@@ -306,6 +367,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
ZyphOrder zyphOrder = BeanUtil.toBean(bo, ZyphOrder.class);
zyphOrder.setDid(bo.getDepartmentId());
zyphOrder.setHid(bo.getHospitalId());
zyphOrder.setVisitor(bo.getVisitorId());
zyphOrderMapper.insert(zyphOrder);
......@@ -317,6 +379,10 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
} else if (bo.getBusinessId() == 6) {// 诊前挂号
ZqghOrder zqghOrder = BeanUtil.toBean(bo, ZqghOrder.class);
zqghOrder.setHid(bo.getHospitalId());
zqghOrder.setDid(bo.getDepartmentId());
zqghOrder.setDoctorId(bo.getDoctorId());
zqghOrderMapper.insert(zqghOrder);
} else if (bo.getBusinessId() == 0) {// 商城订单
......@@ -351,6 +417,15 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
}
@Override
public Boolean finishOrder(TotalOrderBo bo) {
TotalOrder totalOrder = BeanUtil.toBean(bo, TotalOrder.class);
totalOrder.setStatus(2);
return baseMapper.updateById(totalOrder) > 1;
}
@Override
public Object payOrder(TotalOrderBo bo) {
LoginUser loginUser = LoginHelper.getLoginUser();
TotalOrder totalOrder = baseMapper.selectById(Integer.parseInt(bo.getOrderSn()));
......@@ -376,6 +451,42 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
}
@Override
public boolean orderPayCallBack(WxPayOrderNotifyResult result) {
String orderNum = result.getOutTradeNo();
TotalOrder totalOrder = baseMapper.selectOne(new LambdaQueryWrapper<TotalOrder>().eq(TotalOrder::getOrderSn, orderNum));
if(totalOrder.getStatus() == 0){
//修改订单状态为已支付
totalOrder.setStatus(1);
baseMapper.updateById(totalOrder);
//添加支付记录
PaymentRecord paymentRecord = new PaymentRecord();
paymentRecord.setPayType(1);
paymentRecord.setOrderId(totalOrder.getId().intValue());
paymentRecord.setMoney(totalOrder.getPayMoney());
paymentRecord.setUid(totalOrder.getUid());
paymentRecordMapper.insert(paymentRecord);
return true;
}
return false;
}
@Override
public boolean orderRefundCallBack(WxPayRefundNotifyResult wxPayRefundNotifyResult) {
WxPayRefundNotifyResult.ReqInfo reqInfo = wxPayRefundNotifyResult.getReqInfo();
//订单号
String outTradeNo = reqInfo.getOutTradeNo();
TotalOrder totalOrder = baseMapper.selectOne(new LambdaQueryWrapper<TotalOrder>().eq(TotalOrder::getOrderSn, outTradeNo));
totalOrder.setStatus(TotalOrderStatus.REFUND.getCode());
if(baseMapper.updateById(totalOrder) > 0){
return true;
}
return false;
}
@Override
public Boolean refundOrder(TotalOrderBo bo) {
TotalOrder totalOrder = baseMapper.selectById(bo.getId());
totalOrder.setRefundAmount(totalOrder.getPayMoney());
......
......@@ -19,10 +19,7 @@ import com.pz.system.mapper.ZqghOrderMapper;
import com.pz.system.service.IZqghOrderService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.Objects;
import java.util.*;
/**
* 诊前挂号订单Service业务层处理
......@@ -62,18 +59,52 @@ public class ZqghOrderServiceImpl implements IZqghOrderService, ISonOrderService
return baseMapper.selectVoList(lqw);
}
@Override
public List<ZqghOrderVo> queryAppList(ZqghOrderBo bo) {
LambdaQueryWrapper<ZqghOrder> lqw = buildQueryWrapper(bo);
List<ZqghOrderVo> zqghOrderVos = baseMapper.selectVoList(lqw);
//初始化预约集合
Map<String, Integer> countMap = new HashMap<>();
countMap.put(bo.getTimeOfAppointmentArr().get(0),0);
countMap.put(bo.getTimeOfAppointmentArr().get(1),0);
countMap.put(bo.getTimeOfAppointmentArr().get(2),0);
countMap.put(bo.getTimeOfAppointmentArr().get(3),0);
countMap.put(bo.getTimeOfAppointmentArr().get(4),0);
countMap.put(bo.getTimeOfAppointmentArr().get(5),0);
//查询订单医生预约订单
for (ZqghOrderVo obj : zqghOrderVos) {
String propertyValue = obj.getTimeOfAppointment();
countMap.put(propertyValue, countMap.getOrDefault(propertyValue, 0) + 1);
}
List<ZqghOrderVo> zqghOrderVos1 = new ArrayList<>();
// 遍历 Map
for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
ZqghOrderVo zqghOrderVo = new ZqghOrderVo();
zqghOrderVo.setTimeOfAppointment(entry.getKey());
zqghOrderVo.setNum(entry.getValue());
zqghOrderVos1.add(zqghOrderVo);
}
return zqghOrderVos1;
}
private LambdaQueryWrapper<ZqghOrder> buildQueryWrapper(ZqghOrderBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<ZqghOrder> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getOrderId() != null, ZqghOrder::getOrderId, bo.getOrderId());
lqw.eq(bo.getHid() != null, ZqghOrder::getHid, bo.getHid());
lqw.eq(bo.getDid() != null, ZqghOrder::getDid, bo.getDid());
lqw.eq(bo.getDoctorId() != null, ZqghOrder::getDid, bo.getDoctorId());
lqw.eq(bo.getDoctorId() != null, ZqghOrder::getDoctorId, bo.getDoctorId());
lqw.eq(StringUtils.isNotBlank(bo.getTimeOfAppointment()), ZqghOrder::getTimeOfAppointment, bo.getTimeOfAppointment());
lqw.eq(bo.getStatus() != null, ZqghOrder::getStatus, bo.getStatus());
lqw.eq(bo.getOverTime() != null, ZqghOrder::getOverTime, bo.getOverTime());
lqw.eq(StringUtils.isNotBlank(bo.getVoucher()), ZqghOrder::getVoucher, bo.getVoucher());
lqw.eq(bo.getIsCal() != null, ZqghOrder::getIsCal, bo.getIsCal());
lqw.in(bo.getTimeOfAppointmentArr() != null, ZqghOrder::getTimeOfAppointment, bo.getTimeOfAppointmentArr());
return lqw;
}
......
<?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.pz.system.mapper.CityMapper">
<select id="selectAppCity" resultType="com.pz.system.domain.vo.CityVo">
SELECT * FROM city GROUP BY sy
</select>
</mapper>
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