Explorar o código

Merge remote-tracking branch 'origin/master'

ct hai 1 semana
pai
achega
52ffe42f6a

+ 1 - 1
fs-company-app/src/main/java/com/fs/app/controller/FsUserCourseVideoController.java

@@ -329,7 +329,7 @@ public class FsUserCourseVideoController extends AppBaseController {
         R courseSortLink = fsUserCourseService.createAppCourseSortLink(fsCourseLinkCreateParam);
         String url = courseSortLink.get("url").toString();
         batchSendCourseDTO.setUrl(url);
-
+        batchSendCourseDTO.setIsUrgeCourse(false);
         return openIMService.batchSendCourse(batchSendCourseDTO);
     }
 

+ 1 - 1
fs-company/src/main/java/com/fs/user/FsUserAdminController.java

@@ -167,7 +167,7 @@ public class FsUserAdminController extends BaseController {
         R courseSortLink = fsUserCourseService.createAppCourseSortLink(fsCourseLinkCreateParam);
         String url = courseSortLink.get("url").toString();
         batchSendCourseDTO.setUrl(url);
-
+        batchSendCourseDTO.setIsUrgeCourse(false);
         return openIMService.batchSendCourse(batchSendCourseDTO);
     }
 

+ 5 - 1
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1833,7 +1833,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             // 更新观看记录的奖励类
             log.setRewardType(config.getRewardType());
             courseWatchLogMapper.updateFsCourseWatchLog(log);
-            return R.ok("红包发送成功");
+            return R.ok("答题成功!");
         }
 
     }
@@ -2302,6 +2302,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
                 companyUserEndDateTime : periodDays.getEndDateTime();
         // 检查时间范围和状态
         log.error("传入参数:开始时间:{},结束时间:{},periodDays={}",effectiveStartTime,effectiveEndTime,periodDays);
+        if (ObjectUtils.isNotEmpty(effectiveStartTime)||ObjectUtils.isNotEmpty(effectiveEndTime)){
+            log.error("请检查营期时间!");
+            return false;
+        }
         return DateUtil.isWithinRangeSafe(LocalDateTime.now(), effectiveStartTime, effectiveEndTime)&& periodDays.getStatus() == 1;
     }
 

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java

@@ -1,11 +1,14 @@
 package com.fs.hisStore.service;
 
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.param.LoginMaWxParam;
 import com.fs.course.param.newfs.FsUserCourseBeMemberParam;
 import com.fs.course.vo.newfs.FsCourseAnalysisVO;
 import com.fs.his.domain.FsStoreProductAttrValue;
+import com.fs.his.domain.FsUser;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
 import com.fs.live.domain.LiveOrder;
@@ -286,4 +289,7 @@ public interface IFsUserScrmService
     void addTuiLiveMoney(LiveOrder order, List<FsStoreProductAttrValueScrm> productAttrValues);
 
     void subLiveTuiMoney(LiveOrder liveOrder);
+
+    void handleFsUserWx(FsUserScrm user, LoginMaWxParam param, WxMaJscode2SessionResult session);
+
 }

+ 27 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -13,6 +13,8 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fs.common.annotation.DataScope;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.R;
@@ -34,6 +36,7 @@ import com.fs.course.service.IFsCourseRedPacketLogService;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUserWx;
+import com.fs.his.mapper.FsUserWxMapper;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
@@ -851,6 +854,8 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
 
     @Autowired
     private IFsUserService fsUserService;
+    @Autowired
+    private FsUserWxMapper fsUserWxMapper;
 
     @Override
     public R paymentByWxaCode(FsStorePaymentPayParam param) {
@@ -874,6 +879,26 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
 
         //生成支付流水
         String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
+
+        //获取用户openid
+        String openId = null;
+        String appId = param.getAppId();
+
+        //查询fs_user_wx的openId
+        Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
+                .eq(FsUserWx::getFsUserId, param.getUserId())
+                .eq(FsUserWx::getAppId, appId);
+        FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
+        if (fsUserWx != null) {
+            openId = fsUserWx.getOpenId();
+        }else {
+            openId = user.getMaOpenId();
+        }
+
+        if (StringUtils.isEmpty(openId)){
+            return R.error("openId参数错误!");
+        }
+
         FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
         storePayment.setCompanyId(param.getCompanyId());
         //判断销售是否存在
@@ -887,7 +912,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         storePayment.setPayTypeCode("weixin");
         storePayment.setBusinessType(1);//微信收款
         storePayment.setRemark(StringUtils.isNotBlank(param.getRemark()) ? param.getRemark() : "商城收款订单支付");
-        storePayment.setOpenId(user.getMaOpenId());
+        storePayment.setOpenId(openId);
         storePayment.setUserId(user.getUserId());
         storePayment.setPayMode("hf");//目前微信收款仅支持汇付
         storePayment.setAppId(param.getAppId());
@@ -896,7 +921,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         //汇付支付
         HuiFuCreateOrder o = new HuiFuCreateOrder();
         o.setTradeType("T_MINIAPP");
-        o.setOpenid(user.getMaOpenId());
+        o.setOpenid(openId);
         o.setReqSeqId("payment-"+storePayment.getPayCode());
         o.setTransAmt(storePayment.getPayMoney().toString());
         o.setGoodsDesc("商城订单支付");

+ 27 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.service.impl;
 
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -8,6 +9,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.core.domain.entity.SysDictData;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.param.LoginMaWxParam;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.DictUtils;
 import com.fs.common.utils.ParseUtils;
@@ -30,7 +32,10 @@ import com.fs.course.param.newfs.UserCourseVideoPageParam;
 import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
 import com.fs.course.vo.newfs.FsCourseAnalysisVO;
 import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
+import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUserBill;
+import com.fs.his.domain.FsUserWx;
+import com.fs.his.service.IFsUserWxService;
 import com.fs.his.vo.OptionsVO;
 import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
@@ -1130,4 +1135,26 @@ public class FsUserScrmServiceImpl implements IFsUserScrmService
     public List<OptionsVO> selectUserListByMap(Map<String, Object> params) {
         return fsUserMapper.selectUserListByMap(params);
     }
+
+
+    @Autowired
+    private IFsUserWxService fsUserWxService;
+
+    @Override
+    public void handleFsUserWx(FsUserScrm user, LoginMaWxParam param, WxMaJscode2SessionResult session) {
+        try {
+            FsUserWx fsUserWx = new FsUserWx();
+            fsUserWx.setType(1);
+            fsUserWx.setFsUserId(user.getUserId());
+            fsUserWx.setAppId(param.getAppId());
+            fsUserWx.setOpenId(session.getOpenid());
+            fsUserWx.setUnionId(session.getUnionid() != null ? session.getUnionid() : null);
+            fsUserWx.setCreateTime(new Date());
+            fsUserWx.setUpdateTime(new Date());
+            fsUserWxService.saveOrUpdateByUniqueKey(fsUserWx);
+            log.info("zyp \n 【更新或插入用户与小程序{}的绑定关系】:{}", param.getAppId(), user.getUserId());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
 }

+ 3 - 2
fs-service/src/main/java/com/fs/im/service/impl/OpenIMServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -1099,7 +1100,7 @@ public class OpenIMServiceImpl implements OpenIMService {
         FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(batchSendCourseDTO.getCourseId());
         Long project = fsUserCourse != null ? fsUserCourse.getProject() : null;
         long planSendTimeStamp;
-        if(batchSendCourseDTO.getSendType() == 1 && batchSendCourseDTO.getSendTime() != null && batchSendCourseDTO.getSendTime().compareTo(new Date()) > 0){
+        if(ObjectUtils.isNotEmpty(batchSendCourseDTO.getSendType())&&batchSendCourseDTO.getSendType() == 1 && batchSendCourseDTO.getSendTime() != null && batchSendCourseDTO.getSendTime().compareTo(new Date()) > 0){
             planSendTimeStamp = batchSendCourseDTO.getSendTime().getTime();
         } else {
             planSendTimeStamp = System.currentTimeMillis();
@@ -1109,7 +1110,7 @@ public class OpenIMServiceImpl implements OpenIMService {
         OpenImBatchMsgDTO openImBatchMsgDTO = makeOpenImBatchMsgDTO(batchSendCourseDTO, courseUrl, objectMapper, userIds, planSendTimeStamp, "发课");
 
         int sendType;
-        if(batchSendCourseDTO.getSendType() == 1 && batchSendCourseDTO.getSendTime() != null && batchSendCourseDTO.getSendTime().compareTo(new Date()) > 0) {
+        if(ObjectUtils.isNotEmpty(batchSendCourseDTO.getSendType())&&batchSendCourseDTO.getSendType() == 1 && batchSendCourseDTO.getSendTime() != null && batchSendCourseDTO.getSendTime().compareTo(new Date()) > 0) {
             sendType = 1; //定时
         } else {
             sendType = 2; //实时

+ 9 - 3
fs-user-app/src/main/java/com/fs/app/controller/store/WxUserScrmController.java

@@ -11,6 +11,7 @@ import com.fs.app.utils.JwtUtils;
 import com.fs.common.OrderUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
+import com.fs.common.param.LoginMaWxParam;
 import com.fs.common.utils.IpUtil;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxMpProperties;
@@ -358,6 +359,11 @@ public class WxUserScrmController extends AppBaseController {
                 }
                 userService.updateFsUser(userMap);
             }
+            LoginMaWxParam loginMaWxParam = new LoginMaWxParam();
+            loginMaWxParam.setAppId(param.getAppId());
+            loginMaWxParam.setCompanyId(user.getCompanyId());
+
+            userService.handleFsUserWx(user,loginMaWxParam,session);
             String token = jwtUtils.generateToken(user.getUserId());
             return R.ok("登录成功").put("token",token).put("user", user);
         } catch (WxErrorException e) {
@@ -520,12 +526,12 @@ public class WxUserScrmController extends AppBaseController {
         if (StringUtils.isEmpty(newAppId)) {
             return currentAppIds == null ? "" : currentAppIds;
         }
-        
+
         // 如果当前appId为空,直接返回新appId
         if (StringUtils.isEmpty(currentAppIds)) {
             return newAppId;
         }
-        
+
         // 检查是否已存在
         String[] appIdArray = currentAppIds.split(",");
         for (String appId : appIdArray) {
@@ -534,7 +540,7 @@ public class WxUserScrmController extends AppBaseController {
                 return currentAppIds;
             }
         }
-        
+
         // 不存在,追加到末尾
         return currentAppIds + "," + newAppId;
     }