优化量表订单模块
This commit is contained in:
parent
d2d2ea166e
commit
196cc52d33
|
@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.domain.model.XcxLoginBody;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.user.UserException;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
|
@ -110,7 +111,7 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||
newUser.setNickName("健康土豆");
|
||||
newUser.setPhonenumber(phoneNumber);
|
||||
newUser.setOpenId(openid);
|
||||
newUser.setUserType("sys_user");
|
||||
newUser.setUserType(UserType.APP_USER.getUserType());
|
||||
userMapper.insert(newUser);
|
||||
return newUser;
|
||||
} else {
|
||||
|
|
|
@ -42,15 +42,15 @@ 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&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://39.101.193.239:3306/mental_tenant?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||
username: root
|
||||
password: root
|
||||
password: Mz123456*
|
||||
# 从库数据源
|
||||
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&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://39.101.193.239:3306/mental_tenant?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||
username:
|
||||
password:
|
||||
# oracle:
|
||||
|
@ -91,13 +91,13 @@ spring:
|
|||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
host: 39.101.193.239
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# redis 密码必须配置
|
||||
password: ruoyi123
|
||||
# 密码(如没有密码请注释掉)
|
||||
password: Mz123456*
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
|
@ -262,7 +262,7 @@ wx:
|
|||
appId: wx2e09db4124332242
|
||||
mchId: 1646701170
|
||||
mchKey: Mozhekejiyouxiangongsi6296296296
|
||||
keyPath: /usr/local/mental/certs
|
||||
keyPath: /usr/local/tenant/certs
|
||||
miniapp:
|
||||
configs:
|
||||
- appid: wx2e09db4124332242
|
||||
|
|
|
@ -22,7 +22,7 @@ captcha:
|
|||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8080
|
||||
port: 8090
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
|
|
@ -65,6 +65,4 @@ public class WxMyController extends BaseController {
|
|||
public TableDataInfo<ReservationOrderVo> list(ReservationOrderBo bo, PageQuery pageQuery) {
|
||||
return myService.queryReservationPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.dromara.scale.controller.wx;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
|
@ -60,7 +60,7 @@ public class WxOrderController extends BaseController {
|
|||
@Log(title = "量表订单", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/scale")
|
||||
public R<T> addScale(@Validated(AddGroup.class) @RequestBody SysScaleOrderBo bo, HttpServletRequest request) throws Exception {
|
||||
public R<WxPayMpOrderResult> addScale(@Validated(AddGroup.class) @RequestBody SysScaleOrderBo bo, HttpServletRequest request) throws Exception {
|
||||
String clientIpAddress = getClientIpAddress(request);
|
||||
bo.setSpbillCreateIp(clientIpAddress);
|
||||
return R.ok(scaleOrderService.insertByBo(bo));
|
||||
|
@ -72,7 +72,7 @@ public class WxOrderController extends BaseController {
|
|||
@Log(title = "预约订单", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/reservation")
|
||||
public R<T> addReservation(@Validated(AddGroup.class) @RequestBody ReservationOrderBo bo, HttpServletRequest request) throws Exception {
|
||||
public R<WxPayMpOrderResult> addReservation(@Validated(AddGroup.class) @RequestBody ReservationOrderBo bo, HttpServletRequest request) throws Exception {
|
||||
String clientIpAddress = getClientIpAddress(request);
|
||||
bo.setSpbillCreateIp(clientIpAddress);
|
||||
return R.ok(reservationOrderService.insertByBo(bo));
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.scale.service.IReservationOrderService;
|
||||
import org.dromara.scale.service.ISysScaleOrderService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
* @version V1.0.0
|
||||
* @date 2024/7/29 14:08
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
|
@ -36,6 +39,7 @@ public class WxPayController {
|
|||
|
||||
@PostMapping("/notify/order/scale")
|
||||
public String parseScaleNotifyResult(@RequestBody String xmlData) throws WxPayException {
|
||||
log.info("---------量表支付回调-----------------");
|
||||
final WxPayOrderNotifyResult notifyResult = this.payService.parseOrderNotifyResult(xmlData);
|
||||
String outTradeNo = notifyResult.getOutTradeNo();
|
||||
scaleOrderService.processOrder(outTradeNo);
|
||||
|
|
|
@ -83,6 +83,8 @@ public class SysScale extends TenantEntity {
|
|||
|
||||
@AutoMapping(target = "appCoverUrl")
|
||||
private Long appCover;
|
||||
@AutoMapping(target = "detailAnnexUrl")
|
||||
private Long detailAnnex;
|
||||
|
||||
/**
|
||||
* 发布次数
|
||||
|
|
|
@ -33,6 +33,8 @@ public class SysScaleOrder extends TenantEntity {
|
|||
*/
|
||||
private Long scaleId;
|
||||
|
||||
private Long recordId;
|
||||
|
||||
/**
|
||||
* 订单价格
|
||||
*/
|
||||
|
|
|
@ -87,8 +87,10 @@ public class SysScaleBo extends BaseEntity {
|
|||
*/
|
||||
@NotNull(message = "封面不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long cover;
|
||||
|
||||
@NotNull(message = "移动端封面不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long appCover;
|
||||
@NotNull(message = "移动端详情图不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long detailAnnex;
|
||||
|
||||
/**
|
||||
* 量表类型:对应字典项scale_type
|
||||
|
|
|
@ -88,6 +88,8 @@ public class SysScaleVo implements Serializable {
|
|||
|
||||
private Long appCover;
|
||||
|
||||
private Long detailAnnex;
|
||||
|
||||
/**
|
||||
* 封面地址
|
||||
*/
|
||||
|
@ -99,6 +101,9 @@ public class SysScaleVo implements Serializable {
|
|||
//@AutoMapping(target = "appCover")
|
||||
private Long appCoverUrl;
|
||||
|
||||
@Translation(type = TransConstant.OSS_ID_TO_URL)
|
||||
//@AutoMapping(target = "appCover")
|
||||
private Long detailAnnexUrl;
|
||||
/**
|
||||
* 发布次数
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dromara.scale.service;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.scale.domain.bo.ReservationOrderBo;
|
||||
|
@ -46,7 +47,7 @@ public interface IReservationOrderService {
|
|||
* @param bo 预约订单
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
<T> T insertByBo(ReservationOrderBo bo) throws Exception;
|
||||
WxPayMpOrderResult insertByBo(ReservationOrderBo bo) throws Exception;
|
||||
|
||||
Boolean processOrder(String orderId);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dromara.scale.service;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.scale.domain.bo.SysScaleOrderBo;
|
||||
|
@ -46,7 +47,7 @@ public interface ISysScaleOrderService {
|
|||
* @param bo 量表订单
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
<T> T insertByBo(SysScaleOrderBo bo) throws Exception;
|
||||
WxPayMpOrderResult insertByBo(SysScaleOrderBo bo) throws Exception;
|
||||
|
||||
|
||||
Boolean processOrder(String orderId);
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.dromara.scale.service.impl;
|
|||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
|
@ -54,16 +55,12 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
private final ISysWarnRecordService warnRecordService;
|
||||
|
||||
private final SysScaleMapper scaleMapper;
|
||||
|
||||
private final SysScalePublishMapper publishMapper;
|
||||
|
||||
private final SysEvaluationRecordMapper recordMapper;
|
||||
|
||||
private final SysEvaluationConclusionMapper evaluationConclusionMapper;
|
||||
|
||||
private final SysEvaluationAnswerMapper evaluationAnswerMapper;
|
||||
|
||||
private final SysWarnRecordMapper warnMapper;
|
||||
private final SysScaleOrderMapper orderMapper;
|
||||
private final MathContext mathContext = new MathContext(2);
|
||||
|
||||
|
||||
|
@ -117,6 +114,9 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
if (evaluationRecord.getStatus() == 1) {
|
||||
throw new ServiceException("此量表已经答题完毕,请勿重复提交");
|
||||
}
|
||||
if (evaluationRecord.getStatus() == -1) {
|
||||
throw new ServiceException("此量表暂未开始作答,请确认后再尝试");
|
||||
}
|
||||
SysEvaluationRecord update = new SysEvaluationRecord();
|
||||
update.setRecordId(recordId);
|
||||
update.setStatus(StatusEnum.DISABLED.getValue());
|
||||
|
@ -138,7 +138,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
if (ObjectUtil.isEmpty(sysEvaluationRecord)) {
|
||||
throw new ServiceException("未查询到需要测试的记录,请联系管理员");
|
||||
}
|
||||
if (sysEvaluationRecord.getCreateTime() == null) {
|
||||
if (sysEvaluationRecord.getStatus() == -1) {
|
||||
throw new ServiceException("此量表暂未开始作答,请确认后再提交");
|
||||
}
|
||||
if (sysEvaluationRecord.getStatus() == 1) {
|
||||
|
@ -182,7 +182,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
|
||||
Long batchNo = sysEvaluationRecord.getBatchNo();
|
||||
Integer publishFlag = sysEvaluationRecord.getPublishFlag();
|
||||
//判断是个人还是发布
|
||||
//群体发布
|
||||
if (StatusEnum.IN_USE.getValue().equals(publishFlag)) {
|
||||
SysScalePublishVo scalePublishVo = publishMapper.selectVoById(batchNo);
|
||||
//查询考核结果
|
||||
|
@ -207,6 +207,15 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
wre.setSituation(max.get().getSituation());
|
||||
warnRecordService.insertByBo(wre);
|
||||
}
|
||||
} else {
|
||||
//个人要更新订单状态
|
||||
SysScaleOrder scaleOrder = orderMapper.selectOne(new LambdaQueryWrapper<SysScaleOrder>().eq(SysScaleOrder::getRecordId, recordId));
|
||||
SysScaleOrder order = new SysScaleOrder();
|
||||
order.setId(scaleOrder.getId());
|
||||
order.setOrderStatus(2);
|
||||
order.setUseStatus(1);
|
||||
order.setUpdateBy(scaleOrder.getCreateBy());
|
||||
orderMapper.updateById(order);
|
||||
}
|
||||
//不允许查看考核结果
|
||||
if (!allowQueryResult) {
|
||||
|
@ -215,7 +224,6 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
|
||||
BigDecimal totalScore = list.stream()
|
||||
.map(SysEvaluationConclusionVo::getScore)
|
||||
// 使用reduce()聚合函数,得到金额总和
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
return new HashMap<>(2) {{
|
||||
//put("evalRecordId",evalRecord.getId());
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.dromara.scale.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -99,7 +100,7 @@ public class ReservationOrderServiceImpl implements IReservationOrderService {
|
|||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public <T> T insertByBo(ReservationOrderBo bo) throws Exception {
|
||||
public WxPayMpOrderResult insertByBo(ReservationOrderBo bo) throws Exception {
|
||||
ReservationOrder add = MapstructUtils.convert(bo, ReservationOrder.class);
|
||||
ReservationTime reservationTime = timeMapper.selectById(add.getTimeId());
|
||||
Counselor counselor = counselorMapper.selectById(reservationTime.getCounselorId());
|
||||
|
|
|
@ -3,12 +3,14 @@ package org.dromara.scale.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.scale.constant.StatusEnum;
|
||||
import org.dromara.scale.domain.SysEvaluationRecord;
|
||||
import org.dromara.scale.domain.SysScale;
|
||||
|
@ -100,27 +102,38 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
|||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public <T> T insertByBo(SysScaleOrderBo bo) throws Exception {
|
||||
public WxPayMpOrderResult insertByBo(SysScaleOrderBo bo) throws Exception {
|
||||
String openId = LoginHelper.getOpenId();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
SysScaleOrder add = MapstructUtils.convert(bo, SysScaleOrder.class);
|
||||
SysScale sysScale = sysScaleMapper.selectById(add.getScaleId());
|
||||
Long scaleId = add.getScaleId();
|
||||
SysScale sysScale = sysScaleMapper.selectById(scaleId);
|
||||
BigDecimal price = sysScale.getPrice();
|
||||
add.setActualPrice(price);
|
||||
add.setOrderPrice(price);
|
||||
add.setUseStatus(StatusEnum.DISABLED.getValue());
|
||||
add.setOrderStatus(StatusEnum.DISABLED.getValue());
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
baseMapper.insert(add);
|
||||
//初始量测记录
|
||||
SysEvaluationRecord record = new SysEvaluationRecord();
|
||||
record.setUserId(userId);
|
||||
//个人测评订单号就是批次号
|
||||
record.setBatchNo(add.getId());
|
||||
record.setScaleId(scaleId);
|
||||
record.setStatus(-1);
|
||||
record.setCreateBy(userId);
|
||||
record.setUpdateBy(userId);
|
||||
recordMapper.insert(record);
|
||||
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
||||
orderRequest.setBody("墨者科技-量表支付");
|
||||
orderRequest.setOutTradeNo(add.getId().toString());
|
||||
int totalFee = price.multiply(new BigDecimal(100)).intValue();
|
||||
orderRequest.setTotalFee(totalFee);
|
||||
orderRequest.setNotifyUrl("https://api.ysmental.com/xxx/wx/pay/notify/order/scale");
|
||||
orderRequest.setNotifyUrl("https://api.ysmental.com/tenant/wx/pay/notify/order/scale");
|
||||
orderRequest.setTradeType("JSAPI");
|
||||
orderRequest.setSpbillCreateIp(bo.getSpbillCreateIp());
|
||||
orderRequest.setOpenid(openId);
|
||||
return payService.createOrder(orderRequest);
|
||||
|
||||
}
|
||||
|
@ -136,18 +149,15 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
|||
public Boolean processOrder(String orderId) {
|
||||
long id = Long.parseLong(orderId);
|
||||
SysScaleOrder scaleOrder = baseMapper.selectById(id);
|
||||
Long scaleId = scaleOrder.getScaleId();
|
||||
Long userId = scaleOrder.getCreateBy();
|
||||
Long recordId = scaleOrder.getRecordId();
|
||||
//初始量测记录
|
||||
SysEvaluationRecord record = new SysEvaluationRecord();
|
||||
record.setUserId(userId);
|
||||
record.setRecordId(recordId);
|
||||
//个人测评订单号就是批次号
|
||||
record.setBatchNo(id);
|
||||
record.setScaleId(scaleId);
|
||||
record.setStatus(-1);
|
||||
record.setCreateBy(userId);
|
||||
record.setStatus(0);
|
||||
record.setUpdateBy(userId);
|
||||
boolean recordFlag = recordMapper.insert(record) > 0;
|
||||
boolean recordFlag = recordMapper.updateById(record) > 0;
|
||||
//更新订单状态
|
||||
SysScaleOrder order = new SysScaleOrder();
|
||||
order.setId(id);
|
||||
|
|
|
@ -213,7 +213,7 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
|
|||
record.setBatchNo(batchNo);
|
||||
record.setScaleId(Long.parseLong(scaleId));
|
||||
//初始化字段
|
||||
record.setStatus(-1);
|
||||
record.setStatus(0);
|
||||
recordList.add(record);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class SysScaleServiceImpl implements ISysScaleService {
|
|||
.eq(SysEvaluationRecord::getUserId, userId)
|
||||
.eq(SysEvaluationRecord::getScaleId, scaleId)
|
||||
.eq(SysEvaluationRecord::getPublishFlag, 0)
|
||||
.lt(SysEvaluationRecord::getStatus, 1));
|
||||
.eq(SysEvaluationRecord::getStatus, 0));
|
||||
sysScaleVo.setRecordId(sysEvaluationRecord != null ? sysEvaluationRecord.getRecordId() : null);
|
||||
return sysScaleVo;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue