|
@@ -1,21 +1,9 @@
|
|
|
package com.fs.his.strategy.impl;
|
|
package com.fs.his.strategy.impl;
|
|
|
|
|
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
|
|
-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.DateUtils;
|
|
|
-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.domain.FsCourseAnswerLogs;
|
|
|
|
|
-import com.fs.course.domain.FsCourseRedPacketLog;
|
|
|
|
|
-import com.fs.course.domain.FsCourseWatchLog;
|
|
|
|
|
-import com.fs.course.domain.FsUserCourseVideo;
|
|
|
|
|
-import com.fs.course.mapper.FsCourseAnswerLogsMapper;
|
|
|
|
|
-import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
|
|
-import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
|
|
-import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
|
|
-import com.fs.course.param.FsCourseSendRewardUParam;
|
|
|
|
|
import com.fs.his.domain.FsAppRewardCourseRedPacketLog;
|
|
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;
|
|
@@ -26,11 +14,13 @@ 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.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;
|
|
|
|
|
+
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Component
|
|
@Component
|
|
|
public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
@@ -40,22 +30,6 @@ public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStorePaymentService fsStorePaymentService;
|
|
private IFsStorePaymentService fsStorePaymentService;
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private FsCourseWatchLogMapper courseWatchLogMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private FsCourseAnswerLogsMapper courseAnswerLogsMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private FsCourseRedPacketLogMapper redPacketLogMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private FsUserCourseVideoMapper fsUserCourseVideoMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private ISysConfigService configService;
|
|
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WxOpenProperties openProperties;
|
|
private WxOpenProperties openProperties;
|
|
|
|
|
|
|
@@ -73,76 +47,45 @@ public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
|
WxSendRedPacketParam param=buildRedPacketParam(reward, fsUser);
|
|
WxSendRedPacketParam param=buildRedPacketParam(reward, fsUser);
|
|
|
//调用发送红包接口逻辑
|
|
//调用发送红包接口逻辑
|
|
|
R sendRedPacket = fsStorePaymentService.sendRedPacketAppReward(param);
|
|
R sendRedPacket = fsStorePaymentService.sendRedPacketAppReward(param);
|
|
|
|
|
+
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
|
FsAppRewardCourseRedPacketLog record=new FsAppRewardCourseRedPacketLog();
|
|
FsAppRewardCourseRedPacketLog record=new FsAppRewardCourseRedPacketLog();
|
|
|
|
|
+ TransferBillsResult transferBillsResult;
|
|
|
|
|
+ if (sendRedPacket.get("isNew").equals(1)) {
|
|
|
|
|
+ transferBillsResult = (TransferBillsResult) sendRedPacket.get("data");
|
|
|
|
|
+ record.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
|
|
+ record.setBatchId(transferBillsResult.getTransferBillNo());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ record.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
|
|
+ record.setBatchId(sendRedPacket.get("batchId").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ record.setUpdateTime(new Date());
|
|
|
|
|
+ Object aPackage = sendRedPacket.get("package");
|
|
|
|
|
+ if (aPackage != null) {
|
|
|
|
|
+ record.setPackageInfo(aPackage.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ Object mchIdObj = sendRedPacket.get("mchId");
|
|
|
|
|
+ if (mchIdObj != null) {
|
|
|
|
|
+ record.setMchId(mchIdObj.toString());
|
|
|
|
|
+ }
|
|
|
record.setUserId(fsUser.getUserId());
|
|
record.setUserId(fsUser.getUserId());
|
|
|
record.setActivityType(ActivityTypeEnum.FIRST_LOGIN.getCode());
|
|
record.setActivityType(ActivityTypeEnum.FIRST_LOGIN.getCode());
|
|
|
record.setAmount(reward.getRewardAmount());
|
|
record.setAmount(reward.getRewardAmount());
|
|
|
record.setVideoId(reward.getGoodsId());
|
|
record.setVideoId(reward.getGoodsId());
|
|
|
record.setCreateTime(DateUtils.getNowDate());
|
|
record.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+ //保存App红包发放记录
|
|
|
appRewardCourseRedPacketLogMapper.insert(record);
|
|
appRewardCourseRedPacketLogMapper.insert(record);
|
|
|
|
|
+ return RewardResult.successWithExt(sendRedPacket);
|
|
|
} else {
|
|
} else {
|
|
|
return RewardResult.fail("红包发放失败,请联系客服");
|
|
return RewardResult.fail("红包发放失败,请联系客服");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return RewardResult.success();
|
|
|
|
|
|
|
+ return RewardResult.fail("红包发放失败,用户不存在");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
return RewardResult.fail("红包发放失败,请联系客服");
|
|
return RewardResult.fail("红包发放失败,请联系客服");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public R sendRewardByFsUser(FsCourseSendRewardUParam param) {
|
|
|
|
|
- FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
|
|
- if (user == null){
|
|
|
|
|
- return R.error("未识别到用户信息");
|
|
|
|
|
- }
|
|
|
|
|
- FsCourseWatchLog watchLog = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
|
|
|
|
|
- if (watchLog == null) {
|
|
|
|
|
- return R.error("无记录");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- FsCourseAnswerLogs rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(), param.getQwUserId());
|
|
|
|
|
-
|
|
|
|
|
- if (rightLog == null) {
|
|
|
|
|
- log.error("未答题:{}",param.getUserId());
|
|
|
|
|
- return R.error("未答题");
|
|
|
|
|
- }
|
|
|
|
|
- if (watchLog.getRewardType() != null ) {
|
|
|
|
|
- if (watchLog.getRewardType() == 1){
|
|
|
|
|
- FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
|
|
|
|
|
- if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
|
|
|
|
|
- return R.error("已领取该课程奖励,不可重复领取!");
|
|
|
|
|
- }
|
|
|
|
|
- if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 0) {
|
|
|
|
|
- if(StringUtils.isNotEmpty(fsCourseRedPacketLog.getResult())){
|
|
|
|
|
- R r = JSON.parseObject(fsCourseRedPacketLog.getResult(), R.class);
|
|
|
|
|
- return r;
|
|
|
|
|
- } else {
|
|
|
|
|
- return R.error("操作频繁,请稍后再试!");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }else if (watchLog.getRewardType() == 2){
|
|
|
|
|
- return R.error("已领取该课程奖励,不可重复领取!");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 获取视频信息
|
|
|
|
|
- FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(param.getVideoId());
|
|
|
|
|
-
|
|
|
|
|
- // 获取配置信息
|
|
|
|
|
- String json = configService.selectConfigByKey("course.config");
|
|
|
|
|
- CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
|
|
- // 红包奖励
|
|
|
|
|
- //return sendRedPacketRewardFsUser(param, user, watchLog, video, config);
|
|
|
|
|
- return new R();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 构建红包参数
|
|
* 构建红包参数
|
|
|
*/
|
|
*/
|
|
@@ -150,11 +93,10 @@ public class FirstLoginRedPacketStrategy implements RewardStrategy {
|
|
|
WxSendRedPacketParam param = new WxSendRedPacketParam();
|
|
WxSendRedPacketParam param = new WxSendRedPacketParam();
|
|
|
param.setAppId(openProperties.getAppId());
|
|
param.setAppId(openProperties.getAppId());
|
|
|
param.setOpenId(fsUser.getAppOpenId());
|
|
param.setOpenId(fsUser.getAppOpenId());
|
|
|
- param.setRedPacketMode(1);//1:为总公司
|
|
|
|
|
- param.setCompanyId(reward.getCompanyId());
|
|
|
|
|
- param.setUser(fsUser);
|
|
|
|
|
- param.setSource(1);
|
|
|
|
|
param.setAmount(reward.getRewardAmount());
|
|
param.setAmount(reward.getRewardAmount());
|
|
|
|
|
+ param.setRedPacketMode(1);//总公司
|
|
|
|
|
+ param.setSource(3);//3:app端
|
|
|
|
|
+ param.setUser(fsUser);
|
|
|
return param;
|
|
return param;
|
|
|
}
|
|
}
|
|
|
|
|
|