Browse Source

Merge remote-tracking branch 'origin/master'

yjwang 1 week ago
parent
commit
93a5821551

+ 10 - 0
fs-admin/src/main/java/com/fs/course/controller/FsUserCourseComplaintRecordController.java

@@ -75,6 +75,16 @@ public class FsUserCourseComplaintRecordController extends BaseController
         return AjaxResult.success(fsUserCourseComplaintRecordService.selectFsUserCourseComplaintRecordByRecordId(recordId));
     }
 
+    /**
+    * 获取 看课投诉记录详细信息-客户所属关系
+    */
+    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:queryQw')")
+    @GetMapping(value = "/getInfoByUserId/{userId}")
+    public AjaxResult getInfoByUserId(@PathVariable("userId") Long userId)
+    {
+        return AjaxResult.success(fsUserCourseComplaintRecordService.selectFsUserCourseComplaintRecordByUserId(userId));
+    }
+
     /**
      * 新增看课投诉记录
      */

+ 5 - 2
fs-qw-task/src/main/java/com/fs/app/controller/CommonController.java

@@ -103,6 +103,10 @@ public class CommonController {
     @Autowired
     private IQwMaterialService iQwMaterialService;
 
+
+    @Autowired
+    private IFsCourseLinkService iFsCourseLinkService;
+
     /**
     * 发官方通连
     */
@@ -142,8 +146,7 @@ public class CommonController {
     @GetMapping("/testSop")
     public R testSop() throws Exception {
 
-        iQwMaterialService.updateQwMaterialByQw();
-        return R.ok();
+        return iFsCourseLinkService.getWxaCodeGenerateScheme("/pages_course/video.html?course={\"companyId\":100,\"companyUserId\":2020,\"corpId\":\"wweb0666cc79d79da5\",\"courseId\":61,\"link\":\"1950497651577323520\",\"linkType\":3,\"qwExternalId\":2356946,\"qwUserId\":\"1682\",\"uNo\":\"b8b010e1-ee0f-42ec-8ad8-06681d1b449a\",\"videoId\":366}","wx34bba1ae94d34986");
     }
 
     @GetMapping("/testRatingSop")

+ 4 - 0
fs-service/src/main/java/com/fs/course/domain/FsCourseRedPacketLog.java

@@ -59,4 +59,8 @@ public class FsCourseRedPacketLog extends BaseEntity
 
     private String result;
 
+    private String batchId;//微信批次单号
+
+    private String appId;//小程序appId
+
 }

+ 2 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseSendRewardUParam.java

@@ -29,4 +29,6 @@ public class FsCourseSendRewardUParam implements Serializable
 
     private String appId;
 
+    private String code;
+
 }

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/IFsCourseLinkService.java

@@ -92,4 +92,6 @@ public interface IFsCourseLinkService
      * @return
      */
     String getGotoWxAppLink(String linkStr,String appid);
+
+    R getWxaCodeGenerateScheme(String linkStr,String appId);
 }

+ 3 - 0
fs-service/src/main/java/com/fs/course/service/IFsUserCourseComplaintRecordService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.course.domain.FsUserCourseComplaintRecord;
 import com.fs.course.param.UserCourseComplaintRecordParam;
 import com.fs.course.vo.FsUserCourseComplaintRecordPageListVO;
+import com.fs.qw.vo.QwExternalContactComplaintVO;
 
 /**
  * 看课投诉记录Service接口
@@ -21,6 +22,8 @@ public interface IFsUserCourseComplaintRecordService extends IService<FsUserCour
      */
     FsUserCourseComplaintRecordPageListVO selectFsUserCourseComplaintRecordByRecordId(Long recordId);
 
+    List<QwExternalContactComplaintVO> selectFsUserCourseComplaintRecordByUserId(Long userId);
+
     /**
      * 查询看课投诉记录列表
      *

+ 97 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseLinkServiceImpl.java

@@ -12,8 +12,10 @@ import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.date.DateUtil;
 import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.config.cloud.CloudHostProper;
+import com.fs.core.config.WxMaConfig;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.course.config.CourseConfig;
+import com.fs.course.config.CourseMaConfig;
 import com.fs.course.domain.*;
 import com.fs.course.mapper.FsCourseDomainNameMapper;
 import com.fs.course.mapper.FsCourseLinkMapper;
@@ -25,6 +27,7 @@ import com.fs.course.service.IFsCourseLinkService;
 import com.fs.course.service.IFsUserCourseService;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.utils.HttpUtil;
 import com.fs.qw.domain.QwGroupChat;
 import com.fs.qw.domain.QwGroupChatUser;
 import com.fs.qw.domain.QwUser;
@@ -33,8 +36,12 @@ import com.fs.qw.mapper.QwUserMapper;
 import com.fs.qw.service.IQwGroupChatService;
 import com.fs.qw.service.IQwGroupChatUserService;
 import com.fs.qw.vo.GroupUserExternalVo;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.mapper.SysConfigMapper;
 import com.fs.system.service.ISysConfigService;
 import com.fs.voice.utils.StringUtil;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
 import lombok.Synchronized;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
@@ -42,6 +49,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.mp.api.WxMpService;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -104,9 +112,15 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
     @Autowired
     private CompanyUserMapper companyUserMapper;
 
+    @Autowired
+    private ConfigUtil configUtil;
+
     @Autowired
     CloudHostProper cloudHostProper;
 
+    @Autowired
+    private SysConfigMapper sysConfigMapper;
+
     private static String TOKEN_VALID_CODE = "40001";
 
     private volatile Integer version = 0;
@@ -817,4 +831,87 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
         }
         return "";
     }
+
+    @Override
+    public R getWxaCodeGenerateScheme(String linkStr,String appId) {
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClients.createDefault();
+            String[] split = linkStr.split("\\?");
+            if (split.length == 2 && split[0].length() > 0 && split[1].length() > 0) {
+                //处理页面路径
+                String pageUrl = split[0];
+                if (pageUrl.startsWith("/")) {
+//                    pageUrl = pageUrl.substring(1);
+                    pageUrl = "pages_course/video";
+                }
+                //处理参数
+                String query = split[1];
+                query = URLEncoder.encode(query, StandardCharsets.UTF_8.toString());
+
+
+
+                SysConfig sysConfig3 = sysConfigMapper.selectConfigByConfigKey("courseMa.config");
+                List<CourseMaConfig> courseMaConfigs = JSON.parseArray(sysConfig3.getConfigValue(), CourseMaConfig.class);
+                if (courseMaConfigs!=null&& !courseMaConfigs.isEmpty()){
+                    for (CourseMaConfig courseMaConfig : courseMaConfigs) {
+                        if (appId.equals(courseMaConfig.getAppid())) {
+
+                            //获取微信token
+
+                            String url="https://api.weixin.qq.com/cgi-bin/stable_token";
+                            HashMap<String, String> map = new HashMap<>();
+                            map.put("grant_type","client_credential");
+                            map.put("appid",courseMaConfig.getAppid());
+                            map.put("secret",courseMaConfig.getSecret());
+
+
+                            String accessToken = HttpUtil.endApi(url, null, map);
+
+                            Map<String, String> accessTokenMap  = new Gson().fromJson(accessToken, new TypeToken<Map<String, Object>>(){}.getType());
+
+
+                            HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + accessTokenMap.get("access_token"));
+                            JSONObject bodyObj = new JSONObject();
+                            bodyObj.put("path", pageUrl);
+                            bodyObj.put("query", query);
+                            bodyObj.put("env_version", "release");
+
+                            StringEntity entity = new StringEntity(bodyObj.toJSONString(),"UTF-8");
+                            httpPost.setEntity(entity);
+                            httpPost.setHeader("Content-type", "application/json");
+                            httpPost.setHeader("cache-control","max-age=0");
+                            HttpEntity response = client.execute(httpPost).getEntity();
+                            String responseString = EntityUtils.toString(response);
+
+                            JSONObject jsonObject = JSONObject.parseObject(responseString);
+
+
+
+                            if(null != jsonObject && !jsonObject.isEmpty() && jsonObject.containsKey("url_link")){
+                                return R.ok().put("urlLink",jsonObject.getString("url_link")) ;
+                            }else {
+                                return R.error("获取失败:"+jsonObject.getString("errmsg"));
+                            }
+                        }else {
+                            return R.error("未配置小程序id");
+                        }
+                    }
+                }
+
+
+
+            } else {
+                return R.error("页面链接错误,获取失败");
+            }
+
+        } catch (ClientProtocolException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return R.ok();
+    }
+
+
 }

+ 27 - 34
fs-service/src/main/java/com/fs/course/service/impl/FsCourseQuestionBankServiceImpl.java

@@ -241,7 +241,11 @@ public class FsCourseQuestionBankServiceImpl implements IFsCourseQuestionBankSer
 
     @Override
     @Transactional
-    public R courseAnswer(FsCourseQuestionAnswerUParam param,Boolean isH5User) {
+    public R courseAnswer(FsCourseQuestionAnswerUParam param, Boolean isH5User) {
+        FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId());
+        if (user==null){
+            return R.error("未识别到领取信息");
+        }
         //获取配置参数
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
@@ -254,46 +258,35 @@ public class FsCourseQuestionBankServiceImpl implements IFsCourseQuestionBankSer
         //日志id
         Long logId = null;
 
-        FsCourseAnswerLogs rightLog = new FsCourseAnswerLogs();
+        new FsCourseAnswerLogs();
+        FsCourseAnswerLogs rightLog;
         //判断短链类型
-        if (param.getLinkType()!=null&&param.getLinkType()==1){
-            rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(),null);
-            if (rightLog!=null){
-                return R.error("该课程已答题完成,不可重复答题");
-            }
-            errorCount = courseAnswerLogsMapper.selectErrorCountByCourseVideo(param.getVideoId(), param.getUserId(),null);
 
-        }else {
-            FsCourseWatchLog log;
-            if(isH5User){
-                log = courseWatchLogMapper.getWatchLogByFsUser(param.getVideoId(), param.getUserId(), param.getCompanyUserId());
-            } else {
-                log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
-            }
-            if (log==null){
-                return R.error("无记录");
-            }
-            if (log.getLogType()!=2){
-                return R.error("未完课");
-            }
-            logId = log.getLogId();
-
-            rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(), param.getQwUserId());
-            if (rightLog != null) {
-                if (log.getRewardType() != null) {
-                    // 增加判断,去查询红包记录是否已发送成功,如果成功,则返回当前提示,否则返回答题成功(让其可以继续答题,直到红包领取完成)
-                    FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
-                    if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
-                        return R.error("该课程已答题完成,不可重复答题");
-                    } else {
-                        return R.ok("答题成功");
-                    }
+        FsCourseWatchLog log = courseWatchLogMapper.getWatchLogByFsUser(param.getVideoId(), param.getUserId(), param.getCompanyUserId());
+        if (log==null){
+            return R.error("无记录");
+        }
+        if (log.getLogType()!=2){
+            return R.error("未完课");
+        }
+        logId = log.getLogId();
+
+        rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(), param.getQwUserId());
+        if (rightLog != null) {
+            if (log.getRewardType() != null) {
+                // 增加判断,去查询红包记录是否已发送成功,如果成功,则返回当前提示,否则返回答题成功(让其可以继续答题,直到红包领取完成)
+                FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
+                if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
+                    return R.error("该课程已答题完成,不可重复答题");
                 } else {
                     return R.ok("答题成功");
                 }
+            } else {
+                return R.ok("答题成功");
             }
-            errorCount = courseAnswerLogsMapper.selectErrorCountByCourseVideo(param.getVideoId(), param.getUserId(),param.getQwUserId());
         }
+        errorCount = courseAnswerLogsMapper.selectErrorCountByCourseVideo(param.getVideoId(), param.getUserId(),param.getQwUserId());
+
 
 
         if (errorCount >= config.getAnswerErrorCount()) {

+ 6 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseComplaintRecordServiceImpl.java

@@ -12,6 +12,7 @@ import com.fs.course.param.UserCourseComplaintRecordParam;
 import com.fs.course.vo.FsUserCourseComplaintRecordPageListVO;
 import com.fs.qw.domain.QwExternalContact;
 import com.fs.qw.mapper.QwExternalContactMapper;
+import com.fs.qw.vo.QwExternalContactComplaintVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -43,6 +44,11 @@ public class FsUserCourseComplaintRecordServiceImpl extends ServiceImpl<FsUserCo
         return baseMapper.selectFsUserCourseComplaintRecordByRecordId(recordId);
     }
 
+    @Override
+    public List<QwExternalContactComplaintVO> selectFsUserCourseComplaintRecordByUserId(Long userId) {
+        return qwExternalContactMapper.selectFsUserCourseComplaintRecordByUserId(userId);
+    }
+
     /**
      * 查询看课投诉记录列表
      *

+ 75 - 58
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -863,28 +863,21 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         FsCourseWatchLog log = new FsCourseWatchLog();
 
         // 根据链接类型判断是否已发放奖励
-        log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
-        if (log == null) {
-            return R.error("无记录");
-        }
-        if (log.getRewardType() != null) {
+        if (param.getLinkType() != null && param.getLinkType() == 1) {
             FsCourseRedPacketLog packetLog = redPacketLogMapper.selectFsCourseRedPacketLogByTemporary(param.getVideoId(), param.getUserId());
-            if(packetLog != null && packetLog.getStatus() == 1) {
+            if (packetLog != null) {
                 return R.error("奖励已发放");
             }
-            if(packetLog != null && packetLog.getStatus() == 0) {
-                if(StringUtils.isNotEmpty(packetLog.getResult())){
-                    R r = JSON.parseObject(packetLog.getResult(), R.class);
-                    return r;
-                } else {
-                    return R.error("奖励已发放");
-                }
+        } else {
+            log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
+            if (log == null) {
+                return R.error("无记录");
             }
-            if(packetLog != null && packetLog.getStatus() == 2) {
-                return R.error("请联系客服补发");
+            if (log.getRewardType() != null) {
+                return R.error("奖励已发放");
             }
-            return R.error("奖励已发放");
         }
+
         // 获取视频信息
         FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(param.getVideoId());
 
@@ -962,6 +955,19 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
      * @return 处理结果
      */
     private R sendRedPacketReward(FsCourseSendRewardUParam param, FsUser user, FsCourseWatchLog log, FsUserCourseVideo video, CourseConfig config) {
+        // 判断是否属于领取红包时间(会员看课发放红包)
+        FsUserCoursePeriodDays periodDays = new FsUserCoursePeriodDays();
+        periodDays.setVideoId(param.getVideoId());
+        periodDays.setPeriodId(param.getPeriodId());
+        //正常情况是只能查询到一条,之前可能存在重复的脏数据,暂使用查询list的方式
+        List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectFsUserCoursePeriodDaysList(periodDays);
+        if(fsUserCoursePeriodDays != null && !fsUserCoursePeriodDays.isEmpty()){
+            periodDays = fsUserCoursePeriodDays.get(0);
+        }
+
+        if(periodDays != null && periodDays.getLastJoinTime() !=null && LocalDateTime.now().isAfter(periodDays.getLastJoinTime())) {
+            return R.error(403,"已超过领取红包时间");
+        }
 
         // 确定红包金额
         BigDecimal amount = BigDecimal.ZERO;
@@ -977,46 +983,39 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
         packetParam.setOpenId(user.getMpOpenId());
         // 来源是小程序切换openId
+//        if (param.getSource() == 2) {
+//            packetParam.setOpenId(user.getMaOpenId());
+//        }
         if (param.getSource() == 2) {
-            //处理多小程序问题
             FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
-            if (fsUserWx ==null || fsUserWx.getOpenId()==null){
-                packetParam.setOpenId(user.getCourseMaOpenId());
+            if (fsUserWx ==null){
+                packetParam.setOpenId(user.getMaOpenId());
+                try {
+                    handleFsUserWx(user,param.getAppId());
+                } catch (Exception e){
+                    e.printStackTrace();
+                    logger.error(e.getMessage(),e);
+                }
+
             }else {
+                //查出openid并赋值
                 packetParam.setOpenId(fsUserWx.getOpenId());
             }
-            //查出公司绑定openid并赋值
+
 
         }
         packetParam.setAmount(amount);
         packetParam.setSource(param.getSource());
         packetParam.setRedPacketMode(config.getRedPacketMode());
         packetParam.setCompanyId(param.getCompanyId());
+        packetParam.setAppId(param.getAppId());
+        if (StringUtils.isNotEmpty(param.getCode())){
+            packetParam.setCode(param.getCode());
+            packetParam.setUser(user);
+        }
 
-        System.out.println("红包金额"+amount);
-        System.out.println("红包商户号"+packetParam);
-        //2025.6.19 红包金额为0的时候
+        //2025.7.11 红包金额为0的时候
         if (amount.compareTo(BigDecimal.ZERO)>0){
-
-            Company company = companyMapper.selectCompanyByIdForUpdate(param.getCompanyId());
-            BigDecimal money = company.getMoney();
-            BigDecimal subtract = money.subtract(amount);
-            if (subtract.compareTo(BigDecimal.ZERO)<0){
-                FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
-                redPacketLog.setCourseId(param.getCourseId());
-                redPacketLog.setCompanyId(param.getCompanyId());
-                redPacketLog.setUserId(param.getUserId());
-                redPacketLog.setVideoId(param.getVideoId());
-                redPacketLog.setStatus(2);
-                redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
-                redPacketLog.setCompanyUserId(param.getCompanyUserId());
-                redPacketLog.setCreateTime(new Date());
-                redPacketLog.setAmount(amount);
-                redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
-                redPacketLog.setPeriodId(param.getPeriodId());
-                redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
-                return R.error("销售公司余额不足");
-            }
             // 发送红包
             R sendRedPacket = paymentService.sendRedPacket(packetParam);
             if (sendRedPacket.get("code").equals(200)) {
@@ -1026,8 +1025,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
                     transferBillsResult = (TransferBillsResult)sendRedPacket.get("data");
                     redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
                     redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
+                    redPacketLog.setBatchId(transferBillsResult.getTransferBillNo());
                 }else {
                     redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+                    redPacketLog.setBatchId(sendRedPacket.get("batchId").toString());
                 }
                 // 添加红包记录
                 redPacketLog.setCourseId(param.getCourseId());
@@ -1042,28 +1043,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
                 redPacketLog.setAmount(amount);
                 redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
                 redPacketLog.setPeriodId(param.getPeriodId());
+                redPacketLog.setAppId(param.getAppId());
+
                 redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
 
                 // 更新观看记录的奖励类型
+//            if (param.getLinkType() == null || param.getLinkType() == 0) {
                 log.setRewardType(config.getRewardType());
                 courseWatchLogMapper.updateFsCourseWatchLog(log);
-                company.setMoney(subtract);
-                companyMapper.updateCompany(company);
-
-                CompanyMoneyLogs logs=new CompanyMoneyLogs();
-                logs.setCompanyId(company.getCompanyId());
-                logs.setRemark("扣除红包金额");
-                logs.setMoney(amount.multiply(new BigDecimal(-1)));
-                logs.setLogsType(15);
-                logs.setBalance(company.getMoney());
-                logs.setCreateTime(new Date());
-                moneyLogsMapper.insertCompanyMoneyLogs(logs);
-
+//            }
                 return sendRedPacket;
             } else {
                 return R.error("奖励发送失败,请联系客服");
             }
+
         } else {
+            // 发送红包
             FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
             // 添加红包记录
             redPacketLog.setCourseId(param.getCourseId());
@@ -1071,7 +1066,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             redPacketLog.setCompanyId(param.getCompanyId());
             redPacketLog.setUserId(param.getUserId());
             redPacketLog.setVideoId(param.getVideoId());
-            redPacketLog.setStatus(0);
+            redPacketLog.setStatus(1);//直接设置发送成功
+            redPacketLog.setResult("{\"msg\":\"发送0红包成功\",\"code\":200,\"isNew\":1}");
             redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
             redPacketLog.setCompanyUserId(param.getCompanyUserId());
             redPacketLog.setCreateTime(new Date());
@@ -1081,13 +1077,34 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
 
             // 更新观看记录的奖励类型
-//            if (param.getLinkType() == null || param.getLinkType() == 0) {
             log.setRewardType(config.getRewardType());
             courseWatchLogMapper.updateFsCourseWatchLog(log);
-//            }
             return R.ok("红包发送成功");
         }
+    }
 
+    private void handleFsUserWx(FsUser user, String appId) {
+        // 尝试更新
+        boolean updated = fsUserWxService.lambdaUpdate()
+                .eq(FsUserWx::getFsUserId, user.getUserId())
+                .eq(FsUserWx::getAppId,appId )
+                .eq(FsUserWx::getOpenId, user.getMaOpenId())
+//                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
+                .set(FsUserWx::getUpdateTime, new Date())
+                .update();
+
+        // 如果更新失败(记录不存在),则插入
+        if (!updated) {
+            FsUserWx fsUserWx = new FsUserWx();
+            fsUserWx.setType(1);
+            fsUserWx.setFsUserId(user.getUserId());
+            fsUserWx.setAppId(appId);
+            fsUserWx.setOpenId(user.getMaOpenId());
+//            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
+            fsUserWx.setCreateTime(new Date());
+            fsUserWx.setUpdateTime(new Date());
+            fsUserWxService.save(fsUserWx);
+        }
     }
 
     /**

+ 12 - 4
fs-service/src/main/java/com/fs/his/param/WxSendRedPacketParam.java

@@ -1,5 +1,6 @@
 package com.fs.his.param;
 
+import com.fs.his.domain.FsUser;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -10,12 +11,19 @@ public class WxSendRedPacketParam implements Serializable {
 
     private String openId;
 
-    private BigDecimal amount;
+    private BigDecimal amount; //金额
 
-    private Integer source=1;//来源 1:h5  2:小程序
+    private Long companyId; //公司id
 
-    private Integer redPacketMode;
+    private Integer source=1;//来源 1:h5  2:看课小程序
 
-    private Long companyId;
+    private Integer redPacketMode;//红包模式
+
+    private String appId;
+
+    private String code;
+
+
+    private FsUser user;
 
 }

+ 1 - 0
fs-service/src/main/java/com/fs/his/service/IFsInquiryOrderService.java

@@ -128,4 +128,5 @@ public interface IFsInquiryOrderService
     void exportFeedbackData(FsInquiryOrderParam fsInquiryOrder);
 
     byte[] getWxaCodeInquiryOrderUnLimit(Long orderId);
+
 }

+ 2 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java

@@ -410,4 +410,6 @@ public interface QwExternalContactMapper extends BaseMapper<QwExternalContact> {
 
     List<QwExternalContact> selectExternalByFsUserIds(@Param("userIds")List<Long> userIds);
 
+    List<QwExternalContactComplaintVO> selectFsUserCourseComplaintRecordByUserId(Long userId);
+
 }

+ 70 - 0
fs-service/src/main/java/com/fs/qw/vo/QwExternalContactComplaintVO.java

@@ -0,0 +1,70 @@
+package com.fs.qw.vo;
+
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class QwExternalContactComplaintVO extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+
+    private Long id;
+
+    /** 属于员工账号 */
+    private String userId;
+
+    /** 属于员工id */
+    private Long qwUserId;
+
+    /**
+    * 属于员工名称
+    */
+    private String qwUserName;
+
+    /**
+    * 销售账号
+    */
+    private String userName;
+
+    /**
+    * 销售昵称
+    */
+    private String nickName;
+
+
+    /**
+    * 客户小程序id
+    */
+    private Long fsUserId;
+
+    /** 外部联系人id */
+    private String externalUserId;
+
+    /** 客户名称 */
+    private String name;
+
+    /** 头像 */
+    private String avatar;
+
+    private Integer status;
+
+    //看课评论状态,1-拉黑;0-正常
+    private Integer commentStatus;
+
+    /**
+    * 备注
+    */
+    private String remark;
+
+    /** 描述信息 */
+    private String description;
+
+
+
+
+
+}

+ 9 - 1
fs-service/src/main/resources/mapper/course/FsCourseRedPacketLogMapper.xml

@@ -21,10 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="remark"    column="remark"    />
         <result property="result"    column="result"    />
         <result property="periodId"    column="period_id"    />
+        <result property="batchId"    column="batch_id"    />
+        <result property="appId"    column="app_id"    />
     </resultMap>
 
     <sql id="selectFsCourseRedPacketLogVo">
-        select log_id,watch_log_id, remark,out_batch_no,status,update_time,course_id, user_id, video_id, company_user_id, company_id, amount, create_time, qw_user_id,period_id from fs_course_red_packet_log
+        select log_id,watch_log_id, remark,out_batch_no,status,update_time,course_id, user_id, video_id, company_user_id, company_id, amount, create_time, qw_user_id,period_id,result,app_id,batch_id from fs_course_red_packet_log
     </sql>
 
     <select id="selectFsCourseRedPacketLogList" parameterType="FsCourseRedPacketLog" resultMap="FsCourseRedPacketLogResult">
@@ -105,6 +107,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">remark,</if>
             <if test="periodId != null">period_id,</if>
             <if test="result != null">result,</if>
+            <if test="batchId != null">batch_id,</if>
+            <if test="appId != null">app_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="courseId != null">#{courseId},</if>
@@ -122,6 +126,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">#{remark},</if>
             <if test="periodId != null">#{periodId},</if>
             <if test="result != null">#{result},</if>
+            <if test="batchId != null">#{batchId},</if>
+            <if test="appId != null">#{appId},</if>
         </trim>
     </insert>
 
@@ -142,6 +148,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="watchLogId != null">watch_log_id = #{watchLogId},</if>
             <if test="periodId != null">period_id = #{periodId},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="batchId != null">batch_id = #{batchId},</if>
+            <if test="appId != null">app_id = #{appId},</if>
         </trim>
         where log_id = #{logId}
     </update>

+ 10 - 1
fs-service/src/main/resources/mapper/qw/QwExternalContactMapper.xml

@@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="unionid"    column="unionid"    />
         <result property="isInteract"    column="is_interact"    />
         <result property="level"    column="level"    />
-        <result property="leveType"    column="level_type"    />
+        <result property="levelType"    column="level_type"    />
         <result property="firstTime"    column="first_time"    />
         <result property="lastWatchTime"    column="last_watch_time"    />
         <result property="registerTime"    column="register_time"    />
@@ -584,4 +584,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </select>
 
+    <select id="selectFsUserCourseComplaintRecordByUserId" resultType="com.fs.qw.vo.QwExternalContactComplaintVO">
+        select qec.id,qec.qw_user_id,qec.status,qec.user_id,qec.name,qec.avatar,qec.remark,qec.description,qec.fs_user_id,
+               qu.qw_user_name,cu.user_name ,cu.nick_name
+        from qw_external_contact qec
+               left join qw_user qu on qu.id=qec.qw_user_id
+               left join company_user cu on cu.user_id=qu.company_user_id
+        where fs_user_id = #{userId}
+    </select>
+
 </mapper>