fanli/src/main/java/com/yeshi/fanli/dao/dynamic/DynamicInfoDao.java
@@ -123,20 +123,24 @@ * @return */ public void removeByDate(Date createTime) { LogHelper.test("removeByDate--开始执行动态删除---"); for(int i = 0; i < 20; i++) { Query query = new Query(); query.addCriteria(Criteria.where("createTime").lt(createTime)); query.skip(0).limit(100); LogHelper.test("removeByDate--查询---"); List<DynamicInfo> list = mongoTemplate.find(query, DynamicInfo.class); if (list == null || list.size() == 0) { break; } LogHelper.test("removeByDate--for删除---" + list.size()); for (DynamicInfo info: list) { mongoTemplate.remove(info); } } LogHelper.test("removeByDate--结束动态删除---"); } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinReportMapper.java
@@ -17,4 +17,10 @@ * @return */ List<UserTaoLiJinReport> needUpdateReport(); /** * 退回未领取的淘礼金 * @return */ List<UserTaoLiJinReport> refundNotWin(); } fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinReport.java
@@ -55,6 +55,9 @@ private Date updateTime; private Integer totalNum; // 总个数 private BigDecimal preFace; // 单个金额 public String getId() { return id; @@ -160,4 +163,19 @@ this.updateTime = updateTime; } public Integer getTotalNum() { return totalNum; } public void setTotalNum(Integer totalNum) { this.totalNum = totalNum; } public BigDecimal getPreFace() { return preFace; } public void setPreFace(BigDecimal preFace) { this.preFace = preFace; } } fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
@@ -149,7 +149,7 @@ /** * 每天零点删除3天之前数据 */ @Scheduled(cron = "0 0 0,10 * * ?") @Scheduled(cron = "0 0 1,10 * * ?") public void remove() { if (!Constant.IS_TASK) { @@ -157,7 +157,7 @@ } try { LogHelper.test("开始执行态删除"); LogHelper.test("DynamicInfoJob-remove-开始执行态"); dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date())); } catch (Exception e) { try { fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -21,7 +21,7 @@ /** * 更新报告 */ @Scheduled(cron = "0 0 0,10 * * ?") @Scheduled(cron = "0 0 1,10 * * ?") public void insetDynamicInfo() { if (!Constant.IS_TASK) { @@ -31,14 +31,25 @@ try { userTaoLiJinReportService.needUpdateReport(); } catch (Exception e) { try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } } } /** * 退回超过3天无领取的淘礼金 */ @Scheduled(cron = "0 0 1 * * ?") public void refundNotWin() { if (!Constant.IS_TASK) { return; } try { userTaoLiJinReportService.refundNotWin(); } catch (Exception e) { LogHelper.errorDetailInfo(e); } } } fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinRecordMapper.xml
@@ -60,7 +60,7 @@ LIMIT 1 </select> <select id="getByRightsId" resultMap="ResultVOMap"> <select id="getByRightsId" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_user_taolijin_record` d WHERE d.`utlj_rights_id` =#{rightsId} LIMIT 1 fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinReportMapper.xml
@@ -16,6 +16,10 @@ <result column="utr_pre_commission_amount" property="preCommissionAmount" jdbcType="DECIMAL"/> <result column="utr_create_time" property="createTime" jdbcType="TIMESTAMP"/> <result column="utr_update_time" property="updateTime" jdbcType="TIMESTAMP"/> <result column="totalNum" property="totalNum" jdbcType="INTEGER"/> <result column="preFace" property="preFace" jdbcType="DECIMAL"/> </resultMap> <sql id="Base_Column_List">utr_id,utr_unfreeze_amount,utr_unfreeze_num,utr_refund_amount,utr_refund_num,utr_alipay_amount,utr_use_amount,utr_use_num,utr_win_amount,utr_win_num,utr_pre_commission_amount,utr_create_time,utr_update_time</sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select @@ -75,7 +79,15 @@ <select id="needUpdateReport" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_user_taolijin_report t WHERE DATE_SUB(CURDATE(), INTERVAL 3 DAY) <![CDATA[<=]]>DATE(t.`utr_create_time`) WHERE DATE_SUB(CURDATE(), INTERVAL 2 DAY) <![CDATA[<=]]>DATE(t.`utr_create_time`) </select> <select id="refundNotWin" resultMap="BaseResultMap"> SELECT t.*,d.`utlj_total_num` AS totalNum,d.`utlj_per_face` AS preFace FROM `yeshi_ec_user_taolijin_report` t LEFT JOIN `yeshi_ec_user_taolijin_record` d ON t.`utr_id` = d.`utlj_rights_id` WHERE t.`utr_win_num` = 0 AND t.`utr_win_amount` = 0 AND t.`utr_refund_num` = 0 AND DATE_SUB(CURDATE(), INTERVAL 2 DAY) <![CDATA[>]]> DATE(t.`utr_create_time`) </select> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinDetailServiceImpl.java
@@ -210,8 +210,8 @@ // 红包退回 if (taoLiJinOrigin.getOrigin().equals(TaoLiJinOriginEnum.refund)) { detail.setType(TaoLiJinDetailTypeEnum.reduce); detail.setTitle(TaoLiJinDetailTypeEnum.reduce.getDesc()); detail.setType(TaoLiJinDetailTypeEnum.refund); detail.setTitle(TaoLiJinDetailTypeEnum.refund.getDesc()); } else { detail.setType(TaoLiJinDetailTypeEnum.add); detail.setTitle(TaoLiJinDetailTypeEnum.add.getDesc()); fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java
@@ -372,6 +372,7 @@ // 红包明细 userTaoLiJinDetailService.createAddDetail(taoLiJinOrigin); // 消息 executor.execute(new Runnable() { @Override fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinReportServiceImpl.java
@@ -14,6 +14,7 @@ import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @@ -134,4 +135,38 @@ } } @Override public void refundNotWin() { List<UserTaoLiJinReport> list = userTaoLiJinReportMapper.refundNotWin(); if (list == null || list.size() == 0) { return; } for (UserTaoLiJinReport report: list) { // 总个数 Integer totalNum = report.getTotalNum(); BigDecimal preFace = report.getPreFace(); // 总金额 BigDecimal money = MoneyBigDecimalUtil.mul(new BigDecimal(totalNum), preFace); report.setRefundNum(totalNum); report.setRefundAmount(money); report.setUpdateTime(new Date()); try { // 退回淘礼金 userTaoLiJinOriginService.refundMoney(report); } catch (UserTaoLiJinOriginException e) { LogHelper.errorDetailInfo(e); continue; } // 更新报告 userTaoLiJinReportMapper.updateByPrimaryKeySelective(report); } } } fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinReportService.java
@@ -22,4 +22,9 @@ */ public void needUpdateReport(); /** * 超过3天的未领取 退回金额 */ public void refundNotWin(); }