Commit 4cda8641 by zhiwj

门店对外api修改

parent 50370961
......@@ -93,6 +93,12 @@ public class StoreOpenDTO implements Serializable {
/**
* 扩展字段
* [
* {
* "fieldCode":"",
* "fieldValue"""
* }
* ]
*/
private String customField;
......
......@@ -252,42 +252,45 @@ public class StoreOpenApiServiceImpl implements StoreOpenApiService {
List<StoreFieldDTO> fieldList = storeFieldService.listStoreFieldByRegionId(storeOpenDTO.getRegionId());
String customField = storeOpenDTO.getCustomField();
if (StringUtils.isBlank(customField)) {
customField = "";
customField = "[]";
}
List<JSONObject> customFieldList = JSON.parseArray(customField, JSONObject.class);
Map<String, String> apiFieldMap = getApiFieldMap(enterpriseId, storeOpenDTO.getRegionId());
if (apiFieldMap == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "获取gic端和对外API之间门店自定义字段的匹配数据失败");
}
for (JSONObject jsonObject : customFieldList) {
String fieldCode = jsonObject.getString("fieldCode");
String fieldName = apiFieldMap.get(fieldCode);
jsonObject.put("fieldName", fieldName);
}
if (CollectionUtils.isNotEmpty(customFieldList)) {
Map<String, String> apiFieldMap = getApiFieldMap(enterpriseId, storeOpenDTO.getRegionId());
if (apiFieldMap == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "获取gic端和对外API之间门店自定义字段的匹配数据失败");
}
for (JSONObject jsonObject : customFieldList) {
String fieldCode = jsonObject.getString("fieldCode");
String fieldName = apiFieldMap.get(fieldCode);
jsonObject.put("fieldName", fieldName);
}
// logger.info("门店域的ID:{}, 自定义字段数据:{}", regionId, JSON.toJSONString(fieldList));
if (CollectionUtils.isNotEmpty(fieldList)) {
List<StoreExtendDTO> extendDTOList = new ArrayList<>();
for (int i = 0; i < fieldList.size(); i++) {
StoreExtendDTO storeExtendDTO = new StoreExtendDTO();
storeExtendDTO.setStoreFieldId(fieldList.get(i).getStoreFieldId());
for (JSONObject storeFieldObject : customFieldList) {
if (fieldList.get(i).getStoreFieldName().equals(storeFieldObject.getString("fieldName"))) {
storeExtendDTO.setValue(storeFieldObject.getString("fieldValue"));
break;
if (CollectionUtils.isNotEmpty(fieldList)) {
List<StoreExtendDTO> extendDTOList = new ArrayList<>();
for (int i = 0; i < fieldList.size(); i++) {
StoreExtendDTO storeExtendDTO = new StoreExtendDTO();
storeExtendDTO.setStoreFieldId(fieldList.get(i).getStoreFieldId());
for (JSONObject storeFieldObject : customFieldList) {
if (fieldList.get(i).getStoreFieldName().equals(storeFieldObject.getString("fieldName"))) {
storeExtendDTO.setValue(storeFieldObject.getString("fieldValue"));
break;
}
}
storeExtendDTO.setSort(fieldList.get(i).getSort());
// 验证
ServiceResponse fieldResponse = storeApiService.validateFieldExceptRepeat(storeExtendDTO.getValue(), fieldList.get(i));
if (!fieldResponse.isSuccess()) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), fieldResponse.getMessage());
}
extendDTOList.add(storeExtendDTO);
}
storeExtendDTO.setSort(fieldList.get(i).getSort());
// 验证
ServiceResponse fieldResponse = storeApiService.validateFieldExceptRepeat(storeExtendDTO.getValue(), fieldList.get(i));
if (!fieldResponse.isSuccess()) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), fieldResponse.getMessage());
}
extendDTOList.add(storeExtendDTO);
storeDTO.setStoreExtendList(extendDTOList);
} else {
storeDTO.setStoreExtendList(Collections.emptyList());
}
storeDTO.setStoreExtendList(extendDTOList);
} else {
storeDTO.setStoreExtendList(Collections.emptyList());
}
storeDTO.setReason(StoreLogReasonEnum.EXTERNAL.getCode());
......
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