Compare commits

...

2 Commits

Author SHA1 Message Date
huchuansai
f64964a39a fix
Some checks failed
Build and Push Backend / docker (push) Failing after 8s
2025-10-05 22:03:32 +08:00
huchuansai
4ee24aabea fix: 修复bug 2025-10-04 23:59:17 +08:00
17 changed files with 328 additions and 350 deletions

21
deploy-hucs.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/bin/sh
# 发包脚本
set -e
# 获取当前时间并格式化为指定格式
current_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "发布开始,当前时间是:$current_time"
scp ./play-admin/target/play-admin-1.1.jar root@122.51.20.105:/app/service
echo "上传成功!"
ssh root@122.51.20.105 "
source /etc/profile;
cd /app/service;
docker-compose build;
cd /root;
docker-compose down;
docker-compose up -d;
docker-compose logs -f"
# 获取当前时间并格式化为指定格式
current_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "发布完成,当前时间是:$current_time"

View File

@@ -85,16 +85,19 @@ public class GlobalExceptionHandler {
@ExceptionHandler(MismatchedInputException.class) @ExceptionHandler(MismatchedInputException.class)
public R mismatchedInputException(MismatchedInputException e) { public R mismatchedInputException(MismatchedInputException e) {
log.error("请求参数格式异常", e);
return R.error("请求参数格式异常"); return R.error("请求参数格式异常");
} }
@ExceptionHandler(HttpMessageNotReadableException.class) @ExceptionHandler(HttpMessageNotReadableException.class)
public R httpMessageNotReadableException(HttpMessageNotReadableException e) { public R httpMessageNotReadableException(HttpMessageNotReadableException e) {
log.error("请求参数格式异常", e);
return R.error("请求参数格式异常"); return R.error("请求参数格式异常");
} }
@ExceptionHandler(MissingServletRequestParameterException.class) @ExceptionHandler(MissingServletRequestParameterException.class)
public R missingServletRequestParameterException(MissingServletRequestParameterException e) { public R missingServletRequestParameterException(MissingServletRequestParameterException e) {
log.error("请求参数格式异常", e);
return R.error("请求参数格式异常"); return R.error("请求参数格式异常");
} }

View File

@@ -23,8 +23,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 查询当前租户店员总数 * 查询当前租户店员总数
* *
* @param tenantId * @param tenantId 租户ID
* 租户ID
* @return 店员总数 * @return 店员总数
*/ */
List<PlayOrderInfoEntity> getTotalOrderInfo(String tenantId); List<PlayOrderInfoEntity> getTotalOrderInfo(String tenantId);
@@ -32,14 +31,10 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 新增充值单 * 新增充值单
* *
* @param orderNo * @param orderNo 订单编号
* 订单编号 * @param orderMoney 订单金额
* @param orderMoney * @param finalAmount 订单最终金额(支付金额)
* 订单金额 * @param purchaserBy 下单人ID
* @param finalAmount
* 订单最终金额(支付金额)
* @param purchaserBy
* 下单人ID
*/ */
void createRechargeOrder(String orderNo, BigDecimal orderMoney, BigDecimal finalAmount, String purchaserBy); void createRechargeOrder(String orderNo, BigDecimal orderMoney, BigDecimal finalAmount, String purchaserBy);
@@ -55,57 +50,33 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 新增订单信息 - 旧版本方法已废弃建议使用OrderCreationRequest * 新增订单信息 - 旧版本方法已废弃建议使用OrderCreationRequest
* *
* @deprecated 请使用 {@link #createOrderInfo(OrderCreationRequest)} 替代 * @param orderId 订单ID
* @param orderId * @param orderNo 订单编号
* 订单ID * @param orderState 订单状态【0:已下单(待接单);1:已接单(待开始);2:已开始(服务中);3;已完成:4:已取消】
* @param orderNo * @param orderType 订单类型【-1:退款订单;0:充值订单1:提现订单2:普通订单】
* 订单编号 * @param placeType 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
* @param orderState * @param rewardType 0:余额;1:礼物)
* 订单状态【0:已下单(待接单);1:已接单(待开始);2:已开始(服务中);3;已完成:4:已取消 * @param firstOrder 是否是首单【0不是1
* @param orderType * @param commodityId 商品ID
* 订单类型【-1:退款订单;0:充值订单1:提现订单2:普通订单】 * @param commodityType 商品类型[0:礼物1服务]
* @param placeType * @param commodityPrice 商品属性-商品单价
* 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单) * @param serviceDuration 商品属性-服务时长
* @param rewardType * @param commodityName 商品名称
* 0:余额;1:礼物) * @param commodityNumber 商品数量
* @param firstOrder * @param orderMoney 订单金额
* 是否是首单【0不是1是】 * @param finalAmount 订单最终金额(支付金额)
* @param commodityId * @param discountAmount 优惠金额
* 商品ID * @param purchaserBy 下单人
* @param commodityType * @param acceptBy 接单人
* 商品类型[0:礼物1服务] * @param weiChatCode 订单微信号码
* @param commodityPrice * @param couponIds 优惠券ID列表
* 商品属性-商品单价 * @param remark 订单备注
* @param serviceDuration * @param clerkSex 随机单要求-店员性别0:未知;1:男;2:女)
* 商品属性-服务时长 * @param clerkLevelId 随机单要求-店员等级ID
* @param commodityName * @param excludeHistory 随机单要求-是否排除下单过的成员0:不排除;1:排除)
* 商品名称
* @param commodityNumber
* 商品数量
* @param orderMoney
* 订单金额
* @param finalAmount
* 订单最终金额(支付金额)
* @param discountAmount
* 优惠金额
* @param purchaserBy
* 下单人
* @param acceptBy
* 接单人
* @param weiChatCode
* 订单微信号码
* @param couponIds
* 优惠券ID列表
* @param remark
* 订单备注
* @param clerkSex
* 随机单要求-店员性别0:未知;1:男;2:女)
* @param clerkLevelId
* 随机单要求-店员等级ID
* @param excludeHistory
* 随机单要求-是否排除下单过的成员0:不排除;1:排除)
* @author admin * @author admin
* @since 2024/6/3 10:53 * @since 2024/6/3 10:53
* @deprecated 请使用 {@link #createOrderInfo(OrderCreationRequest)} 替代
**/ **/
@Deprecated @Deprecated
void createOrderInfo(String orderId, String orderNo, String orderState, String orderType, String placeType, void createOrderInfo(String orderId, String orderNo, String orderState, String orderType, String placeType,
@@ -117,16 +88,11 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 据店员等级和订单金额,获取店员预计收入 * 据店员等级和订单金额,获取店员预计收入
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param croupIds 优惠券ID列表
* @param croupIds * @param placeType 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
* 优惠券ID列表 * @param firstOrder 是否是首单【0不是1是】
* @param placeType * @param finalAmount 订单支付金额
* 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
* @param firstOrder
* 是否是首单【0不是1是】
* @param finalAmount
* 订单支付金额
* @return com.starry.admin.modules.order.module.vo.ClerkEstimatedRevenueVo * @return com.starry.admin.modules.order.module.vo.ClerkEstimatedRevenueVo
* @author admin * @author admin
* @since 2024/7/18 16:39 * @since 2024/7/18 16:39
@@ -137,14 +103,10 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 根据店员等级和订单金额,获取店员预计收入 * 根据店员等级和订单金额,获取店员预计收入
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param placeType 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
* @param placeType * @param firstOrder 是否是首单【0不是1是】
* 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单) * @param finalAmount 订单支付金额
* @param firstOrder
* 是否是首单【0不是1是】
* @param finalAmount
* 订单支付金额
* @return math.BigDecimal 店员预计收入 * @return math.BigDecimal 店员预计收入
* @author admin * @author admin
* @since 2024/6/3 11:12 * @since 2024/6/3 11:12
@@ -154,12 +116,9 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 根据店员等级,获取店员提成比例 * 根据店员等级,获取店员提成比例
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param placeType 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
* @param placeType * @param firstOrder 是否是首单【0不是1是】
* 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
* @param firstOrder
* 是否是首单【0不是1是】
* @return math.BigDecimal 店员预计收入 * @return math.BigDecimal 店员预计收入
* @author admin * @author admin
* @since 2024/6/3 11:12 * @since 2024/6/3 11:12
@@ -169,10 +128,8 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 根据订单结算状态查询订单 * 根据订单结算状态查询订单
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param orderSettlementState 订单结算状态(0:未结算;1:已结算)
* @param orderSettlementState
* 订单结算状态(0:未结算;1:已结算)
* @return List<PlayOrderInfoEntity> * @return List<PlayOrderInfoEntity>
*/ */
List<PlayOrderInfoEntity> queryBySettlementOrder(String clerkId, String orderSettlementState); List<PlayOrderInfoEntity> queryBySettlementOrder(String clerkId, String orderSettlementState);
@@ -180,10 +137,8 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 查询指定店员在指定时间前完成,并且未结算工资的订单 * 查询指定店员在指定时间前完成,并且未结算工资的订单
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param endTime 结束时间
* @param endTime
* 结束时间
* @return List<PlayOrderInfoEntity> * @return List<PlayOrderInfoEntity>
*/ */
List<PlayOrderInfoEntity> listByEndTime(String clerkId, LocalDateTime endTime); List<PlayOrderInfoEntity> listByEndTime(String clerkId, LocalDateTime endTime);
@@ -191,14 +146,10 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 查询指定店员在一定时间内的订单 * 查询指定店员在一定时间内的订单
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param startTime 开始时间
* @param startTime * @param endTime 结束时间
* 开始时间 * @param orderStatus 店员状态列表
* @param endTime
* 结束时间
* @param orderStatus
* 店员状态列表
* @return List<PlayOrderInfoEntity> * @return List<PlayOrderInfoEntity>
*/ */
List<PlayOrderInfoEntity> listByTime(String clerkId, String startTime, String endTime, List<String> orderStatus); List<PlayOrderInfoEntity> listByTime(String clerkId, String startTime, String endTime, List<String> orderStatus);
@@ -206,8 +157,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 分页查询打赏订单 * 分页查询打赏订单
* *
* @param vo * @param vo 打赏订单查询对象
* 打赏订单查询对象
* @return 打赏订单 * @return 打赏订单
*/ */
IPage<PlayOrderRewardReturnVo> selectRewardOrderInfoByPage(PlayOrderRewardQueryVo vo); IPage<PlayOrderRewardReturnVo> selectRewardOrderInfoByPage(PlayOrderRewardQueryVo vo);
@@ -215,8 +165,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 根据订单ID查询订单信息 * 根据订单ID查询订单信息
* *
* @param orderId * @param orderId 订单ID
* 订单ID
* @return 订单信息 * @return 订单信息
*/ */
PlayOrderDetailsReturnVo selectById(String orderId); PlayOrderDetailsReturnVo selectById(String orderId);
@@ -224,8 +173,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 查询订单 * 查询订单
* *
* @param id * @param id 订单主键
* 订单主键
* @return 订单 * @return 订单
*/ */
PlayOrderInfoEntity selectOrderInfoById(String id); PlayOrderInfoEntity selectOrderInfoById(String id);
@@ -233,8 +181,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 查询订单列表 * 查询订单列表
* *
* @param orderInfoEntity * @param orderInfoEntity 订单
* 订单
* @return 订单集合 * @return 订单集合
*/ */
IPage<PlayOrderInfoReturnVo> selectOrderInfoPage(PlayOrderInfoQueryVo orderInfoEntity); IPage<PlayOrderInfoReturnVo> selectOrderInfoPage(PlayOrderInfoQueryVo orderInfoEntity);
@@ -242,10 +189,8 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 店员查询本人订单详情 * 店员查询本人订单详情
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param id 订单ID
* @param id
* 订单ID
* @return 订单详情 * @return 订单详情
*/ */
@@ -254,8 +199,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 店员分页查询订单本人列表 * 店员分页查询订单本人列表
* *
* @param vo * @param vo 订单列表查询对象
* 订单列表查询对象
* @return 订单集合 * @return 订单集合
*/ */
IPage<PlayClerkOrderListReturnVo> clerkSelectOrderInfoByPage(PlayClerkOrderInfoQueryVo vo); IPage<PlayClerkOrderListReturnVo> clerkSelectOrderInfoByPage(PlayClerkOrderInfoQueryVo vo);
@@ -263,12 +207,9 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 店员查询自己一段时间内的订单 * 店员查询自己一段时间内的订单
* *
* @param clerkId * @param clerkId 店员ID
* 店员ID * @param startTime 开始时间
* @param startTime * @param endTime 结束时间
* 开始时间
* @param endTime
* 结束时间
* @return 订单列表 * @return 订单列表
*/ */
List<PlayOrderInfoEntity> clerkSelectOrderInfoList(String clerkId, String startTime, String endTime); List<PlayOrderInfoEntity> clerkSelectOrderInfoList(String clerkId, String startTime, String endTime);
@@ -276,10 +217,8 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 顾客查询订单详情 * 顾客查询订单详情
* *
* @param customId * @param customId 顾客ID
* 顾客ID * @param orderId 订单ID
* @param orderId
* 订单ID
* @return 订单详情 * @return 订单详情
*/ */
PlayCustomOrderDetailsReturnVo customSelectOrderDetails(String customId, String orderId); PlayCustomOrderDetailsReturnVo customSelectOrderDetails(String customId, String orderId);
@@ -287,8 +226,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 顾客分页查询订单列表 * 顾客分页查询订单列表
* *
* @param vo * @param vo 订单列表查询对象
* 订单列表查询对象
* @return 订单集合 * @return 订单集合
*/ */
IPage<PlayCustomOrderListReturnVo> customSelectOrderInfoByPage(PlayCustomOrderInfoQueryVo vo); IPage<PlayCustomOrderListReturnVo> customSelectOrderInfoByPage(PlayCustomOrderInfoQueryVo vo);
@@ -296,8 +234,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 顾客查询本人订单列表 * 顾客查询本人订单列表
* *
* @param customId * @param customId 顾客ID
* 顾客ID
* @return 订单集合 * @return 订单集合
*/ */
List<PlayOrderInfoEntity> customSelectOrderInfoByList(String customId); List<PlayOrderInfoEntity> customSelectOrderInfoByList(String customId);
@@ -305,44 +242,31 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 修改订单状态为接单 只有管理员或者店员本人才能操作 * 修改订单状态为接单 只有管理员或者店员本人才能操作
* *
* @param operatorByType * @param operatorByType 操作人类型0:顾客;1:店员;2:管理员)
* 操作人类型0:顾客;1:店员;2:管理员) * @param operatorBy 操作人ID
* @param operatorBy * @param acceptBy 接单人ID
* 操作人ID * @param orderId 订单Id
* @param acceptBy
* 接单人ID
* @param orderId
* 订单Id
**/ **/
void updateStateTo1(String operatorByType, String operatorBy, String acceptBy, String orderId); void updateStateTo1(String operatorByType, String operatorBy, String acceptBy, String orderId);
/** /**
* 修改订单状态为开始订单或者完成订单 只有管理员或者店员本人才能操作 * 修改订单状态为开始订单或者完成订单 只有管理员或者店员本人才能操作
* *
* @param operatorByType * @param operatorByType 操作人类型0:顾客;1:店员;2:管理员)
* 操作人类型0:顾客;1:店员;2:管理员) * @param operatorBy 操作人ID
* @param operatorBy * @param orderState 订单状态
* 操作人ID * @param orderId 订单Id
* @param orderState
* 订单状态
* @param orderId
* 订单Id
**/ **/
void updateStateTo23(String operatorByType, String operatorBy, String orderState, String orderId); void updateStateTo23(String operatorByType, String operatorBy, String orderState, String orderId);
/** /**
* 修改订单状态为取消订单 管理员、店员、顾客均可操作 * 修改订单状态为取消订单 管理员、店员、顾客均可操作
* *
* @param operatorByType * @param operatorByType 操作人类型0:顾客;1:店员;2:管理员)
* 操作人类型0:顾客;1:店员;2:管理员) * @param operatorBy 操作人ID
* @param operatorBy * @param orderId 订单Id
* 操作人ID * @param refundReason 订单取消原因
* @param orderId * @param images 证据图片列表
* 订单Id
* @param refundReason
* 订单取消原因
* @param images
* 证据图片列表
**/ **/
void updateStateTo4(String operatorByType, String operatorBy, String orderId, String refundReason, void updateStateTo4(String operatorByType, String operatorBy, String orderId, String refundReason,
List<String> images); List<String> images);
@@ -350,8 +274,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 修改订单 * 修改订单
* *
* @param orderInfoEntity * @param orderInfoEntity 订单
* 订单
* @return 结果 * @return 结果
*/ */
boolean update(PlayOrderInfoEntity orderInfoEntity); boolean update(PlayOrderInfoEntity orderInfoEntity);
@@ -359,8 +282,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 批量删除订单 * 批量删除订单
* *
* @param ids * @param ids 需要删除的订单主键集合
* 需要删除的订单主键集合
* @return 结果 * @return 结果
*/ */
int deleteOrderInfoByIds(String[] ids); int deleteOrderInfoByIds(String[] ids);
@@ -368,8 +290,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 根据订单编号查询订单信息 * 根据订单编号查询订单信息
* *
* @param orderNo * @param orderNo 订单编号
* 订单编号
* @return 订单信息 * @return 订单信息
*/ */
PlayOrderInfoEntity queryByOrderNo(String orderNo); PlayOrderInfoEntity queryByOrderNo(String orderNo);
@@ -377,8 +298,7 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 删除订单信息 * 删除订单信息
* *
* @param id * @param id 订单主键
* 订单主键
* @return 结果 * @return 结果
*/ */
int deleteOrderInfoById(String id); int deleteOrderInfoById(String id);
@@ -393,10 +313,8 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 查询未接单的订单 * 查询未接单的订单
* *
* @param vo * @param vo 查询对象
* 查询对象 * @param clerkId 店员ID
* @param clerkId
* 店员ID
* @return 订单列表 * @return 订单列表
*/ */
IPage<PlayOrderInfoEntity> selectRandomOrderByPage(PlayOrderInfoRandomQueryVo vo, String clerkId); IPage<PlayOrderInfoEntity> selectRandomOrderByPage(PlayOrderInfoRandomQueryVo vo, String clerkId);
@@ -404,10 +322,11 @@ public interface IPlayOrderInfoService extends IService<PlayOrderInfoEntity> {
/** /**
* 分页获取打赏动态 * 分页获取打赏动态
* *
* @param vo * @param vo 查询对象
* 查询对象
* @return 打赏动态列表 * @return 打赏动态列表
*/ */
IPage<PlayRewardInfoReturnVo> selectRewardByPage(PlayRewardOrderQueryVo vo); IPage<PlayRewardInfoReturnVo> selectRewardByPage(PlayRewardOrderQueryVo vo);
Boolean checkFirstOrderFlag(String customId, String clerkId);
} }

View File

@@ -6,6 +6,7 @@ import static com.starry.admin.modules.order.module.constant.OrderConstant.ORDER
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -68,8 +69,6 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
@Resource @Resource
private IPlayClerkUserInfoService playClerkUserInfoService; private IPlayClerkUserInfoService playClerkUserInfoService;
@Resource @Resource
private IPlayCustomUserInfoService playCustomUserInfoService;
@Resource
private IPlayCustomUserInfoService userInfoService; private IPlayCustomUserInfoService userInfoService;
@Resource @Resource
private IPlayOrderRefundInfoService playOrderRefundInfoService; private IPlayOrderRefundInfoService playOrderRefundInfoService;
@@ -180,6 +179,10 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
if (request.isRewardOrder()) { if (request.isRewardOrder()) {
setRewardOrderCompleted(entity); setRewardOrderCompleted(entity);
} }
// 处理首单逻辑
if (StrUtil.isNotBlank(request.getAcceptBy()) && StrUtil.isNotBlank(request.getPurchaserBy())) {
entity.setFirstOrder(this.checkFirstOrderFlag(request.getPurchaserBy(), request.getAcceptBy()) ? "1" : "0");
}
// 保存订单 // 保存订单
userInfoService.saveOrderInfo(entity); userInfoService.saveOrderInfo(entity);
@@ -587,9 +590,9 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
lambdaQueryWrapper.eq(PlayOrderInfoEntity::getOrderStatus, "0"); lambdaQueryWrapper.eq(PlayOrderInfoEntity::getOrderStatus, "0");
// lambdaQueryWrapper.eq(PlayOrderInfoEntity::getLevelId, entity.getLevelId()); // lambdaQueryWrapper.eq(PlayOrderInfoEntity::getLevelId, entity.getLevelId());
lambdaQueryWrapper.eq(PlayOrderInfoEntity::getSex, entity.getSex()); lambdaQueryWrapper.eq(PlayOrderInfoEntity::getSex, entity.getSex());
lambdaQueryWrapper.eq(PlayOrderInfoEntity::getExcludeHistory, "0") // lambdaQueryWrapper.eq(PlayOrderInfoEntity::getExcludeHistory, "0")
.or(wrapper1 -> wrapper1.ne(PlayOrderInfoEntity::getAcceptBy, clerkId) // .or(wrapper1 -> wrapper1.ne(PlayOrderInfoEntity::getAcceptBy, clerkId)
.and(wrapper2 -> wrapper2.eq(PlayOrderInfoEntity::getExcludeHistory, 1))); // .and(wrapper2 -> wrapper2.eq(PlayOrderInfoEntity::getExcludeHistory, 1)));
return this.baseMapper.selectPage(new Page<>(vo.getPageNum(), vo.getPageSize()), lambdaQueryWrapper); return this.baseMapper.selectPage(new Page<>(vo.getPageNum(), vo.getPageSize()), lambdaQueryWrapper);
} }
@@ -613,6 +616,13 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
PlayRewardInfoReturnVo.class, lambdaQueryWrapper); PlayRewardInfoReturnVo.class, lambdaQueryWrapper);
} }
@Override
public Boolean checkFirstOrderFlag(String customId, String clerkId) {
// 检查是否是首单
LambdaQueryWrapper<PlayOrderInfoEntity> wrapper = Wrappers.lambdaQuery(PlayOrderInfoEntity.class).eq(PlayOrderInfoEntity::getPurchaserBy, customId).eq(PlayOrderInfoEntity::getAcceptBy, clerkId).eq(PlayOrderInfoEntity::getOrderStatus, "3");
return this.baseMapper.selectCount(wrapper) > 0;
}
/** /**
* 查询订单 * 查询订单
* *

View File

@@ -18,10 +18,12 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -60,8 +62,7 @@ public class PlayCouponInfoController {
/** /**
* 修改优惠券上下架状态 * 修改优惠券上下架状态
* *
* @param vo * @param vo 优惠券上下架对象
* 优惠券上下架对象
*/ */
@ApiOperation(value = "更新优惠券上下架状态", notes = "修改优惠券上下架状态") @ApiOperation(value = "更新优惠券上下架状态", notes = "修改优惠券上下架状态")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "更新失败,包含详细错误信息")}) @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "更新失败,包含详细错误信息")})
@@ -79,16 +80,17 @@ public class PlayCouponInfoController {
/** /**
* 发放优惠券 * 发放优惠券
* *
* @param vo * @param vo 优惠券发放对象
* 优惠券发放对象
*/ */
@ApiOperation(value = "发放优惠券", notes = "向指定用户发放优惠券") @ApiOperation(value = "发放优惠券", notes = "向指定用户发放优惠券")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "发放失败,包含详细错误信息")}) @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "发放失败,包含详细错误信息")})
@PostMapping("/sendCoupon") @PostMapping("/sendCoupon")
public R sendCoupon(@ApiParam(value = "优惠券发放信息", required = true) @Validated @RequestBody PlayCouponInfoSendVo vo) { public R sendCoupon(@ApiParam(value = "优惠券发放信息", required = true) @Validated @RequestBody PlayCouponInfoSendVo vo) {
PlayCustomUserInfoEntity customUserInfo = playCustomUserInfoService.selectById(vo.getCustomId()); PlayCustomUserInfoEntity customUserInfo = playCustomUserInfoService.selectById(vo.getCustomId());
for (Integer i = 0; i < vo.getSendNumber(); i++) {
playCouponDetailsService.create(customUserInfo.getId(), customUserInfo.getNickname(), playCouponDetailsService.create(customUserInfo.getId(), customUserInfo.getNickname(),
customUserInfo.getLevelId(), vo.getId(), "2", "1"); customUserInfo.getLevelId(), vo.getId(), "2", "1");
}
return R.ok(); return R.ok();
} }

View File

@@ -29,7 +29,6 @@ public class PlayCouponInfoSendVo {
/** /**
* 优惠券数量不能为空 * 优惠券数量不能为空
*/ */
@Max(value = 1, message = "优惠券数量必须小于1")
@Min(value = 1, message = "优惠券数量必须大于1") @Min(value = 1, message = "优惠券数量必须大于1")
private Integer sendNumber; private Integer sendNumber;

View File

@@ -115,7 +115,7 @@ public class WxClerkController {
* 店员获取个人业绩信息 * 店员获取个人业绩信息
*/ */
@ApiOperation(value = "查询店员业绩", notes = "店员获取个人业绩信息") @ApiOperation(value = "查询店员业绩", notes = "店员获取个人业绩信息")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功") }) @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/queryPerformanceInfo") @PostMapping("/user/queryPerformanceInfo")
public R queryPerformanceInfo( public R queryPerformanceInfo(
@@ -134,7 +134,7 @@ public class WxClerkController {
* 店员获取个人等级信息 * 店员获取个人等级信息
*/ */
@ApiOperation(value = "查询店员等级", notes = "店员获取个人等级信息") @ApiOperation(value = "查询店员等级", notes = "店员获取个人等级信息")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功", response = PlayClerkLevelInfoReturnVo.class) }) @ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = PlayClerkLevelInfoReturnVo.class)})
@ClerkUserLogin @ClerkUserLogin
@GetMapping("/user/queryLevelInfo") @GetMapping("/user/queryLevelInfo")
public R queryLevelInfo() { public R queryLevelInfo() {
@@ -159,8 +159,8 @@ public class WxClerkController {
* 店员获取个人信息 * 店员获取个人信息
*/ */
@ApiOperation(value = "查询店员信息", notes = "店员获取个人详细信息") @ApiOperation(value = "查询店员信息", notes = "店员获取个人详细信息")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功", response = PlayClerkUserInfoResultVo.class), @ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = PlayClerkUserInfoResultVo.class),
@ApiResponse(code = 500, message = "用户不存在") }) @ApiResponse(code = 500, message = "用户不存在")})
@ClerkUserLogin @ClerkUserLogin
@GetMapping("/user/queryById") @GetMapping("/user/queryById")
public R queryById() { public R queryById() {
@@ -173,7 +173,7 @@ public class WxClerkController {
} }
@ApiOperation(value = "发送验证码", notes = "店员绑定手机号发送验证码") @ApiOperation(value = "发送验证码", notes = "店员绑定手机号发送验证码")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功", response = String.class) }) @ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = String.class)})
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/sendCode") @PostMapping("/user/sendCode")
public R sendCode( public R sendCode(
@@ -187,7 +187,7 @@ public class WxClerkController {
} }
@ApiOperation(value = "绑定手机号", notes = "店员绑定手机号") @ApiOperation(value = "绑定手机号", notes = "店员绑定手机号")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "验证码错误") }) @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "验证码错误")})
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/bindCode") @PostMapping("/user/bindCode")
public R bindCode( public R bindCode(
@@ -211,17 +211,19 @@ public class WxClerkController {
} }
@ApiOperation(value = "店员申请", notes = "用户申请成为店员") @ApiOperation(value = "店员申请", notes = "用户申请成为店员")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "系统错误,用户不存在"), @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "系统错误,用户不存在"),
@ApiResponse(code = 500, message = "当前用户已经是店员"), @ApiResponse(code = 500, message = "已有申请未审核") }) @ApiResponse(code = 500, message = "当前用户已经是店员"), @ApiResponse(code = 500, message = "已有申请未审核")})
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/add") @PostMapping("/user/add")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public R userAdd(@ApiParam(value = "店员申请信息", required = true) @Validated @RequestBody PlayClerkUserByWxAddVo vo) { public R userAdd(@ApiParam(value = "店员申请信息", required = true) @Validated @RequestBody PlayClerkUserByWxAddVo vo) {
String clerkId = ThreadLocalRequestDetail.getClerkUserInfo().getId(); String clerkId = ThreadLocalRequestDetail.getClerkUserInfo().getId();
PlayClerkUserInfoEntity userInfo = playClerkUserInfoService.selectById(clerkId); PlayClerkUserInfoEntity userInfo = playClerkUserInfoService.selectById(clerkId);
if (userInfo == null) { if (userInfo == null) {
throw new CustomException("系统错误,用户不存在"); throw new CustomException("系统错误,用户不存在");
} }
wxCustomMpService.checkSubscribeThrowsExp(userInfo.getOpenid(), userInfo.getTenantId());
if ("1".equals(userInfo.getClerkState())) { if ("1".equals(userInfo.getClerkState())) {
throw new CustomException("当前用户已经是店员"); throw new CustomException("当前用户已经是店员");
} }
@@ -241,7 +243,7 @@ public class WxClerkController {
} }
@ApiOperation(value = "更新头像", notes = "店员更新头像") @ApiOperation(value = "更新头像", notes = "店员更新头像")
@ApiResponses({ @ApiResponse(code = 200, message = "操作成功") }) @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
@ClerkUserLogin @ClerkUserLogin
@PostMapping("/user/updateAvatar") @PostMapping("/user/updateAvatar")
public R updateAvatar(@ApiParam(value = "头像信息", required = true) @Validated @RequestBody PlayClerkUserAvatarVo vo) { public R updateAvatar(@ApiParam(value = "头像信息", required = true) @Validated @RequestBody PlayClerkUserAvatarVo vo) {
@@ -340,8 +342,7 @@ public class WxClerkController {
/** /**
* 分页获取店员列表 * 分页获取店员列表
* *
* @param vo * @param vo PlayClerkUserInfoQueryVo
* PlayClerkUserInfoQueryVo
* @return 店员列表 * @return 店员列表
*/ */
@PostMapping("/user/queryByPage") @PostMapping("/user/queryByPage")
@@ -369,8 +370,7 @@ public class WxClerkController {
/** /**
* 获取店员礼物信息 * 获取店员礼物信息
* *
* @param id * @param id 店员ID
* 店员ID
* @return 店员礼物 * @return 店员礼物
*/ */
@@ -405,8 +405,7 @@ public class WxClerkController {
/** /**
* 获取店员价格 * 获取店员价格
* *
* @param id * @param id 店员ID
* 店员ID
* @return 店员价格 * @return 店员价格
*/ */
@GetMapping("/user/queryPriceById") @GetMapping("/user/queryPriceById")
@@ -417,8 +416,7 @@ public class WxClerkController {
/** /**
* 店员分页查询本人订单列表 * 店员分页查询本人订单列表
* *
* @param vo * @param vo 订单列表分页查询对象
* 订单列表分页查询对象
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -434,8 +432,7 @@ public class WxClerkController {
/** /**
* 店员查询本人订单详情 * 店员查询本人订单详情
* *
* @param id * @param id 订单ID
* 订单ID
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -448,7 +445,7 @@ public class WxClerkController {
if (StringUtils.isNotEmpty(vo.getAcceptBy()) && !vo.getAcceptBy().equals(ThreadLocalRequestDetail.getClerkUserInfo().getId())) { if (StringUtils.isNotEmpty(vo.getAcceptBy()) && !vo.getAcceptBy().equals(ThreadLocalRequestDetail.getClerkUserInfo().getId())) {
vo.setWeiChatCode(""); vo.setWeiChatCode("");
} }
if(vo.getOrderStatus().equals("4")){ if (vo.getOrderStatus().equals("4")) {
vo.setWeiChatCode(""); vo.setWeiChatCode("");
} }
return R.ok(vo); return R.ok(vo);
@@ -457,8 +454,7 @@ public class WxClerkController {
/** /**
* 店员-接单 * 店员-接单
* *
* @param id * @param id 订单ID
* 订单ID
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -466,16 +462,26 @@ public class WxClerkController {
@ClerkUserLogin @ClerkUserLogin
@GetMapping("/order/accept") @GetMapping("/order/accept")
public R acceptOrder(@RequestParam("id") String id) { public R acceptOrder(@RequestParam("id") String id) {
playOrderInfoService.updateStateTo1("1", ThreadLocalRequestDetail.getClerkUserInfo().getId(), PlayClerkUserInfoEntity clerkUserInfo = ThreadLocalRequestDetail.getClerkUserInfo();
ThreadLocalRequestDetail.getClerkUserInfo().getId(), id); wxCustomMpService.checkSubscribeThrowsExp(clerkUserInfo.getOpenid(), clerkUserInfo.getTenantId());
playOrderInfoService.updateStateTo1("1", clerkUserInfo.getId(),
clerkUserInfo.getId(), id);
return R.ok("成功"); return R.ok("成功");
} }
@GetMapping("/checkSubscribe")
@ClerkUserLogin
public R checkSubscribe() {
String openid = ThreadLocalRequestDetail.getClerkUserInfo().getOpenid();
String tenantId = SecurityUtils.getTenantId();
return R.ok(wxCustomMpService.checkSubscribe(openid, tenantId));
}
/** /**
* 店员-开始订单 * 店员-开始订单
* *
* @param id * @param id 订单ID
* 订单ID
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -490,8 +496,7 @@ public class WxClerkController {
/** /**
* 店员-取消订单 * 店员-取消订单
* *
* @param vo * @param vo 取消订单传参
* 取消订单传参
* @return com.starry.common.result.R * @return com.starry.common.result.R
* @author admin * @author admin
* @since 2024/5/8 15:57 * @since 2024/5/8 15:57
@@ -507,8 +512,7 @@ public class WxClerkController {
/** /**
* 分页获取店员评价(订单评价) * 分页获取店员评价(订单评价)
* *
* @param vo * @param vo 店员评价查询对象
* 店员评价查询对象
* @return 店员评价 * @return 店员评价
*/ */
@PostMapping("/user/queryEvaluateByPage") @PostMapping("/user/queryEvaluateByPage")

View File

@@ -25,11 +25,13 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -139,6 +141,7 @@ public class WxCouponController {
// 优惠券列表 // 优惠券列表
List<WxCouponOrderReturnVo> couponReturnVos = new ArrayList<>(); List<WxCouponOrderReturnVo> couponReturnVos = new ArrayList<>();
for (PlayCouponDetailsReturnVo couponDetails : list) { for (PlayCouponDetailsReturnVo couponDetails : list) {
try {
PlayCouponInfoEntity couponInfo = couponInfoService.selectPlayCouponInfoById(couponDetails.getCouponId()); PlayCouponInfoEntity couponInfo = couponInfoService.selectPlayCouponInfoById(couponDetails.getCouponId());
WxCouponOrderReturnVo wxCouponReturnVo = ConvertUtil.entityToVo(couponDetails, WxCouponOrderReturnVo.class); WxCouponOrderReturnVo wxCouponReturnVo = ConvertUtil.entityToVo(couponDetails, WxCouponOrderReturnVo.class);
String couponReasonForUnavailableUse = couponInfoService.getCouponReasonForUnavailableUse(couponInfo, String couponReasonForUnavailableUse = couponInfoService.getCouponReasonForUnavailableUse(couponInfo,
@@ -151,6 +154,10 @@ public class WxCouponController {
wxCouponReturnVo.setReasonForUnavailableUse(couponReasonForUnavailableUse); wxCouponReturnVo.setReasonForUnavailableUse(couponReasonForUnavailableUse);
} }
couponReturnVos.add(wxCouponReturnVo); couponReturnVos.add(wxCouponReturnVo);
} catch (Exception e) {
}
} }
return R.ok(couponReturnVos); return R.ok(couponReturnVos);
} }

View File

@@ -18,6 +18,7 @@ import com.starry.admin.modules.weichat.entity.WxUserQueryAddressVo;
import com.starry.admin.modules.weichat.service.WxCustomMpService; import com.starry.admin.modules.weichat.service.WxCustomMpService;
import com.starry.admin.modules.weichat.service.WxOauthService; import com.starry.admin.modules.weichat.service.WxOauthService;
import com.starry.admin.modules.weichat.service.WxTokenService; import com.starry.admin.modules.weichat.service.WxTokenService;
import com.starry.admin.utils.SecurityUtils;
import com.starry.common.redis.RedisCache; import com.starry.common.redis.RedisCache;
import com.starry.common.result.R; import com.starry.common.result.R;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -193,6 +194,14 @@ public class WxOauthController {
return R.ok(url); return R.ok(url);
} }
@GetMapping("/checkSubscribe")
@CustomUserLogin
public R checkSubscribe() {
String openid = ThreadLocalRequestDetail.getCustomUserInfo().getOpenid();
String tenantId = SecurityUtils.getTenantId();
return R.ok(wxCustomMpService.checkSubscribe(openid, tenantId));
}
@ApiOperation(value = "顾客登录回调", notes = "微信顾客授权登录回调处理") @ApiOperation(value = "顾客登录回调", notes = "微信顾客授权登录回调处理")
@ApiImplicitParam(name = "code", value = "授权码", required = true, dataType = "String", paramType = "query") @ApiImplicitParam(name = "code", value = "授权码", required = true, dataType = "String", paramType = "query")
@GetMapping("/customLoginCallback") @GetMapping("/customLoginCallback")

View File

@@ -82,8 +82,7 @@ public class WxPlayController {
@ApiResponses({@ApiResponse(code = 200, message = "成功")}) @ApiResponses({@ApiResponse(code = 200, message = "成功")})
@RequestMapping("/jsCallback") @RequestMapping("/jsCallback")
public String wxPayNotify(HttpServletRequest request) { public String wxPayNotify(HttpServletRequest request) {
try (InputStream inStream = request.getInputStream(); try (InputStream inStream = request.getInputStream(); ByteArrayOutputStream outSteam = new ByteArrayOutputStream()) {
ByteArrayOutputStream outSteam = new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len; int len;
while ((len = inStream.read(buffer)) != -1) { while ((len = inStream.read(buffer)) != -1) {
@@ -123,15 +122,13 @@ public class WxPlayController {
orderInfoEntity.setPayState("1"); orderInfoEntity.setPayState("1");
orderInfoService.updateById(orderInfoEntity); orderInfoService.updateById(orderInfoEntity);
// 修改账户余额 // 修改账户余额
customUserInfoService.customAccountBalanceRecharge(orderInfoEntity.getOrderMoney(), customUserInfoService.customAccountBalanceRecharge(orderInfoEntity.getOrderMoney(), orderInfoEntity.getPurchaserBy(), orderInfoEntity.getId());
orderInfoEntity.getPurchaserBy(), orderInfoEntity.getId());
log.info("*********支付处理完成"); log.info("*********支付处理完成");
// 推送通知 // 推送通知
mpService.sendBalanceMessage(orderInfoEntity); mpService.sendBalanceMessage(orderInfoEntity);
// 请求分账 // 请求分账
WxPayService wxPayService = mpService.getWxPay(); WxPayService wxPayService = mpService.getWxPay();
this.profitSharing(wxPayService, orderMap, orderInfoEntity, this.profitSharing(wxPayService, orderMap, orderInfoEntity, tenantService.selectSysTenantByTenantId(orderInfoEntity.getTenantId()));
tenantService.selectSysTenantByTenantId(orderInfoEntity.getTenantId()));
} catch (Exception e) { } catch (Exception e) {
log.error("订单回调业务处理异常,xmlData={}", xmlData); log.error("订单回调业务处理异常,xmlData={}", xmlData);
} }
@@ -155,15 +152,13 @@ public class WxPlayController {
if (StringUtils.isEmpty(money)) { if (StringUtils.isEmpty(money)) {
throw new CustomException("请求参数错误,money不能为空"); throw new CustomException("请求参数错误,money不能为空");
} }
BigDecimal paymentAmount = customUserInfoService.getCustomPaymentAmount(new BigDecimal(money), BigDecimal paymentAmount = customUserInfoService.getCustomPaymentAmount(new BigDecimal(money), ThreadLocalRequestDetail.getCustomUserInfo().getId());
ThreadLocalRequestDetail.getCustomUserInfo().getId());
return R.ok(paymentAmount); return R.ok(paymentAmount);
} }
@ApiOperation(value = "创建充值订单", notes = "创建微信支付充值订单") @ApiOperation(value = "创建充值订单", notes = "创建微信支付充值订单")
@ApiImplicitParam(name = "money", value = "充值金额", required = true, dataType = "String", paramType = "query") @ApiImplicitParam(name = "money", value = "充值金额", required = true, dataType = "String", paramType = "query")
@ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "请求参数错误,money不能为空"), @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "请求参数错误,money不能为空"), @ApiResponse(code = 500, message = "充值金额不能小于10元"), @ApiResponse(code = 500, message = "系统错误,租户ID获取失败")})
@ApiResponse(code = 500, message = "充值金额不能小于10元"), @ApiResponse(code = 500, message = "系统错误,租户ID获取失败")})
@CustomUserLogin @CustomUserLogin
@GetMapping("/custom/createOrder") @GetMapping("/custom/createOrder")
public R createOrder(@RequestParam("money") String money) { public R createOrder(@RequestParam("money") String money) {
@@ -178,17 +173,16 @@ public class WxPlayController {
throw new CustomException("系统错误,租户ID获取失败"); throw new CustomException("系统错误,租户ID获取失败");
} }
// 用户信息 // 用户信息
PlayCustomUserInfoEntity customUserInfo = customUserInfoService PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(ThreadLocalRequestDetail.getCustomUserInfo().getId());
.selectById(ThreadLocalRequestDetail.getCustomUserInfo().getId());
// 租户信息 // 租户信息
SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(tenantId); SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(tenantId);
mpService.checkSubscribeThrowsExp(customUserInfo.getOpenid(), tenant.getTenantId());
Boolean profitSharing = tenant.getProfitsharingRate() > 0; Boolean profitSharing = tenant.getProfitsharingRate() > 0;
// 订单总金额,单位为分 // 订单总金额,单位为分
long totalFee = getTotalFee(money); long totalFee = getTotalFee(money);
// 创建订单信息 // 创建订单信息
String orderNo = playOrderInfoService.getOrderNo(); String orderNo = playOrderInfoService.getOrderNo();
orderInfoService.createRechargeOrder(orderNo, new BigDecimal(totalFee * 1.0 / 100), orderInfoService.createRechargeOrder(orderNo, new BigDecimal(totalFee * 1.0 / 100), new BigDecimal(totalFee * 1.0 / 100), customUserInfo.getId());
new BigDecimal(totalFee * 1.0 / 100), customUserInfo.getId());
WxPayService wxPayService = mpService.getWxPay(); WxPayService wxPayService = mpService.getWxPay();
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest(); WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
@@ -229,10 +223,7 @@ public class WxPlayController {
String paySign = SignUtils.createSign(paySignInfo, "MD5", wxPayService.getConfig().getMchKey(), signInfo); String paySign = SignUtils.createSign(paySignInfo, "MD5", wxPayService.getConfig().getMchKey(), signInfo);
// 组合支付参数 // 组合支付参数
JSONObject jsonObject = new JSONObject().fluentPut("appId", wxPayService.getConfig().getAppId()) JSONObject jsonObject = new JSONObject().fluentPut("appId", wxPayService.getConfig().getAppId()).fluentPut("timeStamp", timeStamp).fluentPut("nonceStr", nonceStr).fluentPut("package", "prepay_id=" + prepayId).fluentPut("signType", "MD5").fluentPut("paySign", paySign);
.fluentPut("timeStamp", timeStamp).fluentPut("nonceStr", nonceStr)
.fluentPut("package", "prepay_id=" + prepayId).fluentPut("signType", "MD5")
.fluentPut("paySign", paySign);
return R.ok(jsonObject); return R.ok(jsonObject);
} }
@@ -243,9 +234,7 @@ public class WxPlayController {
String nonceStr = "dalfhh241lnandnsklajax"; String nonceStr = "dalfhh241lnandnsklajax";
request.setNonceStr(nonceStr); request.setNonceStr(nonceStr);
request.setSignType("HMAC-SHA256"); request.setSignType("HMAC-SHA256");
request.setReceiver(new JSONObject().fluentPut("type", "MERCHANT_ID").fluentPut("account", "1681470208") request.setReceiver(new JSONObject().fluentPut("type", "MERCHANT_ID").fluentPut("account", "1681470208").fluentPut("name", "合肥经济技术开发区陪陪信息技术服务部(个体工商户)").fluentPut("relation_type", "SERVICE_PROVIDER").toString());
.fluentPut("name", "合肥经济技术开发区陪陪信息技术服务部(个体工商户)").fluentPut("relation_type", "SERVICE_PROVIDER")
.toString());
try { try {
ProfitSharingReceiverResult result = wxPayService.getProfitSharingService().addReceiver(request); ProfitSharingReceiverResult result = wxPayService.getProfitSharingService().addReceiver(request);
log.info("请求添加分账结果:" + JSONObject.toJSONString(result)); log.info("请求添加分账结果:" + JSONObject.toJSONString(result));
@@ -256,8 +245,7 @@ public class WxPlayController {
} }
/** /**
* @param money * @param money 金额,单位-元
* 金额,单位-元
* @return 金额, 单位-分 * @return 金额, 单位-分
*/ */
public long getTotalFee(String money) { public long getTotalFee(String money) {
@@ -289,16 +277,14 @@ public class WxPlayController {
return map; return map;
} }
private void profitSharing(WxPayService wxPayService, Map<String, String> orderMap, private void profitSharing(WxPayService wxPayService, Map<String, String> orderMap, PlayOrderInfoEntity orderInfoEntity, SysTenantEntity tenant) throws WxPayException {
PlayOrderInfoEntity orderInfoEntity, SysTenantEntity tenant) throws WxPayException {
Boolean profitSharing = tenant.getProfitsharingRate() > 0; Boolean profitSharing = tenant.getProfitsharingRate() > 0;
if (!profitSharing) { if (!profitSharing) {
return; return;
} }
log.info("开始进行分账。。。。。。。。。。。。。。。"); log.info("开始进行分账。。。。。。。。。。。。。。。");
long totalFee = getTotalFee(orderInfoEntity.getOrderMoney().toString()); long totalFee = getTotalFee(orderInfoEntity.getOrderMoney().toString());
int amount = new BigDecimal(totalFee).multiply(BigDecimal.valueOf((double) tenant.getProfitsharingRate() / 100)) int amount = new BigDecimal(totalFee).multiply(BigDecimal.valueOf((double) tenant.getProfitsharingRate() / 100)).intValue();
.intValue();
if (amount == 0) { if (amount == 0) {
return; return;
} }
@@ -307,17 +293,12 @@ public class WxPlayController {
request.setTransactionId(orderMap.get("transaction_id")); request.setTransactionId(orderMap.get("transaction_id"));
request.setOutOrderNo("ps" + orderMap.get("out_trade_no")); request.setOutOrderNo("ps" + orderMap.get("out_trade_no"));
request.setReceivers(new JSONArray().fluentAdd( request.setReceivers(new JSONArray().fluentAdd(new JSONObject().fluentPut("type", "MERCHANT_ID").fluentPut("name", "合肥经济技术开发区陪陪信息技术服务部(个体工商户)").fluentPut("account", "1681470208").fluentPut("amount", amount)).toString());
new JSONObject().fluentPut("type", "MERCHANT_ID").fluentPut("name", "合肥经济技术开发区陪陪信息技术服务部(个体工商户)")
.fluentPut("account", "1681470208").fluentPut("amount", amount))
.toString());
ProfitSharingResult result = wxPayService.getProfitSharingService().profitSharing(request); ProfitSharingResult result = wxPayService.getProfitSharingService().profitSharing(request);
log.info("分账结果:" + JSONObject.toJSONString(result)); log.info("分账结果:" + JSONObject.toJSONString(result));
// 保存分账金额 // 保存分账金额
BigDecimal profitSharingAmount = new BigDecimal(amount).divide(new BigDecimal(100)); BigDecimal profitSharingAmount = new BigDecimal(amount).divide(new BigDecimal(100));
orderInfoService.update(null, orderInfoService.update(null, Wrappers.lambdaUpdate(PlayOrderInfoEntity.class).eq(PlayOrderInfoEntity::getId, orderInfoEntity.getId()).set(PlayOrderInfoEntity::getProfitSharingAmount, profitSharingAmount));
Wrappers.lambdaUpdate(PlayOrderInfoEntity.class).eq(PlayOrderInfoEntity::getId, orderInfoEntity.getId())
.set(PlayOrderInfoEntity::getProfitSharingAmount, profitSharingAmount));
} }
} }

View File

@@ -2,12 +2,14 @@ package com.starry.admin.modules.weichat.service;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.starry.admin.common.exception.CustomException; import com.starry.admin.common.exception.CustomException;
import com.starry.admin.common.exception.ServiceException;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity; import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserReviewInfoEntity; import com.starry.admin.modules.clerk.module.entity.PlayClerkUserReviewInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService; import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
@@ -28,6 +30,7 @@ import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl; import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
@@ -76,6 +79,7 @@ public class WxCustomMpService {
wxMpService.addConfigStorage(entity.getAppId(), config); wxMpService.addConfigStorage(entity.getAppId(), config);
return wxMpService.switchoverTo(entity.getAppId()); return wxMpService.switchoverTo(entity.getAppId());
} }
public WxMpService proxyWxMpService(String tenantId) { public WxMpService proxyWxMpService(String tenantId) {
if (StrUtil.isBlankIfStr(tenantId)) { if (StrUtil.isBlankIfStr(tenantId)) {
throw new CustomException("系统错误,租户ID不能为空"); throw new CustomException("系统错误,租户ID不能为空");
@@ -329,6 +333,31 @@ public class WxCustomMpService {
if (order.getPlaceType().equals("1") || order.getPlaceType().equals("2")) { if (order.getPlaceType().equals("1") || order.getPlaceType().equals("2")) {
SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(order.getTenantId()); SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(order.getTenantId());
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(order.getPurchaserBy()); PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(order.getPurchaserBy());
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(order.getAcceptBy());
this.sendUserOrderFinishMessage(order, customUserInfo, tenant);
this.sendClerkOrderFinishMessage(order, clerkUserInfo, tenant);
}
}
private void sendClerkOrderFinishMessage(PlayOrderInfoEntity order, PlayClerkUserInfoEntity clerkUserInfo, SysTenantEntity tenant) {
WxMpTemplateMessage templateMessage = getWxMpTemplateMessage(tenant.getDingdanwanchengtongzhiTemplateId(),
clerkUserInfo.getOpenid(),
"https://" + tenant.getTenantKey() + ".julyharbor.com/clerk/#/orderDetail/" + order.getId());
List<WxMpTemplateData> data = new ArrayList<>();
data.add(new WxMpTemplateData("time18", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")));
data.add(new WxMpTemplateData("character_string8", order.getOrderNo()));
data.add(new WxMpTemplateData("thing13", order.getCommodityName()));
templateMessage.setData(data);
try {
proxyWxMpService(tenant.getTenantId()).getTemplateMsgService().sendTemplateMsg(templateMessage);
} catch (WxErrorException e) {
log.error("订单完成发送消息异常", e);
}
}
private void sendUserOrderFinishMessage(PlayOrderInfoEntity order, PlayCustomUserInfoEntity customUserInfo, SysTenantEntity tenant) {
WxMpTemplateMessage templateMessage = getWxMpTemplateMessage(tenant.getDingdanwanchengtongzhiTemplateId(), WxMpTemplateMessage templateMessage = getWxMpTemplateMessage(tenant.getDingdanwanchengtongzhiTemplateId(),
customUserInfo.getOpenid(), customUserInfo.getOpenid(),
"https://" + tenant.getTenantKey() + ".julyharbor.com/user/#/orderDetail/" + order.getId()); "https://" + tenant.getTenantKey() + ".julyharbor.com/user/#/orderDetail/" + order.getId());
@@ -344,8 +373,6 @@ public class WxCustomMpService {
} }
} }
}
public void sendOrderCancelMessage(PlayOrderInfoEntity orderInfo, String refundReason) { public void sendOrderCancelMessage(PlayOrderInfoEntity orderInfo, String refundReason) {
SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(orderInfo.getTenantId()); SysTenantEntity tenant = tenantService.selectSysTenantByTenantId(orderInfo.getTenantId());
@@ -380,5 +407,31 @@ public class WxCustomMpService {
} }
public void checkSubscribeThrowsExp(String openId, String tenantId) {
if (StrUtil.isBlankIfStr(openId)) {
throw new ServiceException("openId不能为空");
}
try {
WxMpUser wxMpUser = proxyWxMpService(tenantId).getUserService().userInfo(openId);
if (!wxMpUser.getSubscribe()) {
log.info("检测到用户未关注公众号:" + JSONObject.toJSONString(wxMpUser));
throw new ServiceException("请先关注公众号然后再来使用系统~");
}
} catch (WxErrorException e) {
throw new RuntimeException(e);
}
}
public Boolean checkSubscribe(String openId, String tenantId) {
if (StrUtil.isBlankIfStr(openId)) {
throw new ServiceException("openId不能为空");
}
try {
WxMpUser wxMpUser = proxyWxMpService(tenantId).getUserService().userInfo(openId);
return wxMpUser.getSubscribe();
} catch (WxErrorException e) {
throw new RuntimeException(e);
}
}
} }

View File

@@ -1,22 +1,27 @@
package com.starry.admin.modules.weichat.service; package com.starry.admin.modules.weichat.service;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.starry.admin.common.exception.ServiceException; import com.starry.admin.common.exception.ServiceException;
import com.starry.admin.common.oss.service.IOssFileService;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity; import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkLevelInfoService; import com.starry.admin.modules.clerk.service.IPlayClerkLevelInfoService;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService; import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity; import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService; import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService; import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.admin.utils.SecurityUtils;
import com.starry.common.utils.ConvertUtil; import com.starry.common.utils.ConvertUtil;
import com.starry.common.utils.IdUtils; import com.starry.common.utils.IdUtils;
import java.io.InputStream;
import java.util.Date; import java.util.Date;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo; import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@@ -42,12 +47,13 @@ public class WxOauthService {
@Resource @Resource
private IPlayCustomLevelInfoService playCustomLevelInfoService; private IPlayCustomLevelInfoService playCustomLevelInfoService;
@Resource
IOssFileService ossFileService;
/** /**
* 微信用户登录 如果用户不存在,初始化用户并登录 * 微信用户登录 如果用户不存在,初始化用户并登录
* *
* @param code * @param code 微信授权code
* 微信授权code
* @return String 用户ID * @return String 用户ID
* @author admin * @author admin
* @since 2024/4/15 11:01 * @since 2024/4/15 11:01
@@ -61,22 +67,24 @@ public class WxOauthService {
PlayClerkUserInfoEntity item = clerkUserInfoService.selectByOpenid(openId); PlayClerkUserInfoEntity item = clerkUserInfoService.selectByOpenid(openId);
if (item == null) { if (item == null) {
PlayClerkUserInfoEntity entity = ConvertUtil.entityToVo(userInfo, PlayClerkUserInfoEntity.class); PlayClerkUserInfoEntity entity = ConvertUtil.entityToVo(userInfo, PlayClerkUserInfoEntity.class);
entity.setAvatar(userInfo.getHeadImgUrl()); entity.setAvatar(generateAvatar(userInfo.getHeadImgUrl()));
entity.setWeiChatAvatar(userInfo.getHeadImgUrl()); entity.setWeiChatAvatar(generateAvatar(userInfo.getHeadImgUrl()));
entity.setId(IdUtils.getUuid()); entity.setId(IdUtils.getUuid());
entity.setLevelId(playClerkLevelInfoService.getDefaultLevel().getId()); entity.setLevelId(playClerkLevelInfoService.getDefaultLevel().getId());
clerkUserInfoService.create(entity); clerkUserInfoService.create(entity);
return entity.getId(); return entity.getId();
} else { } else {
PlayClerkUserInfoEntity entity = new PlayClerkUserInfoEntity();
entity.setId(item.getId());
entity.setAvatar(userInfo.getHeadImgUrl());
entity.setWeiChatAvatar(userInfo.getHeadImgUrl());
clerkUserInfoService.updateById(entity);
return item.getId(); return item.getId();
} }
} }
private String generateAvatar(String imageUrl) {
InputStream inputStream = HttpRequest.get(imageUrl).execute().bodyStream();
String fileAddress = ossFileService.upload(inputStream, SecurityUtils.getTenantId(),
"image");
return fileAddress;
}
public void clerkUserLogout(PlayClerkUserInfoEntity entity) { public void clerkUserLogout(PlayClerkUserInfoEntity entity) {
entity.setToken("empty"); entity.setToken("empty");
clerkUserInfoService.update(entity); clerkUserInfoService.update(entity);
@@ -110,8 +118,7 @@ public class WxOauthService {
/** /**
* 获取微信授权Token * 获取微信授权Token
* *
* @param code * @param code code
* code
* @return WxOAuth2AccessToken * @return WxOAuth2AccessToken
* @author admin * @author admin
* @since 2024/4/8 14:47 * @since 2024/4/8 14:47
@@ -132,8 +139,7 @@ public class WxOauthService {
/** /**
* 获取微信用户ID * 获取微信用户ID
* *
* @param token * @param token code
* code
* @return WxOAuth2AccessToken * @return WxOAuth2AccessToken
* @author admin * @author admin
* @since 2024/4/8 14:47 * @since 2024/4/8 14:47
@@ -152,8 +158,7 @@ public class WxOauthService {
/** /**
* 获取微信用户ID * 获取微信用户ID
* *
* @param token * @param token WxOAuth2AccessToken
* WxOAuth2AccessToken
* @return WxOAuth2UserInfo * @return WxOAuth2UserInfo
* @author admin * @author admin
* @since 2024/4/8 14:47 * @since 2024/4/8 14:47

View File

@@ -16,10 +16,9 @@ spring:
# druid数据源配置 # druid数据源配置
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
# 配置MySQL的驱动程序类 driverClassName: com.mysql.cj.jdbc.Driver
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# 数据库连接地址(以MySql为例) # 数据库连接地址(以MySql为例)
url: jdbc:p6spy:mysql://122.51.20.105:3306/play-with?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true url: jdbc:mysql://122.51.20.105:3306/play-with?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
# 数据库对应的用户名 # 数据库对应的用户名
username: root username: root
# 数据库对应的密码 # 数据库对应的密码

View File

@@ -21,6 +21,8 @@ mybatis-plus:
logic-not-delete-value: 0 logic-not-delete-value: 0
# xml文件路径classpath* 代表所有模块的resources目录 classpath 不加星号代表当前模块下的resources目录 # xml文件路径classpath* 代表所有模块的resources目录 classpath 不加星号代表当前模块下的resources目录
mapper-locations: classpath*:mapper/**/*.xml mapper-locations: classpath*:mapper/**/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
wx: wx:
mp: mp:

View File

@@ -2,7 +2,7 @@
<contextName>logback</contextName> <contextName>logback</contextName>
<!-- name的值是变量的名称value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后可以使“${}”来使用变量。 --> <!-- name的值是变量的名称value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后可以使“${}”来使用变量。 -->
<property name="log.path" value="./log"/> <property name="log.path" value="./logs"/>
<property name="version" value="1.0"/> <property name="version" value="1.0"/>
<!-- 彩色日志 --> <!-- 彩色日志 -->
@@ -12,9 +12,9 @@
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx" <conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/> converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 - 包含关联ID --> <!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" <property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr([%X{correlationId:--}]){yellow} %clr([%X{tenantKey:--}]){blue} %clr([%X{userId:--}]){green} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--输出到控制台--> <!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
@@ -32,15 +32,15 @@
<!-- detail info 文件保存 --> <!-- detail info 文件保存 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/detail.log</file> <file>${log.path}/detail.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/detail/detail-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${log.path}/detail/detail-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <!-- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
<maxFileSize>100MB</maxFileSize> <maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy> <!-- </timeBasedFileNamingAndTriggeringPolicy>-->
<maxHistory>7</maxHistory> <maxHistory>7</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{MM/dd/yyyy HH:mm:ss} %-5level [%thread] [%X{correlationId:--}] [%X{tenantKey:--}] [%X{userId:--}] %logger{16} - %msg%n</pattern> <pattern>%d{MM/dd/yyyy HH:mm:ss} %-5level [%thread]%logger{16} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 --> <charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder> </encoder>
</appender> </appender>
@@ -51,15 +51,15 @@
<file>${log.path}/error.log</file> <file>${log.path}/error.log</file>
<!--日志文件输出格式--> <!--日志文件输出格式-->
<encoder> <encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{correlationId:--}] [%X{tenantKey:--}] [%X{userId:--}] %-5level %logger{50} - %msg%n</pattern> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 --> <charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder> </encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <fileNamePattern>${log.path}/error/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <!-- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
<maxFileSize>100MB</maxFileSize> <maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy> <!-- </timeBasedFileNamingAndTriggeringPolicy>-->
<!--日志文件保留天数--> <!--日志文件保留天数-->
<maxHistory>10</maxHistory> <maxHistory>10</maxHistory>
</rollingPolicy> </rollingPolicy>
@@ -77,17 +77,6 @@
<appender-ref ref="ERROR_FILE"/> <appender-ref ref="ERROR_FILE"/>
</root> </root>
<!-- Set all application loggers to DEBUG --> <logger name="com.starry" level="info"/>
<logger name="com.starry" level="debug"/>
<logger name="com.ctrod" level="info"/>
<!-- Spring framework debug logging for requests -->
<logger name="org.springframework.web.servlet.DispatcherServlet" level="debug"/>
<logger name="org.springframework.security" level="debug"/>
<!-- Database query logging -->
<logger name="org.hibernate.SQL" level="debug"/>
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="trace"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
</configuration> </configuration>

View File

@@ -1,21 +0,0 @@
#3.2.1以上使用modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
# 自定义日志打印
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
#日志输出到控制台
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
# 使用日志系统记录 sql
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
# 设置 p6spy driver 代理
deregisterdrivers=true
# 取消JDBC URL前缀
useprefix=true
# 配置记录 Log 例外,可去掉的结果集error,info,batch,debug,statement,commit,rollback,result,resultset.
excludecategories=info,debug,result,commit,resultset
# 日期格式
dateformat=yyyy-MM-dd HH:mm:ss
# 实际驱动可多个
#driverlist=org.h2.Driver
# 是否开启慢SQL记录
outagedetection=true
# 慢SQL记录标准 2 秒
outagedetectioninterval=2

View File

@@ -101,10 +101,6 @@
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId> <artifactId>fastjson2</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.gavlyukovskiy</groupId>
<artifactId>p6spy-spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>