Authored by LUOXC

refactor

@@ -8,18 +8,13 @@ import java.util.List; @@ -8,18 +8,13 @@ import java.util.List;
8 8
9 public interface InviteSettlementMapper { 9 public interface InviteSettlementMapper {
10 10
11 - int deleteByPrimaryKey(Integer id);  
12 11
13 int insert(InviteSettlement record); 12 int insert(InviteSettlement record);
14 13
15 - int insertSelective(InviteSettlement record);  
16 -  
17 - InviteSettlement selectByPrimaryKey(Integer id);  
18 -  
19 int updateByUidAndId(InviteSettlement record); 14 int updateByUidAndId(InviteSettlement record);
20 15
21 - List<InviteSettlement> selectForInviteSettlementList(  
22 - @Param("uid") Integer uid, @Param("status") Integer status, @Param("start")  
23 - Integer start, @Param("limit") Integer limit); 16 + List<InviteSettlement> selectByUidAndStatusWithLimit(
  17 + @Param("uid") Integer uid, @Param("status") Integer status,
  18 + @Param("start") Integer start, @Param("limit") Integer limit);
24 19
25 } 20 }
@@ -7,6 +7,8 @@ import java.math.BigDecimal; @@ -7,6 +7,8 @@ import java.math.BigDecimal;
7 @Data 7 @Data
8 public class InviteSettlement { 8 public class InviteSettlement {
9 9
  10 + public static final int STATUS_WAIT_SETTLE = 0;
  11 +
10 public static final int STATUS_WAIT_PAY = 1; 12 public static final int STATUS_WAIT_PAY = 1;
11 13
12 public static final int STATUS_PAID = 2; 14 public static final int STATUS_PAID = 2;
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 where id = #{id,jdbcType=INTEGER} and uid = #{uid,jdbcType=INTEGER} 36 where id = #{id,jdbcType=INTEGER} and uid = #{uid,jdbcType=INTEGER}
37 </update> 37 </update>
38 38
39 - <select id="selectForInviteSettlementList" resultMap="BaseResultMap" > 39 + <select id="selectByUidAndStatusWithLimit" resultMap="BaseResultMap" >
40 select 40 select
41 <include refid="Base_Column_List" /> 41 <include refid="Base_Column_List" />
42 from invite_settlement 42 from invite_settlement
@@ -41,7 +41,7 @@ public class InviterServiceImpl implements InviterService { @@ -41,7 +41,7 @@ public class InviterServiceImpl implements InviterService {
41 public InviteSettlementListVO getInviteSettlementList(Integer uid) { 41 public InviteSettlementListVO getInviteSettlementList(Integer uid) {
42 42
43 // build bo 43 // build bo
44 - List<InviteSettlement> inviteSettlementList = inviteSettlementMapper.selectForInviteSettlementList(uid, InviteSettlement.STATUS_PAID, 0, 100); 44 + List<InviteSettlement> inviteSettlementList = inviteSettlementMapper.selectByUidAndStatusWithLimit(uid, InviteSettlement.STATUS_PAID, 0, 100);
45 45
46 // build vo 46 // build vo
47 ZoneOffset zoneOffset = ZoneOffset.of("+8"); 47 ZoneOffset zoneOffset = ZoneOffset.of("+8");
@@ -47,8 +47,8 @@ public class InviterSettleService { @@ -47,8 +47,8 @@ public class InviterSettleService {
47 settlement.setUid(uid); 47 settlement.setUid(uid);
48 settlement.setCreateTime(now); 48 settlement.setCreateTime(now);
49 settlement.setSettleAmount(BigDecimal.ZERO); 49 settlement.setSettleAmount(BigDecimal.ZERO);
50 - settlement.setSettleTime(now);  
51 - settlement.setStatus(InviteSettlement.STATUS_WAIT_PAY); 50 + settlement.setSettleTime(0);
  51 + settlement.setStatus(InviteSettlement.STATUS_WAIT_SETTLE);
52 inviteSettlementMapper.insert(settlement); 52 inviteSettlementMapper.insert(settlement);
53 // 计算结算金额 53 // 计算结算金额
54 try { 54 try {
@@ -78,6 +78,8 @@ public class InviterSettleService { @@ -78,6 +78,8 @@ public class InviterSettleService {
78 uid, settlementId, settleAmountOfType2); 78 uid, settlementId, settleAmountOfType2);
79 // 更新结算金额 79 // 更新结算金额
80 settlement.setSettleAmount(settleAmountOfType1.add(settleAmountOfType2)); 80 settlement.setSettleAmount(settleAmountOfType1.add(settleAmountOfType2));
  81 + settlement.setSettleTime(DateUtil.getCurrentTimeSecond());
  82 + settlement.setStatus(InviteSettlement.STATUS_WAIT_PAY);
81 inviteSettlementMapper.updateByUidAndId(settlement); 83 inviteSettlementMapper.updateByUidAndId(settlement);
82 } 84 }
83 85