Commit e64d86be by 陶光胜

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-store into developer

parents c3e20e2b c8dac834
......@@ -70,5 +70,5 @@ public interface TabClerkMapper {
List<TabClerk> listClerkByIds(@Param("enterpriseId") Integer enterpriseId, @Param("ids") List<Integer> clerkIdList);
TabClerk getClerkByCode(@Param("enterpriseId") Integer enterpriseId, @Param("clerkCode") String clerkCode, @Param("storeInfoId") Integer storeInfoId);
}
\ No newline at end of file
......@@ -109,4 +109,6 @@ public interface ClerkService {
TabClerk getById(Integer clerkId);
List<TabClerk> listClerk(Integer enterpriseId, String search);
TabClerk getClerkByCode(Integer enterpriseId, String clerkCode, Integer storeInfoId);
}
......@@ -132,4 +132,9 @@ public class ClerkServiceImpl implements ClerkService {
return this.tabClerkMapper.listClerkByStoreInfoId(enterpriseId, null, search);
}
@Override
public TabClerk getClerkByCode(Integer enterpriseId, String clerkCode, Integer storeInfoId) {
return tabClerkMapper.getClerkByCode(enterpriseId, clerkCode, storeInfoId);
}
}
......@@ -6,6 +6,7 @@ import com.gic.commons.util.CollectionUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.store.constant.ClerkLogReasonEnum;
import com.gic.store.constant.StoreLogTypeEnum;
import com.gic.store.constant.StoreOwnTypeEnum;
import com.gic.store.dto.*;
......@@ -14,6 +15,8 @@ import com.gic.store.entity.TabStoreGroup;
import com.gic.store.service.*;
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;
......@@ -27,6 +30,8 @@ import java.util.stream.Collectors;
@Service("clerkApiService")
public class ClerkApiServiceImpl implements ClerkApiService {
private Logger logger = LogManager.getLogger(ClerkApiServiceImpl.class);
@Autowired
private ClerkService clerkService;
@Autowired
......@@ -49,8 +54,10 @@ public class ClerkApiServiceImpl implements ClerkApiService {
if (clerkService.isRepeatByClerkCode(clerkDTO.getStoreInfoId(), clerkDTO.getClerkCode(), clerkDTO.getClerkId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "导购关联主键重复");
}
if (clerkService.isRepeatByPhoneNumber(clerkDTO.getStoreInfoId(), clerkDTO.getPhoneNumber(), clerkDTO.getClerkId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号重复");
if (StringUtils.isNotBlank(clerkDTO.getPhoneNumber())) {
if (clerkService.isRepeatByPhoneNumber(clerkDTO.getStoreInfoId(), clerkDTO.getPhoneNumber(), clerkDTO.getClerkId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号重复");
}
}
if (clerkService.isRepeatByClerkName(clerkDTO.getStoreInfoId(), clerkDTO.getClerkName(), clerkDTO.getClerkId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "导购名称重复");
......@@ -70,12 +77,41 @@ public class ClerkApiServiceImpl implements ClerkApiService {
@Override
public ServiceResponse<Integer> saveClerkForOrder(String clerkName, String clerkCode, Integer storeId, Integer enterpriseId, String orderNum) {
return null;
ServiceResponse<StoreDTO> storeResponse = storeApiService.getStoreById(enterpriseId, storeId);
if (storeResponse.getResult() != null) {
StoreDTO store = storeResponse.getResult();
ClerkDTO clerkDTO = new ClerkDTO();
clerkDTO.setClerkName(clerkName);
clerkDTO.setClerkCode(clerkCode);
clerkDTO.setEnterpriseId(enterpriseId);
clerkDTO.setStoreInfoId(store.getStoreInfoId());
clerkDTO.setReason(ClerkLogReasonEnum.ORDER.getCode());
clerkDTO.setRemark("订单号:" + orderNum);
clerkDTO.setStoreName(store.getStoreName());
ServiceResponse serviceResponse = this.saveOrUpdate(clerkDTO);
return serviceResponse;
} else {
logger.warn("门店不存在 enterpriseId:{}, storeId:{}", enterpriseId, storeId);
return EnterpriseServiceResponse.failure(ErrorCode.NOTEXISTS.getCode(), "门店不存在");
}
}
@Override
public ServiceResponse<ClerkDTO> getClerkByCode(Integer enterpriseId, String clerkCode, Integer storeId) {
return null;
ServiceResponse<StoreDTO> storeResponse = storeApiService.getStoreById(enterpriseId, storeId);
if (storeResponse.getResult() != null) {
StoreDTO store = storeResponse.getResult();
TabClerk clerk = this.clerkService.getClerkByCode(enterpriseId, clerkCode, store.getStoreInfoId());
if (clerk != null) {
return EnterpriseServiceResponse.success(EntityUtil.changeEntityByJSON(ClerkDTO.class, clerk));
} else {
return EnterpriseServiceResponse.failure(ErrorCode.NOTEXISTS);
}
} else {
logger.warn("门店不存在 enterpriseId:{}, storeId:{}", enterpriseId, storeId);
return EnterpriseServiceResponse.failure(ErrorCode.NOTEXISTS.getCode(), "门店不存在");
}
}
private void storeLogByAddClerk(ClerkDTO clerkDTO) {
......@@ -209,7 +245,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
storeSearchDTO.setSearchJson(clerkSearchDTO.getSelectJson());
storeSearchDTO.setStoreIds(clerkSearchDTO.getStoreIds());
return this.storeApiService.listStore(storeSearchDTO, pageNum, pageSize, "storeId,storeName,storeCode,storeInfoId,ownType");
return storeApiService.listStore(storeSearchDTO, pageNum, pageSize, "storeId,storeName,storeCode,storeInfoId,ownType");
}
@Override
......@@ -226,7 +262,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
@Override
public ServiceResponse<List<ClerkDTO>> listClerkByStoreId(Integer enterpriseId, Integer storeId, String search) {
ServiceResponse<StoreDTO> response = this.storeApiService.getStoreById(enterpriseId, storeId);
ServiceResponse<StoreDTO> response = storeApiService.getStoreById(enterpriseId, storeId);
if(response.isSuccess() && response.getResult() != null){
List<Integer> storeInfoIds = new ArrayList<>();
storeInfoIds.add(response.getResult().getStoreInfoId());
......
......@@ -189,38 +189,53 @@ public class StoreTaskServiceImpl extends AbstractTaskAllocationOperation implem
Optional<StoreDictDTO> typeTmpDTO = typeList.stream().filter(e -> e.getKey().equals(typeTmp)).findFirst();
storeDTO.setStoreType(Integer.parseInt(typeTmpDTO.get().getValue()));
}
// 判断分组
if (Integer.valueOf(1) == storeStrategyApiService.getStoreGroupStrategyWeight(t.getEnterpriseId()).getResult()) {
// 不启用分组策略
if (StringUtils.isBlank(t.getStoreGroupName())) {
// 取 未分类 分组
TabStoreGroup group = storeGroupService.selectUnGroupedStore(t.getEnterpriseId());
if (StringUtils.isNotBlank(t.getStoreGroupName())) {
storeDTO.setIsEditStoreGroup(1);
TabStoreGroup group = storeGroupService.getStoreGroupByName(t.getStoreGroupName(), t.getEnterpriseId());
if (group != null) {
storeDTO.setStoreGroupId(group.getStoreGroupId());
} else {
// 判断分组是否存在
TabStoreGroup group = storeGroupService.getStoreGroupByName(t.getStoreGroupName(), t.getEnterpriseId());
if (group != null) {
storeDTO.setStoreGroupId(group.getStoreGroupId());
} else {
t.setErrorMessage("分组不存在");
storeImportService.updateData(t);
logger.info("enterpriseId:{}, groupName:{}, 不存在该分组", t.getEnterpriseId(), t.getStoreGroupName());
return;
}
t.setErrorMessage("分组不存在");
storeImportService.updateData(t);
logger.info("enterpriseId:{}, groupName:{}, 不存在该分组", t.getEnterpriseId(), t.getStoreGroupName());
return;
}
} else {
// 启用分组策略
String groupId = storeStrategyService.isHitStrategy(storeDTO, StoreGroupConstant.STORE_GROUP_STRATEGY_TYPE);
if (StringUtils.isNotBlank(groupId)) {
// 命中
storeDTO.setStoreGroupId(Integer.valueOf(groupId));
} else {
// 未命中
TabStoreGroup group = storeGroupService.selectUnGroupedStore(t.getEnterpriseId());
storeDTO.setStoreGroupId(group.getStoreGroupId());
}
storeDTO.setIsEditStoreGroup(0);
}
// 判断分组
// if (Integer.valueOf(1) == storeStrategyApiService.getStoreGroupStrategyWeight(t.getEnterpriseId()).getResult()) {
// // 不启用分组策略
// if (StringUtils.isBlank(t.getStoreGroupName())) {
// // 取 未分类 分组
// TabStoreGroup group = storeGroupService.selectUnGroupedStore(t.getEnterpriseId());
// storeDTO.setStoreGroupId(group.getStoreGroupId());
// } else {
// // 判断分组是否存在
// TabStoreGroup group = storeGroupService.getStoreGroupByName(t.getStoreGroupName(), t.getEnterpriseId());
// if (group != null) {
// storeDTO.setStoreGroupId(group.getStoreGroupId());
// } else {
// t.setErrorMessage("分组不存在");
// storeImportService.updateData(t);
// logger.info("enterpriseId:{}, groupName:{}, 不存在该分组", t.getEnterpriseId(), t.getStoreGroupName());
// return;
// }
// }
// } else {
// // 启用分组策略
// String groupId = storeStrategyService.isHitStrategy(storeDTO, StoreGroupConstant.STORE_GROUP_STRATEGY_TYPE);
// if (StringUtils.isNotBlank(groupId)) {
// // 命中
// storeDTO.setStoreGroupId(Integer.valueOf(groupId));
// } else {
// // 未命中
// TabStoreGroup group = storeGroupService.selectUnGroupedStore(t.getEnterpriseId());
// storeDTO.setStoreGroupId(group.getStoreGroupId());
// }
// }
// 启用策略
String hitStrategy = storeStrategyService.isHitStrategy(storeDTO, StoreGroupConstant.STORE_STRATEGY_TYPE);
storeDTO.setStatus(StringUtils.isNotBlank(hitStrategy) ? Integer.valueOf(hitStrategy) : StoreEnableOrDisAbleEnum.DISABLE.getCode());
......@@ -253,8 +268,6 @@ public class StoreTaskServiceImpl extends AbstractTaskAllocationOperation implem
}
}
storeDTO.setStoreExtendList(extendList);
// 导入门店肯定是没有修改过的
storeDTO.setIsEditStoreGroup(0);
storeDTO.setReason(StoreLogReasonEnum.WEB.getCode());
storeDTO.setRemark("批量导入");
......
......@@ -292,4 +292,12 @@
</foreach>
</if>
</select>
<select id="getClerkByCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_clerk
where enterprise_id = #{enterpriseId}
and store_info_id = #{storeInfoId}
and clerk_code = #{clerkCode}
</select>
</mapper>
\ No newline at end of file
......@@ -529,6 +529,7 @@
<if test="store.storeId != null ">
and t2.store_id &lt;&gt; #{store.storeId}
</if>
limit 1
</select>
<select id="getStoreOwnerByStoreInfoId" resultType="java.lang.Integer">
select
......
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