分账小改动,订单列表优化速度

This commit is contained in:
Jerry Yan 2025-02-21 17:09:14 +08:00
parent b51b3260c7
commit 1c6e3e3cd3
6 changed files with 39 additions and 8 deletions

View File

@ -236,7 +236,7 @@ public class OrderBiz {
} }
}); });
orderRepository.clearOrderCache(orderId); // 更新完了清理下 orderRepository.clearOrderCache(orderId); // 更新完了清理下
profitSharingBiz.revokeProfitSharing(order.getScenicId(), orderId); profitSharingBiz.revokeProfitSharing(order.getScenicId(), orderId, "订单被取消");
} }
public void refundOrder(Long orderId) { public void refundOrder(Long orderId) {
@ -258,6 +258,6 @@ public class OrderBiz {
} }
}); });
orderRepository.clearOrderCache(orderId); // 更新完了清理下 orderRepository.clearOrderCache(orderId); // 更新完了清理下
profitSharingBiz.revokeProfitSharing(order.getScenicId(), orderId); profitSharingBiz.revokeProfitSharing(order.getScenicId(), orderId, "订单已退款");
} }
} }

View File

@ -143,7 +143,7 @@ public class ProfitSharingBiz {
BigDecimal manualAmount; BigDecimal manualAmount;
if (user.getRateMode() == 0) { // 剩余比例 if (user.getRateMode() == 0) { // 剩余比例
userAmount = mode0RemainAmount.divide(BigDecimal.valueOf(mode0User.size()), 2, RoundingMode.HALF_DOWN); userAmount = mode0RemainAmount.divide(BigDecimal.valueOf(mode0User.size()), 2, RoundingMode.HALF_DOWN);
wxAmount = mode0RemainAmount.divide(BigDecimal.valueOf(mode0User.size()), 2, RoundingMode.HALF_DOWN); wxAmount = BigDecimal.ZERO;
manualAmount = userAmount.subtract(wxAmount); manualAmount = userAmount.subtract(wxAmount);
} else { } else {
return; return;
@ -207,7 +207,7 @@ public class ProfitSharingBiz {
recordMapper.batchInsert(records); recordMapper.batchInsert(records);
} }
public void revokeProfitSharing(Long scenicId, Long orderId) { public void revokeProfitSharing(Long scenicId, Long orderId, String revokeReason) {
recordMapper.deleteByScenicIdAndOrderId(scenicId, orderId); recordMapper.deleteByScenicIdAndOrderId(scenicId, orderId, revokeReason);
} }
} }

View File

@ -18,4 +18,5 @@ public class ProfitSharingRecordReqQuery extends BaseQueryParameterReq {
private Date startTime; private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime; private Date endTime;
private boolean withDeleted = false;
} }

View File

@ -15,6 +15,5 @@ public interface ProfitSharingRecordMapper {
void batchInsert(List<ProfitSharingRecord> records); void batchInsert(List<ProfitSharingRecord> records);
@Delete("DELETE FROM profit_sharing_record WHERE scenic_id = #{scenicId} AND order_id = #{orderId}") void deleteByScenicIdAndOrderId(Long scenicId, Long orderId, String reason);
void deleteByScenicIdAndOrderId(Long scenicId, Long orderId);
} }

View File

@ -1,6 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ycwl.basic.mapper.OrderMapper"> <mapper namespace="com.ycwl.basic.mapper.OrderMapper">
<resultMap id="PCBaseResultListMap" type="com.ycwl.basic.model.pc.order.resp.OrderRespVO">
<id column="id" property="id"/>
<result column="scenic_id" property="scenicId"/>
<result column="scenic_name" property="scenicName"/>
<result column="member_id" property="memberId"/>
<result column="nickname" property="memberNickname"/>
<result column="real_name" property="memberRealName"/>
<result column="openid" property="openId"/>
<result column="price" property="price"/>
<result column="slash_price" property="slashPrice"/>
<result column="pay_price" property="payPrice"/>
<result column="remark" property="remark"/>
<result column="broker_id" property="brokerId"/>
<result column="promo_code" property="promoCode"/>
<result column="refund_reason" property="refundReason"/>
<result column="refund_status" property="refundStatus"/>
<result column="status" property="status"/>
<result column="refund_at" property="refundAt"/>
<result column="pay_at" property="payAt"/>
<result column="cancel_at" property="cancelAt"/>
<result column="create_at" property="createAt"/>
<result column="update_at" property="updateAt"/>
</resultMap>
<resultMap id="PCBaseResultMap" type="com.ycwl.basic.model.pc.order.resp.OrderRespVO"> <resultMap id="PCBaseResultMap" type="com.ycwl.basic.model.pc.order.resp.OrderRespVO">
<id column="id" property="id"/> <id column="id" property="id"/>
<result column="scenic_id" property="scenicId"/> <result column="scenic_id" property="scenicId"/>
@ -193,7 +216,7 @@
<delete id="deleteById"> <delete id="deleteById">
delete from `order` where id = #{id} delete from `order` where id = #{id}
</delete> </delete>
<select id="list" resultMap="PCBaseResultMap"> <select id="list" resultMap="PCBaseResultListMap">
select distinct o.id, o.scenic_id, s.name as scenic_name, o.member_id,m.nickname ,m.real_name , o.openid, o.price, pay_price, remark, o.broker_id, o.promo_code, select distinct o.id, o.scenic_id, s.name as scenic_name, o.member_id,m.nickname ,m.real_name , o.openid, o.price, pay_price, remark, o.broker_id, o.promo_code,
refund_reason, refund_status, o.`status`, refund_at, pay_at, cancel_at,oi.id oiId, oi.goods_id, o.create_at refund_reason, refund_status, o.`status`, refund_at, pay_at, cancel_at,oi.id oiId, oi.goods_id, o.create_at
from `order` AS o from `order` AS o

View File

@ -8,11 +8,19 @@
(#{record.scenicId}, #{record.orderId}, #{record.userId}, #{record.userName}, #{record.amount}, #{record.wxAmount}, #{record.manualAmount}, #{record.rateMode}, #{record.wxRate}, #{record.realRate}, #{record.orderAmount}, #{record.createTime}) (#{record.scenicId}, #{record.orderId}, #{record.userId}, #{record.userName}, #{record.amount}, #{record.wxAmount}, #{record.manualAmount}, #{record.rateMode}, #{record.wxRate}, #{record.realRate}, #{record.orderAmount}, #{record.createTime})
</foreach> </foreach>
</insert> </insert>
<update id="deleteByScenicIdAndOrderId">
UPDATE profit_sharing_record
SET delete_time = now(), delete_reason = #{reason}
WHERE scenic_id = #{scenicId} AND order_id = #{orderId}
</update>
<select id="list" resultType="com.ycwl.basic.profitsharing.dto.ProfitSharingRecordRespVO"> <select id="list" resultType="com.ycwl.basic.profitsharing.dto.ProfitSharingRecordRespVO">
SELECT r.*, s.name as scenic_name SELECT r.*, s.name as scenic_name
FROM profit_sharing_record r FROM profit_sharing_record r
LEFT JOIN scenic s ON s.id = r.scenic_id LEFT JOIN scenic s ON s.id = r.scenic_id
<where> <where>
<if test="withDeleted != true">
delete_time is null
</if>
<if test="scenicId != null"> <if test="scenicId != null">
AND r.scenic_id = #{scenicId} AND r.scenic_id = #{scenicId}
</if> </if>