yangdamao 2 жил өмнө
parent
commit
d286cbbe75

+ 10 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/grade/ClassGradeController.java

@@ -233,6 +233,16 @@ public class ClassGradeController extends BaseController {
         return getDataTable(list);
     }
 
+
+    @ApiOperation("查询学员视频学习记录列表")
+    @PreAuthorize("@ss.hasPermi('grade:user:list')")
+    @GetMapping("/listUserVideoRecord")
+    public TableDataInfo<ClassPeriodStudentVo> listUserVideoRecord(ClassGradeUserQueryBo bo) {
+        startPage();
+        List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserVideoRecord(bo);
+        return getDataTable(list);
+    }
+
     /**
      * 查询学时学员记录列表
      */

+ 16 - 27
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserController.java

@@ -1,43 +1,32 @@
 package com.zhongzheng.controller.user;
 
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-
 import cn.afterturn.easypoi.excel.entity.ExportParams;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.zhongzheng.common.core.domain.entity.SysUser;
-import com.zhongzheng.common.core.domain.model.LoginUser;
-import com.zhongzheng.common.utils.ServletUtils;
-import com.zhongzheng.modules.alisms.service.IAliSmsService;
-import com.zhongzheng.modules.course.vo.CourseSectionImport;
-import com.zhongzheng.modules.grade.vo.ClassPeriodStudentExportVo;
-import com.zhongzheng.modules.user.bo.*;
-import com.zhongzheng.modules.user.service.IUserService;
-import com.zhongzheng.modules.user.vo.*;
-import io.netty.util.internal.ObjectUtil;
-import lombok.RequiredArgsConstructor;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.enums.BusinessType;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
-import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.alisms.service.IAliSmsService;
+import com.zhongzheng.modules.user.bo.*;
+import com.zhongzheng.modules.user.service.IUserService;
+import com.zhongzheng.modules.user.vo.UserIdCardBatchVo;
+import com.zhongzheng.modules.user.vo.UserStatstVo;
+import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
+import com.zhongzheng.modules.user.vo.UserVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
 /**
  * 客户端用户Controller
  *

+ 23 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/user/UserController.java

@@ -9,6 +9,7 @@ import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.enums.BusinessType;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.framework.web.service.WxLoginService;
 import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.UserWxFollow;
@@ -18,6 +19,7 @@ import com.zhongzheng.modules.user.service.IUserVisitLogService;
 import com.zhongzheng.modules.user.service.IUserWxFollowService;
 import com.zhongzheng.modules.user.vo.RanKingUser;
 import com.zhongzheng.modules.user.vo.UserVo;
+import com.zhongzheng.modules.wx.bo.WxLoginBody;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -48,7 +50,7 @@ public class UserController extends BaseController {
 
     private final IUserVisitLogService iUserVisitLogService;
 
-
+    private final WxLoginService wxLoginService;
     /**
      * 修改客户端用户
      */
@@ -157,4 +159,24 @@ public class UserController extends BaseController {
         }
         return AjaxResult.success(needUpdate);
     }
+
+    @ApiOperation("购买前获取公众号openid")
+    @PostMapping("/gzh_bind")
+    public AjaxResult gzh_bind(@RequestBody WxLoginBody loginBody)
+    {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        loginBody.setUserId(loginUser.getUser().getUserId());
+        wxLoginService.bindWxGzhUnionIdUser(loginBody);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("检查是否绑定公众号")
+    @PreAuthorize("@ss.hasPermi('system:user:list')")
+    @GetMapping("/checkBindGzh")
+    public AjaxResult<String> checkBindGzh()
+    {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        UserVo userVo = iUserService.queryById(loginUser.getUser().getUserId());
+        return AjaxResult.success("成功",userVo.getGzhOpenId());
+    }
 }

+ 21 - 12
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -625,12 +625,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         if(bo.getTel().length()!=11){
             throw new CustomException("手机号格式错误");
         }
-        if(bo.getIdcard()==null){
-            throw new CustomException("身份证不能为空");
-        }
-        if(bo.getIdcard().length()!=18){
-            throw new CustomException("身份证格式错误");
-        }
+//        if(bo.getIdcard()==null){
+//            throw new CustomException("身份证不能为空");
+//        }
+//        if(bo.getIdcard().length()!=18){
+//            throw new CustomException("身份证格式错误");
+//        }
 //        if(bo.getRealname()==null){
 //            throw new CustomException("真实姓名不能为空");
 //        }
@@ -654,7 +654,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
         inertData.setUserAccount(String.valueOf(idWorker.nextId()));
         inertData.setSex(1);
-        inertData.setIdCard(bo.getIdcard());
+        if (ObjectUtils.isNotNull(bo.getIdcard())){
+            inertData.setIdCard(bo.getIdcard());
+        }
         inertData.setRealname(bo.getRealname());
         inertData.setStatus(1);
         inertData.setRegisterPlat(bo.getRegisterPlat());
@@ -665,7 +667,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         inertData.setCreateTime(DateUtils.getNowTime());
         inertData.setUpdateTime(DateUtils.getNowTime());
 //        String pwd =  ToolsUtils.getSmsCode(); // 随机密码
-        String pwd =  bo.getIdcard().substring(bo.getIdcard().length() - 6);
+        String pwd = "";
+        if (ObjectUtils.isNotNull(bo.getIdcard())){
+            pwd =  bo.getIdcard().substring(bo.getIdcard().length() - 6);
+        }else {
+            pwd =  bo.getTel().substring(bo.getTel().length() - 6);
+        }
         inertData.setPassword(SecurityUtils.encryptPassword(pwd));
         if(!save(inertData)){
             throw new CustomException("注册失败");
@@ -887,9 +894,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
             if(Validator.isEmpty(bo.getTelphone())){
                 throw new CustomException("用户手机号码缺失");
             }
-            if(Validator.isEmpty(bo.getIdCard())){
-                throw new CustomException("用户身份证号码缺失");
-            }
+//            if(Validator.isEmpty(bo.getIdCard())){
+//                throw new CustomException("用户身份证号码缺失");
+//            }
             User user1 = getOne(new LambdaQueryWrapper<User>()
                     .eq(User::getTelphone,EncryptHandler.encrypt(bo.getTelphone())).last("limit 1"));
             //手机号码存在
@@ -900,7 +907,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
                 }
                 if(Validator.isEmpty(user1.getIdCard())){
                     //更新身份证和姓名
-                    user1.setIdCard(bo.getIdCard());
+                    if (ObjectUtil.isNotNull(bo.getIdCard())){
+                        user1.setIdCard(bo.getIdCard());
+                    }
                     user1.setRealname(bo.getRealname());
                     updateById(user1);
                 }

+ 32 - 1
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/WxLoginService.java

@@ -27,6 +27,7 @@ import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import com.zhongzheng.modules.order.domain.Order;
 import com.zhongzheng.modules.system.service.ISysConfigService;
 import com.zhongzheng.modules.user.bo.UserWxFollowAddBo;
 import com.zhongzheng.modules.user.domain.User;
@@ -1206,7 +1207,6 @@ public class WxLoginService implements IWxLoginService {
         initData();
         String param = String.format(gzh_wxAuthParam, gzh_appid, gzh_appsrcret, loginBody.getCode());
         String resultString = HttpUtils.sendGet(gzh_wxAuthUrl, param);
-        System.out.println(resultString);
         //解析json
         JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
         String access_token = String.valueOf(jsonObject.get("access_token"));
@@ -1232,6 +1232,37 @@ public class WxLoginService implements IWxLoginService {
         return user;
     }
 
+    //公众号获取用户信息
+    public User bindWxGzhUnionIdUser(WxLoginBody loginBody) {
+        initData();
+        String param = String.format(gzh_wxAuthParam, gzh_appid, gzh_appsrcret, loginBody.getCode());
+        String resultString = HttpUtils.sendGet(gzh_wxAuthUrl, param);
+        //解析json
+        JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
+        String access_token = String.valueOf(jsonObject.get("access_token"));
+        if(access_token.equals("null")){
+            throw new CustomException( String.valueOf(jsonObject.get("errmsg")));
+        }
+        String openId = String.valueOf(jsonObject.get("openid"));
+
+        String userInfoParam = String.format(gzh_wxUserInfoParam, access_token, openId);
+        String userInfoResultString = HttpUtils.sendGet(gzh_wxUserInfoUrl, userInfoParam);
+
+        //解析json
+        JSONObject jsonObject1 = (JSONObject) JSONObject.parse(userInfoResultString);
+        String unionId = String.valueOf(jsonObject1.get("unionid"));
+        User user = iUserService.getOne(new LambdaQueryWrapper<User>().eq(User::getUserId,loginBody.getUserId()));
+        if (user == null) {
+            throw new CustomException("您尚未注册,请前往小程序注册");
+        }
+        if (!Validator.isNotNull(user.getGzhOpenId())) {
+            user.setGzhOpenId(openId);
+            user.setUnionId(unionId);
+            iUserService.updateById(user);
+        }
+        return user;
+    }
+
     public String obtainWxPhone(String iv, String encryptedData, String session_key) {
         String userInfo = null;
         JSONObject userInfoJSON = null;

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/bo/ClassGradeUserQueryBo.java

@@ -236,6 +236,7 @@ public class ClassGradeUserQueryBo extends BaseEntity {
 	@ApiModelProperty("学员身份证")
 	private String idCard;
 
+
 	/**
 	 * 学员身份证集合
 	 */

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeUserMapper.java

@@ -28,6 +28,8 @@ public interface ClassGradeUserMapper extends BaseMapper<ClassGradeUser> {
 
     List<ClassPeriodStudentVo> listUserPeriod(ClassGradeUserQueryBo bo);
 
+    List<ClassPeriodStudentVo> listUserVideoRecord(ClassGradeUserQueryBo bo);
+
     List<ClassPeriodStudentVo> listUserPeriodExport(ClassGradeUserQueryBo bo);
 
     List<ClassPeriodUserVo> listPeriod(ClassGradeUserQueryBo bo);

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IClassGradeUserService.java

@@ -84,6 +84,8 @@ public interface IClassGradeUserService extends IService<ClassGradeUser> {
 
 	List<ClassPeriodStudentVo> listUserPeriodRecord(ClassGradeUserQueryBo bo);
 
+	List<ClassPeriodStudentVo> listUserVideoRecord(ClassGradeUserQueryBo bo);
+
 	List<UserPeriodExportVo> listUserStudyRecord(ClassGradeUserQueryBo bo);
 
 	List<UserPeriodExportV2Vo> listUserStudyRecordV2(ClassGradeUserQueryBo bo);

+ 15 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -1219,6 +1219,21 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         return classPeriodStudentVos;
     }
 
+    @Override
+    public List<ClassPeriodStudentVo> listUserVideoRecord(ClassGradeUserQueryBo bo) {
+        //查询班级学员信息
+        List<ClassPeriodStudentVo> classPeriodStudentVos = baseMapper.listUserVideoRecord(bo);
+        //查找学员学习记录
+        for (ClassPeriodStudentVo classPeriodStudentVo : classPeriodStudentVos) {
+            //取学时所有拍照最新的一张
+             String recentPhoto = userStudyRecordPhotoMapper.selectGradeRecentOnePhoto(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGradeId());
+           if (Validator.isNotEmpty(recentPhoto)) {
+                classPeriodStudentVo.setIdCardImg1(recentPhoto);
+            }
+        }
+        return classPeriodStudentVos;
+    }
+
     private Integer changePeriodStatus(Long gradePeriodStatus) {
         //當前班級學員審核狀態 -1不可审核 0待審  1未通过 2通过 3审核中
         //班级里的审核状态字段,保持一致 0 未通过 1通过 2待审核 -1 不可审核 3审核中

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/vo/ClassPeriodStudentVo.java

@@ -205,4 +205,20 @@ public class ClassPeriodStudentVo {
 	@ApiModelProperty("学时通过时间")
 	private Long periodTime;
 
+	@Excel(name = "节名称")
+	@ApiModelProperty("节名称")
+	private String sectionName;
+	@Excel(name = "公司名称")
+	@ApiModelProperty("公司名称")
+	private String companyName;
+	@Excel(name = "节时长")
+	@ApiModelProperty("节时长")
+	private String durationTime;
+
+	@ApiModelProperty("学习开始时间")
+	private Long recordStartTime;
+	@ApiModelProperty("学习结束时间")
+	private Long recordEndTime;
+	@ApiModelProperty("最近在线时间")
+	private Long onLineTime;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/bo/WxLoginBody.java

@@ -51,4 +51,7 @@ public class WxLoginBody {
     @ApiModelProperty("身份证号码")
     private String idcard;
 
+    @ApiModelProperty("用户ID")
+    private Long userId;
+
 }

+ 37 - 0
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml

@@ -124,6 +124,12 @@
         <result property="serviceEndTime" column="service_end_time"/>
         <result property="oneInchPhotos" column="one_inch_photos"/>
         <result property="periodTime" column="period_time"/>
+        <result property="sectionName" column="section_name"/>
+        <result property="companyName" column="company_name"/>
+        <result property="durationTime" column="duration_time"/>
+        <result property="recordStartTime" column="record_start_time"/>
+        <result property="recordEndTime" column="record_end_time"/>
+        <result property="onLineTime" column="on_line_time"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodUserVo" id="ClassPeriodUserVo">
@@ -316,6 +322,37 @@
         order by u.create_time desc
     </select>
 
+    <select id="listUserVideoRecord" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
+            resultMap="ClassPeriodStudentVo">
+        SELECT
+            up.* ,cg.class_name,cs.duration_time,u.id_card,u.realname,u.one_inch_photos,u.company_name,cs.`name` as section_name,ups.record_start_time,ups.record_end_time,ups.update_time as on_line_time
+        FROM
+            user_period up
+                LEFT JOIN user_period_status ups ON up.id = ups.period_id
+                LEFT JOIN class_grade cg on up.grade_id = cg.grade_id
+                LEFT JOIN  goods g ON up.goods_id = g.goods_id
+                LEFT JOIN course_section cs ON up.section_id = cs.section_id
+                LEFT JOIN `user` u ON up.user_id = u.user_id
+        WHERE
+            up.grade_id > 0  and up.type = 1
+        <if test="businessId != null and businessId != ''">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND g.education_type_id = #{educationTypeId}
+        </if>
+        <if test="realname != null and realname != ''">
+            AND u.realname = #{realname}
+        </if>
+        <if test="idCard != null and idCard != ''">
+            AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+        </if>
+        <if test="companyName != null and companyName != ''">
+            AND u.company_name = #{companyName}
+        </if>
+        order by up.create_time desc
+    </select>
+
 
     <select id="listUserPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
             resultMap="ClassPeriodStudentVo">