姜永辉 il y a 1 an
Parent
commit
4491a757dd

+ 2 - 1
src/main/java/com/dk/oauth/mapper/integral/IntegralMapper.java

@@ -1,5 +1,6 @@
 package com.dk.oauth.mapper.integral;
 
+import com.dk.oauth.entity.Trade;
 import com.dk.oauth.model.pojo.integral.Integral;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.oauth.model.query.integral.IntegralQuery;
@@ -36,6 +37,6 @@ public interface IntegralMapper extends BaseMapper<Integral>{
      */
     Long countByCond(IntegralQuery integralQuery);
 
-
+    int updateById(Integral t);
 }
 

+ 6 - 0
src/main/java/com/dk/oauth/mapper/integral/IntegralMapper.xml

@@ -75,6 +75,12 @@
         <include refid="Condition"/>
     </select>
 
+    <!-- 更新数据-->
+    <update id="updateById">
+        update dkic_a.t_mst_integral tmi set integral = integral + #{integral}
+        where tmi.cp_id = #{cpId}
+    </update>
+
     <!-- 根据主键查询表dkic_a.t_mst_integral的一行数据 -->
     <select id="selectById" resultMap="BaseResultMapResponse">
         SELECT

+ 25 - 14
src/main/java/com/dk/oauth/service/integral/SignRecordService.java

@@ -21,9 +21,11 @@ import com.dk.oauth.mapper.integral.SignRecordMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.oauth.model.query.integral.IntegralItemQuery;
+import com.dk.oauth.model.query.integral.IntegralQuery;
 import com.dk.oauth.model.query.integral.IntegralTacticQuery;
 import com.dk.oauth.model.query.integral.SignRecordQuery;
 import com.dk.oauth.model.response.integral.IntegralItemResponse;
+import com.dk.oauth.model.response.integral.IntegralResponse;
 import com.dk.oauth.model.response.integral.IntegralTacticResponse;
 import com.dk.oauth.model.response.integral.SignRecordResponse;
 import org.springframework.stereotype.Service;
@@ -39,6 +41,11 @@ import java.util.List;
 public class SignRecordService extends BaseService<SignRecord> {
 
     @Override
+    public String getPrimaryKey() {
+        return "record_id";
+    }
+
+    @Override
     public BaseMapper<SignRecord> getRepository() {
         return signRecordMapper;
     }
@@ -93,7 +100,7 @@ public class SignRecordService extends BaseService<SignRecord> {
             signRecord.setLastDate(LocalDate.now());
             signRecordMapper.insert(signRecord);
             // 积分数据
-            this.insertIntegralData(integralTactic,signRecordVO,false);
+            this.insertIntegralData(integralTactic, signRecordVO, false);
         } else {
             // 签到表 包含数据
             SignRecordResponse signRecordResponse = signRecordResponses.get(0);
@@ -103,23 +110,24 @@ public class SignRecordService extends BaseService<SignRecord> {
                 return ResponseResultUtil.success(signRecordResponse.getLastDate());
             }
             // 连续昨天的
-            if (signRecordResponse.getLastDate().plusDays(1) == LocalDate.now()) {
+            if (LocalDate.now().compareTo(signRecordResponse.getLastDate().plusDays(1)) == 0) {
                 //判断是否超过15天
                 //签到数据更新
                 SignRecord signRecord = new SignRecord();
                 signRecord.setRecordId(signRecordResponse.getRecordId());
-                if(signRecordResponse.getSignDays() == 15){
+                if (signRecordResponse.getSignDays() == 15) {
                     signRecord.setSignDays(1);
-                }else{
+                } else {
                     signRecord.setSignDays(1 + signRecordResponse.getSignDays());
                 }
                 signRecord.setLastDate(LocalDate.now());
-                signRecordMapper.updateById(signRecord);
+                ResponseResultVO<Boolean> booleanResponseResultVO = super.updateByUuid(signRecord);
+
                 // 积分数据--连续15天签到积分
-                if(signRecordResponse.getSignDays() + 1 == 15) {
-                    this.insertIntegralData(integralTactic, signRecordVO, true);
-                }else{
+                if (signRecordResponse.getSignDays() + 1 == 15) {
                     this.insertIntegralData(integralTactic, signRecordVO, true);
+                } else {
+                    this.insertIntegralData(integralTactic, signRecordVO, false);
                 }
             } else {
                 //不连续 日期
@@ -128,9 +136,9 @@ public class SignRecordService extends BaseService<SignRecord> {
                 signRecord.setRecordId(signRecordResponse.getRecordId());
                 signRecord.setSignDays(1);
                 signRecord.setLastDate(LocalDate.now());
-                signRecordMapper.updateById(signRecord);
+                super.updateByUuid(signRecord);
                 // 积分数据
-                this.insertIntegralData(integralTactic,signRecordVO,false);
+                this.insertIntegralData(integralTactic, signRecordVO, false);
             }
         }
         return ResponseResultUtil.success();
@@ -161,13 +169,16 @@ public class SignRecordService extends BaseService<SignRecord> {
         Integral integral = new Integral();
         integral.setCpId(signRecordVO.getCpId());
         integral.setFlgValid(true);
-        List<Integral> integrals = integralMapper.selectByCond(integral);
-        if (integrals != null && integrals.size() > 0) {
+        IntegralQuery integralQuery = new IntegralQuery();
+        integralQuery.setCpId(signRecordVO.getCpId());
+        integralQuery.setFlgValid(true);
+        List<IntegralResponse> integralResponses = integralMapper.selectByCond(integralQuery);
+        if (integralResponses != null && integralResponses.size() > 0) {
             // 是否签到积分 15天签到积分
             if (!sign) {
-                integral.setIntegral(integralTactic.getSignIntegral() + integrals.get(0).getIntegral());
+                integral.setIntegral(integralTactic.getSignIntegral());
             } else {
-                integral.setIntegral(integralTactic.getFifteenIntegral() + integrals.get(0).getIntegral());
+                integral.setIntegral(integralTactic.getFifteenIntegral());
             }
             integralMapper.updateById(integral);
         } else {