Commit 77fdfa07 by 陶光胜

联合商户授权

parent edecb3ac
......@@ -4,6 +4,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.store.dto.StoreDTO;
import javax.xml.ws.Service;
import java.util.List;
public interface StoreAuthorizationApiService {
......@@ -15,6 +16,8 @@ public interface StoreAuthorizationApiService {
*/
ServiceResponse<Void> authStore(Integer storeResourceId, Integer toEnterpriseId, Integer enterpriseId);
ServiceResponse<Void> reAuthStore(String key);
ServiceResponse<Void> authorizationSingleStore(String params);
ServiceResponse<Void> saveStore(StoreDTO storeDTO, Integer logId);
......
......@@ -56,4 +56,11 @@ public interface TabAuthStoreLogMapper {
List<TabAuthStoreLog> listLogByKey(@Param("key") String key,
@Param("status") int status);
List<TabAuthStoreLog> listFailedStore(@Param("key") String key);
List<TabAuthStoreLog> listLog(@Param("key") String key,
@Param("storeInfoId") Integer storeInfoId,
@Param("toEnterpriseId") Integer toEnterpriseId);
}
\ No newline at end of file
package com.gic.store.service;
import com.gic.store.entity.TabAuthStoreLog;
import java.util.List;
public interface AuthStoreLogService {
int saveAuthStoreLog(Integer storeInfoId, Integer fromEnterpriseId, Integer toEnterpriseId, String key);
int updateStatus(Integer id, int status);
int getCount(String key, int status);
int getCount(String key, Integer status);
List<TabAuthStoreLog> listFailedStore(String key);
}
......@@ -16,12 +16,16 @@ public class AuthStoreLogServiceImpl implements AuthStoreLogService {
@Override
public int saveAuthStoreLog(Integer storeInfoId, Integer fromEnterpriseId, Integer toEnterpriseId, String key) {
List<TabAuthStoreLog> list = this.tabAuthStoreLogMapper.listLog(key, storeInfoId, toEnterpriseId);
if(CollectionUtils.isNotEmpty(list)){
return list.get(0).getId();
}
TabAuthStoreLog log = new TabAuthStoreLog();
log.setStoreInfoId(storeInfoId);
log.setFromEnterpriseId(fromEnterpriseId);
log.setKey(key);
log.setToEnterpriseId(toEnterpriseId);
log.setStatus(1);
log.setStatus(0);
this.tabAuthStoreLogMapper.insertSelective(log);
return log.getId();
}
......@@ -35,11 +39,16 @@ public class AuthStoreLogServiceImpl implements AuthStoreLogService {
}
@Override
public int getCount(String key, int status) {
public int getCount(String key, Integer status) {
List<TabAuthStoreLog> list = this.tabAuthStoreLogMapper.listLogByKey(key, status);
if(CollectionUtils.isNotEmpty(list)){
return list.size();
}
return 0;
}
@Override
public List<TabAuthStoreLog> listFailedStore(String key) {
return this.tabAuthStoreLogMapper.listFailedStore(key);
}
}
......@@ -15,6 +15,7 @@ import com.gic.store.constant.StoreOwnTypeEnum;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.dto.StoreWidgetDTO;
import com.gic.store.entity.TabAuthStoreLog;
import com.gic.store.entity.TabStoreGroup;
import com.gic.store.service.*;
import org.apache.commons.collections.CollectionUtils;
......@@ -66,13 +67,31 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
storeSearchDTO.setSearchJson(storeWidgetDTO.getSearchParam());
Long count = this.storeApiService.queryStoreCountFromES(storeSearchDTO).getResult();
if(count > 0){
this.queryStoreByPage(count, storeSearchDTO, toEnterpriseId, enterpriseId);
this.queryStoreByPage(count, storeSearchDTO, toEnterpriseId, enterpriseId, null);
}else {
this.unionEnterpriseApiService.updateStoreAuthorizationStatus(AuthorizationStatusEnum.SUCCESS.getCode(),
enterpriseId, "授权成功", null);
}
}
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> reAuthStore(String key) {
List<TabAuthStoreLog> list = this.authStoreLogService.listFailedStore(key);
StringBuilder storeInfoIds = new StringBuilder();
if(CollectionUtils.isNotEmpty(list)){
Integer fromEnterpriseId = list.get(0).getFromEnterpriseId();
Integer toEnterpriseId = list.get(0).getToEnterpriseId();
for(TabAuthStoreLog log : list){
storeInfoIds.append(log.getStoreInfoId()).append(",");
}
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(toEnterpriseId);
storeSearchDTO.setStoreInfoIds(storeInfoIds.toString());
this.queryStoreByPage(Long.valueOf(list.size()+""), storeSearchDTO, toEnterpriseId, fromEnterpriseId, key);
}
return null;
}
......@@ -85,7 +104,6 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
Integer toEnterpriseId = json.getInteger("toEnterpriseId");
Integer fromEnterpriseId = json.getInteger("enterpriseId");
Integer isEnd = json.getInteger("isEnd");
int total = json.getInteger("total");
String key = json.getString("key");
storeDTO.setEnterpriseId(toEnterpriseId);
storeDTO.setFromEnterpriseId(fromEnterpriseId);
......@@ -93,6 +111,7 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
this.saveStore(storeDTO, logId);
if(isEnd == 1){
int count = this.authStoreLogService.getCount(key, 2);
int total = this.authStoreLogService.getCount(key, null);
if(count > 0){
this.unionEnterpriseApiService.updateStoreAuthorizationStatus
(AuthorizationStatusEnum.PARTSUCCESS.getCode(), storeDTO.getEnterpriseId(), "成功授权"+(total-count)+"条数据,失败"+count+"条", key);
......@@ -118,6 +137,8 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
log.info("{},门店授权结果:{}", storeDTO.getStoreInfoId(), i);
if(i == 0 && logId != 0){
this.authStoreLogService.updateStatus(logId, 2);
}else {
this.authStoreLogService.updateStatus(logId, 1);
}
return ServiceResponse.success();
}
......@@ -135,8 +156,10 @@ public class StoreAuthorizationApiServiceImpl implements StoreAuthorizationApiSe
return ServiceResponse.success();
}
private void queryStoreByPage(Long count, StoreSearchDTO storeSearchDTO, Integer toEnterpriseId, Integer enterpriseId){
String key = ToolUtil.randomUUID();
private void queryStoreByPage(Long count, StoreSearchDTO storeSearchDTO, Integer toEnterpriseId, Integer enterpriseId, String key){
if(StringUtils.isBlank(key)){
key = ToolUtil.randomUUID();
}
int pages = count/pageSize + count%pageSize>0 ? 1 : 0;
Set<Integer> regionSet = new HashSet<>();
Set<String> storeTypeSet = new HashSet<>();
......
......@@ -110,10 +110,24 @@
where id = #{id,jdbcType=INTEGER}
</update>
<select id="listLogByKey" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_auth_store_log
where key = #{key}
<if test="status != null">
and status = #{status}
</if>
</select>
<select id="listFailedStore" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_auth_store_log
where key = #{key}
and status = #{status}
where key = #{key} and (status =0 or status = 2)
</select>
<select id="listLog" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_auth_store_log
where key = #{key} and to_enterprise_id=#{toEnterpriseId} and store_info_id=#{storeInfoId}
</select>
</mapper>
\ No newline at end of file
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