Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-store
Commits
800d9342
Commit
800d9342
authored
Feb 27, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
700e0eaa
b0e6b424
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
31 deletions
+37
-31
StoreOpenApiServiceImpl.java
...gic/store/service/outer/impl/StoreOpenApiServiceImpl.java
+37
-31
No files found.
gic-store-service/src/main/java/com/gic/store/service/outer/impl/StoreOpenApiServiceImpl.java
View file @
800d9342
...
...
@@ -17,6 +17,7 @@ import com.gic.erp.operation.api.dto.ApiFieldDTO;
import
com.gic.erp.operation.api.service.ApiFieldApiService
;
import
com.gic.gateway.sdk.anno.GatewayExporter
;
import
com.gic.gateway.sdk.anno.GatewayParams
;
import
com.gic.store.constant.CreateTypeEnum
;
import
com.gic.store.constant.StoreLogReasonEnum
;
import
com.gic.store.dto.*
;
import
com.gic.store.dto.open.BusinessTimeOpenDTO
;
...
...
@@ -124,6 +125,7 @@ public class StoreOpenApiServiceImpl implements StoreOpenApiService {
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户ID错误,无此商户"
);
}
StoreDTO
storeDTO
=
EntityUtil
.
changeEntityByJSON
(
StoreDTO
.
class
,
storeOpenDTO
);
storeDTO
.
setEnterpriseId
(
enterpriseId
);
if
(
StringUtils
.
isBlank
(
storeOpenDTO
.
getStoreName
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"门店名称不能为空"
);
}
...
...
@@ -145,7 +147,7 @@ public class StoreOpenApiServiceImpl implements StoreOpenApiService {
Integer
erpType
=
storeOpenDTO
.
getErpType
();
String
storeTypeTmp
=
erpType
.
toString
();
for
(
StoreDictDTO
storeDictDTO
:
list
)
{
if
(
storeDictDTO
.
get
Key
().
equals
(
storeTypeTmp
))
{
if
(
storeDictDTO
.
get
Value
().
equals
(
storeTypeTmp
))
{
storeDTO
.
setStoreType
(
Integer
.
valueOf
(
storeDictDTO
.
getValue
()));
break
;
}
...
...
@@ -167,7 +169,7 @@ public class StoreOpenApiServiceImpl implements StoreOpenApiService {
Integer
erpStatus
=
storeOpenDTO
.
getErpStatus
();
String
storeStatusType
=
erpStatus
.
toString
();
for
(
StoreDictDTO
storeDictDTO
:
list
)
{
if
(
storeDictDTO
.
get
Key
().
equals
(
storeStatusType
))
{
if
(
storeDictDTO
.
get
Value
().
equals
(
storeStatusType
))
{
storeDTO
.
setStoreType
(
Integer
.
valueOf
(
storeDictDTO
.
getValue
()));
break
;
}
...
...
@@ -252,45 +254,49 @@ 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
());
storeDTO
.
setCreateType
(
CreateTypeEnum
.
API
.
getCode
());
// 保存门店
// this.storeService.save(storeDTO);
ServiceResponse
<
Integer
>
serviceResponse
=
storeApiService
.
saveOrUpdate
(
storeDTO
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment