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
e5a40c23
Commit
e5a40c23
authored
Jul 05, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分组策略
parent
77f0f11f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
0 deletions
+117
-0
StoreStrategyApiService.java
...n/java/com/gic/store/service/StoreStrategyApiService.java
+10
-0
StoreStrategyService.java
...main/java/com/gic/store/service/StoreStrategyService.java
+10
-0
StoreStrategyServiceImpl.java
.../com/gic/store/service/impl/StoreStrategyServiceImpl.java
+6
-0
StoreStrategyApiServiceImpl.java
.../gic/store/service/outer/StoreStrategyApiServiceImpl.java
+91
-0
No files found.
gic-store-api/src/main/java/com/gic/store/service/StoreStrategyApiService.java
View file @
e5a40c23
...
...
@@ -85,4 +85,14 @@ public interface StoreStrategyApiService {
ServiceResponse
getStoreGroupStrategyWeight
(
Integer
enterpriseId
);
/**
* 验证是否命中,如果命中,返回的result值就是命中值,否则是空字符串
* @param storeId
* @param enterpriseId
* @param strategyType
* @return
*/
ServiceResponse
isHitStrategy
(
int
storeId
,
int
enterpriseId
,
int
strategyType
);
}
gic-store-service/src/main/java/com/gic/store/service/StoreStrategyService.java
View file @
e5a40c23
...
...
@@ -4,6 +4,8 @@ import com.gic.store.dto.StoreStrategyDTO;
import
com.gic.store.entity.TabStoreStrategy
;
import
com.github.pagehelper.Page
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/4 9:46 AM
...
...
@@ -101,6 +103,14 @@ public interface StoreStrategyService {
*/
Page
<
TabStoreStrategy
>
listStoreStrategy
(
int
enterpriseId
,
String
search
,
int
strategyType
,
Integer
pageNum
,
Integer
pageSize
);
/**
* 查询策略列表数据
* @param enterpriseId
* @param strategyType
* @return
*/
List
<
TabStoreStrategy
>
listStoreStrategy
(
int
enterpriseId
,
int
strategyType
);
void
updateSortById
(
int
strategyId
,
double
sort
);
}
gic-store-service/src/main/java/com/gic/store/service/impl/StoreStrategyServiceImpl.java
View file @
e5a40c23
...
...
@@ -118,6 +118,12 @@ public class StoreStrategyServiceImpl implements StoreStrategyService{
return
(
Page
<
TabStoreStrategy
>)
list
;
}
@Override
public
List
<
TabStoreStrategy
>
listStoreStrategy
(
int
enterpriseId
,
int
strategyType
)
{
List
<
TabStoreStrategy
>
list
=
tabStoreStrategyMapper
.
listStoreStrategy
(
enterpriseId
,
null
,
strategyType
);
return
list
;
}
public
double
getMaxSort
(
int
enterpriseId
,
int
strategyType
)
{
Double
sort
=
tabStoreStrategyMapper
.
getMaxSort
(
enterpriseId
,
strategyType
);
return
sort
==
null
?
1
d
:
sort
;
...
...
gic-store-service/src/main/java/com/gic/store/service/outer/StoreStrategyApiServiceImpl.java
View file @
e5a40c23
...
...
@@ -8,8 +8,11 @@ import com.gic.commons.util.EntityUtil;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.store.constant.StoreGroupConstant
;
import
com.gic.store.constant.StrategyStoreFieldEnum
;
import
com.gic.store.dto.StoreStrategyDTO
;
import
com.gic.store.entity.TabStore
;
import
com.gic.store.entity.TabStoreStrategy
;
import
com.gic.store.service.StoreService
;
import
com.gic.store.service.StoreStrategyApiService
;
import
com.gic.store.service.StoreStrategyService
;
import
com.gic.store.utils.ErrorCode
;
...
...
@@ -31,6 +34,8 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
@Autowired
private
StoreStrategyService
storeStrategyService
;
@Autowired
private
StoreService
storeService
;
@Override
public
ServiceResponse
<
Integer
>
saveStoreStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
...
...
@@ -219,6 +224,82 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
return
ServiceResponse
.
success
(
Integer
.
valueOf
(
value
.
toString
()));
}
public
ServiceResponse
isHitStrategy
(
int
storeId
,
int
enterpriseId
,
int
strategyType
)
{
List
<
TabStoreStrategy
>
strategyList
=
storeStrategyService
.
listStoreStrategy
(
enterpriseId
,
strategyType
);
//命中值
String
result
=
""
;
TabStore
store
=
storeService
.
getById
(
storeId
);
for
(
int
num
=
0
,
strategyLength
=
strategyList
.
size
();
num
<
strategyLength
;
num
++)
{
//如果数值对上,则说明命中
int
validSize
=
0
;
TabStoreStrategy
strategy
=
strategyList
.
get
(
num
);
String
targetValue
=
strategy
.
getTargetValue
();
String
conditions
=
strategy
.
getConditions
();
int
regionId
=
strategy
.
getStoreRegionId
();
String
storeCreateType
=
strategy
.
getStoreCreateType
();
//valid
if
(
store
.
getRegionId
().
intValue
()
!=
regionId
)
{
continue
;
}
validSize
++;
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
conditions
);
for
(
int
i
=
0
,
length
=
jsonArray
.
size
();
i
<
length
;
i
++)
{
JSONObject
object
=
jsonArray
.
getJSONObject
(
i
);
String
key
=
object
.
getString
(
"key"
);
String
value
=
object
.
getString
(
"value"
);
if
(
StrategyStoreFieldEnum
.
RelatedBrand
.
getCode
().
equals
(
key
))
{
if
(!
isBrandIdHitStrategy
(
store
.
getBrandIds
(),
value
))
{
continue
;
}
}
else
if
(
StrategyStoreFieldEnum
.
StoreCity
.
getCode
().
equals
(
key
))
{
if
(!
isBrandIdHitStrategy
(
store
.
getCityId
(),
value
))
{
continue
;
}
}
else
if
(
StrategyStoreFieldEnum
.
StoreProvince
.
getCode
().
equals
(
key
))
{
if
(!
isBrandIdHitStrategy
(
store
.
getProvinceId
(),
value
))
{
continue
;
}
}
else
if
(
StrategyStoreFieldEnum
.
StoreCountry
.
getCode
().
equals
(
key
))
{
if
(!
isBrandIdHitStrategy
(
store
.
getAreaId
(),
value
))
{
continue
;
}
}
else
{
//单选或者多选
//todo 根据key值和storeId查询门店扩展表的value值,进行比对
}
validSize
++;
}
if
(
strategyType
==
StoreGroupConstant
.
STORE_STRATEGY_TYPE
)
{
//如果是门店启用状态策略,需要验证门店创建方式
if
(!
isBrandIdHitStrategy
(
store
.
getCreateType
().
toString
(),
storeCreateType
))
{
continue
;
}
validSize
++;
}
int
hitSize
;
if
(
strategyType
==
StoreGroupConstant
.
STORE_STRATEGY_TYPE
)
{
hitSize
=
jsonArray
.
size
()
+
2
;
}
else
{
hitSize
=
jsonArray
.
size
()
+
1
;
}
//命中
if
(
validSize
==
hitSize
)
{
result
=
targetValue
;
break
;
}
}
return
ServiceResponse
.
success
(
result
);
}
private
boolean
validConditionsIsRepeatKey
(
String
conditions
)
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
conditions
);
//每一种属性都不能一样
...
...
@@ -240,4 +321,14 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
return
false
;
}
private
boolean
isBrandIdHitStrategy
(
String
brandIds
,
String
value
)
{
String
[]
values
=
value
.
split
(
","
);
for
(
String
str
:
values
)
{
if
(
brandIds
.
contains
(
str
))
{
return
true
;
}
}
return
false
;
}
}
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