Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
02eaee7a
Commit
02eaee7a
authored
Jul 05, 2023
by
guojx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-2023-06-目标配置' into 'master'
Feature 2023 06 目标配置 See merge request
!1344
parents
98530592
4c049cd7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1057 additions
and
0 deletions
+1057
-0
StoreTargetConfigController.java
...ge/web/controller/target/StoreTargetConfigController.java
+425
-0
DataTargetMemberPyramidQO.java
...aoban/manage/web/qo/target/DataTargetMemberPyramidQO.java
+30
-0
QueryDataStatisticsCommonQO.java
...ban/manage/web/qo/target/QueryDataStatisticsCommonQO.java
+4
-0
StoreTargetConfigHttpUtils.java
...n/manage/web/utils/target/StoreTargetConfigHttpUtils.java
+370
-0
StoreTargetDisassemblyDetailVO.java
.../manage/web/vo/target/StoreTargetDisassemblyDetailVO.java
+113
-0
StoreTargetReachDetailVO.java
...haoban/manage/web/vo/target/StoreTargetReachDetailVO.java
+113
-0
dubbo-haoban-manage-wx.xml
...ge3-wx/src/main/webapp/WEB-INF/dubbo-haoban-manage-wx.xml
+2
-0
No files found.
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/target/StoreTargetConfigController.java
0 → 100644
View file @
02eaee7a
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
.
target
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.BasePageInfo
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.web.qo.PageQo
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.api.dto.StoreGroupDTO
;
import
com.gic.enterprise.api.dto.target.DataTargetConfigNewVersionsDTO
;
import
com.gic.enterprise.api.qdto.target.QueryNewDataTargetConfigQDTO
;
import
com.gic.enterprise.api.service.StoreGroupService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.enterprise.api.service.target.DataTargetConfigNewVersionsApiService
;
import
com.gic.haoban.manage.web.exception.TargetException
;
import
com.gic.haoban.manage.web.qo.target.DataTargetMemberPyramidQO
;
import
com.gic.haoban.manage.web.qo.target.QueryDataStatisticsCommonQO
;
import
com.gic.haoban.manage.web.utils.StoreAuthUtils
;
import
com.gic.haoban.manage.web.utils.target.StoreTargetConfigHttpUtils
;
import
com.gic.haoban.manage.web.vo.target.StoreTargetDisassemblyDetailVO
;
import
com.gic.haoban.manage.web.vo.target.StoreTargetReachDetailVO
;
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.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 好办小程序-门店目标跟进正式版
* @Author guojx
* @Date 2023/6/12 9:09
*/
@Controller
@RequestMapping
(
"/store-target-config"
)
public
class
StoreTargetConfigController
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
StoreTargetConfigController
.
class
);
@Autowired
private
StoreAuthUtils
storeAuthUtils
;
@Autowired
private
StoreService
storeService
;
@Autowired
private
DataTargetConfigNewVersionsApiService
dataTargetConfigNewVersionsApiService
;
@Autowired
private
StoreGroupService
storeGroupService
;
/**
* 是否有配置的发布门店
* @param qo
* @return
*/
@RequestMapping
(
value
=
"valid-target-store"
)
@ResponseBody
public
RestResponse
<
Integer
>
validTargetStore
(
QueryDataStatisticsCommonQO
qo
)
{
List
<
String
>
storeIdList
=
getStoreIdList
(
qo
,
false
);
QueryNewDataTargetConfigQDTO
param
=
new
QueryNewDataTargetConfigQDTO
();
param
.
setStoreIdList
(
storeIdList
);
param
.
setEnterpriseId
(
qo
.
getEnterpriseId
());
param
.
setReleaseFlag
(
1
);
param
.
setTargetYear
(
qo
.
getTime
().
substring
(
0
,
4
));
ServiceResponse
<
Page
<
DataTargetConfigNewVersionsDTO
>>
res
=
dataTargetConfigNewVersionsApiService
.
queryNewDataTargetConfig
(
param
,
new
BasePageInfo
());
if
(
res
.
isSuccess
())
{
if
(
res
.
getResult
().
getTotalCount
()
>
0
)
{
return
RestResponse
.
successResult
(
1
);
}
}
return
RestResponse
.
successResult
(
0
);
}
/**
* 目标跟进核心目标达成概况
* @return
*/
@RequestMapping
(
value
=
"get-target-reach-overview"
)
@ResponseBody
public
RestResponse
getTargetReachOverview
(
QueryDataStatisticsCommonQO
qo
)
{
JSONObject
jsonObject
=
getCommon
(
qo
);
queryStoreGroupType
(
jsonObject
,
8
);
Map
<
String
,
Object
>
res
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
isYearQuery
()
?
"data_target_mgt_group_year_stat"
:
"data_target_mgt_group_month_stat"
);
return
StoreTargetConfigHttpUtils
.
responsePageOne
(
res
);
}
/**
* 目标跟进核心指标趋势分月/累计
* @param qo
* @return
*/
@RequestMapping
(
value
=
"get-target-chart"
)
@ResponseBody
public
RestResponse
getTargetChart
(
QueryDataStatisticsCommonQO
qo
)
{
qo
.
setTimeType
(
null
);
JSONObject
jsonObject
=
getCommon
(
qo
);
queryStoreGroupType
(
jsonObject
,
8
);
//因为有天,2条最多62调数据
jsonObject
.
put
(
"pageNum"
,
1
);
jsonObject
.
put
(
"pageSize"
,
100
);
//不传月参数,返回12条月数据。否则返回一条合计
Map
<
String
,
Object
>
res
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
"data_target_mgt_group_month_stat"
);
return
StoreTargetConfigHttpUtils
.
responsePageList
(
res
);
}
/**
* 目标跟进达成分析门店明细数据
* @param qo
* @param pageQo
* @param orderByType 排序类型 1 正序asc 2倒序desc
* @param orderByFields 数字。具体看数据组的文档,备注里会有文档链接
* @return
*/
@RequestMapping
(
value
=
"get-target-analysis-store-detail"
)
@ResponseBody
public
RestResponse
<
Page
<
StoreTargetReachDetailVO
>>
getTargetAnalysisStoreDetail
(
QueryDataStatisticsCommonQO
qo
,
PageQo
pageQo
,
Integer
orderByType
,
Integer
orderByFields
)
{
JSONObject
jsonObject
=
getCommon
(
qo
);
queryStoreGroupType
(
jsonObject
,
8
);
//不传月参数,返回12条月数据。否则返回一条合计
Map
<
String
,
Object
>
totalRes
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
isYearQuery
()
?
"data_target_mgt_group_year_stat"
:
"data_target_mgt_group_month_stat"
);
if
(!
StoreTargetConfigHttpUtils
.
isSuccess
(
totalRes
))
{
throw
new
TargetException
(
totalRes
.
get
(
"errMsg"
).
toString
());
}
JSONObject
totalData
=
StoreTargetConfigHttpUtils
.
getPageOne
(
totalRes
);
//查询列表数据
jsonObject
.
put
(
"pageSize"
,
pageQo
.
getPageSize
());
jsonObject
.
put
(
"pageNum"
,
pageQo
.
getPageNum
());
//滚动达成率(总销售额) 排序33
jsonObject
.
put
(
"orderByFields"
,
orderByType
==
null
?
1
:
orderByType
);
jsonObject
.
put
(
"orderByType"
,
orderByFields
==
null
?
33
:
orderByFields
);
queryStoreGroupType
(
jsonObject
,
7
);
Map
<
String
,
Object
>
res
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
isYearQuery
()
?
"data_target_mgt_group_year_stat"
:
"data_target_mgt_group_month_stat"
);
Page
page
=
StoreTargetConfigHttpUtils
.
getPageData
(
res
);
Page
<
StoreTargetReachDetailVO
>
resultPage
=
EntityUtil
.
changeEntityNew
(
Page
.
class
,
page
);
List
<
JSONObject
>
list
=
StoreTargetConfigHttpUtils
.
getPageList
(
res
);
List
<
StoreTargetReachDetailVO
>
voList
=
JSONObject
.
parseArray
(
JSONObject
.
toJSONString
(
list
),
StoreTargetReachDetailVO
.
class
);
if
(
pageQo
.
getPageNum
()
==
1
)
{
StoreTargetReachDetailVO
vo
=
JSONObject
.
parseObject
(
totalData
.
toJSONString
(),
StoreTargetReachDetailVO
.
class
);
vo
.
setStoreId
(
"-1"
);
vo
.
setStoreName
(
"合计"
);
vo
.
setStoreCode
(
"-1"
);
voList
.
add
(
0
,
vo
);
}
resultPage
.
setResult
(
voList
);
return
RestResponse
.
successResult
(
resultPage
);
}
/**
* 树跳转-目标跟进达成分析门店明细数据
* @param qo
* @param pageQo
* @param orderByType 排序类型 1 正序asc 2倒序desc
* @param orderByFields 数字。具体看数据组的文档,备注里会有文档链接
* @return
*/
@RequestMapping
(
value
=
"get-target-analysis-store-detail-of-tree"
)
@ResponseBody
public
RestResponse
<
Page
<
StoreTargetDisassemblyDetailVO
>>
getTargetAnalysisStoreDetailOfTree
(
QueryDataStatisticsCommonQO
qo
,
PageQo
pageQo
,
Integer
orderByType
,
Integer
orderByFields
)
{
JSONObject
jsonObject
=
getCommon
(
qo
);
queryStoreGroupType
(
jsonObject
,
8
);
//不传月参数,返回12条月数据。否则返回一条合计
Map
<
String
,
Object
>
totalRes
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
isYearQuery
()
?
"data_target_mgt_mbr_pay_amt_dismbl_year"
:
"data_target_mgt_mbr_pay_amt_dismbl_month"
);
if
(!
StoreTargetConfigHttpUtils
.
isSuccess
(
totalRes
))
{
throw
new
TargetException
(
totalRes
.
get
(
"errMsg"
).
toString
());
}
JSONObject
totalData
=
StoreTargetConfigHttpUtils
.
getPageOne
(
totalRes
);
//查询列表数据
jsonObject
.
put
(
"pageSize"
,
pageQo
.
getPageSize
());
jsonObject
.
put
(
"pageNum"
,
pageQo
.
getPageNum
());
//会员消费次数滚动达成率 排序11
jsonObject
.
put
(
"orderByFields"
,
orderByType
==
null
?
1
:
orderByType
);
jsonObject
.
put
(
"orderByType"
,
orderByFields
==
null
?
11
:
orderByFields
);
queryStoreGroupType
(
jsonObject
,
7
);
Map
<
String
,
Object
>
res
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
isYearQuery
()
?
"data_target_mgt_mbr_pay_amt_dismbl_year"
:
"data_target_mgt_mbr_pay_amt_dismbl_month"
);
Page
page
=
StoreTargetConfigHttpUtils
.
getPageData
(
res
);
Page
<
StoreTargetDisassemblyDetailVO
>
resultPage
=
EntityUtil
.
changeEntityNew
(
Page
.
class
,
page
);
List
<
JSONObject
>
list
=
StoreTargetConfigHttpUtils
.
getPageList
(
res
);
List
<
StoreTargetDisassemblyDetailVO
>
voList
=
JSONObject
.
parseArray
(
JSONObject
.
toJSONString
(
list
),
StoreTargetDisassemblyDetailVO
.
class
);
if
(
pageQo
.
getPageNum
()
==
1
)
{
StoreTargetDisassemblyDetailVO
vo
=
JSONObject
.
parseObject
(
totalData
.
toJSONString
(),
StoreTargetDisassemblyDetailVO
.
class
);
vo
.
setStoreId
(
"-1"
);
vo
.
setStoreName
(
"合计"
);
vo
.
setStoreCode
(
"-1"
);
voList
.
add
(
0
,
vo
);
}
resultPage
.
setResult
(
voList
);
return
RestResponse
.
successResult
(
resultPage
);
}
private
int
getStoreGroupType
(
Integer
showAllStoreFlag
,
String
nextStoreGroupId
)
{
//1:分组1,2:分组2,3:分组3,4:分组4,5:分组5,6:分组6,7:门店,8:区经)
if
(
showAllStoreFlag
!=
null
&&
showAllStoreFlag
==
1
)
{
return
7
;
}
if
(
StringUtils
.
isNotBlank
(
nextStoreGroupId
))
{
StoreGroupDTO
storeGroupDTO
=
storeGroupService
.
getStoreGroupById
(
nextStoreGroupId
);
return
storeGroupDTO
.
getGroupLevel
()
+
1
;
}
return
1
;
}
private
void
dealNextStoreIdParam
(
JSONObject
jsonObject
,
String
nextStoreGroupId
)
{
QueryNewDataTargetConfigQDTO
qdto
=
new
QueryNewDataTargetConfigQDTO
();
qdto
.
setStoreGroupId
(
nextStoreGroupId
);
qdto
.
setEnterpriseId
(
jsonObject
.
getString
(
"enterpriseId"
));
List
<
String
>
nextStoreIdList
=
dataTargetConfigNewVersionsApiService
.
getQueryStoreParam
(
qdto
).
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
nextStoreIdList
))
{
if
(
jsonObject
.
containsKey
(
"storeId"
))
{
String
authStoreId
=
jsonObject
.
get
(
"storeId"
).
toString
();
List
<
String
>
authStoreIdList
=
Arrays
.
stream
(
authStoreId
.
split
(
","
)).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
authStoreIdList
))
{
//交集
nextStoreIdList
.
retainAll
(
authStoreIdList
);
}
jsonObject
.
put
(
"storeId"
,
nextStoreIdList
.
stream
().
collect
(
Collectors
.
joining
(
","
)));
}
}
}
private
static
void
queryStoreGroupType
(
JSONObject
jsonObject
,
int
type
)
{
jsonObject
.
put
(
"storeGroup"
,
type
);
}
private
JSONObject
getCommon
(
QueryDataStatisticsCommonQO
qo
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"enterpriseId"
,
qo
.
getEnterpriseId
());
if
(
StringUtils
.
isBlank
(
qo
.
getTime
()))
{
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy"
);
qo
.
setTime
(
df
.
format
(
new
Date
()));
}
if
(
qo
.
isYearQuery
())
{
jsonObject
.
put
(
"targetYear"
,
qo
.
getTime
());
}
else
{
jsonObject
.
put
(
"targetMonth"
,
qo
.
getTime
());
}
jsonObject
.
put
(
"storeId"
,
getStoreIdList
(
qo
,
true
).
stream
().
collect
(
Collectors
.
joining
(
","
)));
return
jsonObject
;
}
private
List
<
String
>
getStoreIdList
(
QueryDataStatisticsCommonQO
qo
,
boolean
isRelease
)
{
List
<
String
>
storeIdList
;
if
(
StringUtils
.
isBlank
(
qo
.
getStoreId
()))
{
storeIdList
=
storeAuthUtils
.
queryClerkStoreIds
(
qo
.
getClerkId
(),
qo
.
getWxEnterpriseId
());
}
else
{
storeIdList
=
new
ArrayList
<>();
String
[]
storeIds
=
qo
.
getStoreId
().
split
(
","
);
for
(
String
storeIdTemp
:
storeIds
)
{
if
(
StringUtils
.
isBlank
(
storeIdTemp
))
{
continue
;
}
storeIdList
.
add
(
storeIdTemp
);
}
}
if
(!
isRelease
)
{
return
storeIdList
;
}
List
<
String
>
targetStoreIdList
=
getReleaseStore
(
qo
,
1
);
//交集 (已发布的门店数据统计过滤)
if
(
CollectionUtils
.
isEmpty
(
targetStoreIdList
))
{
targetStoreIdList
=
new
ArrayList
<>();
targetStoreIdList
.
add
(
"-123456789"
);
}
if
(
CollectionUtils
.
isEmpty
(
storeIdList
))
{
//全部权限,则给出发布门店数据
return
targetStoreIdList
;
}
else
{
storeIdList
.
retainAll
(
targetStoreIdList
);
if
(
CollectionUtils
.
isEmpty
(
storeIdList
))
{
storeIdList
.
add
(
"-1234567890"
);
}
}
return
storeIdList
;
}
public
List
<
String
>
getReleaseStore
(
QueryDataStatisticsCommonQO
params
,
Integer
releaseFlag
)
{
List
<
String
>
storeIdList
=
new
ArrayList
<>();
QueryNewDataTargetConfigQDTO
qdto
=
new
QueryNewDataTargetConfigQDTO
();
qdto
.
setEnterpriseId
(
params
.
getEnterpriseId
());
if
(
StringUtils
.
isNotBlank
(
params
.
getTime
()))
{
qdto
.
setTargetYear
(
params
.
getTime
().
substring
(
0
,
4
));
}
qdto
.
setReleaseFlag
(
releaseFlag
);
BasePageInfo
basePageInfo
=
new
BasePageInfo
();
basePageInfo
.
setPageNum
(
1
);
basePageInfo
.
setPageSize
(
1000
);
ServiceResponse
<
Page
<
DataTargetConfigNewVersionsDTO
>>
res
=
dataTargetConfigNewVersionsApiService
.
queryNewDataTargetConfig
(
qdto
,
basePageInfo
);
Page
<
DataTargetConfigNewVersionsDTO
>
page
=
res
.
getResult
();
Integer
total
=
page
.
getTotalCount
();
if
(
total
<=
0
)
{
return
null
;
}
List
<
DataTargetConfigNewVersionsDTO
>
list
=
page
.
getResult
();
for
(
DataTargetConfigNewVersionsDTO
dto
:
list
)
{
storeIdList
.
add
(
dto
.
getStoreId
());
}
int
pageNum
=
total
/
1000
+
1
;
if
(
pageNum
>
1
)
{
for
(
int
i
=
2
;
i
<
pageNum
;
i
++)
{
basePageInfo
.
setPageNum
(
i
);
res
=
dataTargetConfigNewVersionsApiService
.
queryNewDataTargetConfig
(
qdto
,
basePageInfo
);
List
<
DataTargetConfigNewVersionsDTO
>
temp
=
res
.
getResult
().
getResult
();
for
(
DataTargetConfigNewVersionsDTO
dto
:
temp
)
{
storeIdList
.
add
(
dto
.
getStoreId
());
}
}
}
return
storeIdList
;
}
/**
* 会员销售额(服务门店维度)拆解 树
* @param qo
* @return
*/
@RequestMapping
(
value
=
"get-member-sales-disassemble"
)
@ResponseBody
public
RestResponse
getMemberSalesDisassemble
(
QueryDataStatisticsCommonQO
qo
)
{
JSONObject
jsonObject
=
getCommon
(
qo
);
//聚合成一条
queryStoreGroupType
(
jsonObject
,
8
);
LOGGER
.
info
(
"会员销售额树 {}"
,
jsonObject
.
toJSONString
());
jsonObject
.
put
(
"orderByFields"
,
5
);
jsonObject
.
put
(
"orderByType"
,
1
);
//总数据查询
Map
<
String
,
Object
>
totalRes
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
qo
.
isYearQuery
()
?
"data_target_mgt_mbr_pay_amt_dismbl_year"
:
"data_target_mgt_mbr_pay_amt_dismbl_month"
);
LOGGER
.
info
(
"树返回 {}"
,
JSONObject
.
toJSONString
(
totalRes
));
return
StoreTargetConfigHttpUtils
.
responsePageOne
(
totalRes
);
}
/**
* 会员转化漏斗
* @param qo
* @return
*/
@RequestMapping
(
value
=
"get-consumption-conversion"
)
@ResponseBody
public
RestResponse
getConsumptionConversion
(
DataTargetMemberPyramidQO
qo
)
{
JSONObject
jsonObject
=
getCommon
(
qo
);
//聚合成一条
queryStoreGroupType
(
jsonObject
,
8
);
if
(
qo
.
getMemberType
()
!=
null
)
{
jsonObject
.
put
(
"isNewMbr"
,
qo
.
getMemberType
());
}
LOGGER
.
info
(
"会员转化漏斗 {}"
,
jsonObject
.
toJSONString
());
//总数据查询
Map
<
String
,
Object
>
totalRes
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
"data_target_mgt_mbr_harch_stat"
);
LOGGER
.
info
(
"漏斗返回 {}"
,
JSONObject
.
toJSONString
(
totalRes
));
return
StoreTargetConfigHttpUtils
.
responseRest
(
totalRes
);
}
/**
* 会员金字塔分层
* @param qo
* @return
*/
@RequestMapping
(
value
=
"get-member-pyramid-hierarchy"
)
@ResponseBody
public
RestResponse
getMemberPyramidHierarchy
(
DataTargetMemberPyramidQO
qo
)
{
JSONObject
jsonObject
=
getCommon
(
qo
);
//聚合成一条
queryStoreGroupType
(
jsonObject
,
8
);
if
(
qo
.
getMemberType
()
!=
null
)
{
jsonObject
.
put
(
"isNewMbr"
,
qo
.
getMemberType
());
}
if
(
qo
.
getMemberConsume
()
!=
null
)
{
if
(
qo
.
getMemberConsume
()
==
1
)
{
// 今年未复购会员
jsonObject
.
put
(
"isRepchMbr"
,
0
);
}
else
if
(
qo
.
getMemberConsume
()
==
2
)
{
//今年未消费会员
jsonObject
.
put
(
"isCsmeMbr"
,
0
);
}
else
if
(
qo
.
getMemberConsume
()
==
3
)
{
//今年仅消费一次会员
jsonObject
.
put
(
"csmeCnt"
,
1
);
}
}
LOGGER
.
info
(
"会员金字塔分层 {}"
,
jsonObject
.
toJSONString
());
//总数据查询
Map
<
String
,
Object
>
totalRes
=
StoreTargetConfigHttpUtils
.
http
(
jsonObject
.
toJSONString
(),
"data_target_mgt_harch_631_stat"
);
LOGGER
.
info
(
"金字塔返回 {}"
,
JSONObject
.
toJSONString
(
totalRes
));
return
StoreTargetConfigHttpUtils
.
responseRest
(
totalRes
);
}
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/qo/target/DataTargetMemberPyramidQO.java
0 → 100644
View file @
02eaee7a
package
com
.
gic
.
haoban
.
manage
.
web
.
qo
.
target
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* 会员金字塔分层&漏斗查询
* @author yangzhang
*/
@Data
public
class
DataTargetMemberPyramidQO
extends
QueryDataStatisticsCommonQO
implements
Serializable
{
// private String storeGroupId;
// private String storeId;
// private String enterpriseId;
/**
* 1新增会员 0存量会员 不传为全部
*/
private
Integer
memberType
;
/**
* 1 今年未复购会员 2今年未消费会员 3今年仅消费一次会员
*/
private
Integer
memberConsume
;
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/qo/target/QueryDataStatisticsCommonQO.java
View file @
02eaee7a
...
...
@@ -92,4 +92,8 @@ public class QueryDataStatisticsCommonQO implements Serializable {
this
.
enterpriseId
=
enterpriseId
;
return
this
;
}
public
boolean
isYearQuery
()
{
return
timeType
==
null
||
timeType
==
1
;
}
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/utils/target/StoreTargetConfigHttpUtils.java
0 → 100644
View file @
02eaee7a
package
com
.
gic
.
haoban
.
manage
.
web
.
utils
.
target
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.haoban.manage.web.exception.TargetException
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 目标配置调用数据组http接口工具类
* @Author guojx
* @Date 2022/5/6 17:01
*/
public
class
StoreTargetConfigHttpUtils
extends
HttpClient
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
StoreTargetConfigHttpUtils
.
class
);
public
static
void
main
(
String
[]
args
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"enterpriseId"
,
"ff8080815dacd3a2015dacd3ef5c0000"
);
//Map<String, Object> res = http(getParamNoPage(jsonObject).toJSONString(), "data_mbr_target_overview_targetActual");
//System.out.println(JSON.toJSONString(responseOfOne(res, null)));
}
public
static
boolean
isSuccess
(
Map
<
String
,
Object
>
res
)
{
return
res
.
get
(
"errCode"
).
toString
().
equals
(
"0"
);
}
public
static
RestResponse
errorRes
(
Map
<
String
,
Object
>
res
)
{
return
RestResponse
.
failure
(
res
.
get
(
"errCode"
).
toString
(),
res
.
get
(
"errMsg"
).
toString
());
}
public
static
List
<
JSONObject
>
getDataList
(
Map
<
String
,
Object
>
res
)
{
return
(
List
<
JSONObject
>)
res
.
get
(
"data"
);
}
public
static
<
T
>
RestResponse
<
Page
<
T
>>
responsePage
(
Map
<
String
,
Object
>
res
,
Class
clazz
)
{
if
(
isSuccess
(
res
))
{
RestResponse
response
=
responsePage
(
res
);
Page
page
=
(
Page
)
response
.
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
Page
<
T
>
resPage
=
EntityUtil
.
changeEntityNew
(
Page
.
class
,
page
);
resPage
.
setResult
(
EntityUtil
.
changeEntityListNew
(
clazz
,
page
.
getResult
()));
return
RestResponse
.
successResult
(
resPage
);
}
return
RestResponse
.
successResult
(
page
);
}
return
errorRes
(
res
);
}
public
static
Page
getPageData
(
Map
<
String
,
Object
>
res
)
{
if
(!
isSuccess
(
res
))
{
throw
new
TargetException
(
res
.
get
(
"errMsg"
).
toString
());
}
JSONObject
data
=
(
JSONObject
)
res
.
get
(
"data"
);
Page
page
=
new
Page
();
page
.
setTotalCount
(
data
.
getIntValue
(
"totalNum"
));
page
.
setPageSize
(
data
.
getIntValue
(
"pageSize"
));
page
.
setCurrentPage
(
data
.
getIntValue
(
"pageNum"
));
List
<
JSONObject
>
list
=
(
List
<
JSONObject
>)
data
.
get
(
"rows"
);
page
.
setResult
(
list
);
return
page
;
}
public
static
RestResponse
responsePage
(
Map
<
String
,
Object
>
res
)
{
if
(
isSuccess
(
res
))
{
return
RestResponse
.
successResult
(
getPageData
(
res
));
}
return
errorRes
(
res
);
}
public
static
RestResponse
responsePageOne
(
Map
<
String
,
Object
>
res
)
{
return
RestResponse
.
successResult
(
getPageOne
(
res
));
}
public
static
RestResponse
responsePageList
(
Map
<
String
,
Object
>
res
)
{
Page
page
=
getPageData
(
res
);
return
RestResponse
.
successResult
(
page
.
getResult
());
}
public
static
RestResponse
responseRest
(
Map
<
String
,
Object
>
res
)
{
if
(
isSuccess
(
res
))
{
return
RestResponse
.
successResult
(
getDataList
(
res
));
}
return
errorRes
(
res
);
}
public
static
JSONObject
getPageOne
(
Map
<
String
,
Object
>
res
)
{
Page
page
=
getPageData
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
return
(
JSONObject
)
page
.
getResult
().
get
(
0
);
}
return
new
JSONObject
();
}
public
static
List
<
JSONObject
>
getPageList
(
Map
<
String
,
Object
>
res
)
{
Page
page
=
getPageData
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getResult
()))
{
return
(
List
<
JSONObject
>)
page
.
getResult
();
}
return
Collections
.
EMPTY_LIST
;
}
public
static
JSONObject
getDefaultMonth
(
JSONObject
resJson
)
{
if
(!
resJson
.
containsKey
(
"1"
))
{
resJson
.
put
(
"1"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"2"
))
{
resJson
.
put
(
"2"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"3"
))
{
resJson
.
put
(
"3"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"4"
))
{
resJson
.
put
(
"4"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"5"
))
{
resJson
.
put
(
"5"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"6"
))
{
resJson
.
put
(
"6"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"7"
))
{
resJson
.
put
(
"7"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"8"
))
{
resJson
.
put
(
"8"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"9"
))
{
resJson
.
put
(
"9"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"10"
))
{
resJson
.
put
(
"10"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"11"
))
{
resJson
.
put
(
"11"
,
0
D
);
}
if
(!
resJson
.
containsKey
(
"12"
))
{
resJson
.
put
(
"12"
,
0
D
);
}
return
resJson
;
}
public
static
JSONObject
getCommonParam
(
String
enterpriseId
,
String
storeId
,
String
startTime
,
String
endTime
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"enterpriseId"
,
enterpriseId
);
jsonObject
.
put
(
"entId"
,
enterpriseId
);
jsonObject
.
put
(
"storeId"
,
storeId
);
jsonObject
.
put
(
"startTime"
,
startTime
);
jsonObject
.
put
(
"startDate"
,
startTime
);
jsonObject
.
put
(
"endTime"
,
endTime
);
jsonObject
.
put
(
"endDate"
,
endTime
);
return
jsonObject
;
}
public
static
RestResponse
responseOfOneForRest
(
Map
<
String
,
Object
>
res
,
JSONObject
defaultJson
)
{
if
(
isSuccess
(
res
))
{
List
<
JSONObject
>
list
=
getDataList
(
res
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
return
RestResponse
.
successResult
(
list
.
get
(
0
));
}
if
(
defaultJson
!=
null
)
{
return
RestResponse
.
successResult
(
defaultJson
);
}
return
RestResponse
.
successResult
();
}
return
RestResponse
.
failure
(
"-1"
,
res
.
get
(
"errMsg"
).
toString
());
}
public
static
void
dealStoreIdParam
(
JSONObject
objParam
)
{
if
(
objParam
!=
null
)
{
if
(
objParam
.
containsKey
(
"storeId"
))
{
Object
storeId
=
objParam
.
get
(
"storeId"
);
if
(
storeId
==
null
||
StringUtils
.
isBlank
(
storeId
.
toString
()))
{
objParam
.
remove
(
"storeId"
);
}
}
}
}
public
static
Map
<
String
,
Object
>
http
(
String
jsonParam
,
String
apolloKey
)
{
if
(
StringUtils
.
isNotBlank
(
jsonParam
))
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
jsonParam
);
dealStoreIdParam
(
jsonObject
);
jsonParam
=
jsonObject
.
toJSONString
();
}
LOGGER
.
info
(
"接口的key:{}"
,
apolloKey
);
Config
config
=
ConfigService
.
getConfig
(
"COMMON.data-api-config"
);
String
value
=
config
.
getProperty
(
apolloKey
,
""
);
if
(
StringUtils
.
isBlank
(
value
))
{
throw
new
TargetException
(
"数据接口配置有误!"
);
}
LOGGER
.
info
(
"{}:Apollo查询的配置信息:{}"
,
apolloKey
,
value
);
String
[]
split
=
value
.
split
(
"\\+\\+\\+\\+"
);
String
url
=
split
[
0
];
String
token
=
split
[
1
];
Map
<
String
,
String
>
head
=
new
HashMap
<>();
head
.
put
(
"Content-Type"
,
"application/json"
);
head
.
put
(
"Authorization"
,
token
);
Map
<
String
,
Object
>
res
=
HttpClient
.
getWinxinResByJson
(
url
,
jsonParam
,
head
);
if
(!
isSuccess
(
res
))
{
throw
new
TargetException
((
String
)
res
.
get
(
"errorInfo"
));
}
LOGGER
.
info
(
"调用接口{},返回结果:{}"
,
url
,
res
);
return
res
;
}
public
static
JSONObject
getParam
(
JSONObject
objParam
)
{
if
(
objParam
!=
null
)
{
if
(
objParam
.
containsKey
(
"storeId"
))
{
Object
storeId
=
objParam
.
get
(
"storeId"
);
if
(
storeId
==
null
||
StringUtils
.
isBlank
(
storeId
.
toString
()))
{
objParam
.
remove
(
"storeId"
);
}
}
}
return
objParam
;
}
/**
* 保留2位小数 .元转万元
*
* @param a
* @param isNeedToTransfer true除以10000
* @return by wws
*/
public
static
Double
transferTenThousand
(
Object
a
,
boolean
isNeedToTransfer
)
{
if
(
a
==
null
)
{
return
0.00
;
}
BigDecimal
bd
=
new
BigDecimal
(
a
.
toString
());
if
(
isNeedToTransfer
)
{
bd
=
bd
.
divide
(
new
BigDecimal
(
10000
));
}
bd
=
bd
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
return
bd
.
doubleValue
();
}
/**
* 保留2位小数 .元转万元
*
* @param a
* @return by wws
*/
public
static
Double
transferTenThousand
(
Double
a
)
{
BigDecimal
bd
=
new
BigDecimal
(
a
/
10000
);
bd
=
bd
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
return
bd
.
doubleValue
();
}
public
static
Double
transferTenThousand
(
String
a
)
{
BigDecimal
bd
=
new
BigDecimal
(
a
);
bd
=
bd
.
divide
(
new
BigDecimal
(
"10000"
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
return
bd
.
doubleValue
();
}
public
static
Double
transferTenThousand
(
Object
a
)
{
if
(
a
==
null
)
{
return
0.00
;
}
BigDecimal
bd
=
new
BigDecimal
(
a
.
toString
());
bd
=
bd
.
divide
(
new
BigDecimal
(
"10000"
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
return
bd
.
doubleValue
();
}
public
static
Double
parseDouble
(
Object
a
)
{
if
(
a
==
null
)
{
return
0.00
;
}
return
Double
.
parseDouble
(
a
.
toString
());
}
public
static
Double
transferTenThousandNoDivide
(
Double
a
)
{
if
(
a
==
null
)
{
return
0.00
;
}
BigDecimal
bd
=
new
BigDecimal
(
a
.
toString
());
bd
=
bd
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
return
bd
.
doubleValue
();
}
public
static
String
formatToSepara
(
Double
data
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
return
df
.
format
(
data
);
}
public
static
String
formatToSepara
(
Integer
data
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"#,###"
);
return
df
.
format
(
data
);
}
public
static
String
getContrast
(
String
data
)
{
if
(
"--"
.
equals
(
data
))
{
return
data
;
}
Double
dataDouble
=
Double
.
parseDouble
(
data
);
if
(
dataDouble
>
0
)
{
return
"+"
+
data
+
"%"
;
}
else
{
return
data
+
"%"
;
}
}
public
static
String
getJsonOrDefault
(
Object
a
,
Object
object
)
{
if
(
a
==
null
)
{
return
object
.
toString
();
}
return
a
.
toString
();
}
public
static
Object
getObjectOrDefault
(
Object
a
,
Object
object
)
{
if
(
a
==
null
)
{
return
object
;
}
return
a
;
}
public
static
String
getContrastOrDefault
(
Object
a
,
Object
object
)
{
return
getContrast
(
getJsonOrDefault
(
a
,
object
));
}
public
static
String
getRateOrDefault
(
Object
a
,
Object
object
)
{
String
data
=
getJsonOrDefault
(
a
,
object
);
if
(
"--"
.
equals
(
data
))
{
return
data
;
}
return
data
+
"%"
;
}
public
static
JSONObject
fixLastMonthSales
(
JSONObject
resJson
,
Double
yearSales
)
{
if
(
yearSales
==
null
||
yearSales
<=
0
)
{
return
resJson
;
}
int
lastMonth
=
1
;
//取出最后一个有值的月份
for
(
int
i
=
1
;
i
<=
12
;
i
++)
{
if
(
resJson
.
containsKey
(
String
.
valueOf
(
i
)))
{
//如果有值
if
(
i
>
lastMonth
)
{
lastMonth
=
i
;
}
}
}
Double
sum
=
0
D
;
for
(
int
i
=
1
;
i
<
lastMonth
;
i
++)
{
if
(
resJson
.
containsKey
(
String
.
valueOf
(
i
)))
{
sum
+=
resJson
.
getDouble
(
String
.
valueOf
(
i
));
}
}
resJson
.
put
(
String
.
valueOf
(
lastMonth
),
transferTenThousandNoDivide
(
yearSales
-
sum
));
return
resJson
;
}
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/vo/target/StoreTargetDisassemblyDetailVO.java
0 → 100644
View file @
02eaee7a
package
com
.
gic
.
haoban
.
manage
.
web
.
vo
.
target
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Author guojx
* @Date 2023/6/9 9:21
*/
@Data
public
class
StoreTargetDisassemblyDetailVO
implements
Serializable
{
private
String
storeId
;
private
String
storeName
;
private
String
storeGroupId
;
private
String
storeGroupName
;
private
String
storeCode
;
/**
* 会员消费次数实际值 排序7
*/
private
Integer
mbrCsmeCnt
;
/**
* 会员消费次数去年同期值 排序8
*/
private
Integer
mbrCsmeCntSply
;
/**
* 会员消费次数全年目标值 排序9
*/
private
Integer
mbrCsmeCntTarget
;
/**
* 会员消费次数当前应达目标值 排序10
*/
private
Integer
mbrCsmeCntCurTarget
;
/**
* 会员消费次数滚动达成率 排序11
*/
private
Double
mbrCsmeCntRollAch
;
/**
* 会员消费次数累计达成率 排序12
*/
private
Double
mbrCsmeCntAccAch
;
/**
* 存量会员消费总次数实际值 排序19
*/
private
Integer
stockMbrCsmeCnt
;
/**
* 存量会员消费总次数去年同期值 排序20
*/
private
Integer
stockMbrCsmeCntSply
;
/**
* 存量会员消费总次数全年目标值 排序21
*/
private
Integer
stockMbrCsmeCntTarget
;
/**
* 存量会员消费总次数当前应达目标值 排序22
*/
private
Integer
stockMbrCsmeCntCurTarget
;
/**
* 存量会员消费总次数滚动达成率 排序23
*/
private
Double
stockMbrCsmeCntRollAch
;
/**
* 存量会员消费总次数累计达成率 排序24
*/
private
Double
stockMbrCsmeCntAccAch
;
/**
* 新增会员消费总次数实际值 排序25
*/
private
Integer
newMbrCsmeCnt
;
/**
* 新增会员消费总次数去年同期值 排序26
*/
private
Integer
newMbrCsmeCntSply
;
/**
* 新增会员消费总次数全年目标值 排序27
*/
private
Integer
newMbrCsmeCntTarget
;
/**
* 新增会员消费总次数当前应达目标值 排序28
*/
private
Integer
newMbrCsmeCntCurTarget
;
/**
* 新增会员消费总次数滚动达成率 排序29
*/
private
Double
newMbrCsmeCntRollAch
;
/**
* 新增会员消费总次数累计达成率 排序30
*/
private
Double
newMbrCsmeCntAccAch
;
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/vo/target/StoreTargetReachDetailVO.java
0 → 100644
View file @
02eaee7a
package
com
.
gic
.
haoban
.
manage
.
web
.
vo
.
target
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Author guojx
* @Date 2023/6/9 9:21
*/
@Data
public
class
StoreTargetReachDetailVO
implements
Serializable
{
private
String
storeId
;
private
String
storeName
;
private
String
storeGroupId
;
private
String
storeGroupName
;
private
String
storeCode
;
/**
* 总销售额(目标值) 排序1
*/
private
Double
payAmtTarget
;
/**
* 总销售额(实际值) 排序9
*/
private
Double
payAmt
;
/**
* 总销售额(去年同期) 排序17
*/
private
Double
payAmtSply
;
/**
* 总销售额(当前应达目标值) 排序25
*/
private
Double
payAmtCurTarget
;
/**
* 滚动达成率(总销售额) 排序33
*/
private
Double
payAmtRollAch
;
/**
* 累计达成率(总销售额) 排序34
*/
private
Double
payAmtAccAch
;
/**
* 会员销售额(消费门店)(目标值) 排序2
*/
private
Double
mbrPayAmtTarget
;
/**
* 会员销售额(消费门店)(实际值) 排序10
*/
private
Double
mbrPayAmt
;
/**
* 会员销售额(消费门店)(去年同期) 排序18
*/
private
Double
mbrPayAmtSply
;
/**
* 会员销售额(消费门店)(当前应达目标值) 排序26
*/
private
Double
mbrPayAmtCurTarget
;
/**
* 滚动达成率(会员销售额) 排序39
*/
private
Double
mbrPayAmtRollAch
;
/**
* 累计达成率(会员销售额) 排序40
*/
private
Double
mbrPayAmtAccAch
;
/**
* 会员订单率(目标值) 排序7
*/
private
Double
mbrOrderRateTarget
;
/**
* 会员订单率(实际值) 排序15
*/
private
Double
mbrOrderRate
;
/**
* 会员订单率(去年同期) 排序23
*/
private
Double
mbrOrderRateSply
;
/**
* 会员订单率(当前应达目标值) 排序31
*/
private
Double
mbrOrderRateCurTarget
;
/**
* 滚动达成率(会员订单率) 排序45
*/
private
Double
mbrOrderRateRollAch
;
/**
* 累计达成率(会员订单率) 排序46
*/
private
Double
mbrOrderRateAccAch
;
}
haoban-manage3-wx/src/main/webapp/WEB-INF/dubbo-haoban-manage-wx.xml
View file @
02eaee7a
...
...
@@ -143,5 +143,7 @@
<dubbo:reference
interface=
"com.gic.haoban.task.manage.api.service.IMarketClueTaskApiService"
id=
"iMarketClueTaskApiService"
timeout=
"10000"
retries=
"0"
check=
"false"
/>
<dubbo:reference
interface=
"com.gic.haoban.task.api.service.TelTaskApiService"
id=
"telTaskApiService"
timeout=
"10000"
retries=
"0"
check=
"false"
/>
<dubbo:reference
id=
"dataTargetConfigNewVersionsApiService"
interface=
"com.gic.enterprise.api.service.target.DataTargetConfigNewVersionsApiService"
timeout=
"100000"
retries=
"0"
check=
"false"
/>
<dubbo:reference
id=
"storeGroupService"
interface=
"com.gic.enterprise.api.service.StoreGroupService"
timeout=
"10000"
retries=
"0"
check=
"false"
/>
</beans>
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