Procházet zdrojové kódy

Merge branch 'dev_recycle' into test

Mr.qian před 1 měsícem
rodič
revize
89a7b0c6b6

+ 17 - 35
cif-api/src/main/java/com/txz/cif/dto/EarningsDTO.java

@@ -1,59 +1,41 @@
 /*
-*
-* @date 2025-07-15
-*/
+ *
+ * @date 2025-07-15
+ */
 package com.txz.cif.dto;
 
+import lombok.Data;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
-import java.util.Date;
 
+@Data
 public class EarningsDTO implements Serializable {
-
+    
     /**
      * 订单号
      */
     private String orderNo;
-
-
+    
+    
     /**
      * 用户id
      */
     private Long userId;
-
+    
     /**
      * 收益金额
      */
     private BigDecimal earnings;
-
-
-
+    
+    /**
+     * 业务类型
+     */
+    private Integer bizType;
+    
     /**
      * c_red_envelope
      */
     private static final long serialVersionUID = 1L;
-
-    public String getOrderNo() {
-        return orderNo;
-    }
-
-    public void setOrderNo(String orderNo) {
-        this.orderNo = orderNo;
-    }
-
-    public Long getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Long userId) {
-        this.userId = userId;
-    }
-
-    public BigDecimal getEarnings() {
-        return earnings;
-    }
-
-    public void setEarnings(BigDecimal earnings) {
-        this.earnings = earnings;
-    }
+    
 }

+ 5 - 5
cif-api/src/main/java/com/txz/cif/service/RedEnvelopeDubboService.java

@@ -3,14 +3,14 @@ package com.txz.cif.service;
 
 import com.txz.cif.dto.EarningsDTO;
 import com.txz.cif.dto.OrderParam;
-import com.txz.cif.dto.Result;
-import com.txz.cif.dto.UserDTO;
 
 import java.util.List;
 
 public interface RedEnvelopeDubboService {
-
-
+    
+    
     List<EarningsDTO> getEarningsByOrders(List<OrderParam> params);
-
+    
+    List<EarningsDTO> getEarningsInfoByOrders(List<OrderParam> params);
+    
 }

+ 2 - 0
cif-service/src/main/java/com/txz/cif/dao/RedEnvelopeMapper.java

@@ -16,6 +16,8 @@ public interface RedEnvelopeMapper extends Mapper<RedEnvelope> {
     List<UserTopBo> top(HashMap<String, Object> map);
 
     List<EarningsDTO> sumWithOrderNo(String orderNo, Long userId);
+    
+    List<EarningsDTO> queryOrderNo(String orderNo, Long userId);
 
     BigDecimal sumByStatus(HashMap map);
 }

+ 1 - 1
cif-service/src/main/java/com/txz/cif/dubbo/impl/AccountDubboServiceImpl.java

@@ -236,7 +236,7 @@ public class AccountDubboServiceImpl implements AccountDubboService {
     public Result addRedEnvelope(SignRedEnvelopeParam param) {
         RedEnvelopeParam p = BeanUtil.toBean(param, RedEnvelopeParam.class);
         p.setUserIds(CollUtil.newArrayList(OrderParam.builder().userId(param.getUserId()).orderNo(param.getOrderNo()).build()));
-        if (param.getBizType() == BizTypeEnum.SIGN_RED_ENVELOPE || param.getBizType() == BizTypeEnum.PROMOTION_COMMISSION) {
+        if (param.getBizType() == BizTypeEnum.SIGN_RED_ENVELOPE || param.getBizType() == BizTypeEnum.PROMOTION_COMMISSION || param.getBizType() == BizTypeEnum.RECYCLE) {
             p.setBizType(param.getBizType().getKey());
         } else {
             return Result.genFailResult(LocalUtil.get("unsupported.type"));

+ 14 - 0
cif-service/src/main/java/com/txz/cif/dubbo/impl/RedEnvelopeDubboServiceImpl.java

@@ -36,4 +36,18 @@ public class RedEnvelopeDubboServiceImpl implements RedEnvelopeDubboService {
         }
         return ret;
     }
+    
+    @Override
+    public List<EarningsDTO> getEarningsInfoByOrders(List<OrderParam> params) {
+        List<EarningsDTO> ret = new ArrayList<>();
+        for (OrderParam param : params) {
+            List<EarningsDTO> dtos = redEnvelopeService.queryOrderNo(param.getOrderNo(), param.getUserId());
+            for (EarningsDTO dto : dtos) {
+                if (dto.getUserId().compareTo(param.getUserId()) == 0) {
+                    ret.add(dto);
+                }
+            }
+        }
+        return ret;
+    }
 }

+ 2 - 0
cif-service/src/main/java/com/txz/cif/service/RedEnvelopeService.java

@@ -31,6 +31,8 @@ public interface RedEnvelopeService extends Service<RedEnvelope> {
     List<UserTopBo> top(Integer type, Integer page, Integer size);
 
     List<EarningsDTO> sumWithOrderNo(String orderNo, Long userId);
+    
+    List<EarningsDTO> queryOrderNo(String orderNo, Long userId);
 
     void settle(RedEnvelope redEnvelope);
 

+ 7 - 0
cif-service/src/main/java/com/txz/cif/service/impl/RedEnvelopeServiceImpl.java

@@ -130,6 +130,11 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
         return cRedEnvelopeMapper.sumWithOrderNo(orderNo, userId);
     }
     
+    @Override
+    public List<EarningsDTO> queryOrderNo(String orderNo, Long userId) {
+        return cRedEnvelopeMapper.queryOrderNo(orderNo, userId);
+    }
+    
     @Override
     public void settle(RedEnvelope redEnvelope) {
         flowService.settle(redEnvelope);
@@ -290,6 +295,8 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
                 return NoticeEnum.REWARD_SECONDARY_COMMISSION;
             case 5006:
                 return NoticeEnum.REWARD_REFER_FRIENDS;
+            case 5007:
+                return NoticeEnum.ORDER_RECYCLE_REWARD;
         }
         return ret;
     }

+ 77 - 77
cif-service/src/main/resources/mapper/RedEnvelopeMapper.xml

@@ -1,86 +1,86 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.txz.cif.dao.RedEnvelopeMapper">
-  <resultMap id="BaseResultMap" type="com.txz.cif.model.RedEnvelope">
-    <!--
-      WARNING - @mbg.generated
-    -->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
-    <result column="tran_no" jdbcType="VARCHAR" property="tranNo" />
-    <result column="user_id" jdbcType="BIGINT" property="userId" />
-    <result column="amount" jdbcType="DECIMAL" property="amount" />
-    <result column="balance" jdbcType="DECIMAL" property="balance" />
-    <result column="debit_account" jdbcType="BIGINT" property="debitAccount" />
-    <result column="credit_account" jdbcType="BIGINT" property="creditAccount" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-    <result column="biz_type" jdbcType="INTEGER" property="bizType" />
-    <result column="trans_time" jdbcType="TIMESTAMP" property="transTime" />
-    <result column="settle_time" jdbcType="TIMESTAMP" property="settleTime" />
-    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
-    <result column="update_user" jdbcType="VARCHAR" property="updateUser" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="version" jdbcType="VARCHAR" property="version" />
+    <resultMap id="BaseResultMap" type="com.txz.cif.model.RedEnvelope">
+        <!--
+          WARNING - @mbg.generated
+        -->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
+        <result column="tran_no" jdbcType="VARCHAR" property="tranNo"/>
+        <result column="user_id" jdbcType="BIGINT" property="userId"/>
+        <result column="amount" jdbcType="DECIMAL" property="amount"/>
+        <result column="balance" jdbcType="DECIMAL" property="balance"/>
+        <result column="debit_account" jdbcType="BIGINT" property="debitAccount"/>
+        <result column="credit_account" jdbcType="BIGINT" property="creditAccount"/>
+        <result column="status" jdbcType="INTEGER" property="status"/>
+        <result column="biz_type" jdbcType="INTEGER" property="bizType"/>
+        <result column="trans_time" jdbcType="TIMESTAMP" property="transTime"/>
+        <result column="settle_time" jdbcType="TIMESTAMP" property="settleTime"/>
+        <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
+        <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="version" jdbcType="VARCHAR" property="version"/>
 
-    <result column="name" jdbcType="VARCHAR" property="name" />
-    <result column="phone_no" jdbcType="VARCHAR" property="phoneNo" />
-    <result column="memo" jdbcType="VARCHAR" property="memo" />
-  </resultMap>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="phone_no" jdbcType="VARCHAR" property="phoneNo"/>
+        <result column="memo" jdbcType="VARCHAR" property="memo"/>
+    </resultMap>
 
-  <select id="sumWithDay" resultType="java.math.BigDecimal">
-    SELECT SUM(amount) AS total_amount
-    FROM c_red_envelope
-    WHERE user_id=#{userId}
-    <if test="day != null">
-      and trans_time >= #{day}
-    </if>
-    <if test="type == 1">
-      and status = 1
-    </if>
-    <if test="type == 2">
-      and status = 2
-    </if>
-  </select>
+    <select id="sumWithDay" resultType="java.math.BigDecimal">
+        SELECT SUM(amount) AS total_amount
+        FROM c_red_envelope
+        WHERE user_id=#{userId}
+        <if test="day != null">
+            and trans_time >= #{day}
+        </if>
+        <if test="type == 1">
+            and status = 1
+        </if>
+        <if test="type == 2">
+            and status = 2
+        </if>
+    </select>
 
-  <select id="top" resultType="com.txz.cif.web.bo.UserTopBo">
-    SELECT
-    user_id as userId,
-    SUM(amount) AS l7DEarnings,
-    count(id) AS groupNum
-    FROM
-      c_red_envelope
-    WHERE
-    create_time >= #{startTime}
-    GROUP BY
-    user_id
-    ORDER BY
-    l7DEarnings DESC
-  </select>
+    <select id="top" resultType="com.txz.cif.web.bo.UserTopBo">
+        SELECT user_id AS userId, SUM(amount) AS l7DEarnings, COUNT(id) AS groupNum
+        FROM c_red_envelope
+        WHERE create_time >= #{startTime}
+        GROUP BY user_id
+        ORDER BY l7DEarnings DESC
+    </select>
 
-  <select id="sumWithOrderNo" resultType="com.txz.cif.dto.EarningsDTO">
-    SELECT SUM(amount) AS earnings, user_id as userId,order_no as orderNo
-    FROM c_red_envelope
-    WHERE order_no=#{orderNo} 
-    AND user_id = #{userId}
-    group by user_id
-  </select>
+    <select id="sumWithOrderNo" resultType="com.txz.cif.dto.EarningsDTO">
+        SELECT SUM(amount) AS earnings, user_id AS userId, order_no AS orderNo
+        FROM c_red_envelope
+        WHERE order_no = #{orderNo}
+            AND user_id = #{userId}
+        GROUP BY user_id
+    </select>
 
-  <select id="sumByStatus" resultType="java.math.BigDecimal">
-    SELECT SUM(amount)
-    FROM c_red_envelope
-    WHERE
-    1=1
-    <if test="status == 1">
-       and status = 1
-    </if>
-    <if test="status == 2">
-      and status = 2
-    </if>
-    <if test="bizType != null">
-      and biz_type = #{bizType}
-    </if>
-    and create_time >= #{startTime} and #{endTime} >=  create_time
-    and user_id = #{userId} <!-- 添加分片键确保查询正确路由 -->
-  </select>
+    <select id="queryOrderNo" resultType="com.txz.cif.dto.EarningsDTO">
+        SELECT amount AS earnings, user_id AS userId, order_no AS orderNo, biz_type AS bizType
+        FROM c_red_envelope
+        WHERE order_no = #{orderNo}
+            AND user_id = #{userId}
+    </select>
+
+    <select id="sumByStatus" resultType="java.math.BigDecimal">
+        SELECT SUM(amount)
+        FROM c_red_envelope
+        WHERE
+        1=1
+        <if test="status == 1">
+            and status = 1
+        </if>
+        <if test="status == 2">
+            and status = 2
+        </if>
+        <if test="bizType != null">
+            and biz_type = #{bizType}
+        </if>
+        and create_time >= #{startTime} and #{endTime} >= create_time
+        and user_id = #{userId} <!-- 添加分片键确保查询正确路由 -->
+    </select>
 </mapper>