|
|
@@ -7,17 +7,13 @@ import com.dgtly.common.core.domain.AjaxResult;
|
|
|
import com.dgtly.common.core.domain.ParameterObject;
|
|
|
import com.dgtly.common.utils.http.HttpUtils;
|
|
|
import com.dgtly.common.utils.security.EncryptPassWordClass;
|
|
|
-import com.dgtly.wxportal.domain.WxBanner;
|
|
|
-import com.dgtly.wxportal.domain.WxMagnet;
|
|
|
+import com.dgtly.system.service.ISysConfigService;
|
|
|
import com.dgtly.wxportal.utils.qywxutils.QyWxSendMessageUtil;
|
|
|
import com.dgtly.wxportal.utils.qywxutils.QyWxUserUtil;
|
|
|
import com.dgtly.common.utils.RedisUtil;
|
|
|
import com.dgtly.system.domain.SysUser;
|
|
|
-import com.dgtly.wxportal.domain.WxQyUser;
|
|
|
import com.dgtly.system.service.ISysUserService;
|
|
|
import com.dgtly.wxportal.service.IWxQyUserService;
|
|
|
-import com.dgtly.wxportal.utils.qywxutils.messageModel.QyWxTextCard;
|
|
|
-import com.dgtly.wxportal.utils.qywxutils.messageModel.QyWxTextCardMessage;
|
|
|
import com.dgtly.wxportal.utils.qywxutils.messageModel.QyWxTextMessage;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
@@ -25,11 +21,14 @@ import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
|
|
|
@Api(tags = "企业微信相关API", description = "提供企业微信相关的AP")
|
|
|
@@ -40,10 +39,10 @@ public class WxController extends ApiBaseController {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- private RedisUtil redisUtil;
|
|
|
+ private QyWxUserUtil qyWxUserUtil;
|
|
|
|
|
|
@Autowired
|
|
|
- private QyWxUserUtil qyWxUserUtil;
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
|
@Autowired
|
|
|
private IWxQyUserService wxQyUserService;
|
|
|
@@ -81,7 +80,12 @@ public class WxController extends ApiBaseController {
|
|
|
ParameterObject obj = getParameterObject();
|
|
|
obj.checkParameterNotNull("code");
|
|
|
String code = obj.getString("code");
|
|
|
- JSONObject json = qyWxUserUtil.getUserId(code);
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ try{
|
|
|
+ json = qyWxUserUtil.getUserId(code);
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("获取用户微信信息异常");
|
|
|
+ }
|
|
|
String userId ="";
|
|
|
if(!json.containsKey("UserId")){
|
|
|
return AjaxResult.error(301,"当前用户不是企业成员");
|
|
|
@@ -95,63 +99,81 @@ public class WxController extends ApiBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "根据用户userId发送文本",
|
|
|
- notes = "参数:{userId:123," +
|
|
|
- "content:\"XXXXXXXXXXXXXXXXXX\"} " +
|
|
|
- "错误:301 当前用户未绑定企业微信")
|
|
|
+ @ApiOperation(value = "根据用户经销商组织代码 customer_code发送文本",
|
|
|
+ notes = "参数:{\"XXX\":\"123,456\"}(说明:key是经销商code 值是订单编号列表)" )
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
})
|
|
|
- @PostMapping("sendTextMessage")
|
|
|
+ @PostMapping("sendTextMessageByCustomerCode")
|
|
|
public Object sendTextMessage(){
|
|
|
ParameterObject obj = getParameterObject();
|
|
|
- obj.checkParameterNotNull("userId,content");
|
|
|
- String userId = obj.getString("userId");
|
|
|
- WxQyUser wxQyUser = wxQyUserService.selectWxQyUserBySysUserId(userId);
|
|
|
- if(wxQyUser==null){
|
|
|
- logger.error("发送企业微信细信息对象为空");
|
|
|
- return AjaxResult.error(301,"发送对象位绑定企业微信");
|
|
|
+ JSONObject jobj = obj.getJSONObject();
|
|
|
+ Set<String> customerCodes = jobj.keySet();
|
|
|
+ Map<String,Map<String,Object>> maps = sysUserService.selectLoginNamesByCostumerCode(customerCodes);
|
|
|
+ String temple =configService.selectConfigByKey("wx.notification.time");
|
|
|
+ if(customerCodes.size()>0){
|
|
|
+ qyWxSendMessageUtil.sendNoticeMessage(customerCodes,obj.getJSONObject(),maps,temple);
|
|
|
}
|
|
|
- QyWxTextMessage qyWxTextMessage = new QyWxTextMessage();
|
|
|
- qyWxTextMessage.setTouser(wxQyUser.getUserid());
|
|
|
- qyWxTextMessage.setText(obj.getString("content"));
|
|
|
-
|
|
|
- qyWxSendMessageUtil.sendMessage(qyWxTextMessage);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "根据用户userId发送文本card",
|
|
|
- notes = "参数:{userId:123," +
|
|
|
- "title:\"标题,不超过128个字节\"," +
|
|
|
- "description:\"描述,不超过512个字节\"" +
|
|
|
- "url:\"点击后跳转的链接。\"," +
|
|
|
- "btntxt:\"按钮文字。 默认为“详情”, 不超过4个文字\"} " +
|
|
|
- "错误:301 当前用户未绑定企业微信")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
- })
|
|
|
- @PostMapping("sendTextCardMessage")
|
|
|
- public Object sendTextCardMessage(){
|
|
|
- ParameterObject obj = getParameterObject();
|
|
|
- obj.checkParameterNotNull("userId,title,description,url");
|
|
|
- String userId = obj.getString("userId");
|
|
|
-
|
|
|
- QyWxTextCard tc = obj.parseBean(QyWxTextCard.class);
|
|
|
|
|
|
- WxQyUser wxQyUser = wxQyUserService.selectWxQyUserBySysUserId(userId);
|
|
|
- if(wxQyUser==null){
|
|
|
- logger.error("发送企业微信细信息对象为空");
|
|
|
- return AjaxResult.error(301,"发送对象位绑定企业微信");
|
|
|
- }
|
|
|
- QyWxTextCardMessage q = new QyWxTextCardMessage();
|
|
|
|
|
|
- q.setTouser(wxQyUser.getUserid());
|
|
|
- q.setTextcard(tc);
|
|
|
- qyWxSendMessageUtil.sendMessage(q);
|
|
|
- return AjaxResult.success();
|
|
|
- }
|
|
|
+// @ApiOperation(value = "根据用户userId发送文本",
|
|
|
+// notes = "参数:{userId:123," +
|
|
|
+// "content:\"XXXXXXXXXXXXXXXXXX\"} " +
|
|
|
+// "错误:301 当前用户未绑定企业微信")
|
|
|
+// @ApiImplicitParams({
|
|
|
+// @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+// })
|
|
|
+// @PostMapping("sendTextMessage")
|
|
|
+// public Object sendTextMessage(){
|
|
|
+// ParameterObject obj = getParameterObject();
|
|
|
+// obj.checkParameterNotNull("userId,content");
|
|
|
+// Long userId = obj.getLong("userId");
|
|
|
+// SysUser sysUser = sysUserService.selectUserById(userId);
|
|
|
+// if(sysUser==null){
|
|
|
+// logger.error("发送企业微信细信息对象为空");
|
|
|
+// return AjaxResult.error(301,"未找到相应对象");
|
|
|
+// }
|
|
|
+// QyWxTextMessage qyWxTextMessage = new QyWxTextMessage();
|
|
|
+// qyWxTextMessage.setTouser(sysUser.getLoginName());
|
|
|
+// qyWxTextMessage.setText(obj.getString("content"));
|
|
|
+//
|
|
|
+// qyWxSendMessageUtil.sendMessage(qyWxTextMessage);
|
|
|
+// return AjaxResult.success();
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ApiOperation(value = "根据用户userId发送文本card",
|
|
|
+// notes = "参数:{userId:123," +
|
|
|
+// "title:\"标题,不超过128个字节\"," +
|
|
|
+// "description:\"描述,不超过512个字节\"" +
|
|
|
+// "url:\"点击后跳转的链接。\"," +
|
|
|
+// "btntxt:\"按钮文字。 默认为“详情”, 不超过4个文字\"} " +
|
|
|
+// "错误:301 当前用户未绑定企业微信")
|
|
|
+// @ApiImplicitParams({
|
|
|
+// @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+// })
|
|
|
+// @PostMapping("sendTextCardMessage")
|
|
|
+// public Object sendTextCardMessage(){
|
|
|
+// ParameterObject obj = getParameterObject();
|
|
|
+// obj.checkParameterNotNull("userId,title,description,url");
|
|
|
+// Long userId = obj.getLong("userId");
|
|
|
+//
|
|
|
+// QyWxTextCard tc = obj.parseBean(QyWxTextCard.class);
|
|
|
+//
|
|
|
+// SysUser sysUser = sysUserService.selectUserById(userId);
|
|
|
+// if(sysUser==null){
|
|
|
+// logger.error("发送企业微信细信息对象为空");
|
|
|
+// return AjaxResult.error(301,"未找到相应对象");
|
|
|
+// }
|
|
|
+// QyWxTextCardMessage q = new QyWxTextCardMessage();
|
|
|
+//
|
|
|
+// q.setTouser(sysUser.getLoginName());
|
|
|
+// q.setTextcard(tc);
|
|
|
+// qyWxSendMessageUtil.sendMessage(q);
|
|
|
+// return AjaxResult.success();
|
|
|
+// }
|
|
|
|
|
|
@ApiOperation(value = "根据立邦微信基建返回的Ticket获取用户信息",notes = "参数:{'Ticket':1}=" +
|
|
|
" 错误:301 根据Ticket获取用户信息失败" +
|
|
|
@@ -188,7 +210,7 @@ public class WxController extends ApiBaseController {
|
|
|
return AjaxResult.error(301,"根据Ticket获取用户信息失败");
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "根据账户密码获取用户权限",notes = "参数:{'username':'1','password':'xxx'}" +
|
|
|
+ @ApiOperation(value = "根据账户密码获取用户信息",notes = "参数:{'username':'1','password':'xxx'}" +
|
|
|
" 错误:301 密码错误" +
|
|
|
"错误:302 查无此人")
|
|
|
@ApiImplicitParams({
|