Browse Source

update:add task

yonge 3 năm trước cách đây
mục cha
commit
0d474a88c3

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/PlatformCashAccountRecordDao.java

@@ -19,6 +19,9 @@ import java.util.List;
 public interface PlatformCashAccountRecordDao extends BaseMapper<PlatformCashAccountRecord> {
 
     int insertBatch(@Param("entities") List<PlatformCashAccountRecord> entities);
+    
+    int batchUpdate(List<PlatformCashAccountRecord> list);
+    
 
     IPage<PlatformCashAccountRecord> queryPage(@Param("page") IPage<PlatformCashAccountRecord> page, @Param("param") PlatformCashAccountRecordSearch query);
 

+ 73 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PlatformCashAccountRecordServiceImpl.java

@@ -1,6 +1,18 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import java.util.ArrayList;
 import java.util.Date;
@@ -22,7 +34,10 @@ import com.yonge.cooleshow.biz.dal.entity.PlatformCashAccountRecord;
 import com.yonge.cooleshow.biz.dal.entity.SysConfig;
 import com.yonge.cooleshow.biz.dal.enums.AccountBizTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.PlatformCashAccountRecordService;
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.biz.dal.vo.PlatformCashAccountRecordSummaryVo;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
+import com.yonge.cooleshow.common.enums.PostStatusEnum;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,6 +62,9 @@ public class PlatformCashAccountRecordServiceImpl extends ServiceImpl<PlatformCa
     @Autowired
     private SysConfigService sysConfigService;
 
+    @Autowired
+    private SysConfigService sysConfigService;
+
     @Override
     public PlatformCashAccountRecordDao getDao() {
         return this.baseMapper;
@@ -65,11 +83,66 @@ public class PlatformCashAccountRecordServiceImpl extends ServiceImpl<PlatformCa
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public boolean updateWaitRecord() {
+
+		List<String> paramNames = new ArrayList<String>();
+		paramNames.add(SysConfigConstant.MALL_ACCOUNT_PERIOD);
+		paramNames.add(SysConfigConstant.MUSIC_ACCOUNT_PERIOD);
+		paramNames.add(SysConfigConstant.VIP_ACCOUNT_PERIOD);
+		paramNames.add(SysConfigConstant.VIDEO_ACCOUNT_PERIOD);
+		paramNames.add(SysConfigConstant.LIVE_ACCOUNT_PERIOD);
+		//paramNames.add(SysConfigConstant.PRACTICE_ACCOUNT_PERIOD);
+
+		List<SysConfig> sysConfigs = sysConfigService.findByParamName(paramNames);
+
+		Map<String,String> configMap = sysConfigs.stream().collect(Collectors.toMap(SysConfig :: getParamName, SysConfig :: getParamValue));
+
+		List<PlatformCashAccountRecord> list = new ArrayList<PlatformCashAccountRecord>();
 		//根据不同类型(业务类型:PRACTICE、陪练课 LIVE、直播课 VIDEO、视频课 MUSIC、乐谱)查询超过账期待结算的记录
 
 		//getDao().queryByBizTypeAndPaymentDays(bizType, paymentDays);
 
 		return false;
+		List<PlatformCashAccountRecord> list1 = getDao().queryByBizTypeAndPaymentDays(AccountBizTypeEnum.MALL_SHARE.getCode(), Integer.parseInt(configMap.get(SysConfigConstant.MALL_ACCOUNT_PERIOD).toString()));
+		List<PlatformCashAccountRecord> list2 = getDao().queryByBizTypeAndPaymentDays(AccountBizTypeEnum.MUSIC_SHARE.getCode(), Integer.parseInt(configMap.get(SysConfigConstant.MUSIC_ACCOUNT_PERIOD).toString()));
+		List<PlatformCashAccountRecord> list3 = getDao().queryByBizTypeAndPaymentDays(AccountBizTypeEnum.VIP_SHARE.getCode(), Integer.parseInt(configMap.get(SysConfigConstant.VIP_ACCOUNT_PERIOD).toString()));
+		List<PlatformCashAccountRecord> list4 = getDao().queryByBizTypeAndPaymentDays(AccountBizTypeEnum.VIDEO_SHARE.getCode(), Integer.parseInt(configMap.get(SysConfigConstant.VIDEO_ACCOUNT_PERIOD).toString()));
+		List<PlatformCashAccountRecord> list5 = getDao().queryByBizTypeAndPaymentDays(AccountBizTypeEnum.LIVE_SHARE.getCode(), Integer.parseInt(configMap.get(SysConfigConstant.LIVE_ACCOUNT_PERIOD).toString()));
+		//List<PlatformCashAccountRecord> list6 = getDao().queryByBizTypeAndPaymentDays(AccountBizTypeEnum.PRACTICE.getCode(), Integer.parseInt(configMap.get(SysConfigConstant.PRACTICE_ACCOUNT_PERIOD).toString()));
+
+		if(list1.size() > 0){
+			list.addAll(list1);
+		}
+		if(list2.size() > 0){
+			list.addAll(list2);
+		}
+		if(list3.size() > 0){
+			list.addAll(list3);
+		}
+		if(list4.size() > 0){
+			list.addAll(list4);
+		}
+		if(list5.size() > 0){
+			list.addAll(list5);
+		}
+
+		if(list.size() > 0){
+			Date date = new Date();
+			List<PlatformCashAccountRecord> batchUpdateList = new ArrayList<PlatformCashAccountRecord>();
+
+			for(PlatformCashAccountRecord pcar : list){
+				//预收改成实收
+				pcar.setPostStatus(PostStatusEnum.RECORDED);
+				pcar.setUpdateTime(date);
+				batchUpdateList.add(pcar);
+			}
+
+			if(batchUpdateList.size() > 0){
+				getDao().batchUpdate(batchUpdateList);
+			}
+		}
+
+
+		return true;
 	}
 
 	@Override

+ 42 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/PlatformCashAccountRecordMapper.xml

@@ -30,6 +30,47 @@
             #{entity.bizId}, #{entity.memo}, #{entity.orderNo}, #{entity.createTime}, #{entity.updateTime})
         </foreach>
     </insert>
+
+    <update id="batchUpdate">
+        <foreach collection="list" item="param" separator=";">
+            UPDATE platform_cash_account_record
+            <set>
+                <if test="param.accountId">
+    				account_id_ = #{param.accountId}
+	    		</if>
+                <if test="param.transAmount">
+    				trans_amount_ = #{param.transAmount}
+	    		</if>
+                <if test="param.memo">
+    				memo_ = #{param.memo}
+	    		</if>
+                <if test="param.orderNo">
+    				order_no_ = #{param.orderNo}
+	    		</if>
+	    		<if test="param.bizId">
+	    			biz_id_ = #{param.bizId}
+	    		</if>
+	    		<if test="param.inOrOut">
+	    			in_or_out_ = #{param.inOrOut}
+	    		</if>
+	    		<if test="param.bizType">
+	    			biz_type_ = #{param.bizType}
+	    		</if>
+	    		<if test="param.status">
+	    			post_status_ = #{param.status}
+	    		</if>
+	    		<if test="param.startDate">
+	    			update_time_ &gt;= #{param.startDate}
+	    		</if>
+	    		<if test="param.endDate">
+	    			update_time_ &lt;= #{param.endDate}
+	    		</if>
+                update_time_ = NOW()
+            </set>
+            WHERE
+            id_ = #{param.id}
+        </foreach>
+    </update>
     
     <select id="queryPage" resultType="com.yonge.cooleshow.biz.dal.entity.PlatformCashAccountRecord">
     	select * from platform_cash_account_record
@@ -91,7 +132,7 @@
     </select>
     
     <select id="queryByBizTypeAndPaymentDays" resultType="com.yonge.cooleshow.biz.dal.entity.PlatformCashAccountRecord">
-    	select * from platform_cash_account_record where biz_type_ = #{bizType} and TIMESTAMPDIFF(HOUR, create_time_, now()) &gt;= ${24 * paymentDays}
+    	select * from platform_cash_account_record where biz_type_ = #{bizType} and TIMESTAMPDIFF(HOUR, create_time_, now()) &gt;= ${24 * paymentDays} and post_status_ = 'WAIT'
     </select>
 
     <update id="batchUpdate">