Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-webapp-plug
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-webapp-plug
Commits
b489bb4d
Commit
b489bb4d
authored
May 21, 2020
by
xub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
积分商品同步es测试接口
parent
90ebd4b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
19 deletions
+100
-19
AppletConfigGoodsController.java
...lug/web/controller/goods/AppletConfigGoodsController.java
+100
-19
No files found.
src/main/java/com/gic/plug/web/controller/goods/AppletConfigGoodsController.java
View file @
b489bb4d
...
...
@@ -24,6 +24,7 @@ import com.gic.widget.screening.api.service.EsScreeningSearchService;
import
com.google.common.base.Joiner
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.curator.shaded.com.google.common.base.Splitter
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -36,6 +37,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 商城装修选择器
...
...
@@ -91,6 +93,7 @@ public class AppletConfigGoodsController extends BaseGoodsController {
/**
* 商城组对外提供的组件
*
* @param currentPage
* @param pageSize
* @param appConfigId
...
...
@@ -100,7 +103,7 @@ public class AppletConfigGoodsController extends BaseGoodsController {
*/
@RequestMapping
(
"list-mall-goods-selector"
)
public
RestResponse
listGoodsByChannel
(
@RequestParam
(
value
=
"currentPage"
,
defaultValue
=
"1"
)
Integer
currentPage
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
String
appConfigId
,
String
search
,
Long
cordId
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
String
appConfigId
,
String
search
,
Long
cordId
,
Long
shopId
)
{
Long
areaId
=
null
;
if
(
StringUtils
.
isNotBlank
(
appConfigId
))
{
...
...
@@ -135,21 +138,21 @@ public class AppletConfigGoodsController extends BaseGoodsController {
ServiceResponse
<
ESResponseQueryBatchDTO
>
serviceResponse
=
searchGoods
(
currentPage
,
pageSize
,
areaId
,
search
,
Constant
.
CHANNEL_CODE_MALL
,
cordJSON
);
if
(
serviceResponse
.
isSuccess
())
{
List
<
Long
>
goodsIds
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
serviceResponse
.
getResult
().
getRes
()))
{
serviceResponse
.
getResult
().
getRes
().
forEach
(
json
->
{
Long
goodsId
=
json
.
getLong
(
"goodsId"
);
goodsIds
.
add
(
goodsId
);
});
}
ServiceResponse
<
Map
<
Long
,
BigDecimal
>>
mapServiceResponse
=
mallGoodsBusinessApiService
.
getLowestSkuPrice
(
goodsIds
,
getEnterpriseId
());
if
(
mapServiceResponse
.
isSuccess
())
{
Map
<
Long
,
BigDecimal
>
map
=
mapServiceResponse
.
getResult
();
serviceResponse
.
getResult
().
getRes
().
forEach
(
json
->
{
Long
goodsId
=
json
.
getLong
(
"goodsId"
);
json
.
put
(
"minSkuPrice"
,
map
.
getOrDefault
(
goodsId
,
BigDecimal
.
valueOf
(
0
)));
});
}
List
<
Long
>
goodsIds
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
serviceResponse
.
getResult
().
getRes
()))
{
serviceResponse
.
getResult
().
getRes
().
forEach
(
json
->
{
Long
goodsId
=
json
.
getLong
(
"goodsId"
);
goodsIds
.
add
(
goodsId
);
});
}
ServiceResponse
<
Map
<
Long
,
BigDecimal
>>
mapServiceResponse
=
mallGoodsBusinessApiService
.
getLowestSkuPrice
(
goodsIds
,
getEnterpriseId
());
if
(
mapServiceResponse
.
isSuccess
())
{
Map
<
Long
,
BigDecimal
>
map
=
mapServiceResponse
.
getResult
();
serviceResponse
.
getResult
().
getRes
().
forEach
(
json
->
{
Long
goodsId
=
json
.
getLong
(
"goodsId"
);
json
.
put
(
"minSkuPrice"
,
map
.
getOrDefault
(
goodsId
,
BigDecimal
.
valueOf
(
0
)));
});
}
return
RestResponse
.
success
(
serviceResponse
.
getResult
());
}
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
...
...
@@ -157,6 +160,7 @@ public class AppletConfigGoodsController extends BaseGoodsController {
/**
* 商城组对内的渠道商品组件
*
* @param currentPage
* @param pageSize
* @param search
...
...
@@ -164,8 +168,8 @@ public class AppletConfigGoodsController extends BaseGoodsController {
*/
@RequestMapping
(
"list-channel-goods-selector"
)
public
RestResponse
listGoodsChannel
(
@RequestParam
(
value
=
"currentPage"
,
defaultValue
=
"1"
)
Integer
currentPage
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
String
search
,
Double
startPrice
,
Double
endPrice
,
Integer
startStock
,
Integer
endStock
,
String
channelCode
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
String
search
,
Double
startPrice
,
Double
endPrice
,
Integer
startStock
,
Integer
endStock
,
String
channelCode
)
{
JSONObject
queryObject
=
null
;
if
(
startPrice
!=
null
)
{
queryObject
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"goodsPrice"
,
...
...
@@ -206,8 +210,27 @@ public class AppletConfigGoodsController extends BaseGoodsController {
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
private
Long
getGoodsDomainIdByAponfigId
(
String
appConfigId
)
{
Long
goodsDomainId
=
null
;
ServiceResponse
<
AppletsConfigSimpleOutputDTO
>
appServiceResponse
=
appletsConfigApiService
.
selectAppletsConfigIdByAppId
(
appConfigId
,
getEnterpriseId
());
if
(
appServiceResponse
.
getResult
()
==
null
)
{
log
.
info
(
"查不到小程序信息 appConfigId={}"
,
appConfigId
);
}
Integer
shopType
=
2
;
ServiceResponse
<
ShopDTO
>
shopDTOServiceResponse
=
shopApiService
.
getShopByAppletId
(
appServiceResponse
.
getResult
().
getAppletConfigId
(),
getEnterpriseId
(),
shopType
);
if
(
shopDTOServiceResponse
.
getResult
()
==
null
)
{
log
.
info
(
"查不到店铺信息 appConfigId={}"
,
appConfigId
);
return
null
;
}
goodsDomainId
=
shopDTOServiceResponse
.
getResult
().
getAreaId
();
return
goodsDomainId
;
}
private
ServiceResponse
<
ESResponseQueryBatchDTO
>
searchGoods
(
Integer
currentPage
,
Integer
pageSize
,
Long
goodsDomainId
,
String
search
,
String
channelCode
,
JSONObject
queryObject
)
{
Long
goodsDomainId
,
String
search
,
String
channelCode
,
JSONObject
queryObject
)
{
DynamicSearchDTO
searchDTO
=
new
DynamicSearchDTO
();
String
searchCode
=
""
;
if
(
Constant
.
CHANNEL_CODE_MALL
.
equals
(
channelCode
))
{
...
...
@@ -258,4 +281,62 @@ public class AppletConfigGoodsController extends BaseGoodsController {
return
serviceResponse
;
}
/**
* 小程序积分商城查询
*
* @param currentPage
* @param pageSize
* @param appConfigId
* @param cordId
* @return 调试接口
*/
//@RequestMapping("list-integral-goods-selector")
public
RestResponse
listIntegralGoodsByChannel
(
@RequestParam
(
value
=
"currentPage"
,
defaultValue
=
"1"
)
Integer
currentPage
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"20"
)
Integer
pageSize
,
String
appConfigId
,
Long
cordId
,
String
sortColumn
,
String
ids
,
Integer
proType
)
{
Long
goodsDomainId
=
getGoodsDomainIdByAponfigId
(
appConfigId
);
DynamicSearchDTO
searchDTO
=
new
DynamicSearchDTO
();
String
columnCategoryCode
=
"gic_integral_goods"
;
String
esName
=
esScreeningSearchService
.
getCurrentEsName
(
getEnterpriseId
()
+
""
,
columnCategoryCode
);
searchDTO
.
setIndexName
(
esName
);
searchDTO
.
setColumnCategoryCode
(
columnCategoryCode
);
searchDTO
.
setEnterpriseId
(
getEnterpriseId
()
+
""
);
searchDTO
.
setType
(
"mapper_type"
);
searchDTO
.
setBegin
((
currentPage
-
1
)
*
pageSize
);
searchDTO
.
setRecordNumber
(
pageSize
);
JSONObject
sortNode
=
QueryConditionAssemblyUtil
.
createSortNode
(
sortColumn
,
"desc"
);
List
<
JSONObject
>
jsonArray
=
new
ArrayList
<>();
JSONObject
proTypejson
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"proType"
,
OperateEnum
.
OPERATE_EQ
,
proType
);
JSONObject
goodsDomainIdJson
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"goodsDomainId"
,
OperateEnum
.
OPERATE_EQ
,
goodsDomainId
);
JSONObject
json
=
QueryConditionAssemblyUtil
.
addQueryNodeForSiblin
(
proTypejson
,
goodsDomainIdJson
,
OperateEnum
.
OPERATE_AND
);
JSONObject
upShelvesTimejson
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"upShelvesTime"
,
OperateEnum
.
OPERATE_LTE
,
System
.
currentTimeMillis
());
json
=
QueryConditionAssemblyUtil
.
addQueryNodeForSiblin
(
json
,
upShelvesTimejson
,
OperateEnum
.
OPERATE_AND
);
if
(
cordId
!=
null
)
{
JSONObject
goodsCodeJson
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"goodsCordId"
,
OperateEnum
.
OPERATE_EQ
,
cordId
);
json
=
QueryConditionAssemblyUtil
.
addQueryNodeForSiblin
(
json
,
goodsCodeJson
,
OperateEnum
.
OPERATE_AND
);
jsonArray
.
add
(
goodsCodeJson
);
}
if
(
ids
!=
null
)
{
List
<
Long
>
collect
=
Splitter
.
on
(
","
).
splitToList
(
ids
).
stream
().
map
(
x
->
Long
.
parseLong
(
x
)).
collect
(
Collectors
.
toList
());
JSONObject
goodsIdsJSON
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"id"
,
OperateEnum
.
OPERATE_CONTAIN
,
Joiner
.
on
(
" "
).
join
(
collect
));
JSONObject
strategyJson
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"strategyFlag"
,
OperateEnum
.
OPERATE_EQ
,
0
);
JSONObject
strategyAndgoodsIdsJSON
=
QueryConditionAssemblyUtil
.
addQueryNodeForSiblin
(
goodsIdsJSON
,
strategyJson
,
OperateEnum
.
OPERATE_OR
);
json
=
QueryConditionAssemblyUtil
.
addQueryNodeForSiblin
(
json
,
strategyAndgoodsIdsJSON
,
OperateEnum
.
OPERATE_AND
);
jsonArray
.
add
(
strategyAndgoodsIdsJSON
);
}
else
{
JSONObject
strategyJson
=
QueryConditionAssemblyUtil
.
createSimpleQueryNode
(
"strategyFlag"
,
OperateEnum
.
OPERATE_EQ
,
0
);
json
=
QueryConditionAssemblyUtil
.
addQueryNodeForSiblin
(
json
,
strategyJson
,
OperateEnum
.
OPERATE_AND
);
jsonArray
.
add
(
strategyJson
);
}
searchDTO
.
setSearchJson
(
json
);
searchDTO
.
setSortJson
(
sortNode
);
log
.
info
(
"查询条件 = {}"
,
JSONObject
.
toJSONString
(
searchDTO
));
ServiceResponse
<
ESResponseQueryBatchDTO
>
serviceResponse
=
esBusinessOperaApiService
.
queryDataBatch
(
searchDTO
,
false
,
null
);
if
(
serviceResponse
.
isSuccess
())
{
return
RestResponse
.
success
(
serviceResponse
.
getResult
());
}
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
}
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