|
|
@@ -45,6 +45,7 @@ import com.fs.company.cache.ICompanyUserCacheService;
|
|
|
import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
|
import com.fs.company.service.ICompanyTagService;
|
|
|
+import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsUserCompanyUser;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
@@ -2334,7 +2335,13 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
FsIntegralRedPacketLog fsIntegralRedPacketLog = saveRedPacketLog(userId, applicationAmount,param.getAppId());
|
|
|
//来源是小程序切换openId
|
|
|
WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
|
|
|
- String openId = getOpenId(param, fsUser);
|
|
|
+
|
|
|
+ // 先使用服务号发红包
|
|
|
+ // 获取配置信息
|
|
|
+ String courseConfigJson = configService.selectConfigByKey("course.config");
|
|
|
+ CourseConfig courseConfig = JSONUtil.toBean(courseConfigJson, CourseConfig.class);
|
|
|
+
|
|
|
+ String openId = fsUser.getMpOpenId();
|
|
|
if (StringUtils.isBlank(openId)) {
|
|
|
fsIntegralRedPacketLog.setStatus("-1");
|
|
|
fsIntegralRedPacketLog.setRemark("失败原因:未使用微信登录");
|
|
|
@@ -2342,10 +2349,11 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
integralRedPacketLogMapper.updateFsIntegralRedPacketLog(fsIntegralRedPacketLog);
|
|
|
return R.error("请重新使用微信登录");
|
|
|
}
|
|
|
- packetParam.setOpenId(openId);
|
|
|
packetParam.setAmount(applicationAmount);
|
|
|
packetParam.setSource(param.getSource());
|
|
|
- packetParam.setAppId(param.getAppId());
|
|
|
+ packetParam.setAppId(courseConfig.getMpAppId());
|
|
|
+ packetParam.setOpenId(openId);
|
|
|
+
|
|
|
try {
|
|
|
//发送红包
|
|
|
R sendRedPacket = paymentService.sendIntegralRedPacket(packetParam);
|
|
|
@@ -2398,51 +2406,6 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
return redPacketLog;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取用户openId
|
|
|
- */
|
|
|
- private String getOpenId(FsIntegralWithdrawalParam param, FsUser user) {
|
|
|
- if (param.getSource()==2){
|
|
|
- FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
|
- if (Objects.nonNull(fsUserWx) && StringUtils.isNotBlank(fsUserWx.getOpenId())) {
|
|
|
- return fsUserWx.getOpenId();
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(user.getCourseMaOpenId())) {
|
|
|
- try {
|
|
|
- handleFsUserWx(user,param.getAppId());
|
|
|
- } catch (Exception e){
|
|
|
- log.error("【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(), e);
|
|
|
- }
|
|
|
- return user.getCourseMaOpenId();
|
|
|
- }
|
|
|
- } else if (param.getSource()==3){
|
|
|
- if (StringUtils.isNotBlank(user.getAppOpenId())) {
|
|
|
- return user.getAppOpenId();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return user.getMpOpenId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理用户与小程序的绑定
|
|
|
- */
|
|
|
- private void handleFsUserWx(FsUser user,String appId) {
|
|
|
- FsUserWx fsUserWx = new FsUserWx();
|
|
|
- fsUserWx.setType(1);
|
|
|
- fsUserWx.setFsUserId(user.getUserId());
|
|
|
- fsUserWx.setAppId(appId);
|
|
|
- fsUserWx.setOpenId(user.getCourseMaOpenId());
|
|
|
- fsUserWx.setUnionId(user.getUnionId());
|
|
|
- fsUserWx.setCreateTime(new Date());
|
|
|
- fsUserWx.setUpdateTime(new Date());
|
|
|
- fsUserWxService.saveOrUpdateByUniqueKey(fsUserWx);
|
|
|
-
|
|
|
- logger.info("zyp \n 【更新或插入用户与小程序{}的绑定关系】:{}", appId, user.getUserId());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 批量禁用用户
|
|
|
*/
|