package com.yc.sdk.miniapp.action;
|
|
import com.google.gson.JsonArray;
|
import com.google.gson.JsonObject;
|
import com.yc.action.BaseAction;
|
import com.yc.entity.DataSourceEntity;
|
import com.yc.entity.UserAccountEntity;
|
import com.yc.multiData.MultiDataSource;
|
import com.yc.multiData.SpObserver;
|
import com.yc.sdk.miniapp.entity.EducationEntity;
|
import com.yc.sdk.miniapp.entity.MaCompanyEntity;
|
import com.yc.sdk.miniapp.entity.OrganizationEntity;
|
import com.yc.sdk.miniapp.service.MaUserIfc;
|
import com.yc.sdk.shopping.action.api.MatCode;
|
import com.yc.sdk.shopping.action.api.ShopCcCode;
|
import com.yc.sdk.shopping.entity.DepartmentEntity;
|
import com.yc.sdk.shopping.entity.MatCodeEntity;
|
import com.yc.sdk.shopping.entity.SettingEntity;
|
import com.yc.sdk.shopping.entity.ShopCcCodeEntity;
|
import com.yc.sdk.shopping.service.MatCodeIfc;
|
import com.yc.sdk.shopping.service.SettingIfc;
|
import com.yc.sdk.shopping.service.department.DepartmentIfc;
|
import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc;
|
import com.yc.sdk.shopping.util.SettingKey;
|
import com.yc.sdk.weixincp.entity.MyWxCpUser;
|
import com.yc.sdk.weixincp.service.ERPUserIfc;
|
import com.yc.sdk.weixinmp.entity.MyWxMpUser;
|
import com.yc.service.user.UserAccountServiceIfc;
|
import com.yc.utils.SessionKey;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import javax.servlet.ServletException;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpSession;
|
import java.text.SimpleDateFormat;
|
import java.util.Arrays;
|
import java.util.List;
|
|
@Controller
|
public class MaCardUserInfo extends BaseAction{
|
@Autowired
|
ERPUserIfc erpUserIfc ;
|
@Autowired
|
MaUserIfc maUserIfc ;
|
@Autowired
|
SettingIfc settingIfc;
|
@Autowired
|
ShoppingImageDataIfc imgData;
|
@Autowired
|
UserAccountServiceIfc userAccountService;
|
@Autowired
|
DepartmentIfc departmentIfc ;
|
// 商品资料
|
@Autowired
|
MatCodeIfc matCodeIfc;
|
|
/**
|
* 获取我的名片列表
|
* @param request
|
* @param response
|
* @throws ServletException
|
*/
|
@RequestMapping("/wx/getCardUserList.do")
|
public void getCardUserList(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
HttpSession session=request.getSession();
|
|
//String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
// if (fromUserId == null || "".equals(fromUserId)) {
|
// errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
|
// json.add("error", errJson);
|
// this.printJson(response, json.toString());
|
// return;
|
// }
|
|
String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
if (dbId == null || "".equals(dbId)) {
|
dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
|
(String) session.getAttribute(SessionKey.DATA_BASE_ID));
|
}
|
String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
|
if (corpId == null || "".equals(corpId)) {
|
corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
|
}
|
if (corpId == null || "".equals(corpId)) {
|
corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
|
}
|
if (corpId == null || "".equals(corpId)) {
|
errJson.addProperty("warning","必须传递 AppId 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String openId = request.getParameter(SessionKey.WEIXIN_OPENID);
|
if (openId == null || "".equals(openId)) {
|
openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID);
|
}
|
if (openId == null|| "".equals(openId)) {
|
errJson.addProperty("warning", "必须传递 OpenId 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String hostUrl = SettingKey.getHostUrl(request) ;
|
DataSourceEntity dataSourceEntity = null ;
|
try {
|
dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
if (dataSourceEntity == null) {
|
errJson.addProperty("warning", "未找到数据源【"+ dbId+"】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
if (SpObserver.isDemoInstance("_"+dataSourceEntity.getDbId() )) {
|
errJson.addProperty("warning", "未找到数据源【"+ dataSourceEntity.getDbId()+"】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
}catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
|
try {
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
SettingEntity settingEntity = settingIfc.getSettingEntity(request) ;
|
|
//取网店 shopcccode
|
ShopCcCodeEntity shopCcCodeEntity = ShopCcCode.getShopCcCode(settingEntity,request);
|
|
//向后台导购发送AI提示消息
|
List<MyWxCpUser> userList = maUserIfc.getKeFuUserList(openId,shopCcCodeEntity.getShopCcCode()) ;
|
JsonArray matCodeJsonArray = new JsonArray();
|
for(int i = 0;userList !=null && i<userList.size();i++) {
|
MyWxCpUser myWxCpUser = userList.get(i) ;
|
JsonObject jsonObject = new JsonObject();
|
jsonObject.addProperty("UserId", myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId());
|
jsonObject.addProperty("Name", myWxCpUser.getName()==null?"":myWxCpUser.getName());
|
jsonObject.addProperty("Position", myWxCpUser.getPosition()==null?"":myWxCpUser.getPosition());
|
jsonObject.addProperty("Mobile", myWxCpUser.getMobile()==null?"":myWxCpUser.getMobile());
|
jsonObject.addProperty("Telephone", myWxCpUser.getTelephone()==null?"":myWxCpUser.getTelephone());
|
jsonObject.addProperty("WeiXinUserCode", myWxCpUser.getWeiXinUserCode()==null?"":myWxCpUser.getWeiXinUserCode());
|
jsonObject.addProperty("EMail", myWxCpUser.getEmail()==null?"":myWxCpUser.getEmail());
|
|
String defaultAvatar = myWxCpUser.getAvatar()==null?"":myWxCpUser.getAvatar() ;
|
|
if ((defaultAvatar==null||"".equals(defaultAvatar)) && myWxCpUser.getAvatarUnid() != null && !"".equals(myWxCpUser.getAvatarUnid())) {
|
defaultAvatar = imgData.getImageUrl(myWxCpUser.getAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
|
}
|
|
if (defaultAvatar==null||"".equals(defaultAvatar)) {
|
defaultAvatar = hostUrl + "/shopping/weixinby3rd/setting/image/defaultavatar.png" ;
|
}
|
|
jsonObject.addProperty("Avatar",defaultAvatar );
|
|
String companyName = "" ,address = "",longitude = "" ,latitude = "",industryTypeName = "",companyPhoto = "" ;
|
UserAccountEntity userAccount = userAccountService.getUserInfoByWeiXinCorpUserId(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId()) ;
|
DepartmentEntity departmentEntity = null ;
|
if (userAccount != null ) {
|
MaCompanyEntity maCompanyEntity = erpUserIfc.getMaCompanyEntity(userAccount.getCompanyId());
|
companyName = (maCompanyEntity.getCompanyName()==null?"":maCompanyEntity.getCompanyName()+" ") ;
|
address = (maCompanyEntity.getAddress()==null?"":maCompanyEntity.getAddress()) ;
|
longitude = maCompanyEntity.getLongitude()==null?"":maCompanyEntity.getLongitude() ;
|
latitude = maCompanyEntity.getLatitude()==null?"":maCompanyEntity.getLatitude() ;
|
companyPhoto = imgData.getImageUrl(maCompanyEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);
|
industryTypeName = erpUserIfc.getIndustryTypeName(maCompanyEntity.getCompanyId()) ;
|
if (userAccount.getCcCode()!=null && !"".equals(userAccount.getCcCode())) {
|
departmentEntity = departmentIfc.getDepartmentByCcCode(userAccount.getCcCode()) ;
|
if (departmentEntity!= null) {
|
if (settingEntity.isStartupLeagueShopCcCode()) {
|
companyName = (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
|
companyPhoto = imgData.getImageUrl(departmentEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);
|
industryTypeName = erpUserIfc.getIndustryTypeName(userAccount.getCcCode()) ;
|
}else {
|
companyName += (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
|
}
|
address = (departmentEntity.getAddress()==null?"":departmentEntity.getAddress()) ;
|
longitude = departmentEntity.getLongitude()==null?"":departmentEntity.getLongitude() ;
|
latitude = departmentEntity.getLatitude()==null?"":departmentEntity.getLatitude() ;
|
}
|
}
|
}
|
jsonObject.addProperty("CompanyName", companyName) ;
|
jsonObject.addProperty("Address", address);
|
jsonObject.addProperty("Longitude", longitude);
|
jsonObject.addProperty("Latitude", latitude);
|
jsonObject.addProperty("CompanyPhoto", companyPhoto);
|
jsonObject.addProperty("IndustryTypeName", industryTypeName==null?"":industryTypeName);
|
|
String cardImage = imgData.getImageUrl(myWxCpUser.getCardImage(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);
|
jsonObject.addProperty("CardImage",cardImage );
|
|
matCodeJsonArray.add(jsonObject);
|
|
}
|
json.add("list", matCodeJsonArray);
|
json.addProperty("state", "success");
|
this.printJson(response, json.toString());
|
return;
|
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
|
/**
|
* 获取我的名片详细记录
|
* @param request
|
* @param response
|
* @throws ServletException
|
*/
|
@RequestMapping("/wx/getCardUserInfo.do")
|
public void getCardUserInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
HttpSession session=request.getSession();
|
|
|
|
String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
|
//String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
// if (fromUserId == null || "".equals(fromUserId)) {
|
// errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
|
// json.add("error", errJson);
|
// this.printJson(response, json.toString());
|
// return;
|
// }
|
|
String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
if (dbId == null || "".equals(dbId)) {
|
dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
|
(String) session.getAttribute(SessionKey.DATA_BASE_ID));
|
}
|
String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
|
if (corpId == null || "".equals(corpId)) {
|
corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
|
}
|
if (corpId == null || "".equals(corpId)) {
|
corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
|
}
|
if (corpId == null || "".equals(corpId)) {
|
errJson.addProperty("warning","必须传递 AppId 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
|
String cltCode = (String) session.getAttribute(SettingKey.CLTCODE) ;
|
String hostUrl = SettingKey.getHostUrl(request) ;
|
SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
|
try {
|
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
if (dataSourceEntity == null) {
|
errJson.addProperty("warning", "未找到数据源【"+ dbId+"】【CorpId:"+ corpId+ "】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
if (SpObserver.isDemoInstance("_"+dataSourceEntity.getDbId() )) {
|
errJson.addProperty("warning", "未找到数据源【"+ dataSourceEntity.getDbId()+"】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
SettingEntity settingEntity = settingIfc.getSettingEntity(request) ;
|
|
//如果传递了 UserRowId 参数,则认为是直播二维码带过来的 ,详细说明参考:SettingKey.FROMUSERROWID //此处注释掉,因为后面的代码要重新获取一次 FromUserId 参数
|
// if (fromUserRowId!=null && !"".equals(fromUserRowId) ) {
|
// fromUserId = null ;
|
// MyWxCpUser cpUser = erpUserIfc.getWorkAppUserByRowId(fromUserRowId);
|
// if (cpUser!= null) {
|
// fromUserId = cpUser.getUserId() ;
|
// }
|
// }
|
|
//获取导购信息用于发送AI雷达提示消息
|
MyWxCpUser myWxCpUser = maUserIfc.getSendAIMessageUser(fromUserId,dataSourceEntity.getSystemDescribe(),openId) ;
|
json.addProperty("UserId", myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId()); //名片 userid
|
json.addProperty("Name", myWxCpUser.getName()==null?"":myWxCpUser.getName()); //名片上的姓名
|
json.addProperty("Position", myWxCpUser.getPosition()==null?"":myWxCpUser.getPosition()); //职位
|
json.addProperty("Mobile", myWxCpUser.getMobile()==null?"":myWxCpUser.getMobile()); //手机
|
json.addProperty("Telephone", myWxCpUser.getTelephone()==null?"":myWxCpUser.getTelephone()); //办公电话
|
json.addProperty("WeiXinUserCode", myWxCpUser.getWeiXinUserCode()==null?"":myWxCpUser.getWeiXinUserCode()); //微信号
|
json.addProperty("EMail", myWxCpUser.getEmail()==null?"":myWxCpUser.getEmail()); //邮件
|
|
json.addProperty(SettingKey.FROMUSERROWID,myWxCpUser.getRowId()==null?"":myWxCpUser.getRowId()); //修改了 FROMUSERROWID 值
|
|
//取导购企业用户头像
|
String defaultAvatar = imgData.getImageUrl(myWxCpUser.getAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
|
|
|
if (fromUserId!=null&& !"".equals(fromUserId) && openId != null && !"".equals(openId)) {
|
//更新小程序用户“最近服务的客服” 和 “最近选择的联盟”
|
maUserIfc.updateLastUserIdAndShopCcCode(myWxCpUser.getUserId()!=null?myWxCpUser.getUserId():fromUserId,myWxCpUser.getShopCcCode(), openId);
|
}
|
|
//取导购企业用户头像
|
if ((defaultAvatar==null||"".equals(defaultAvatar)) && myWxCpUser.getAvatarUnid() != null && !"".equals(myWxCpUser.getAvatarUnid())) {
|
defaultAvatar = (myWxCpUser.getAvatar()==null?"":myWxCpUser.getAvatar() ); //imgData.getImageUrl(myWxCpUser.getAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
|
}
|
|
//取导购小程序用户的头像
|
if (defaultAvatar==null||"".equals(defaultAvatar)) {
|
MyWxMpUser shopGuideUser = maUserIfc.getUserByTelephone(myWxCpUser.getMobile()) ;
|
if (shopGuideUser !=null) {
|
defaultAvatar = imgData.getImageUrl(shopGuideUser.getWeiXinAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
|
if (defaultAvatar==null||"".equals(defaultAvatar)) {
|
defaultAvatar = shopGuideUser.getHeadImgUrl();
|
}
|
}
|
}
|
|
if (defaultAvatar==null||"".equals(defaultAvatar)) {
|
defaultAvatar = hostUrl + "/shopping/weixinby3rd/setting/image/defaultavatar.png" ;
|
}
|
|
json.addProperty("Avatar",defaultAvatar );
|
|
String companyName = "" ,address = "",longitude = "" ,latitude = "",industryTypeName = "",companyPhoto = "" ;
|
UserAccountEntity userAccount = userAccountService.getUserInfoByWeiXinCorpUserId(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId()) ;
|
DepartmentEntity departmentEntity = null ;
|
if (userAccount != null ) {
|
MaCompanyEntity maCompanyEntity = erpUserIfc.getMaCompanyEntity(userAccount.getCompanyId());
|
companyName = (maCompanyEntity.getCompanyName()==null?"":maCompanyEntity.getCompanyName()+" ") ;
|
address = (maCompanyEntity.getAddress()==null?"":maCompanyEntity.getAddress()) ;
|
longitude = maCompanyEntity.getLongitude()==null?"":maCompanyEntity.getLongitude() ;
|
latitude = maCompanyEntity.getLatitude()==null?"":maCompanyEntity.getLatitude() ;
|
companyPhoto = imgData.getImageUrl(maCompanyEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);
|
industryTypeName = erpUserIfc.getIndustryTypeName(maCompanyEntity.getCompanyId()) ;
|
if (userAccount.getCcCode()!=null && !"".equals(userAccount.getCcCode())) {
|
departmentEntity = departmentIfc.getDepartmentByCcCode(userAccount.getCcCode()) ;
|
if (departmentEntity!= null) {
|
if (settingEntity.isStartupLeagueShopCcCode()) {
|
companyName = (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
|
companyPhoto = imgData.getImageUrl(departmentEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);
|
industryTypeName = erpUserIfc.getIndustryTypeName(userAccount.getCcCode()) ;
|
}else {
|
//不用显示部门名称,Modified by Johns Wang,2020-06-10
|
//companyName += (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
|
}
|
address = (departmentEntity.getAddress()==null?"":departmentEntity.getAddress()) ;
|
longitude = departmentEntity.getLongitude()==null?"":departmentEntity.getLongitude() ;
|
latitude = departmentEntity.getLatitude()==null?"":departmentEntity.getLatitude() ;
|
}
|
}
|
}
|
json.addProperty("CompanyName", companyName) ; //公司名称
|
json.addProperty("Address", address); //地址
|
json.addProperty("Longitude", longitude); //坐标
|
json.addProperty("Latitude", latitude); //坐标
|
json.addProperty("CompanyPhoto", companyPhoto); //公司背景图
|
json.addProperty("IndustryTypeName", industryTypeName==null?"":industryTypeName); //所属行业
|
|
String cardImage = imgData.getImageUrl(myWxCpUser.getCardImage(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request); //名片背景图
|
json.addProperty("CardImage",cardImage ); //名片背景图
|
|
|
//取处理过的我的个人简介
|
request.setAttribute(SettingKey.FROMOPENID, openId);
|
String description = imgData.getDescriptionByNewImgLink(myWxCpUser.getDescription()==null?"":myWxCpUser.getDescription(), request) ;
|
json.addProperty("Description", description); //我的个人简介
|
json.addProperty("Hometown", myWxCpUser.getHometown()==null?"":myWxCpUser.getHometown()); //家乡
|
json.addProperty("HometownGreetings", myWxCpUser.getHometownGreetings()==null?"":myWxCpUser.getHometownGreetings()); //同乡问候语
|
boolean isHometown = maUserIfc.isHometown(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), openId) ;
|
json.addProperty("IsHometown",isHometown) ; //是否同乡
|
json.addProperty("HometownGreetingsImage",imgData.getImageUrl(settingEntity.getHometownGreetingsImage(), settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request) ) ; //同乡问候语图片
|
|
//我的标签
|
String myTags[] = (myWxCpUser.getMyTag()==null?"":myWxCpUser.getMyTag()).split(";") ;
|
JsonArray myTagJsonArray = new JsonArray();
|
for (int i = 0 ;i < myTags.length;i ++) {
|
JsonObject myTabJson = new JsonObject();
|
myTabJson.addProperty("MyTag" ,myTags[i] ) ;
|
Integer likeActionTimes = maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), null,"LikeMyTag",myTags[i]) ;
|
myTabJson.addProperty("LikeMyTagTimes" ,likeActionTimes ) ; //点赞总数
|
Integer likeMyTagForMe = maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), openId,"LikeMyTag",myTags[i]) ;
|
myTabJson.addProperty("isLikeMyTagForMe" ,likeMyTagForMe!=null&& likeMyTagForMe.intValue() > 0?true:false) ; //此标签我是否点过赞?
|
myTagJsonArray.add(myTabJson) ;
|
}
|
json.add("MyTagList",myTagJsonArray) ; //我的标签
|
|
//我的语音
|
json.addProperty("MyVoice", imgData.getImageUrl(myWxCpUser.getMyVoice(), settingEntity.getImageProductWidth(),settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),settingEntity.isFromCached(), request) );
|
//我的视频
|
json.addProperty("MyVideo", imgData.getImageUrl(myWxCpUser.getMyVideo(), settingEntity.getImageProductWidth(),settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),settingEntity.isFromCached(), request) );
|
//我的视频封面
|
json.addProperty("MyVideoCover",imgData.getImageUrl( myWxCpUser.getMyVideoCover(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request));
|
|
//我的照片
|
JsonArray myPhotoJsonArray = new JsonArray();
|
if (myWxCpUser.getMyPhoto() != null && !"".equals(myWxCpUser.getMyPhoto())) {
|
String unids[] = myWxCpUser.getMyPhoto().split(";") ;
|
String unid = unids[0] ;
|
for (int m = 0 ;m < unids.length;m++) {
|
if (m == 0) continue ;
|
String seq = unids[m] ;
|
JsonObject unidSeqJson = new JsonObject();
|
unidSeqJson.addProperty(SettingKey.UNID,unid) ;
|
unidSeqJson.addProperty("seq",seq) ;
|
unidSeqJson.addProperty("url",imgData.getImageUrl(unid +";" + seq, settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request) ) ;
|
myPhotoJsonArray.add(unidSeqJson) ;
|
}
|
}
|
json.add("MyPhotoList",myPhotoJsonArray) ; //我的照片
|
|
json.addProperty("AboutUs", myWxCpUser.getAboutUs()==null?"":myWxCpUser.getAboutUs()); //关于我们
|
|
//获取点赞名片最近5个人的头像
|
//ActionType值范围: LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
|
List<MyWxMpUser> likeMyCardList = maUserIfc.getUserLastVisitList(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(),5);
|
Integer viewMyCardTimes = 0 ;
|
JsonArray viewMyCardListArray = new JsonArray();
|
for(int i = 0;likeMyCardList!= null && i < likeMyCardList.size() ; i ++) {
|
String weiXinAvatarUnid = imgData.getImageUrl(likeMyCardList.get(i).getWeiXinAvatarUnid(), settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request);
|
if (weiXinAvatarUnid!= null && !"".equals(weiXinAvatarUnid)) {
|
viewMyCardListArray.add(weiXinAvatarUnid);
|
}
|
viewMyCardTimes = likeMyCardList.get(i).getViewMyCardTimes();
|
}
|
json.add("ViewMyCardList",viewMyCardListArray) ; //最近访问名片的人列表(只取前6个人)
|
json.addProperty("ViewMyCardTimes",viewMyCardTimes) ; //查看名片总次数
|
|
//名片点赞总数
|
Integer likeActionTimes = maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), null,"LikeMyCard",null) ;
|
json.addProperty("LikeMyCardTimes",likeActionTimes) ; //名片点赞总数
|
|
Integer isLikeMyCardForMe = maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), openId,"LikeMyCard",null) ;
|
json.addProperty("isLikeMyCardForMe",isLikeMyCardForMe!=null&& isLikeMyCardForMe.intValue()>0?true:false) ; //名片点赞总数
|
|
//我推荐的商品
|
List<MatCodeEntity> matCodeList = matCodeIfc.getMatCodesByFromUserId(fromUserId,myWxCpUser.getShopCcCode(),cltCode,openId) ;
|
JsonArray matCodeJsonArray = MatCode.getJsonArrayByMatCodeList(matCodeList,request, settingEntity,dataSourceEntity.getDbId()) ;
|
json.add("MatCodeList",matCodeJsonArray) ;
|
|
//我的教育经历
|
List<EducationEntity> educationList = maUserIfc.getEducationList(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(),openId);
|
JsonArray educationListArray = new JsonArray();
|
for (int i = 0 ;educationList!= null && i < educationList.size() ; i ++) {
|
JsonObject educationJson = new JsonObject();
|
educationJson.addProperty("SchoolCode",educationList.get(i).getSchoolCode() ) ; //学校编码
|
educationJson.addProperty("SchoolName",educationList.get(i).getSchoolName() ) ; //学校名称
|
educationJson.addProperty("Education",educationList.get(i).getEducation() ) ; //学历
|
educationJson.addProperty("Major",educationList.get(i).getMajor() ) ; //专业
|
educationJson.addProperty("LearningStartDate",educationList.get(i).getLearningStartDate()==null?"":yearFormat.format(educationList.get(i).getLearningStartDate()) ) ; //在校开始时间
|
educationJson.addProperty("LearningEndDate",educationList.get(i).getLearningEndDate()==null?"":yearFormat.format(educationList.get(i).getLearningEndDate()) ) ; //在校结束时间
|
educationJson.addProperty("SchoolmateGreetings",educationList.get(i).getSchoolmateGreetings() ) ; //同校问喉语
|
educationJson.addProperty("IsSchoolfellow",educationList.get(i).isSchoolfellow() ) ; //是否校友
|
educationJson.addProperty(SettingKey.DOCCODE,educationList.get(i).getDocCode() ) ; //doccode
|
educationJson.addProperty(SettingKey.ROWID,educationList.get(i).getRowId() ) ; //rowid
|
|
educationListArray.add(educationJson) ;
|
}
|
json.add("EducationList",educationListArray) ;
|
json.addProperty("SchoolmateGreetingsImage",imgData.getImageUrl(settingEntity.getSchoolmateGreetingsImage(), settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request) ) ; //校友问候语图片
|
|
//我的其它公司信息
|
List<OrganizationEntity> organizationList = erpUserIfc.getOrganizationList(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId()) ;
|
JsonArray organizationListArray = new JsonArray();
|
for (int i = 0 ;organizationList!= null && i < organizationList.size() ; i ++) {
|
JsonObject organizationJson = new JsonObject();
|
organizationJson.addProperty("DocCode",organizationList.get(i).getDocCode()) ; //单号
|
organizationJson.addProperty("RowId",organizationList.get(i).getRowId()) ; //rowid
|
organizationJson.addProperty("DocItem",organizationList.get(i).getDocItem()) ; //排序
|
organizationJson.addProperty("OrganizationName",organizationList.get(i).getOrganizationName()) ; //公司名称
|
organizationJson.addProperty("Description",organizationList.get(i).getDescription()) ; //公司描述
|
organizationJson.addProperty("Position",organizationList.get(i).getPosition()) ; //职务
|
organizationJson.addProperty("Telephone",organizationList.get(i).getTelephone()) ; //电话
|
organizationJson.addProperty("Address",organizationList.get(i).getAddress()) ; //地址
|
organizationJson.addProperty("Longitude",organizationList.get(i).getLongitude()) ; //地理经度(x)
|
organizationJson.addProperty("Latitude",organizationList.get(i).getLatitude()) ; //地理纬度(y)
|
organizationJson.addProperty("IndustryTypeFullName",organizationList.get(i).getIndustryTypeFullName()) ; //拼接的行业名称
|
|
organizationListArray.add(organizationJson) ;
|
}
|
json.add("OrganizationList",organizationListArray) ;
|
|
json.addProperty("state", "success");
|
this.printJson(response, json.toString());
|
return;
|
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
|
/**
|
* 新增或删除点赞记录
|
* @param request
|
* @param response
|
* @throws ServletException
|
*/
|
@RequestMapping("/wx/saveLikeAction.do")
|
public void saveLikeAction(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
HttpSession session=request.getSession();
|
|
String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
|
//String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
if (fromUserId == null || "".equals(fromUserId)) {
|
errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
if (dbId == null || "".equals(dbId)) {
|
dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
|
(String) session.getAttribute(SessionKey.DATA_BASE_ID));
|
}
|
String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
|
if (corpId == null || "".equals(corpId)) {
|
corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
|
}
|
if (corpId == null || "".equals(corpId)) {
|
corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
|
}
|
if (corpId == null || "".equals(corpId)) {
|
errJson.addProperty("warning","必须传递 AppId 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
|
String actionType = request.getParameter("ActionType") ;
|
if (actionType == null || "".equals(actionType)) {
|
errJson.addProperty("warning","必须传递 ActionType 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String actionName = (request.getParameter("ActionName")==null?"":request.getParameter("ActionName")) ;
|
//ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 ,
|
// LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,
|
// LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
|
if (Arrays.asList("LikeMyCard","LikeMyVoice","LikeMyVideo").contains(actionType)) {
|
if (actionName != null && !"".equals(actionName)) {
|
errJson.addProperty("warning","ActionType为[LikeMyCard,LikeMyVoice,LikeMyVideo]时,不需要传递 ActionName 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
}
|
|
if (Arrays.asList("LikeWebsite","LikeProductDetail","LikeInformation","LikeMyPhoto","LikeMyTag").contains(actionType)) {
|
if (actionName == null || "".equals(actionName)) {
|
errJson.addProperty("warning","ActionType为[LikeWebsite,LikeProductDetail,LikeInformation,LikeMyPhoto,LikeMyTag]时,必需要传递 ActionName 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
}
|
|
|
String ac = request.getParameter("ac") ;
|
if (ac == null || "".equals(ac)) {
|
errJson.addProperty("warning","必须传递 ac 参数,且该参数值只能是 add 或 delete");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
if (! Arrays.asList("add","delete").contains(ac)) {
|
errJson.addProperty("warning","传递的 ac 参数只能是 add 或 delete");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
//SettingEntity settingEntity = settingIfc.getSettingEntity() ;
|
|
//ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
|
Integer affectedRowCount = null ;
|
if (ac.equals("add")) {
|
affectedRowCount = maUserIfc.addLikeAction(fromUserId, openId, actionType, actionName) ;
|
}else {
|
affectedRowCount = maUserIfc.deleteLikeAction(fromUserId, openId, actionType, actionName) ;
|
}
|
|
Integer likeActionTimes = maUserIfc.getLikeActionTimes( fromUserId, null, actionType, actionName);
|
|
json.addProperty("likeActionTimes", likeActionTimes); //点赞记录总数
|
Integer likeActionTimesForMe = maUserIfc.getLikeActionTimes( fromUserId, openId, actionType, actionName);
|
|
json.addProperty("isLikeActionForMe", likeActionTimesForMe!=null&& likeActionTimesForMe.intValue() > 0 ? true:false); //我是否点过赞了
|
json.addProperty("affectedRowCount", affectedRowCount); //本次更新影响的行数
|
json.addProperty("state", "success");
|
this.printJson(response, json.toString());
|
return;
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 新增或删除同乡记录
|
* @param request
|
* @param response
|
* @throws ServletException
|
*/
|
@RequestMapping("/wx/saveHometown.do")
|
public void saveHometown(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
HttpSession session=request.getSession();
|
|
String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
|
//String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
if (fromUserId == null || "".equals(fromUserId)) {
|
errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
if (dbId == null || "".equals(dbId)) {
|
dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
|
(String) session.getAttribute(SessionKey.DATA_BASE_ID));
|
}
|
String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
|
if (corpId == null || "".equals(corpId)) {
|
corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
|
}
|
if (corpId == null || "".equals(corpId)) {
|
corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
|
}
|
if (corpId == null || "".equals(corpId)) {
|
errJson.addProperty("warning","必须传递 AppId 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
|
|
|
String ac = request.getParameter("ac") ;
|
if (ac == null || "".equals(ac)) {
|
errJson.addProperty("warning","必须传递 ac 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
if (! Arrays.asList("add","delete").contains(ac)) {
|
errJson.addProperty("warning","传递的 ac 参数只能是 add 或 delete");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
//SettingEntity settingEntity = settingIfc.getSettingEntity() ;
|
|
//ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
|
Integer affectedRowCount = null ;
|
if (ac.equals("add")) {
|
affectedRowCount = maUserIfc.addHometown(fromUserId, openId) ;
|
}else {
|
affectedRowCount = maUserIfc.deleteHometown(fromUserId, openId) ;
|
}
|
json.addProperty("affectedRowCount", affectedRowCount);
|
json.addProperty("state", "success");
|
this.printJson(response, json.toString());
|
return;
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
|
/**
|
* 新增或删除校友记录
|
* @param request
|
* @param response
|
* @throws ServletException
|
*/
|
@RequestMapping("/wx/saveSchoolfellow.do")
|
public void saveSchoolfellow(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
HttpSession session=request.getSession();
|
|
String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
|
//String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
if (fromUserId == null || "".equals(fromUserId)) {
|
errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
if (dbId == null || "".equals(dbId)) {
|
dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
|
(String) session.getAttribute(SessionKey.DATA_BASE_ID));
|
}
|
String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
|
if (corpId == null || "".equals(corpId)) {
|
corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
|
}
|
if (corpId == null || "".equals(corpId)) {
|
corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
|
}
|
if (corpId == null || "".equals(corpId)) {
|
errJson.addProperty("warning","必须传递 AppId 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
|
|
|
String ac = request.getParameter("ac") ;
|
if (ac == null || "".equals(ac)) {
|
errJson.addProperty("warning","必须传递 ac 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
if (! Arrays.asList("add","delete").contains(ac)) {
|
errJson.addProperty("warning","传递的 ac 参数只能是 add 或 delete");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
String schoolDocCode = request.getParameter(SettingKey.DOCCODE) ;
|
if (schoolDocCode == null || "".equals(schoolDocCode)) {
|
errJson.addProperty("warning","必须传递 " + SettingKey.DOCCODE + " 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
String schoolRowId = request.getParameter(SettingKey.ROWID) ;
|
if (schoolRowId == null || "".equals(schoolRowId)) {
|
errJson.addProperty("warning","必须传递 " + SettingKey.ROWID + " 参数");
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
//SettingEntity settingEntity = settingIfc.getSettingEntity() ;
|
|
//ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
|
Integer affectedRowCount = null ;
|
if (ac.equals("add")) {
|
affectedRowCount = maUserIfc.addSchoolfellow(fromUserId, openId,schoolDocCode,schoolRowId) ;
|
}else {
|
affectedRowCount = maUserIfc.deleteSchoolfellow(fromUserId, openId,schoolDocCode,schoolRowId) ;
|
}
|
json.addProperty("affectedRowCount", affectedRowCount);
|
json.addProperty("state", "success");
|
this.printJson(response, json.toString());
|
return;
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
}
|