|
@@ -3,6 +3,7 @@ package com.fs.his.strategy.impl;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.core.config.WxOpenProperties;
|
|
import com.fs.core.config.WxOpenProperties;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
import com.fs.course.config.CourseConfig;
|
|
@@ -15,23 +16,21 @@ import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.course.param.FsCourseSendRewardUParam;
|
|
import com.fs.course.param.FsCourseSendRewardUParam;
|
|
|
|
|
+import com.fs.his.domain.FsAppRewardCourseRedPacketLog;
|
|
|
import com.fs.his.domain.FsUser;
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.domain.FsUserRewards;
|
|
import com.fs.his.domain.FsUserRewards;
|
|
|
import com.fs.his.enums.ActivityTypeEnum;
|
|
import com.fs.his.enums.ActivityTypeEnum;
|
|
|
|
|
+import com.fs.his.mapper.FsAppRewardCourseRedPacketLogMapper;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
import com.fs.his.param.WxSendRedPacketParam;
|
|
import com.fs.his.param.WxSendRedPacketParam;
|
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
|
import com.fs.his.strategy.RewardResult;
|
|
import com.fs.his.strategy.RewardResult;
|
|
|
import com.fs.his.strategy.RewardStrategy;
|
|
import com.fs.his.strategy.RewardStrategy;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
-import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
-
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Component
|
|
@Component
|
|
|
public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
@@ -59,6 +58,9 @@ public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WxOpenProperties openProperties;
|
|
private WxOpenProperties openProperties;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsAppRewardCourseRedPacketLogMapper appRewardCourseRedPacketLogMapper;
|
|
|
@Override
|
|
@Override
|
|
|
public RewardResult process(FsUserRewards reward) {
|
|
public RewardResult process(FsUserRewards reward) {
|
|
|
log.info("处理首次登录红包发放: rewardId={}", reward.getId());
|
|
log.info("处理首次登录红包发放: rewardId={}", reward.getId());
|
|
@@ -72,29 +74,13 @@ public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
|
//调用发送红包接口逻辑
|
|
//调用发送红包接口逻辑
|
|
|
R sendRedPacket = fsStorePaymentService.sendRedPacketAppReward(param);
|
|
R sendRedPacket = fsStorePaymentService.sendRedPacketAppReward(param);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
|
- FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
|
|
- TransferBillsResult transferBillsResult;
|
|
|
|
|
- if (sendRedPacket.get("isNew").equals(1)){
|
|
|
|
|
- transferBillsResult = (TransferBillsResult)sendRedPacket.get("data");
|
|
|
|
|
- redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
|
|
|
|
|
- redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
|
|
- }else {
|
|
|
|
|
- redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
|
|
- redPacketLog.setBatchId(sendRedPacket.get("batchId").toString());
|
|
|
|
|
- }
|
|
|
|
|
- // 添加红包记录
|
|
|
|
|
- //redPacketLog.setCourseId(param.getCourseId());
|
|
|
|
|
- //redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
|
|
- redPacketLog.setUserId(reward.getFsUserId());
|
|
|
|
|
- //redPacketLog.setVideoId(reward.getVideoId()); 注册登录奖励无视频小节id
|
|
|
|
|
- redPacketLog.setStatus(0);
|
|
|
|
|
- redPacketLog.setCreateTime(new Date());
|
|
|
|
|
- redPacketLog.setAmount(reward.getRewardAmount());
|
|
|
|
|
- //redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
|
|
- //redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
|
|
- //redPacketLog.setAppId(param.getAppId());
|
|
|
|
|
-
|
|
|
|
|
- redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
|
+ FsAppRewardCourseRedPacketLog record=new FsAppRewardCourseRedPacketLog();
|
|
|
|
|
+ record.setUserId(fsUser.getUserId());
|
|
|
|
|
+ record.setActivityType(ActivityTypeEnum.FIRST_LOGIN.getCode());
|
|
|
|
|
+ record.setAmount(reward.getRewardAmount());
|
|
|
|
|
+ record.setVideoId(reward.getGoodsId());
|
|
|
|
|
+ record.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+ appRewardCourseRedPacketLogMapper.insert(record);
|
|
|
} else {
|
|
} else {
|
|
|
return RewardResult.fail("红包发放失败,请联系客服");
|
|
return RewardResult.fail("红包发放失败,请联系客服");
|
|
|
}
|
|
}
|