Commit 034c09a3 by sdif

用户端代码提交

parent c8663b2b
--- # 临时文件存储位置 避免临时文件被系统清理报错
spring.servlet.multipart.location: /ruoyi/server/temp
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
......@@ -52,37 +49,37 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
url: jdbc:mysql://db1.prd.jianghuxx.com:3317/pz?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username: root
password: root
password: 4f9fa23639242790
# 从库数据源
slave:
lazy: true
type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username:
password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
# slave:
# lazy: true
# type: ${spring.datasource.type}
# driverClassName: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
# username:
# password:
# oracle:
# type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# hikari:
# connectionTestQuery: SELECT 1 FROM DUAL
# postgres:
# type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA
# password: root
hikari:
# 最大连接池数量
maxPoolSize: 20
......@@ -105,13 +102,13 @@ spring:
spring:
redis:
# 地址
host: localhost
host: cluster1.prd.nyinhong.com
# 端口,默认为6379
port: 6379
port: 6319
# 数据库索引
database: 0
# 密码(如没有密码请注释掉)
# password:
password: yongqi@2022
# 连接超时时间
timeout: 10s
# 是否开启ssl
......@@ -121,17 +118,17 @@ redisson:
# redis key前缀
keyPrefix:
# 线程池数量
threads: 16
threads: 4
# Netty线程池数量
nettyThreads: 32
nettyThreads: 8
# 单节点配置
singleServerConfig:
# 客户端名称
clientName: ${ruoyi.name}
# 最小空闲连接数
connectionMinimumIdleSize: 32
connectionMinimumIdleSize: 8
# 连接池大小
connectionPoolSize: 64
connectionPoolSize: 32
# 连接空闲超时,单位:毫秒
idleConnectionTimeout: 10000
# 命令等待超时,单位:毫秒
......
......@@ -102,15 +102,7 @@ public class AppletSysUserController extends BaseController {
*/
@PutMapping
public R<Void> edit(@Validated @RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
if (!userService.checkUserNameUnique(user)) {
return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUserId(LoginHelper.getLoginUser().getUserId());
return toAjax(userService.updateUser(user));
}
......
......@@ -191,10 +191,11 @@ public class AppletTotalOrderController extends BaseController {
*/
@RepeatSubmit()
@PostMapping("/refundOrder")
public R<Void> refundOrder(@Validated(AddGroup.class) @RequestBody TotalOrderBo recordBo) {
return toAjax(iTotalOrderService.refundOrder(recordBo));
public R<Boolean> refundOrder(@Validated(AddGroup.class) @RequestBody TotalOrderBo recordBo) {
return R.ok(iTotalOrderService.refundOrder(recordBo));
}
/**
* 退款回调
*/
......
......@@ -74,4 +74,10 @@ public interface ISonOrderService {
throw new UnsupportedOperationException("不支持该操作");
}
/**
* 查询服务开始时间
*/
default String getFinishTime(Integer totalId){
throw new UnsupportedOperationException("不支持该操作");
}
}
......@@ -18,6 +18,7 @@ import java.util.HashMap;
*/
@Component
@ConditionalOnBean({
StoreOrderServiceImpl.class,
DbwzOrderServiceImpl.class, YypzOrderServiceImpl.class, ZqghOrderServiceImpl.class,
DbmyOrderServiceImpl.class, ZyphOrderServiceImpl.class, DbghOrderServiceImpl.class})
public class SonOrderServiceBuilder {
......@@ -32,7 +33,9 @@ public class SonOrderServiceBuilder {
DbmyOrderServiceImpl dbmyOrderService = SpringUtils.getBean(DbmyOrderServiceImpl.class);
ZyphOrderServiceImpl zyphOrderService = SpringUtils.getBean(ZyphOrderServiceImpl.class);
DbghOrderServiceImpl dbghOrderService = SpringUtils.getBean(DbghOrderServiceImpl.class);
StoreOrderServiceImpl storeOrderService = SpringUtils.getBean(StoreOrderServiceImpl.class);
sonOrderHashMap = new HashMap<>(8);
sonOrderHashMap.put(0, storeOrderService);
sonOrderHashMap.put(1, yypzOrderService);
sonOrderHashMap.put(2, dbghOrderService);
sonOrderHashMap.put(3, dbwzOrderService);
......
......@@ -97,4 +97,14 @@ public class TotalOrderBo extends BaseEntity {
private String logisticsCode;
private String phone;
/**
* 区分退款和售后
*/
private Integer isRefund;
/**
* 凭证
*/
private String voucher;
}
......@@ -128,6 +128,11 @@ public class TotalOrderVo {
private Double salePrice;
/**
* 医生
*/
private String doctor;
/**
* 服务状态
*/
private Integer serviceStatus;
......
......@@ -40,4 +40,9 @@ public interface DbghOrderMapper extends BaseMapperPlus<DbghOrderMapper, DbghOrd
* @return 代办挂号订单
*/
DbghOrderItemVo selectDbghOrderDetailDateByTotalId(Integer totalId);
/**
* 查询子订单完成时间
*/
String selectFinishTime(Integer totalId);
}
......@@ -40,4 +40,9 @@ public interface DbwzOrderMapper extends BaseMapperPlus<DbwzOrderMapper, DbwzOrd
* @return 代办挂号
*/
DbwzOrderItemVo selectDbwzOrderDetailDataByTotalId(Integer totalId);
/**
* 查询子订单完成时间
*/
String selectFinishTime(Integer totalId);
}
......@@ -38,4 +38,8 @@ public interface YypzOrderMapper extends BaseMapperPlus<YypzOrderMapper, YypzOrd
* @return 预约陪诊相关信息
*/
YypzOrderItemVo selectYypzOrderDetailDataByTotalId(Integer totalId);
/**
* 查询子订单完成时间
*/
String selectFinishTime(Integer totalId);
}
......@@ -42,4 +42,9 @@ public interface ZqghOrderMapper extends BaseMapperPlus<ZqghOrderMapper, ZqghOrd
*/
ZqghOrderItemVo selectZqghOrderDetailDateByTotalId(Integer totalId);
/**
* 查询服务时间
*/
String selectFinishTime(Integer totalId);
}
......@@ -40,4 +40,10 @@ public interface ZyphOrderMapper extends BaseMapperPlus<ZyphOrderMapper, ZyphOrd
* @return 住院陪护订单
*/
ZyphOrderItemVo selectZyphOrderDetailDataByTotalId(Integer totalId);
/**
* 查询子订单完成时间
*/
String selectFinishTime(Integer totalId);
}
......@@ -100,6 +100,7 @@ public interface ITotalOrderService {
*/
Boolean refundOrder(TotalOrderBo bo);
boolean orderRefundCallBack(WxPayRefundNotifyResult wxPayRefundNotifyResult);
/**
......
......@@ -207,8 +207,13 @@ public class ArticleServiceImpl implements IArticleService {
for (String num : numberArray) {
integerList.add(num.trim());
}*/
List<String> ids = JsonUtils.parseArray(articleVo.getCover(), String.class);
//List<String> ids = JsonUtils.parseArray(articleVo.getCover(), String.class);
List<String> ids = new ArrayList<>();
// 使用逗号分割字符串,并逐个转换为 Integer 添加到 List 中
if(null != articleVo.getCover()){
Collections.addAll(ids, articleVo.getCover().split(","));
articleVo.setCoverList(ids);
}
// 设置点赞数
articleVo.setAppreciateNum(appreciateNumMap.getOrDefault(articleVo.getId(), 0));
......
......@@ -319,4 +319,9 @@ public class DbghOrderServiceImpl implements IDbghOrderService, ISonOrderService
delayQueue.addOrder(task);
return true;
}
@Override
public String getFinishTime(Integer totalId) {
return baseMapper.selectFinishTime(totalId);
}
}
......@@ -298,4 +298,5 @@ public class DbmyOrderServiceImpl implements IDbmyOrderService, ISonOrderService
delayQueue.addOrder(task);
return true;
}
}
......@@ -320,4 +320,9 @@ public class DbwzOrderServiceImpl implements IDbwzOrderService, ISonOrderService
delayQueue.addOrder(task);
return true;
}
@Override
public String getFinishTime(Integer totalId) {
return baseMapper.selectFinishTime(totalId);
}
}
......@@ -7,6 +7,9 @@ import com.pz.common.core.domain.PageQuery;
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.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.service.ISonOrderService;
import com.pz.system.domain.bo.OrderFinishedBo;
import com.pz.system.domain.vo.StoreAdminOrderVo;
import com.pz.system.mapper.CityMapper;
import com.pz.system.mapper.TotalOrderMapper;
......@@ -32,7 +35,7 @@ import java.util.Optional;
*/
@RequiredArgsConstructor
@Service
public class StoreOrderServiceImpl implements IStoreOrderService {
public class StoreOrderServiceImpl implements IStoreOrderService, ISonOrderService {
private final StoreOrderMapper baseMapper;
......@@ -132,4 +135,15 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
}
return baseMapper.deleteBatchIds(ids) > 0;
}
@Override
public SonOrderVo getSonOrderSimpleDataByTotalId(Integer totalId) {
return null;
}
@Override
public boolean switchSonOrderStatus(Long totalId, Integer target) {
return false;
}
}
......@@ -311,14 +311,14 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
@Transactional(rollbackFor = Exception.class)
public int updateUser(SysUser user) {
Long userId = user.getUserId();
// 删除用户与角色关联
/*// 删除用户与角色关联
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
// 新增用户与角色管理
insertUserRole(user);
// 删除用户与岗位关联
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, userId));
// 新增用户与岗位管理
insertUserPost(user);
insertUserPost(user);*/
return baseMapper.updateById(user);
}
......
package com.pz.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -9,7 +11,9 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.pz.common.config.KbProperties;
import com.pz.common.core.domain.model.LoginUser;
import com.pz.common.core.page.TableDataInfo;
......@@ -23,6 +27,7 @@ import com.pz.common.enums.TotalOrderStatus;
import com.pz.common.exception.ServiceException;
import com.pz.common.utils.HttpUtils;
import com.pz.merchant.domain.vo.EmployeesVo;
import com.pz.common.utils.JsonUtils;
import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService;
......@@ -49,6 +54,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.HashMap;
import java.util.Date;
......@@ -112,6 +119,8 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
private final UserAddressMapper userAddressMapper;
private final SysUserMapper sysUserMapper;
@Override
public TotalOrderVo queryById(Long id) {
return baseMapper.selectVoById(id);
......@@ -167,6 +176,8 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
dbwzOrder.getStatus()
);
// totalOrderVo = BeanUtil.toBean(dbwzOrder, TotalOrderVo.class);
//totalOrderVo = BeanUtil.toBean(dbwzOrder, TotalOrderVo.class);
totalOrderVo.setProject(servicesMapper.selectVoById(totalOrderVo.getServiceId()).getName());
totalOrderVo.setDepartment(departmentMapper.selectById(dbwzOrder.getDid()).getTitle());
totalOrderVo.setVisitor(userVsitorMapper.selectById(dbwzOrder.getVisitor()).getName());
totalOrderVo.setVisitTime(dbwzOrder.getVisitTime());
......@@ -222,9 +233,9 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
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.setDoctor(doctorMapper.selectById(zqghOrder.getDoctorId()).getName());
totalOrderVo.setTimeOfAppointment(zqghOrder.getTimeOfAppointment());
totalOrderVo.setOverTime(zqghOrder.getOverTime());
totalOrderVo.setVoucher(zqghOrder.getVoucher());
......@@ -236,15 +247,17 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
storeOrder.getStatus()
);
StoreGoodsVo storeGoods = storeGoodsMapper.selectVoById(storeOrder.getOrderId());
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, getTages(storeGoods.getTags())).select(StoreGoodsTag::getTitle));
StoreGoodsVo storeGoods = storeGoodsMapper.selectVoById(storeOrder.getGoodsId());
List<Integer> ids = JsonUtils.parseArray(storeGoods.getTags(), Integer.class);
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, ids).select(StoreGoodsTag::getTitle));
totalOrderVo.setTags(storeGoodsTags);
totalOrderVo.setStoreGoodsVo(storeGoods);
UserAddressVo userAddressVo = userAddressMapper.selectVoById(storeGoods.getAddressId());
UserAddressVo userAddressVo = userAddressMapper.selectVoById(storeOrder.getAddressId());
totalOrderVo.setUserAddressVo(userAddressVo);
TotalOrderBo totalOrderBo = new TotalOrderBo();
totalOrderBo.setId(totalOrderVo.getId());
totalOrderBo.setPhone(userAddressVo.getPhone());
totalOrderBo.setLogisticsCode(storeOrder.getLogisticsCode());
totalOrderVo.setObject(selectLogisticsStatus(totalOrderBo));
}
return totalOrderVo;
......@@ -268,7 +281,9 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
// 业务
Business business = businessMapper.selectById(totalOrderVo.getBusinessId());
if(null != business){
totalOrderVo.setName(business.getName());
}
// 服务封面
Services services = servicesMapper.selectById(totalOrderVo.getServiceId());
......@@ -322,8 +337,9 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
storeOrder.getStatus()
);
StoreGoods storeGoods = storeGoodsMapper.selectById(storeOrder.getOrderId());
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, getTages(storeGoods.getTags())).select(StoreGoodsTag::getTitle));
StoreGoods storeGoods = storeGoodsMapper.selectById(storeOrder.getGoodsId());
List<Integer> ids = JsonUtils.parseArray(storeGoods.getTags(), Integer.class);
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, ids).select(StoreGoodsTag::getTitle));
totalOrderVo.setTags(storeGoodsTags);
totalOrderVo.setName(storeGoods.getTitle());
......@@ -395,16 +411,14 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
totalOrderVo.setPayMoney(bo.getPayMoney());
// 计算订单过期时间(当前时间加上30分钟)
long expirationTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(24);
long expirationTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(30);
// 未付款的订单延迟24小时自动取消
TotalOrderDelayOperator totalOrderDelayOperator = new TotalOrderDelayOperator(totalOrder.getId(), expirationTime, id -> {
TotalOrder order = baseMapper.selectById(id);
if (order.getEmId() == 0) {// 预约陪诊
order.setStatus(TotalOrderStatus.CANCEL.getCode());
baseMapper.updateById(totalOrder);
} else {
throw new ServiceException("该订单已分配给陪诊员,不允许取消订单!");
}
});
delayQueue.addOrder(totalOrderDelayOperator);
......@@ -478,6 +492,38 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
@Override
public Boolean cancelOrder(TotalOrderBo bo) {
TotalOrder totalOrder = baseMapper.selectById(bo.getId());
ISonOrderService orderService = serviceBuilder.getSonOrderService(totalOrder.getBusinessId());
Objects.requireNonNull(orderService, "订单业务属性出错");
SonOrderVo sonOrderSimpleDataByTotalId = orderService.getSonOrderSimpleDataByTotalId(totalOrder.getId().intValue());
//待办问诊 已接单下取消订单调用退款接口
//已接单、待服务状态下等待陪诊员开始服务或取消订单
TotalOrderBo totalOrderBo = new TotalOrderBo();
totalOrderBo.setId(totalOrder.getId());
if(totalOrder.getBusinessId() == 3 && totalOrder.getStatus() == 1 ){
totalOrderBo.setIsRefund(0);
return this.refundOrder(totalOrderBo);
}
//进行中、待完成状态下等待陪诊员完成服务
if(totalOrder.getBusinessId() == 3 && totalOrder.getStatus() == 6 ){
totalOrderBo.setIsRefund(1);
return this.refundOrder(totalOrderBo);
}
//待办买药已接单 代发货下取消订单调用退款接口
if(totalOrder.getBusinessId() == 5 && totalOrder.getStatus() == 1){
totalOrderBo.setIsRefund(0);
return this.refundOrder(totalOrderBo);
}
//已接单、待收货状态下等待药品到达后确认
if(totalOrder.getBusinessId() == 5 && totalOrder.getStatus() == 2){
totalOrderBo.setIsRefund(1);
return this.refundOrder(totalOrderBo);
}
if (totalOrder.getEmId() == 0) {// 预约陪诊
// yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId,totalOrder));
totalOrder.setStatus(TotalOrderStatus.CANCEL.getCode());
......@@ -498,18 +544,19 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
@Override
public Object payOrder(TotalOrderBo bo) {
// LoginUser loginUser = LoginHelper.getLoginUser();
LoginUser loginUser = LoginHelper.getLoginUser();
TotalOrder totalOrder = baseMapper.selectById(Integer.parseInt(bo.getOrderSn()));
Object payment = null;
int money = (int) (totalOrder.getPayMoney() * 100);
try {
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
orderRequest.setBody(bo.getOrderTitle());
orderRequest.setOutTradeNo(totalOrder.getOrderSn());
orderRequest.setTotalFee(money);// 元转成分
orderRequest.setOpenid("o37SK64I29ISwKLPb3tfBEYgZHAM");
orderRequest.setOpenid(sysUserMapper.selectById(loginUser.getUserId()).getOpenId());
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl("http://127.0.0.1:8089/applet/totalOrder/orderPayCallBack");
orderRequest.setNotifyUrl("https://peizheng.shanpeikj.com/api/applet/totalOrder/orderPayCallBack");
orderRequest.setTradeType("JSAPI");
payment = iPayService.createOrder(orderRequest);
......@@ -544,12 +591,19 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
@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());
ISonOrderService orderService = serviceBuilder.getSonOrderService(totalOrder.getBusinessId());
Objects.requireNonNull(orderService, "订单业务属性出错");
// 修改子订单状态
boolean sonOrderFlag = orderService.switchSonOrderStatus(totalOrder.getId(), CommonOrderStatus.REFUND.getCode());
if (!sonOrderFlag) {
throw new ServiceException("子订单状态修改出错,接单失败");
}
if (baseMapper.updateById(totalOrder) > 0) {
// 添加退款记录
PaymentRecord paymentRecord = new PaymentRecord();
......@@ -566,104 +620,95 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
@Override
public Boolean refundOrder(TotalOrderBo bo) {
TotalOrder totalOrder = baseMapper.selectById(bo.getId());
totalOrder.setRefundAmount(totalOrder.getPayMoney());
totalOrder.setRefundReason(bo.getRefundReason());
if (totalOrder.getBusinessId() == 1) {// 预约陪诊
YypzOrder yypzOrder = yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId, totalOrder.getId()));
if (yypzOrder.getStatus().equals(CommonOrderStatus.TAKE_ORDER.getCode())) {
throw new ServiceException("陪诊员已接单,不允许退款!");
}
} else if (totalOrder.getBusinessId() == 2) {// 代办挂号
ISonOrderService orderService = serviceBuilder.getSonOrderService(totalOrder.getBusinessId());
Objects.requireNonNull(orderService, "订单业务属性出错");
DbghOrder dbghOrder = dbghOrderMapper.selectOne(new LambdaQueryWrapper<DbghOrder>().eq(DbghOrder::getOrderId, totalOrder.getId()));
if (dbghOrder.getStatus().equals(CommonOrderStatus.TAKE_ORDER.getCode())) {
throw new ServiceException("陪诊员已接单,不允许退款!");
SonOrderVo sonOrderSimpleDataByTotalId = orderService.getSonOrderSimpleDataByTotalId(totalOrder.getId().intValue());
if (null == sonOrderSimpleDataByTotalId) {
throw new ServiceException("子订单状态出错!");
}
} else if (totalOrder.getBusinessId() == 3) {// 代办问诊
//订单退款金额
double money = 0;
DbwzOrder dbwzOrder = dbwzOrderMapper.selectOne(new LambdaQueryWrapper<DbwzOrder>().eq(DbwzOrder::getOrderId, totalOrder.getId()));
if (dbwzOrder.getStatus().equals(CommonOrderStatus.TAKE_ORDER.getCode())) {
throw new ServiceException("陪诊员已接单,不允许退款!");
if(bo.getIsRefund() == 0){//陪诊员订单未完成用户主动退款
//主订单必须为付款并且子订单为已接单
if(totalOrder.getStatus() != 1 && sonOrderSimpleDataByTotalId.getOrderStatus() != 1){
throw new ServiceException("退款出错!");
}
/**
*责任归属:用户下单,陪诊人员接单后,客户单方面取消,客户为本次订单负责:
*
* (1)订单开始前12小时取消--无责退款
*
* (2)订单开始前6小时取消--需承担服务项目金额的30%
*
* (3)订单开始前3小时取消--需承担服务项目金额的50%
*/
} else if (totalOrder.getBusinessId() == 4) {// 住院陪护
//待办问诊和待办买药走取消订单退款
/*if(totalOrder.getBusinessId() == 3 || totalOrder.getBusinessId() == 5){
throw new ServiceException("待办问诊和待办买药退款失败!");
}*/
ZyphOrder zyphOrder = zyphOrderMapper.selectOne(new LambdaQueryWrapper<ZyphOrder>().eq(ZyphOrder::getOrderId, totalOrder.getId()));
if (zyphOrder.getStatus().equals(CommonOrderStatus.TAKE_ORDER.getCode())) {
throw new ServiceException("陪诊员已接单,不允许退款!");
}
/**
* 待办买药
*/
if(totalOrder.getBusinessId() == 5){
money = totalOrder.getPayMoney();
}else if(totalOrder.getBusinessId() == 0){//商城订单
} else if (totalOrder.getBusinessId() == 5) {// 代办买药
}else {//一般陪诊订单
//一般订单开始服务时间
DbmyOrder dbmyOrder = dbmyOrderMapper.selectOne(new LambdaQueryWrapper<DbmyOrder>().eq(DbmyOrder::getOrderId, totalOrder.getId()));
if (dbmyOrder.getStatus().equals(DBMYOrderStatus.TAKE_ORDER.getCode())) {
throw new ServiceException("陪诊员已接单,不允许退款!");
String serveTime = orderService.getFinishTime(totalOrder.getBusinessId());
if(StringUtils.isNotEmpty(serveTime)) {
money = getMoney(serveTime,totalOrder.getPayMoney());//计算退款金额
}
} else if (totalOrder.getBusinessId() == 6) {// 诊前挂号
ZqghOrder zqghOrder = zqghOrderMapper.selectOne(new LambdaQueryWrapper<ZqghOrder>().eq(ZqghOrder::getOrderId, totalOrder.getId()));
if (zqghOrder.getStatus().equals(CommonOrderStatus.TAKE_ORDER.getCode())) {
throw new ServiceException("陪诊员已接单,不允许退款!");
}
} else if (totalOrder.getBusinessId() == 0) {// 商城订单
WxPayRefundRequest request = new WxPayRefundRequest();
StoreOrder storeOrder = storeOrderMapper.selectOne(new LambdaQueryWrapper<StoreOrder>().eq(StoreOrder::getOrderId, totalOrder.getId()));
if (storeOrder.getStatus().equals(ShopOrderStatus.DELIVER.getCode())) {
throw new ServiceException("商品已发货,不允许退款!");
}
request.setOutTradeNo(totalOrder.getOrderSn());
request.setOutRefundNo(UUID.randomUUID().toString());
request.setTotalFee((int) (totalOrder.getPayMoney() * 100));
request.setRefundFee((int) (money * 100));
request.setNotifyUrl("https://peizheng.shanpeikj.com/api/applet/totalOrder/orderRefundCallBack");
try {
iPayService.refund(request);
} catch (WxPayException e) {
e.printStackTrace();
}
totalOrder.setRefundAmount(totalOrder.getPayMoney());
}else if (bo.getIsRefund() == 1){//陪诊员订单完成走审批流程
if(sonOrderSimpleDataByTotalId.getOrderStatus() != 2){
throw new ServiceException("订单状态错误");
}
// 修改主订单退款理由
baseMapper.updateById(totalOrder);
if (totalOrder.getBusinessId() == 1) {// 预约陪诊
yypzOrderMapper.update(null, new LambdaUpdateWrapper<YypzOrder>()
.eq(YypzOrder::getOrderId, totalOrder.getId())
.set(YypzOrder::getStatus, CommonOrderStatus.BEING_REFUND.getCode()));
} else if (totalOrder.getBusinessId() == 2) {// 代办挂号
dbghOrderMapper.update(null, new LambdaUpdateWrapper<DbghOrder>()
.eq(DbghOrder::getOrderId, totalOrder.getId())
.set(DbghOrder::getStatus, CommonOrderStatus.BEING_REFUND.getCode()));
} else if (totalOrder.getBusinessId() == 3) {// 代办问诊
dbwzOrderMapper.update(null, new LambdaUpdateWrapper<DbwzOrder>()
.eq(DbwzOrder::getOrderId, totalOrder.getId())
.set(DbwzOrder::getStatus, CommonOrderStatus.BEING_REFUND.getCode()));
} else if (totalOrder.getBusinessId() == 4) {// 住院陪护
zyphOrderMapper.update(null, new LambdaUpdateWrapper<ZyphOrder>()
.eq(ZyphOrder::getOrderId, totalOrder.getId())
.set(ZyphOrder::getStatus, CommonOrderStatus.BEING_REFUND.getCode()));
} else if (totalOrder.getBusinessId() == 5) {// 代办买药
totalOrder.setRefundAmount(totalOrder.getPayMoney());
totalOrder.setRefundReason(bo.getRefundReason());
dbmyOrderMapper.update(null, new LambdaUpdateWrapper<DbmyOrder>()
.eq(DbmyOrder::getOrderId, totalOrder.getId())
.set(DbmyOrder::getStatus, DBMYOrderStatus.BEING_REFUND.getCode()));
}
} else if (totalOrder.getBusinessId() == 6) {// 诊前挂号
zqghOrderMapper.update(null, new LambdaUpdateWrapper<ZqghOrder>()
.eq(ZqghOrder::getOrderId, totalOrder.getId())
.set(ZqghOrder::getStatus, CommonOrderStatus.BEING_REFUND.getCode()));
// 修改子订单状态
boolean sonOrderFlag = orderService.switchSonOrderStatus(totalOrder.getId(), CommonOrderStatus.REFUND.getCode());
} else if (totalOrder.getBusinessId() == 0) {// 商城订单
if (!sonOrderFlag) {
throw new ServiceException("子订单状态修改出错");
}
if (totalOrder.getBusinessId() == 0) {// 商城订单
storeOrderMapper.update(null, new LambdaUpdateWrapper<StoreOrder>()
.eq(StoreOrder::getOrderId, totalOrder.getId())
.set(StoreOrder::getStatus, ShopOrderStatus.BEING_REFUND.getCode()));
}
baseMapper.updateById(totalOrder);
return true;
}
......@@ -847,8 +892,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
}
// data参数是个json格式的字符串 建议使用函数或方法去生成
bodys.put("data", jsonStr);
System.out.println(bodys);
try {
/**
* 重要提示如下:
......@@ -861,7 +905,10 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
*/
HttpResponse response = HttpUtils.doPost(host, path, requestMethod, headers, querys, bodys);
System.out.println(response.toString());
return EntityUtils.toString(response.getEntity());
String responseBody = EntityUtils.toString(response.getEntity());
// 将响应体数据转换为 JSON 对象
JSONObject jsonResponse = new JSONObject(responseBody);
return jsonResponse;
} catch (Exception e) {
e.printStackTrace();
......@@ -925,4 +972,39 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
return null;
}
}
public long getHour(String date){
LocalDateTime startTime = LocalDateTime.parse(date);
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 计算当前时间和订单开始时间之间的时间差
Duration duration = Duration.between(now, startTime);
return duration.toHours();
}
public double getMoney(String serveTime,double payMoney){
double money = 0;
double deduction = 0;
double remainingAmount = 0;
long hour = getHour(serveTime);
if (hour >= 12 || (hour <= 12 && hour > 6)) {
money = payMoney;
} else if ((hour <= 6) && (hour >= 3)) {
// 计算扣除30%后的金额
deduction = payMoney * 0.3;
remainingAmount = payMoney - deduction;
money = remainingAmount;
} else if ((hour <= 3) && (hour >= 0)) {
// 计算扣除50%后的金额
deduction = payMoney * 0.5;
remainingAmount = payMoney - deduction;
money = remainingAmount;
}
return money;
}
}
......@@ -320,4 +320,9 @@ public class YypzOrderServiceImpl implements IYypzOrderService, ISonOrderService
delayQueue.addOrder(task);
return true;
}
@Override
public String getFinishTime(Integer totalId) {
return baseMapper.selectFinishTime(totalId);
}
}
......@@ -177,4 +177,8 @@ public class ZqghOrderServiceImpl implements IZqghOrderService, ISonOrderService
return baseMapper.updateById(sonOrder) > 0;
}
@Override
public String getFinishTime(Integer totalId) {
return baseMapper.selectFinishTime(totalId);
}
}
......@@ -331,4 +331,9 @@ public class ZyphOrderServiceImpl implements IZyphOrderService, ISonOrderService
delayQueue.addOrder(task);
return true;
}
@Override
public String getFinishTime(Integer totalId) {
return baseMapper.selectFinishTime(totalId);
}
}
......@@ -91,6 +91,11 @@
left join department on department.id = dbgh_order.did
where total_order.id = #{id}
</select>
<select id="selectFinishTime" resultType="java.lang.String">
select visit_time
from total_order t left join dbgh_order d on d.order_id = t.id
where t.id = #{id}
</select>
</mapper>
......@@ -95,6 +95,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join services on total_order.service_id = services.id
where total_order.id = #{id}
</select>
<select id="selectFinishTime" resultType="java.lang.String">
select over_time
from total_order t left join dbmy_order d on d.order_id = t.id
where d.status = 2 and t.id = #{id}
</select>
</mapper>
......@@ -101,6 +101,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join department on department.id = dbwz_order.did
where total_order.id = #{id}
</select>
<select id="selectFinishTime" resultType="java.lang.String">
select visit_time
from total_order t left join dbwz_order d on d.order_id = t.id
where t.id = #{id}
</select>
</mapper>
......@@ -60,6 +60,7 @@
t.update_by,
t.update_time,
t.remark,
e.name as emName,
b.name as business,
s.name as service
from total_order t
......
......@@ -95,4 +95,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join department on department.id = yypz_order.did
where total_order.id = #{id}
</select>
<select id="selectFinishTime" resultType="java.lang.String">
select visit_time
from total_order t left join yypz_order d on d.order_id = t.id
where t.id = #{id}
</select>
</mapper>
......@@ -80,5 +80,10 @@
left join doctor on zqgh_order.doctor_id = doctor.id
where total_order.id = #{id}
</select>
<select id="selectFinishTime" resultType="java.lang.String">
select DATE_FORMAT(time_of_appointment, '%Y-%m-%d')
FROM total_order t left join zqgh_order d on d.order_id = t.id
where t.id = #{id}
</select>
</mapper>
......@@ -99,5 +99,11 @@
where total_order.id = #{id}
</select>
<select id="selectFinishTime" resultType="java.lang.String">
select start_day
from total_order t left join zyph_order d on d.order_id = t.id
where t.id = #{id}
</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