Your Name 3 年前
父节点
当前提交
1f24399e03

+ 13
- 0
src/main/java/com/yunzhi/marketing/common/CommConstant.java 查看文件

@@ -78,6 +78,11 @@ public class CommConstant {
78 78
      */
79 79
     public final static String FAVOR_ACTIVITY = "activity";
80 80
 
81
+    /**
82
+     * 课程点赞
83
+     */
84
+    public final static String FAVOR_CURRICULUM = "curriculum";
85
+
81 86
 
82 87
     /**
83 88
      * 兑换商品
@@ -923,4 +928,12 @@ public class CommConstant {
923 928
      * 系统参数  通知消息次时间间隔
924 929
      */
925 930
     public static final String SYSPARAM_NOTICE_MESSAGE_INTERVAL = "notice_message_interval";
931
+
932
+
933
+    /**
934
+     * 课程授权人员类型
935
+     */
936
+    public static final String CURRICULUM_TYPE_AGENT = "1";
937
+    public static final String CURRICULUM_TYPE_COUSULTANT = "2";
938
+    public static final String CURRICULUM_TYPE_COUSULTANT_AND_AGENT = "3";
926 939
 }

+ 62
- 15
src/main/java/com/yunzhi/marketing/common/WorkWxUtils.java 查看文件

@@ -11,6 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
11 11
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
12 12
 import org.springframework.stereotype.Component;
13 13
 
14
+import java.util.ArrayList;
15
+import java.util.HashMap;
16
+import java.util.List;
17
+
14 18
 @Slf4j
15 19
 @Component
16 20
 @EnableConfigurationProperties(WorkConfig.class)
@@ -31,12 +35,22 @@ public class WorkWxUtils {
31 35
     }
32 36
 
33 37
     /**
34
-     * 获取房间ID
38
+     * 依据手机号获取人员信息
39
+     * @param mobile
40
+     * @return
41
+     * @throws WxErrorException
42
+     */
43
+    public String getUserByPhone(String mobile) throws WxErrorException {
44
+        return wxCpService.getUserService().getUserId(mobile);
45
+    }
46
+
47
+    /**
48
+     * 获取人员直播房间列表
35 49
      * @param userId
36 50
      * @return
37 51
      * @throws Exception
38 52
      */
39
-    public JSONObject getLastLivingInfo(String userId) throws Exception {
53
+    public List<JSONObject> getLivingRoomsOfUser(String userId) throws Exception {
40 54
         if (StringUtils.isEmpty(userId)) {
41 55
             throw new Exception("未指定用户ID");
42 56
         }
@@ -44,21 +58,24 @@ public class WorkWxUtils {
44 58
         try {
45 59
             JSONObject params = new JSONObject();
46 60
             params.put("userid", userId);
47
-            params.put("limit", 10);
48
-            JSONObject result = post("/cgi-bin/living/get_user_all_livingid", params);
49
-            JSONArray lst = result.getJSONArray("livingid_list");
50
-            String livingId = lst.size() > 0 ? (String) lst.get(0) : null;
61
+            params.put("limit", 20);
62
+            JSONObject response = post("/cgi-bin/living/get_user_all_livingid", params);
63
+            JSONArray lst = response.getJSONArray("livingid_list");
51 64
 
52
-            if (!StringUtils.isEmpty(livingId)) {
53
-                JSONObject res = post("/cgi-bin/living/get_living_info?livingid="+StringUtils.urlEncode(livingId), null);
54
-                JSONObject liveInfo = res.getJSONObject("living_info");
55
-                if (null != liveInfo) {
56
-                    liveInfo.put("livingid", livingId);
65
+            List<JSONObject> rtn = new ArrayList<>();
66
+            if (lst.size() > 0) {
67
+                for (int i = 0; i < lst.size(); i++) {
68
+                    String livingId = lst.get(i).toString();
69
+                    JSONObject res = post("/cgi-bin/living/get_living_info?livingid="+StringUtils.urlEncode(livingId), null);
70
+                    JSONObject liveInfo = res.getJSONObject("living_info");
71
+                    if (null != liveInfo) {
72
+                        liveInfo.put("livingid", livingId);
73
+                        rtn.add(liveInfo);
74
+                    }
57 75
                 }
58
-                return  liveInfo;
59 76
             }
60 77
 
61
-            return null;
78
+            return rtn;
62 79
         } catch (WxErrorException e) {
63 80
             if (90601 == e.getError().getErrorCode()) {
64 81
                 throw new Exception("直播房间不存在");
@@ -71,6 +88,36 @@ public class WorkWxUtils {
71 88
         }
72 89
     }
73 90
 
91
+    /**
92
+     * 获取房间信息
93
+     * @param livingId
94
+     * @return
95
+     * @throws Exception
96
+     */
97
+    public JSONObject getLivingInfoById(String livingId) throws Exception {
98
+        if (StringUtils.isEmpty(livingId)) {
99
+            throw new Exception("未指定房间ID");
100
+        }
101
+
102
+        try {
103
+            JSONObject res = post("/cgi-bin/living/get_living_info?livingid="+StringUtils.urlEncode(livingId), null);
104
+            JSONObject liveInfo = res.getJSONObject("living_info");
105
+            if (null != liveInfo) {
106
+                liveInfo.put("livingid", livingId);
107
+            }
108
+            return  liveInfo;
109
+        } catch (WxErrorException e) {
110
+            if (90601 == e.getError().getErrorCode()) {
111
+                throw new Exception("直播房间不存在");
112
+            } else {
113
+                throw new Exception(String.format("获取直播间信息失败: %s", e.getError().getErrorMsg()));
114
+            }
115
+        } catch (Exception e) {
116
+            e.printStackTrace();
117
+            throw e;
118
+        }
119
+    }
120
+
74 121
     /**
75 122
      * 获取直播授权码
76 123
      * @param livingid
@@ -87,8 +134,8 @@ public class WorkWxUtils {
87 134
             JSONObject params = new JSONObject();
88 135
             params.put("livingid", livingid);
89 136
             params.put("openid", openid);
90
-            JSONObject result = post("/cgi-bin/living/get_living_code", params);
91
-            return result.getString("living_code");
137
+            JSONObject response = post("/cgi-bin/living/get_living_code", params);
138
+            return response.getString("living_code");
92 139
         } catch (WxErrorException e) {
93 140
             if (90601 == e.getError().getErrorCode()) {
94 141
                 throw new Exception("直播房间不存在");

+ 10
- 3
src/main/java/com/yunzhi/marketing/controller/TaLiveActivityController.java 查看文件

@@ -307,16 +307,16 @@ public class TaLiveActivityController extends BaseController {
307 307
     }
308 308
 
309 309
     @GetMapping("/wx/taLiveActivity/work/livingCode")
310
-    public ResponseBean getWorkLivingCode(@RequestParam("user") String user,
310
+    public ResponseBean getWorkLivingCode(@RequestParam("livingId") String livingId,
311 311
                                           HttpServletRequest request) {
312 312
         String openid = getOpenId(request);
313 313
         try {
314
-            JSONObject liveInfo = workWxUtils.getLastLivingInfo(user);
314
+            JSONObject liveInfo = workWxUtils.getLivingInfoById(livingId);
315 315
             if (null == liveInfo) {
316 316
                 return ResponseBean.error("未找到直播房间", ResponseBean.ERROR_UNAVAILABLE);
317 317
             }
318 318
 
319
-            String livingCode = workWxUtils.getLivingCode(liveInfo.getString("livingid"), openid);
319
+            String livingCode = workWxUtils.getLivingCode(livingId, openid);
320 320
             liveInfo.put("livingCode", livingCode);
321 321
 
322 322
             return ResponseBean.success(liveInfo);
@@ -324,4 +324,11 @@ public class TaLiveActivityController extends BaseController {
324 324
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
325 325
         }
326 326
     }
327
+
328
+    @GetMapping("/admin/taLiveActivity/work/rooms")
329
+    public ResponseBean getWorkLivingRooms(@RequestParam("phone") String phone,
330
+                                          HttpServletRequest request) throws Exception {
331
+        String userid = workWxUtils.getUserByPhone(phone);
332
+        return ResponseBean.success(workWxUtils.getLivingRoomsOfUser(userid));
333
+    }
327 334
 }

+ 1
- 0
src/main/java/com/yunzhi/marketing/service/ITaSaveService.java 查看文件

@@ -24,4 +24,5 @@ public interface ITaSaveService extends IService<TaSave> {
24 24
     List<String> getTargesOfPerson(String personId, String tagertType);
25 25
 
26 26
     TaSave getInfoBy(String personId, String tagertType, String savedTarget);
27
+
27 28
 }

+ 9
- 1
src/main/java/com/yunzhi/marketing/service/impl/TaUvServiceImpl.java 查看文件

@@ -12,6 +12,7 @@ import com.yunzhi.marketing.mapper.TaPersonMapper;
12 12
 import com.yunzhi.marketing.mapper.TaUvMapper;
13 13
 import com.yunzhi.marketing.service.ITaUvService;
14 14
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
15
+import com.yunzhi.marketing.xlk.mapper.CurriculumMapper;
15 16
 import org.springframework.beans.factory.annotation.Autowired;
16 17
 import org.springframework.stereotype.Service;
17 18
 
@@ -37,6 +38,9 @@ public class TaUvServiceImpl extends ServiceImpl<TaUvMapper, TaUv> implements IT
37 38
     @Autowired
38 39
     TaBuildingMapper buildingMapper;
39 40
 
41
+    @Autowired
42
+    CurriculumMapper curriculumMapper;
43
+
40 44
     @Override
41 45
     public ResponseBean saveData(String openid, String typeOf, String id) {
42 46
         List<TaPerson> persons = getPersonsByOpenId(openid);
@@ -84,10 +88,14 @@ public class TaUvServiceImpl extends ServiceImpl<TaUvMapper, TaUv> implements IT
84 88
         }
85 89
 
86 90
         // 如果是点赞置业, 则人员点赞 + 1
87
-        if (typeOf.equals(CommConstant.FAVOR_CONSULTANT)) {
91
+        if (CommConstant.FAVOR_CONSULTANT.equals(typeOf)) {
88 92
             taPersonMapper.setFieldIncrement(id,"hot_num", 1);
89 93
         }
90 94
 
95
+        if (CommConstant.FAVOR_CURRICULUM.equals(typeOf)) {
96
+            curriculumMapper.setFieldIncrement(id,"look_num", 1);
97
+        }
98
+
91 99
         return ResponseBean.success("");
92 100
     }
93 101
 

+ 49
- 17
src/main/java/com/yunzhi/marketing/xlk/controller/CurriculumController.java 查看文件

@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 7
 import com.yunzhi.marketing.base.BaseController;
8 8
 import com.yunzhi.marketing.base.ResponseBean;
9
+import com.yunzhi.marketing.common.CommConstant;
9 10
 import com.yunzhi.marketing.common.StringUtils;
10 11
 import com.yunzhi.marketing.entity.TaPerson;
12
+import com.yunzhi.marketing.entity.TaSave;
11 13
 import com.yunzhi.marketing.service.ITaPersonService;
14
+import com.yunzhi.marketing.service.ITaSaveService;
15
+import com.yunzhi.marketing.service.ITaUvService;
12 16
 import com.yunzhi.marketing.xlk.dto.CurriculumDTO;
13 17
 import com.yunzhi.marketing.xlk.entity.Brand;
14 18
 import com.yunzhi.marketing.xlk.entity.Video;
@@ -54,6 +58,12 @@ public class CurriculumController extends BaseController {
54 58
     @Autowired
55 59
     public ITaPersonService taPersonService;
56 60
 
61
+    @Autowired
62
+    public ITaUvService iTaUvService;
63
+
64
+    @Autowired
65
+    public ITaSaveService iTaSaveService;
66
+
57 67
 
58 68
     /**
59 69
      * 分页查询列表
@@ -199,22 +209,16 @@ public class CurriculumController extends BaseController {
199 209
     @ApiOperation(value = "wx-查询课程表列表", notes = "wx-查询课程表列表")
200 210
     @RequestMapping(value="/wx/curriculum",method= RequestMethod.GET)
201 211
     public ResponseBean wxCurriculumList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
202
-                                       @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
203
-                                       @RequestParam(value ="name",required = false) String name,
204
-                                       @RequestParam(value ="roleId",required = false) Integer roleId,
205
-                                       @RequestHeader("authorization") String token, HttpServletRequest request){
212
+                                         @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
213
+                                         @RequestParam(value ="name",required = false) String name,
214
+                                         @RequestHeader("authorization") String token,
215
+                                         HttpServletRequest request){
206 216
         ResponseBean responseBean = new ResponseBean();
217
+        TaPerson person = taPersonService.getById(getPersonId(request));
207 218
         try {
208 219
             //使用分页插件
209 220
             IPage<Curriculum> pg = new Page<>(pageNum, pageSize);
210
-            LambdaQueryWrapper<Curriculum> queryWrapper = new LambdaQueryWrapper<>();
211
-            queryWrapper.eq(Curriculum::getOrgId,getOrgId(request));
212
-            queryWrapper.eq(!StringUtils.isEmpty(name),Curriculum::getName,name);
213
-            queryWrapper.eq(null != roleId,Curriculum::getRoleId,roleId);
214
-            queryWrapper.orderByDesc(Curriculum::getWeight);
215
-            queryWrapper.orderByDesc(Curriculum::getCreatedTime);
216
-
217
-            IPage<Curriculum> result = iCurriculumService.page(pg, queryWrapper);
221
+            IPage<Curriculum> result = iCurriculumService.getWxList(pg, name, person);
218 222
             responseBean.addSuccess(result);
219 223
         }catch (Exception e){
220 224
             e.printStackTrace();
@@ -233,8 +237,8 @@ public class CurriculumController extends BaseController {
233 237
     @ApiOperation(value = "wx-查询我收藏的课程表列表", notes = "wx-查询我收藏的课程表列表")
234 238
     @RequestMapping(value="/wx/curriculum/save",method= RequestMethod.GET)
235 239
     public ResponseBean saveCurriculumList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
236
-                                         @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
237
-                                         @RequestHeader("authorization") String token, HttpServletRequest request){
240
+                                           @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
241
+                                           @RequestHeader("authorization") String token, HttpServletRequest request){
238 242
         ResponseBean responseBean = new ResponseBean();
239 243
         try {
240 244
 
@@ -261,12 +265,23 @@ public class CurriculumController extends BaseController {
261 265
     @ApiOperation(value = "wx-根据id查询课程表详情", notes = "wx-根据id查询课程表详情")
262 266
     @RequestMapping(value="/wx/curriculum/{id}",method= RequestMethod.GET)
263 267
     public ResponseBean curriculum(@PathVariable String id,
264
-                                      @RequestHeader("authorization") String token, HttpServletRequest request){
268
+                                   @RequestHeader("authorization") String token,
269
+                                   HttpServletRequest request){
265 270
         ResponseBean responseBean = new ResponseBean();
266 271
         try {
267 272
             Curriculum curriculum = iCurriculumService.getById(id);
268
-            curriculum.setLookNum(curriculum.getLookNum() + 1);
269
-            iCurriculumService.updateById(curriculum);
273
+            TaPerson person = taPersonService.getById(getPersonId(request));
274
+
275
+            if (!checkRights(person.getPersonType(), curriculum.getRoleId())) {
276
+                return ResponseBean.error("您暂无权限查看当前课程", ResponseBean.ERROR_UNAVAILABLE);
277
+            }
278
+
279
+            TaSave taSave = iTaSaveService.getInfoBy(getPersonId(request), CommConstant.FAVOR_CURRICULUM, id);
280
+            curriculum.setIsSaved(null != taSave);
281
+
282
+            // 记录 UV
283
+            iTaUvService.saveData(getOpenId(request), CommConstant.FAVOR_CURRICULUM, id);
284
+
270 285
             responseBean.addSuccess(curriculum);
271 286
         }catch (Exception e){
272 287
             e.printStackTrace();
@@ -275,4 +290,21 @@ public class CurriculumController extends BaseController {
275 290
         }
276 291
         return responseBean;
277 292
     }
293
+
294
+    private boolean checkRights(String personType, String requireRole) {
295
+        if (null == requireRole) {
296
+            return false;
297
+        }
298
+
299
+        switch (requireRole) {
300
+            case CommConstant.CURRICULUM_TYPE_COUSULTANT_AND_AGENT:
301
+                return CommConstant.PERSON_ESTATE_CHANNEL.equals(personType) || CommConstant.PERSON_REALTY_CONSULTANT.equals(personType);
302
+            case CommConstant.CURRICULUM_TYPE_COUSULTANT:
303
+                return CommConstant.PERSON_REALTY_CONSULTANT.equals(personType);
304
+            case CommConstant.CURRICULUM_TYPE_AGENT:
305
+                return CommConstant.PERSON_ESTATE_CHANNEL.equals(personType);
306
+            default:
307
+                return false;
308
+        }
309
+    }
278 310
 }

+ 5
- 1
src/main/java/com/yunzhi/marketing/xlk/entity/Curriculum.java 查看文件

@@ -113,5 +113,9 @@ public class Curriculum implements java.io.Serializable {
113 113
      */
114 114
     private Integer isPublish;
115 115
 
116
-
116
+    /**
117
+     * 是否收藏
118
+     */
119
+    @TableField(exist = false)
120
+    private Boolean isSaved;
117 121
 }

+ 6
- 0
src/main/java/com/yunzhi/marketing/xlk/mapper/CurriculumMapper.java 查看文件

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6 6
 import org.apache.ibatis.annotations.Mapper;
7 7
 import org.apache.ibatis.annotations.Param;
8 8
 
9
+import java.util.List;
10
+
9 11
 /**
10 12
  * <p>
11 13
  * 课程表  Mapper 接口
@@ -17,5 +19,9 @@ import org.apache.ibatis.annotations.Param;
17 19
 @Mapper
18 20
 public interface CurriculumMapper extends BaseMapper<Curriculum> {
19 21
 
22
+    IPage<Curriculum> getWxList(IPage<Curriculum> pg, @Param("orgId") Integer orgId, @Param("name") String name, @Param("roleList") List<String> roleList);
23
+
20 24
     IPage<Curriculum> selectMySaveList(IPage<Curriculum> pg,@Param("personId") String personId);
25
+
26
+    int setFieldIncrement(@Param("curriculumId") String curriculumId, @Param("field") String field, @Param("increment") int increment);
21 27
 }

+ 2
- 0
src/main/java/com/yunzhi/marketing/xlk/service/ICurriculumService.java 查看文件

@@ -24,4 +24,6 @@ public interface ICurriculumService extends IService<Curriculum> {
24 24
      * @return
25 25
      */
26 26
     IPage<Curriculum> selectMySaveList(Integer pageNum, Integer pageSize, TaPerson person);
27
+
28
+    IPage<Curriculum> getWxList(IPage<Curriculum> pg, String name, TaPerson person);
27 29
 }

+ 21
- 0
src/main/java/com/yunzhi/marketing/xlk/service/impl/CurriculumServiceImpl.java 查看文件

@@ -2,6 +2,7 @@ package com.yunzhi.marketing.xlk.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.yunzhi.marketing.common.CommConstant;
5 6
 import com.yunzhi.marketing.entity.TaPerson;
6 7
 import com.yunzhi.marketing.xlk.entity.Curriculum;
7 8
 import com.yunzhi.marketing.xlk.mapper.CurriculumMapper;
@@ -10,6 +11,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10 11
 import com.yunzhi.marketing.xlk.vo.SearchHouseVO;
11 12
 import org.springframework.stereotype.Service;
12 13
 
14
+import java.util.ArrayList;
15
+import java.util.List;
16
+
13 17
 /**
14 18
  * <p>
15 19
  * 课程表  服务实现类
@@ -35,4 +39,21 @@ public class CurriculumServiceImpl extends ServiceImpl<CurriculumMapper, Curricu
35 39
         IPage<Curriculum> result = this.baseMapper.selectMySaveList(pg,person.getPersonId());
36 40
         return result;
37 41
     }
42
+
43
+    @Override
44
+    public IPage<Curriculum> getWxList(IPage<Curriculum> pg, String name, TaPerson person) {
45
+        List<String> roleList = new ArrayList<>();
46
+        if (CommConstant.PERSON_REALTY_CONSULTANT.equals(person.getPersonType())) {
47
+            roleList.add(CommConstant.CURRICULUM_TYPE_COUSULTANT);
48
+            roleList.add(CommConstant.CURRICULUM_TYPE_COUSULTANT_AND_AGENT);
49
+        } else if (CommConstant.PERSON_ESTATE_CHANNEL.equals(person.getPersonType())) {
50
+            roleList.add(CommConstant.CURRICULUM_TYPE_AGENT);
51
+            roleList.add(CommConstant.CURRICULUM_TYPE_COUSULTANT_AND_AGENT);
52
+        } else {
53
+            roleList.add("*");
54
+        }
55
+
56
+        IPage<Curriculum> result = this.baseMapper.getWxList(pg, person.getOrgId(), name, roleList);
57
+        return result;
58
+    }
38 59
 }

+ 27
- 4
src/main/resources/mapper/xlk/CurriculumMapper.xml 查看文件

@@ -1,15 +1,38 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.marketing.xlk.mapper.CurriculumMapper">
4
+    <update id="setFieldIncrement">
5
+        UPDATE xlk_curriculum
6
+        SET ${field} = IFNULL(${field}, 0) + #{increment}
7
+        WHERE curriculum_id = #{curriculumId}
8
+    </update>
4 9
 
5 10
     <select id="selectMySaveList" resultType="com.yunzhi.marketing.xlk.entity.Curriculum">
11
+        SELECT
12
+            x.*
13
+        FROM
14
+            ta_save t
15
+                LEFT JOIN xlk_curriculum x ON t.save_id = x.curriculum_id
16
+        WHERE
17
+            t.saved_target = "curriculum"
18
+          AND t.person_id = #{personId}
19
+    </select>
20
+
21
+    <select id="getWxList" resultType="com.yunzhi.marketing.xlk.entity.Curriculum">
6 22
         SELECT
7 23
         x.*
8 24
         FROM
9
-        ta_save t
10
-        LEFT JOIN xlk_curriculum x ON t.save_id = x.curriculum_id
25
+        xlk_curriculum x
11 26
         WHERE
12
-        t.saved_target = "curriculum"
13
-        AND t.person_id = #{personId}
27
+        x.ORG_ID = #{orgId}
28
+        AND x.is_publish = 1
29
+        <if test="name != null and name != ''">
30
+            AND x.`name` like concat('%', #{name},'%')
31
+        </if>
32
+        AND x.role_id in
33
+        <foreach collection="roleList" item="role" open="(" close=")" separator=",">
34
+            #{role}
35
+        </foreach>
36
+        ORDER BY x.WEIGHT DESC, CREATED_TIME DESC
14 37
     </select>
15 38
 </mapper>