From 8e260f9d392990940a7d7a03efad61b983e25ff2 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Thu, 29 Apr 2021 20:59:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/WechatAppletController.java | 73 ++++++++++--------- .../stdiet/custom/domain/SysWxUserInfo.java | 4 + 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java index 59a48e8cf..11367381b 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java @@ -1,9 +1,6 @@ package com.stdiet.web.controller.custom; import com.aliyun.vod20170321.models.GetPlayInfoResponseBody; -import com.aliyun.vod20170321.models.GetVideoInfoResponseBody; -import com.aliyun.vod20170321.models.GetVideoListResponseBody; -import com.itextpdf.io.util.DateTimeUtil; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.page.TableDataInfo; @@ -21,7 +18,6 @@ import com.stdiet.custom.dto.response.MessageNoticeResponse; import com.stdiet.custom.dto.response.NutritionalVideoResponse; import com.stdiet.custom.page.WxLogInfo; import com.stdiet.custom.service.*; -import org.aspectj.weaver.loadtime.Aj; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -100,6 +96,7 @@ public class WechatAppletController extends BaseController { /** * 同步客户信息 + * * @param sysWxUserInfo * @return */ @@ -116,10 +113,10 @@ public class WechatAppletController extends BaseController { } else { sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo); } - Map result = new HashMap<>(); + Map result = new HashMap<>(); //根据手机号查询返回用户加密ID SysCustomer customer = sysCustomerService.getCustomerByPhone(sysWxUserInfo.getPhone()); - result.put("customerId", customer != null ? AesUtils.encrypt(customer.getId()+"", null) : null); + result.put("customerId", customer != null ? AesUtils.encrypt(customer.getId() + "", null) : null); //查询未读消息数量 SysMessageNotice messageParam = new SysMessageNotice(); messageParam.setReadType(0); @@ -337,9 +334,9 @@ public class WechatAppletController extends BaseController { @GetMapping(value = "/getCustomerMessage") public TableDataInfo getCustomerMessage(SysMessageNotice sysMessageNotice) { startPage(); - if(StringUtils.isNotEmpty(sysMessageNotice.getCustomerId())){ + if (StringUtils.isNotEmpty(sysMessageNotice.getCustomerId())) { sysMessageNotice.setMessageCustomer(Long.parseLong(AesUtils.decrypt(sysMessageNotice.getCustomerId(), null))); - }else{ + } else { sysMessageNotice.setMessageCustomer(0L); } List list = sysMessageNoticeService.getCustomerMessage(sysMessageNotice); @@ -350,7 +347,7 @@ public class WechatAppletController extends BaseController { * 更新用户通知消息已读状态 */ @GetMapping(value = "/updateMessageReadStatus") - public AjaxResult updateMessageReadStatus(@RequestParam("id")Long id) { + public AjaxResult updateMessageReadStatus(@RequestParam("id") Long id) { SysMessageNotice sysMessageNotice = new SysMessageNotice(); sysMessageNotice.setReadType(1); sysMessageNotice.setId(id); @@ -366,29 +363,29 @@ public class WechatAppletController extends BaseController { startPage(); //int total = 0; //List nutritionalVideoList = new ArrayList<>(); - try{ + try { /**GetVideoListResponseBody videoListResponseBody = AliyunVideoUtils.getVideoListByPage(null, "Normal", 1, 10); - if(videoListResponseBody != null){ - total = videoListResponseBody.total; - for (GetVideoListResponseBody.GetVideoListResponseBodyVideoListVideo video : videoListResponseBody.videoList.video) { - NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); - nutritionalVideoResponse.setCoverURL(video.getCoverURL()); - nutritionalVideoResponse.setTitle(video.getTitle()); - nutritionalVideoResponse.setVideoId(video.getVideoId()); - nutritionalVideoResponse.setDescription(video.getDescription()); - nutritionalVideoResponse.setTags(video.getTags()); - nutritionalVideoList.add(nutritionalVideoResponse); - System.out.println(video.getVideoId()); - System.out.println(video.getCoverURL()); - System.out.println(video.getTitle()); - System.out.println(video.getDescription()); - } - } - System.out.println();**/ + if(videoListResponseBody != null){ + total = videoListResponseBody.total; + for (GetVideoListResponseBody.GetVideoListResponseBodyVideoListVideo video : videoListResponseBody.videoList.video) { + NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); + nutritionalVideoResponse.setCoverURL(video.getCoverURL()); + nutritionalVideoResponse.setTitle(video.getTitle()); + nutritionalVideoResponse.setVideoId(video.getVideoId()); + nutritionalVideoResponse.setDescription(video.getDescription()); + nutritionalVideoResponse.setTags(video.getTags()); + nutritionalVideoList.add(nutritionalVideoResponse); + System.out.println(video.getVideoId()); + System.out.println(video.getCoverURL()); + System.out.println(video.getTitle()); + System.out.println(video.getDescription()); + } + } + System.out.println();**/ sysNutritionalVideo.setShowFlag(1); List list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo); return getDataTable(list); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } return null; @@ -402,13 +399,13 @@ public class WechatAppletController extends BaseController { public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) { AjaxResult result = AjaxResult.success(); NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); - try{ + try { SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId); - if(sysNutritionalVideo != null){ + if (sysNutritionalVideo != null) { GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId); //GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId); List playList = playInfoResponseBody.playInfoList.playInfo; - if(playList != null && playList.size() > 0){ + if (playList != null && playList.size() > 0) { nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); } nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription()); @@ -416,7 +413,7 @@ public class WechatAppletController extends BaseController { nutritionalVideoResponse.setTitle(sysNutritionalVideo.getTitle()); nutritionalVideoResponse.setCreateTime(DateUtils.dateTime(sysNutritionalVideo.getCreateTime())); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } result.put("videoDetail", nutritionalVideoResponse); @@ -431,11 +428,13 @@ public class WechatAppletController extends BaseController { SysWxUserInfo curWxUserInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserInfo.getOpenid()); // 第一次尝试匹配,搜索sys_wx_user_info表,尝试查找cus_id,此时不需要手机号 - if (StringUtils.isEmpty(sysWxUserInfo.getPhone()) && StringUtils.isNull(curWxUserInfo) || StringUtils.isNull(curWxUserInfo.getCusId())) { + if (StringUtils.isEmpty(sysWxUserInfo.getPhone()) && (StringUtils.isNull(curWxUserInfo) || StringUtils.isNull(curWxUserInfo.getCusId()))) { // 如果没找到任何信息,此时为未登录过的新用户 || 没有cusId,没有创建用户信息 return AjaxResult.error(5000, "需要手机号进一步匹配"); - } else { - // 第二次尝试匹配,带上手机号,先去sys_customer查找,找到就更新sys_wx_user_info表,并返回一系列登录后的数据 + } + + // 第二次尝试匹配,带上手机号,先去sys_customer查找,找到就更新sys_wx_user_info表,并返回一系列登录后的数据 + if (StringUtils.isNotEmpty(sysWxUserInfo.getPhone())) { SysCustomer sysCustomer = iSysCustomerService.getCustomerByPhone(sysWxUserInfo.getPhone()); if (StringUtils.isNull(sysCustomer)) { return AjaxResult.error(5003, "未查到用户信息,请联系销售顾问"); @@ -444,11 +443,15 @@ public class WechatAppletController extends BaseController { if (StringUtils.isNull(curWxUserInfo)) { // 新增sys_wx_user_info sysWxUserInfo.setCusId(sysCustomer.getId()); + sysWxUserInfo.setCreateTime(DateUtils.getNowDate()); sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo); } } + // 更新sys_wx_user_info数据,并返回一系列登录后的数据 + curWxUserInfo.setUpdateTime(DateUtils.getNowDate()); sysWxUserInfoService.updateSysWxUserInfo(curWxUserInfo); return AjaxResult.success(curWxUserInfo); + } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserInfo.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserInfo.java index 671301b87..2dfeb9903 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserInfo.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxUserInfo.java @@ -71,8 +71,12 @@ public class SysWxUserInfo { private Date createTime; + private String createBy; + private Date updateTime; + private String updateBy; + private String remark; } \ No newline at end of file