feat(企业微信): 添加获取管理员用户ID的功能并优化消息发送逻辑
添加`selectAdminUserIds`方法以获取管理员用户ID,并优化`sendNewsMessage`方法中的URL参数,移除调试参数。此外,调整订单商品状态验证逻辑,允许状态为5的商品进行操作。
This commit is contained in:
parent
8e6131c197
commit
2ec5255615
|
@ -29,7 +29,7 @@ public class QywxApiUtil {
|
||||||
* @return 消息发送结果
|
* @return 消息发送结果
|
||||||
*/
|
*/
|
||||||
public static NewsMessageResponse sendNewsMessage(String accessToken, Integer agentId, String toUser, String toparty, String totag, List<NewsArticle> articles) {
|
public static NewsMessageResponse sendNewsMessage(String accessToken, Integer agentId, String toUser, String toparty, String totag, List<NewsArticle> articles) {
|
||||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + accessToken + "&debug=" + 1;
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + accessToken;
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("touser", toUser);
|
params.put("touser", toUser);
|
||||||
|
|
|
@ -31,4 +31,16 @@ public interface QyUserMapper extends BaseMapper<QyUserEntity> {
|
||||||
"AND deleted = 0")
|
"AND deleted = 0")
|
||||||
QyUserEntity selectByUserid(@Param("userid") String userid, @Param("corpid") String corpid);
|
QyUserEntity selectByUserid(@Param("userid") String userid, @Param("corpid") String corpid);
|
||||||
|
|
||||||
|
@Select("SELECT DISTINCT qu.userid " +
|
||||||
|
"FROM qy_user qu " +
|
||||||
|
"LEFT JOIN sys_user_qy_user suqy ON qu.id = suqy.qy_user_id " +
|
||||||
|
"LEFT JOIN sys_user su ON suqy.sys_user_id = su.user_id " +
|
||||||
|
"LEFT JOIN sys_role sr ON su.role_id = sr.role_id " +
|
||||||
|
"WHERE qu.deleted = 0 " +
|
||||||
|
"AND suqy.deleted = 0 " +
|
||||||
|
"AND su.deleted = 0 " +
|
||||||
|
"AND sr.deleted = 0 " +
|
||||||
|
"AND sr.role_key = 'admin'")
|
||||||
|
List<String> selectAdminUserIds();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,6 @@ public interface QyUserService extends IService<QyUserEntity> {
|
||||||
List<QyUserEntity> selectAll();
|
List<QyUserEntity> selectAll();
|
||||||
|
|
||||||
QyUserEntity getUserByUserId(String userid, String corpid);
|
QyUserEntity getUserByUserId(String userid, String corpid);
|
||||||
|
|
||||||
|
List<String> selectAdminUserIds();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,4 +38,9 @@ public class QyUserServiceImpl extends ServiceImpl<QyUserMapper, QyUserEntity> i
|
||||||
public QyUserEntity getUserByUserId(String userid, String corpid) {
|
public QyUserEntity getUserByUserId(String userid, String corpid) {
|
||||||
return baseMapper.selectByUserid(userid, corpid);
|
return baseMapper.selectByUserid(userid, corpid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> selectAdminUserIds() {
|
||||||
|
return baseMapper.selectAdminUserIds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.agileboot.domain.qywx.api.QywxApiUtil;
|
||||||
import com.agileboot.domain.qywx.api.response.NewsArticle;
|
import com.agileboot.domain.qywx.api.response.NewsArticle;
|
||||||
import com.agileboot.domain.qywx.authCorpInfo.AuthCorpInfoApplicationService;
|
import com.agileboot.domain.qywx.authCorpInfo.AuthCorpInfoApplicationService;
|
||||||
import com.agileboot.domain.qywx.authCorpInfo.db.QyAuthCorpInfoEntity;
|
import com.agileboot.domain.qywx.authCorpInfo.db.QyAuthCorpInfoEntity;
|
||||||
|
import com.agileboot.domain.qywx.user.db.QyUserService;
|
||||||
import com.agileboot.domain.shop.approval.command.AddReturnApprovalCommand;
|
import com.agileboot.domain.shop.approval.command.AddReturnApprovalCommand;
|
||||||
import com.agileboot.domain.shop.approval.command.UpdateReturnApprovalCommand;
|
import com.agileboot.domain.shop.approval.command.UpdateReturnApprovalCommand;
|
||||||
import com.agileboot.domain.shop.approval.db.ReturnApprovalEntity;
|
import com.agileboot.domain.shop.approval.db.ReturnApprovalEntity;
|
||||||
|
@ -57,6 +58,7 @@ public class ReturnApprovalApplicationService {
|
||||||
private final GoodsModelFactory goodsModelFactory;
|
private final GoodsModelFactory goodsModelFactory;
|
||||||
private final AuthCorpInfoApplicationService authCorpInfoApplicationService;
|
private final AuthCorpInfoApplicationService authCorpInfoApplicationService;
|
||||||
private final AccessTokenApplicationService accessTokenApplicationService;
|
private final AccessTokenApplicationService accessTokenApplicationService;
|
||||||
|
private final QyUserService qyUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取退货审批列表
|
* 获取退货审批列表
|
||||||
|
@ -203,8 +205,9 @@ public class ReturnApprovalApplicationService {
|
||||||
.filter(a -> "wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw".equals(a.getCorpid()))
|
.filter(a -> "wpZ1ZrEgAA2QTxIRcB4cMtY7hQbTcPAw".equals(a.getCorpid()))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid(appid, authCorpInfo.getCorpid());
|
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid(appid, authCorpInfo.getCorpid());
|
||||||
// TODO 获取用户ID
|
// 获取用户ID
|
||||||
String toUser = "woZ1ZrEgAAV9AEdRt1MGQxSg-KDJrDlA|woZ1ZrEgAAoFQl9vWHMj4PkFoSc8FR8w";
|
List<String> adminUserIds = qyUserService.selectAdminUserIds();
|
||||||
|
String toUser = String.join("|", adminUserIds);
|
||||||
String toparty = "";
|
String toparty = "";
|
||||||
String totag = "";
|
String totag = "";
|
||||||
List<NewsArticle> articles = new ArrayList<>();
|
List<NewsArticle> articles = new ArrayList<>();
|
||||||
|
|
|
@ -72,19 +72,12 @@ public class OrderApplicationService {
|
||||||
if (orderModel.getStatus() != 2) {
|
if (orderModel.getStatus() != 2) {
|
||||||
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单状态不允许操作");
|
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单状态不允许操作");
|
||||||
}
|
}
|
||||||
Date payTime = orderModel.getPayTime();
|
|
||||||
if (payTime == null)
|
|
||||||
payTime = orderModel.getCreateTime();
|
|
||||||
// 验证payTime是否在24小时内
|
|
||||||
if (DateUtil.offsetHour(payTime, 24).before(new Date())) {
|
|
||||||
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单支付时间超过24小时,不允许操作");
|
|
||||||
}
|
|
||||||
|
|
||||||
ShopOrderGoodsEntity goodsEntity = orderGoodsService.getById(orderGoodsId);
|
ShopOrderGoodsEntity goodsEntity = orderGoodsService.getById(orderGoodsId);
|
||||||
if (null == goodsEntity || !orderId.equals(goodsEntity.getOrderId())) {
|
if (null == goodsEntity || !orderId.equals(goodsEntity.getOrderId())) {
|
||||||
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单商品不存在");
|
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单商品不存在");
|
||||||
}
|
}
|
||||||
if (goodsEntity.getStatus() != 1) {
|
if (goodsEntity.getStatus() != 1 && goodsEntity.getStatus()!= 5) {
|
||||||
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单商品状态不允许操作");
|
throw new ApiException(ErrorCode.Client.COMMON_FORBIDDEN_TO_CALL, "订单商品状态不允许操作");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue