Commit a0d45170 by guojuxing

资源组变更通知业务方

parent 47a8db29
package com.gic.enterprise.dto.union;
import java.io.Serializable;
import java.util.List;
/**
* 联合商户资源授权通知
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/2/24 4:50 PM

*/
public class UnionEnterpriseAuthResNoticeDTO implements Serializable{
private static final long serialVersionUID = -7222957448764839407L;
/**
* 自有商户ID
*/
private Integer ownEnterpriseId;
/**
* 联合商户ID
*/
private Integer unionEnterpriseId;
/**
* 门店资源
*/
private Long storeResource;
/**
* 商品资源
*/
private Long goodsResourceId;
/**
* 用户域的域数据变更信息
*/
private List<UserResourceChangeInfoDTO> userResourceInfoList;
public Long getStoreResource() {
return storeResource;
}
public UnionEnterpriseAuthResNoticeDTO setStoreResource(Long storeResource) {
this.storeResource = storeResource;
return this;
}
public Long getGoodsResourceId() {
return goodsResourceId;
}
public UnionEnterpriseAuthResNoticeDTO setGoodsResourceId(Long goodsResourceId) {
this.goodsResourceId = goodsResourceId;
return this;
}
public List<UserResourceChangeInfoDTO> getUserResourceInfoList() {
return userResourceInfoList;
}
public UnionEnterpriseAuthResNoticeDTO setUserResourceInfoList(List<UserResourceChangeInfoDTO> userResourceInfoList) {
this.userResourceInfoList = userResourceInfoList;
return this;
}
public Integer getOwnEnterpriseId() {
return ownEnterpriseId;
}
public UnionEnterpriseAuthResNoticeDTO setOwnEnterpriseId(Integer ownEnterpriseId) {
this.ownEnterpriseId = ownEnterpriseId;
return this;
}
public Integer getUnionEnterpriseId() {
return unionEnterpriseId;
}
public UnionEnterpriseAuthResNoticeDTO setUnionEnterpriseId(Integer unionEnterpriseId) {
this.unionEnterpriseId = unionEnterpriseId;
return this;
}
@Override
public String toString() {
return "UnionEnterpriseAuthResNoticeDTO{" +
"ownEnterpriseId=" + ownEnterpriseId +
", unionEnterpriseId=" + unionEnterpriseId +
", storeResource=" + storeResource +
", goodsResourceId=" + goodsResourceId +
", userResourceInfoList=" + userResourceInfoList +
'}';
}
}
package com.gic.enterprise.dto.union;
import java.io.Serializable;
import java.util.List;
/**
* 用户域资源域数据(小程序、服务号、会员卡等)变更情况信息
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/2/24 4:53 PM

*/
public class UserResourceChangeInfoDTO implements Serializable{
private static final long serialVersionUID = 5480272198512708835L;
/**
* 域数据类型 CuTypeEnum枚举
*/
private Integer type;
/**
* 增加的域ID
*/
private List<Long> addList;
/**
* 删除的域ID集合
*/
private List<Long> deleteList;
public Integer getType() {
return type;
}
public UserResourceChangeInfoDTO setType(Integer type) {
this.type = type;
return this;
}
public List<Long> getAddList() {
return addList;
}
public UserResourceChangeInfoDTO setAddList(List<Long> addList) {
this.addList = addList;
return this;
}
public List<Long> getDeleteList() {
return deleteList;
}
public UserResourceChangeInfoDTO setDeleteList(List<Long> deleteList) {
this.deleteList = deleteList;
return this;
}
@Override
public String toString() {
return "UserResourceChangeInfoDTO{" +
"type=" + type +
", addList=" + addList +
", deleteList=" + deleteList +
'}';
}
}
package com.gic.enterprise.service.outer.impl.union;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.auth.dto.ResourceGroupCustomUserDTO;
import com.gic.auth.dto.ResourceGroupDTO;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.service.ResourceGroupApiService;
import com.gic.auth.service.UserApiService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.constant.union.UnionEnterpriseAuthDetailStatusEnum;
import com.gic.enterprise.constant.union.UnionEnterpriseAuthResOperateEnum;
......@@ -17,9 +21,13 @@ import com.gic.enterprise.entity.TabSysUnionEnterpriseAuthApp;
import com.gic.enterprise.entity.TabSysUnionEnterpriseAuthResDetail;
import com.gic.enterprise.qo.union.UnionEnterpriseAuthResLogQO;
import com.gic.enterprise.service.*;
import com.gic.mq.sdk.GicMQClient;
import com.gic.store.service.StoreAuthorizationApiService;
import net.sf.json.JSONArray;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -47,6 +55,7 @@ import java.util.stream.Collectors;
*/
@Service("unionEnterpriseAuthApiService")
public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApiService{
private static Logger LOGGER = LogManager.getLogger(UnionEnterpriseAuthApiServiceImpl.class);
@Autowired
private UnionEnterpriseAuthService unionEnterpriseAuthService;
@Autowired
......@@ -96,30 +105,21 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
}
}
//是否是编辑。编辑和新增授权同步资源处理不同
boolean isEdit = !dto.getResourceGroupId().equals(old.getResourceGroupId());
//todo starrynight 通知业务方,同步数据
boolean isEdit = old.getResourceGroupId() != null && !old.getResourceGroupId().equals(dto.getResourceGroupId());
Integer resourceGroupId = dto.getResourceGroupId();
ServiceResponse<ResourceGroupDTO> resourceResponse = resourceGroupApiService.getResourceGroup(resourceGroupId);
if (!resourceResponse.isSuccess() || resourceResponse.getResult() == null) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "资源组数据不存在");
ResourceGroupDTO resourceGroupDTO = getResourceGroup(resourceGroupId);
ResourceGroupDTO oldResourceGroupDTO = null;
if (isEdit) {
oldResourceGroupDTO = getResourceGroup(old.getResourceGroupId());
}
//
checkResourceDealing((old.getUnionEnterpriseAuthId()));
if (isEdit) {
//todo 重置最新联合时间和解除时间?
} else {
}
ResourceGroupDTO resourceGroupDTO = resourceResponse.getResult();
//门店通知
if (resourceGroupDTO.getStoreResource() != null) {
storeAuthorizationApiService.authStore(resourceGroupDTO.getStoreResource().intValue(), dto.getUnionEnterpriseId(), dto.getOwnEnterpriseId());
}
//授权通知
resourceGroupApiService.syncResourceAuthChangeMQ(dto.getOwnEnterpriseId(), dto.getUnionEnterpriseId(), resourceGroupDTO, oldResourceGroupDTO);
unionEnterpriseAuthService.update(data);
//初始化未授权资源数据
unionEnterpriseAuthResDetailService.initUnionEnterpriseAuthResDetail(old.getUnionEnterpriseAuthId());
return ServiceResponse.success();
......@@ -445,4 +445,12 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
}
}
private ResourceGroupDTO getResourceGroup(Integer resourceGroupId) {
ServiceResponse<ResourceGroupDTO> resourceResponse = resourceGroupApiService.getResourceGroup(resourceGroupId);
if (!resourceResponse.isSuccess() || resourceResponse.getResult() == null) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "资源组数据不存在");
}
return resourceResponse.getResult();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment