This commit is contained in:
huangdeliang 2021-04-29 20:59:14 +08:00
parent ec71568749
commit 8e260f9d39
2 changed files with 42 additions and 35 deletions

View File

@ -1,9 +1,6 @@
package com.stdiet.web.controller.custom; package com.stdiet.web.controller.custom;
import com.aliyun.vod20170321.models.GetPlayInfoResponseBody; 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.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
import com.stdiet.common.core.page.TableDataInfo; 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.dto.response.NutritionalVideoResponse;
import com.stdiet.custom.page.WxLogInfo; import com.stdiet.custom.page.WxLogInfo;
import com.stdiet.custom.service.*; import com.stdiet.custom.service.*;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -100,6 +96,7 @@ public class WechatAppletController extends BaseController {
/** /**
* 同步客户信息 * 同步客户信息
*
* @param sysWxUserInfo * @param sysWxUserInfo
* @return * @return
*/ */
@ -116,10 +113,10 @@ public class WechatAppletController extends BaseController {
} else { } else {
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo); sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
} }
Map<String,Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
//根据手机号查询返回用户加密ID //根据手机号查询返回用户加密ID
SysCustomer customer = sysCustomerService.getCustomerByPhone(sysWxUserInfo.getPhone()); 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(); SysMessageNotice messageParam = new SysMessageNotice();
messageParam.setReadType(0); messageParam.setReadType(0);
@ -337,9 +334,9 @@ public class WechatAppletController extends BaseController {
@GetMapping(value = "/getCustomerMessage") @GetMapping(value = "/getCustomerMessage")
public TableDataInfo getCustomerMessage(SysMessageNotice sysMessageNotice) { public TableDataInfo getCustomerMessage(SysMessageNotice sysMessageNotice) {
startPage(); startPage();
if(StringUtils.isNotEmpty(sysMessageNotice.getCustomerId())){ if (StringUtils.isNotEmpty(sysMessageNotice.getCustomerId())) {
sysMessageNotice.setMessageCustomer(Long.parseLong(AesUtils.decrypt(sysMessageNotice.getCustomerId(), null))); sysMessageNotice.setMessageCustomer(Long.parseLong(AesUtils.decrypt(sysMessageNotice.getCustomerId(), null)));
}else{ } else {
sysMessageNotice.setMessageCustomer(0L); sysMessageNotice.setMessageCustomer(0L);
} }
List<MessageNoticeResponse> list = sysMessageNoticeService.getCustomerMessage(sysMessageNotice); List<MessageNoticeResponse> list = sysMessageNoticeService.getCustomerMessage(sysMessageNotice);
@ -350,7 +347,7 @@ public class WechatAppletController extends BaseController {
* 更新用户通知消息已读状态 * 更新用户通知消息已读状态
*/ */
@GetMapping(value = "/updateMessageReadStatus") @GetMapping(value = "/updateMessageReadStatus")
public AjaxResult updateMessageReadStatus(@RequestParam("id")Long id) { public AjaxResult updateMessageReadStatus(@RequestParam("id") Long id) {
SysMessageNotice sysMessageNotice = new SysMessageNotice(); SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setReadType(1); sysMessageNotice.setReadType(1);
sysMessageNotice.setId(id); sysMessageNotice.setId(id);
@ -366,7 +363,7 @@ public class WechatAppletController extends BaseController {
startPage(); startPage();
//int total = 0; //int total = 0;
//List<NutritionalVideoResponse> nutritionalVideoList = new ArrayList<>(); //List<NutritionalVideoResponse> nutritionalVideoList = new ArrayList<>();
try{ try {
/**GetVideoListResponseBody videoListResponseBody = AliyunVideoUtils.getVideoListByPage(null, "Normal", 1, 10); /**GetVideoListResponseBody videoListResponseBody = AliyunVideoUtils.getVideoListByPage(null, "Normal", 1, 10);
if(videoListResponseBody != null){ if(videoListResponseBody != null){
total = videoListResponseBody.total; total = videoListResponseBody.total;
@ -388,7 +385,7 @@ public class WechatAppletController extends BaseController {
sysNutritionalVideo.setShowFlag(1); sysNutritionalVideo.setShowFlag(1);
List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo); List<SysNutritionalVideo> list = sysNutritionalVideoService.selectSysNutritionalVideoList(sysNutritionalVideo);
return getDataTable(list); return getDataTable(list);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
@ -402,13 +399,13 @@ public class WechatAppletController extends BaseController {
public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) { public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) {
AjaxResult result = AjaxResult.success(); AjaxResult result = AjaxResult.success();
NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse();
try{ try {
SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId); SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId);
if(sysNutritionalVideo != null){ if (sysNutritionalVideo != null) {
GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId); GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId);
//GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId); //GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId);
List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo; List<GetPlayInfoResponseBody.GetPlayInfoResponseBodyPlayInfoListPlayInfo> playList = playInfoResponseBody.playInfoList.playInfo;
if(playList != null && playList.size() > 0){ if (playList != null && playList.size() > 0) {
nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL());
} }
nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription()); nutritionalVideoResponse.setDescription(sysNutritionalVideo.getDescription());
@ -416,7 +413,7 @@ public class WechatAppletController extends BaseController {
nutritionalVideoResponse.setTitle(sysNutritionalVideo.getTitle()); nutritionalVideoResponse.setTitle(sysNutritionalVideo.getTitle());
nutritionalVideoResponse.setCreateTime(DateUtils.dateTime(sysNutritionalVideo.getCreateTime())); nutritionalVideoResponse.setCreateTime(DateUtils.dateTime(sysNutritionalVideo.getCreateTime()));
} }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
result.put("videoDetail", nutritionalVideoResponse); result.put("videoDetail", nutritionalVideoResponse);
@ -431,11 +428,13 @@ public class WechatAppletController extends BaseController {
SysWxUserInfo curWxUserInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserInfo.getOpenid()); SysWxUserInfo curWxUserInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserInfo.getOpenid());
// 第一次尝试匹配搜索sys_wx_user_info表尝试查找cus_id此时不需要手机号 // 第一次尝试匹配搜索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没有创建用户信息 // 如果没找到任何信息此时为未登录过的新用户 || 没有cusId没有创建用户信息
return AjaxResult.error(5000, "需要手机号进一步匹配"); 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()); SysCustomer sysCustomer = iSysCustomerService.getCustomerByPhone(sysWxUserInfo.getPhone());
if (StringUtils.isNull(sysCustomer)) { if (StringUtils.isNull(sysCustomer)) {
return AjaxResult.error(5003, "未查到用户信息,请联系销售顾问"); return AjaxResult.error(5003, "未查到用户信息,请联系销售顾问");
@ -444,11 +443,15 @@ public class WechatAppletController extends BaseController {
if (StringUtils.isNull(curWxUserInfo)) { if (StringUtils.isNull(curWxUserInfo)) {
// 新增sys_wx_user_info // 新增sys_wx_user_info
sysWxUserInfo.setCusId(sysCustomer.getId()); sysWxUserInfo.setCusId(sysCustomer.getId());
sysWxUserInfo.setCreateTime(DateUtils.getNowDate());
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo); sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
} }
} }
// 更新sys_wx_user_info数据并返回一系列登录后的数据 // 更新sys_wx_user_info数据并返回一系列登录后的数据
curWxUserInfo.setUpdateTime(DateUtils.getNowDate());
sysWxUserInfoService.updateSysWxUserInfo(curWxUserInfo); sysWxUserInfoService.updateSysWxUserInfo(curWxUserInfo);
return AjaxResult.success(curWxUserInfo); return AjaxResult.success(curWxUserInfo);
}
} }

View File

@ -71,8 +71,12 @@ public class SysWxUserInfo {
private Date createTime; private Date createTime;
private String createBy;
private Date updateTime; private Date updateTime;
private String updateBy;
private String remark; private String remark;
} }