Przeglądaj źródła

提现失败自动补偿一次

wujiefeng 9 miesięcy temu
rodzic
commit
f2eb495f42

+ 17 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/param/TestSettleParam.java

@@ -0,0 +1,17 @@
+package com.zhongshu.reward.client.model.param;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/17
+ */
+@Data
+public class TestSettleParam {
+
+    private List<String> idList;
+
+    private List<String> vipRecordIdList;
+}

+ 56 - 17
RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/TestController.java

@@ -1,11 +1,16 @@
 package com.zhongshu.reward.server.core.controller;
 
+import com.zhongshu.reward.client.model.param.TestSettleParam;
 import com.zhongshu.reward.client.ret.ResultContent;
+import com.zhongshu.reward.server.core.dao.VipUserRecordDao;
+import com.zhongshu.reward.server.core.dao.WalletReceiptsDao;
 import com.zhongshu.reward.server.core.domain.VipUserRecord;
+import com.zhongshu.reward.server.core.domain.WalletReceipts;
 import com.zhongshu.reward.server.core.service.Impl.InviteRecordFeignServiceImpl;
 import com.zhongshu.reward.server.core.service.WalletReceiptsService;
 import com.zhongshu.reward.server.core.util.DateUtils;
 import com.zhongshu.vip.client.model.param.VipUserParam;
+import com.zswl.cloud.bdb.client.vo.InviteReceiptsRoleVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -18,6 +23,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.time.LocalDate;
 import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
 
 /**
  * @author wjf
@@ -35,27 +42,59 @@ public class TestController {
     @Autowired
     InviteRecordFeignServiceImpl inviteRecordFeignService;
 
-    @ApiOperation("会员消息")
-    @PostMapping("vipUser")
-    public Object vipUser(@RequestBody VipUserParam param){
-        VipUserRecord vipUserRecord = new VipUserRecord();
-        BeanUtils.copyProperties(param, vipUserRecord, "createTime");
-        vipUserRecord.setOperateTime(DateUtils.timeToLong(param.getCreateTime(), DateUtils.FORMAT_LONG));
-        walletReceiptsService.receipts(vipUserRecord);
-        return ResultContent.buildSuccess();
-    }
+    @Autowired
+    WalletReceiptsDao walletReceiptsDao;
+
+    @Autowired
+    VipUserRecordDao vipUserRecordDao;
+
+//    @ApiOperation("会员消息")
+//    @PostMapping("vipUser")
+//    public Object vipUser(@RequestBody VipUserParam param){
+//        VipUserRecord vipUserRecord = new VipUserRecord();
+//        BeanUtils.copyProperties(param, vipUserRecord, "createTime");
+//        vipUserRecord.setOperateTime(DateUtils.timeToLong(param.getCreateTime(), DateUtils.FORMAT_LONG));
+//        walletReceiptsService.receipts(vipUserRecord);
+//        return ResultContent.buildSuccess();
+//    }
 
     @ApiOperation("结算奖励")
     @PostMapping("settle")
-    public Object settle(Integer day){
-        walletReceiptsService.settle(day);
-        return ResultContent.buildSuccess();
-    }
+    public Object settle(@RequestBody TestSettleParam param){
+        Date date = new Date();
+        if (param.getIdList()!=null && !param.getIdList().isEmpty()){
+            Iterable<WalletReceipts> allById = walletReceiptsDao.findAllById(param.getIdList());
+            allById.forEach(it->{
+                it.setCreateTime(DateUtils.last(it.getCreateTime()));
+                it.setEstimatedTime(DateUtils.last(it.getEstimatedTime()));
+                VipUserRecord vipUserRecord = it.getVipUserRecord();
+                vipUserRecord.setOperateTime(DateUtils.last(vipUserRecord.getOperateTime()));
+                it.setVipUserRecord(vipUserRecord);
+                InviteReceiptsRoleVo ruler = it.getRuler();
+                ruler.setDay(Integer.parseInt(String.format("%tm", date)));
+                it.setRuler(ruler);
+            });
+            walletReceiptsDao.saveAll(allById);
+        }
+
 
-    @ApiOperation("生成持续订购返利")
-    @PostMapping("autoReceipts")
-    public Object autoReceipts(){
-        walletReceiptsService.autoReceipts();
+        if (param.getVipRecordIdList()!=null && !param.getVipRecordIdList().isEmpty()){
+            Iterable<VipUserRecord> vipRecordList = vipUserRecordDao.findAllById(param.getVipRecordIdList());
+            vipRecordList.forEach(it->{
+                it.setOperateTime(DateUtils.last(it.getOperateTime()));
+                it.setCreateTime(DateUtils.last(it.getCreateTime()));
+            });
+            vipUserRecordDao.saveAll(vipRecordList);
+        }
+
+        walletReceiptsService.settle(Integer.parseInt(String.format("%td", date)));
         return ResultContent.buildSuccess();
     }
+
+//    @ApiOperation("生成持续订购返利")
+//    @PostMapping("autoReceipts")
+//    public Object autoReceipts(){
+//        walletReceiptsService.autoReceipts();
+//        return ResultContent.buildSuccess();
+//    }
 }

+ 29 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/util/DateUtils.java

@@ -34,6 +34,33 @@ public class DateUtils {
         }
         return null;
     }
+
+    /**
+     * 获取上月指定日期时间
+     */
+    public static Long last(Long time){
+        Date date = new Date(time);
+        String year = String.format("%tY", date);
+        String day = String.format("%td", date);
+        String month = String.format("%tm", date);
+        String hour = String.format("%tH", date);
+        String m = String.format("%tM", date);
+        String s = String.format("%tS", date);
+        int yearInt = Integer.parseInt(year);
+        int monthInt = Integer.parseInt(month);
+        int dayInt = Integer.parseInt(day);
+        int hourInt = Integer.parseInt(hour);
+        int mInt = Integer.parseInt(m);
+        int sInt = Integer.parseInt(s);
+
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(yearInt, monthInt-2, dayInt, hourInt, mInt, sInt);
+//        calendar.set(Calendar.MONTH, Integer.getInteger(month)-1);
+        return calendar.getTimeInMillis();
+    }
+
+
     /**
      * 判断当日是否当月最后一天
      */
@@ -276,6 +303,8 @@ public class DateUtils {
     public static void main(String[] args) {
         Long hourMinuteStartTime = getHourMinuteStartTime(23, 0);
 
+        log.info(paresTime(last(1723898160215L), FORMAT_LONG));
+
         log.info(paresTime(getDayOfMonthStartTime(28), FORMAT_LONG));
         log.info(paresTime( getDayOfMonthEndTime(30), FORMAT_LONG));
 //        log.info(paresTime(getDayOfMonthStartTime(2), FORMAT_LONG));