Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-spark-tag-4.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
wangxiaokang
gic-spark-tag-4.0
Commits
7f145625
Commit
7f145625
authored
Aug 26, 2020
by
guos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员标签4.0
parent
f5b3e5fb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
15 deletions
+48
-15
TrdEcuBrandLabelBean.java
.../java/com/gic/spark/entity/bean/TrdEcuBrandLabelBean.java
+9
-0
TagAverageDiscountFactorFilter.java
.../com/gic/spark/filter/TagAverageDiscountFactorFilter.java
+5
-1
TagPerCustomerTransactionFilter.java
...com/gic/spark/filter/TagPerCustomerTransactionFilter.java
+4
-1
TagValueParser.java
src/main/java/com/gic/spark/tag/TagValueParser.java
+12
-13
IndexRequestUtil.java
src/main/java/com/gic/spark/util/IndexRequestUtil.java
+18
-0
No files found.
src/main/java/com/gic/spark/entity/bean/TrdEcuBrandLabelBean.java
View file @
7f145625
...
...
@@ -15,6 +15,7 @@ public class TrdEcuBrandLabelBean implements Serializable {
private
Integer
store_info_id
;
//门店id
private
Integer
order_times
;
//消费次数(根据配置取的)
private
Integer
seff_goods_num
;
//净销售件数
private
Double
receive_amt
;
//应收额
private
Double
pay_amt
;
//实付额
private
Double
total_amt
;
//吊牌价总额
private
Integer
sleep_days
;
//休眠天数
...
...
@@ -99,4 +100,12 @@ public class TrdEcuBrandLabelBean implements Serializable {
public
void
setEnt_brand_id
(
Long
ent_brand_id
)
{
this
.
ent_brand_id
=
ent_brand_id
;
}
public
Double
getReceive_amt
()
{
return
receive_amt
;
}
public
void
setReceive_amt
(
Double
receive_amt
)
{
this
.
receive_amt
=
receive_amt
;
}
}
src/main/java/com/gic/spark/filter/TagAverageDiscountFactorFilter.java
View file @
7f145625
...
...
@@ -43,8 +43,11 @@ public class TagAverageDiscountFactorFilter extends AbstractTagConsumFilter {
TagConsumeDoubleRequest
consumeRequest
=(
TagConsumeDoubleRequest
)
request
;
JavaRDD
<
TrdEcuBrandLabelBean
>
consumeRDD
=
MysqlRddManager
.
getPojoFromDataset
(
dataSourceHive
.
getDatasetByEntId
(
enterpriseId
),
TrdEcuBrandLabelBean
.
class
).
javaRDD
();
consumeRDD
=
statisticsTypeHandle
(
consumeRDD
,
consumeRequest
);
int
configStatus
=
CommonUtil
.
getConfigStatus
(
enterpriseId
);
JavaRDD
<
Long
>
ecuRdd
=
consumeRDD
.
mapToPair
(
data
->
Tuple2
.
apply
(
data
.
getEcu_id
(),
data
))
.
reduceByKey
((
x
,
y
)->{
x
.
setReceive_amt
(
x
.
getReceive_amt
()+
y
.
getReceive_amt
());
x
.
setPay_amt
(
x
.
getPay_amt
()+
y
.
getPay_amt
());
x
.
setTotal_amt
(
x
.
getTotal_amt
()+
y
.
getTotal_amt
());
return
x
;
...
...
@@ -53,7 +56,8 @@ public class TagAverageDiscountFactorFilter extends AbstractTagConsumFilter {
List
<
Long
>
result
=
new
ArrayList
();
while
(
data
.
hasNext
()){
Tuple2
<
Long
,
TrdEcuBrandLabelBean
>
tp2
=
data
.
next
();
double
avgDiscountRate
=
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getPay_amt
())/
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getTotal_amt
());
double
avgDiscountRate
=
1
==
configStatus
?
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getPay_amt
())/
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getTotal_amt
())
:
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getReceive_amt
())/
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getTotal_amt
());
switch
(
consumeRequest
.
getNumberType
()){
case
gt:
if
(
avgDiscountRate
>
consumeRequest
.
getBeginNum
()){
...
...
src/main/java/com/gic/spark/filter/TagPerCustomerTransactionFilter.java
View file @
7f145625
...
...
@@ -40,8 +40,10 @@ public class TagPerCustomerTransactionFilter extends AbstractTagConsumFilter{
TagConsumeRequest
consumeRequest
=(
TagConsumeRequest
)
request
;
JavaRDD
<
TrdEcuBrandLabelBean
>
consumeRDD
=
MysqlRddManager
.
getPojoFromDataset
(
dataSourceHive
.
getDatasetByEntId
(
enterpriseId
),
TrdEcuBrandLabelBean
.
class
).
javaRDD
();
consumeRDD
=
statisticsTypeHandle
(
consumeRDD
,
consumeRequest
);
int
configStatus
=
CommonUtil
.
getConfigStatus
(
enterpriseId
);
JavaRDD
<
Long
>
ecuRdd
=
consumeRDD
.
mapToPair
(
data
->
Tuple2
.
apply
(
data
.
getEcu_id
(),
data
))
.
reduceByKey
((
x
,
y
)->{
x
.
setReceive_amt
(
x
.
getReceive_amt
()+
y
.
getReceive_amt
());
x
.
setPay_amt
(
x
.
getPay_amt
()+
y
.
getPay_amt
());
x
.
setOrder_times
(
x
.
getOrder_times
()+
y
.
getOrder_times
());
return
x
;
...
...
@@ -50,7 +52,8 @@ public class TagPerCustomerTransactionFilter extends AbstractTagConsumFilter{
List
<
Long
>
result
=
new
ArrayList
();
while
(
data
.
hasNext
()){
Tuple2
<
Long
,
TrdEcuBrandLabelBean
>
tp2
=
data
.
next
();
double
CusSinglePiece
=
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getPay_amt
())/
CommonUtil
.
isEmptyInteger2int
(
tp2
.
_2
().
getOrder_times
());
double
CusSinglePiece
=
1
==
configStatus
?
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getPay_amt
())/
CommonUtil
.
isEmptyInteger2int
(
tp2
.
_2
().
getOrder_times
())
:
CommonUtil
.
isEmptyDouble2double
(
tp2
.
_2
().
getReceive_amt
())/
CommonUtil
.
isEmptyInteger2int
(
tp2
.
_2
().
getOrder_times
());
switch
(
consumeRequest
.
getNumberType
()){
case
gt:
if
(
CusSinglePiece
>
consumeRequest
.
getBeginNum
()){
...
...
src/main/java/com/gic/spark/tag/TagValueParser.java
View file @
7f145625
...
...
@@ -136,43 +136,43 @@ public class TagValueParser {
//线上消费店铺
case
TagConstant
.
TAG_CODE_FIRST_ONLINE_CONSUMPTION_STORE
:
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
());
break
;
case
TagConstant
.
TAG_CODE_LATELY_ONLINE_CONSUMPTION_STORE
:
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
());
break
;
case
TagConstant
.
TAG_CODE_HISTORY_ONLINE_CONSUMPTION_STORE
:
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
());
break
;
case
TagConstant
.
TAG_CODE_ONLINE_CONSUMPTION_STORE
:
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
request
=
getOnlineConsumeStoreRequest
(
conditionDTO
.
getTagTemplateElInfo
());
break
;
//消费商品
case
TagConstant
.
TAG_CODE_FIRST_CONSUME_COMMODITY
:
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
());
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
break
;
case
TagConstant
.
TAG_CODE_LATELY_CONSUME_COMMODITY
:
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
());
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
break
;
case
TagConstant
.
TAG_CODE_HISTORY_CONSUME_COMMODITY
:
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
());
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
break
;
case
TagConstant
.
TAG_CODE_CONSUME_COMMODITY
:
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
());
request
=
getConsumeCommodityRequest
(
conditionDTO
.
getTagTemplateElInfo
()
,
enterpriseId
);
break
;
default
:
break
;
}
return
request
;
}
private
static
AbstractFilterRequest
getConsumeCommodityRequest
(
List
<
TagConditionValDTO
>
conditionValDTOList
)
{
private
static
AbstractFilterRequest
getConsumeCommodityRequest
(
List
<
TagConditionValDTO
>
conditionValDTOList
,
Integer
enterpriseId
)
{
TagConsumeCommodityRequest
request
=
new
TagConsumeCommodityRequest
();
for
(
TagConditionValDTO
conditionValDTO
:
conditionValDTOList
)
{
if
(
Pattern
.
compile
(
"flag"
).
matcher
(
conditionValDTO
.
getKey
()).
find
())
{
setStatisticsTypeHandle
(
request
,
conditionValDTO
.
getKey
(),
conditionValDTO
.
getVal
());
}
else
if
(
conditionValDTO
.
getKey
().
equals
(
TagValKeyEnum
.
COMPONENT_COMMODITY
.
getKey
())){
List
<
String
>
skuCodeList
=
new
ArrayList
();
//需要调用接口
List
<
String
>
skuCodeList
=
IndexRequestUtil
.
getGoodsSkucod
(
enterpriseId
,
conditionValDTO
.
getVal
(),
TagProcessManager
.
getInstance
().
isProduction
());
request
.
setSkuCodeList
(
skuCodeList
);
}
else
if
(
Pattern
.
compile
(
"timeRange"
).
matcher
(
conditionValDTO
.
getKey
()).
find
()){
String
[]
keys
=
conditionValDTO
.
getKey
().
split
(
"\\."
);
...
...
@@ -201,7 +201,7 @@ public class TagValueParser {
return
request
;
}
private
static
AbstractFilterRequest
getOnlineConsumeStoreRequest
(
List
<
TagConditionValDTO
>
conditionValDTOList
,
Integer
enterpriseId
)
{
private
static
AbstractFilterRequest
getOnlineConsumeStoreRequest
(
List
<
TagConditionValDTO
>
conditionValDTOList
)
{
TagConsumeStoreRequest
request
=
new
TagConsumeStoreRequest
();
List
<
String
>
storeList
=
new
ArrayList
();
for
(
TagConditionValDTO
conditionValDTO
:
conditionValDTOList
)
{
...
...
@@ -247,8 +247,7 @@ public class TagValueParser {
if
(
Pattern
.
compile
(
"flag"
).
matcher
(
conditionValDTO
.
getKey
()).
find
())
{
setStatisticsTypeHandle
(
request
,
conditionValDTO
.
getKey
(),
conditionValDTO
.
getVal
());
}
else
if
(
conditionValDTO
.
getKey
().
equals
(
TagValKeyEnum
.
COMPONENT_STORE
.
getKey
())){
String
val
=
conditionValDTO
.
getVal
();
List
<
String
>
storeList
=
IndexRequestUtil
.
getStoreId
(
enterpriseId
,
val
,
TagProcessManager
.
getInstance
().
isProduction
())
;
//需要调用接口
List
<
String
>
storeList
=
IndexRequestUtil
.
getStoreId
(
enterpriseId
,
conditionValDTO
.
getVal
(),
TagProcessManager
.
getInstance
().
isProduction
())
;
//需要调用接口
request
.
setStoreList
(
storeList
);
}
else
if
(
Pattern
.
compile
(
"timeRange"
).
matcher
(
conditionValDTO
.
getKey
()).
find
()){
String
[]
keys
=
conditionValDTO
.
getKey
().
split
(
"\\."
);
...
...
src/main/java/com/gic/spark/util/IndexRequestUtil.java
View file @
7f145625
...
...
@@ -36,6 +36,24 @@ public class IndexRequestUtil {
}
public
static
List
<
String
>
getGoodsSkucod
(
Integer
enterpriseId
,
String
selectorId
,
boolean
isProd
){
String
url
=
isProd
?
"https://ideal.demogic.com/api-goods/goods-selector-process?goodsSelectorId="
+
selectorId
+
"&enterpriseId="
+
enterpriseId
:
"https://four.gicdev.com/api-goods/goods-selector-process?goodsSelectorId="
+
selectorId
+
"&enterpriseId="
+
enterpriseId
;
HttpResponse
response
=
HttpClient
.
getHttpResponseByGet
(
url
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
HttpClient
.
getResponseString
(
response
));
List
<
String
>
result
=
new
ArrayList
();
try
{
JSONArray
jsonArray
=
jsonObject
.
getJSONObject
(
"result"
).
getJSONObject
(
"result"
).
getJSONArray
(
"list"
);
for
(
Object
obj
:
jsonArray
)
{
result
.
add
((
String
)
obj
);
}
}
catch
(
Exception
e
)
{
DingtalkMessageUtil
.
sendAlertMessage
(
"selectorId: "
+
selectorId
+
" enterpriseId: "
+
enterpriseId
+
" parsing store error "
);
}
return
result
;
}
public
static
List
<
String
>
getGoodsInfoById
(
String
enterpriseId
,
String
selectorId
,
boolean
isProd
)
{
String
url
=
"http://gicdev.demogic.com/api-plug/get-store-goods-sku-filter?enterpriseId="
+
enterpriseId
+
"&id="
+
selectorId
;
...
...
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