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
a16c6a5c
Commit
a16c6a5c
authored
Jul 05, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分组策略
parent
82d392f5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
28 deletions
+95
-28
StoreStrategyDTO.java
...api/src/main/java/com/gic/store/dto/StoreStrategyDTO.java
+5
-5
TabStoreStrategy.java
.../src/main/java/com/gic/store/entity/TabStoreStrategy.java
+5
-5
StoreStrategyServiceImpl.java
.../com/gic/store/service/impl/StoreStrategyServiceImpl.java
+1
-1
StoreStrategyApiServiceImpl.java
.../gic/store/service/outer/StoreStrategyApiServiceImpl.java
+58
-0
TabStoreStrategyMapper.xml
...vice/src/main/resources/mapper/TabStoreStrategyMapper.xml
+12
-12
StoreStrategyQO.java
...a/com/gic/store/web/qo/storestrategy/StoreStrategyQO.java
+14
-5
No files found.
gic-store-api/src/main/java/com/gic/store/dto/StoreStrategyDTO.java
View file @
a16c6a5c
...
...
@@ -33,7 +33,7 @@ public class StoreStrategyDTO implements Serializable{
/**
* 门店分组条件,json数组
*/
private
String
condition
;
private
String
condition
s
;
/**
* 策略命中值;如果type为门店分组策略,对应分组id;否则为门店启用和不启用值
...
...
@@ -107,12 +107,12 @@ public class StoreStrategyDTO implements Serializable{
this
.
storeRegionId
=
storeRegionId
;
}
public
String
getCondition
()
{
return
condition
;
public
String
getCondition
s
()
{
return
condition
s
;
}
public
void
setCondition
(
String
condition
)
{
this
.
condition
=
condition
;
public
void
setCondition
s
(
String
conditions
)
{
this
.
condition
s
=
conditions
;
}
public
String
getTargetValue
()
{
...
...
gic-store-service/src/main/java/com/gic/store/entity/TabStoreStrategy.java
View file @
a16c6a5c
...
...
@@ -29,7 +29,7 @@ public class TabStoreStrategy {
/**
* 门店分组条件,json数组
*/
private
String
condition
;
private
String
condition
s
;
/**
* 策略命中值;如果type为门店分组策略,对应分组id;否则为门店启用和不启用值
...
...
@@ -98,12 +98,12 @@ public class TabStoreStrategy {
this
.
storeRegionId
=
storeRegionId
;
}
public
String
getCondition
()
{
return
condition
;
public
String
getCondition
s
()
{
return
condition
s
;
}
public
void
setCondition
(
String
condition
)
{
this
.
condition
=
condition
;
public
void
setCondition
s
(
String
conditions
)
{
this
.
condition
s
=
conditions
;
}
public
String
getTargetValue
()
{
...
...
gic-store-service/src/main/java/com/gic/store/service/impl/StoreStrategyServiceImpl.java
View file @
a16c6a5c
...
...
@@ -27,7 +27,7 @@ public class StoreStrategyServiceImpl implements StoreStrategyService{
public
int
saveStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
TabStoreStrategy
storeStrategy
=
EntityUtil
.
changeEntityNew
(
TabStoreStrategy
.
class
,
storeStrategyDTO
);
tabStoreStrategyMapper
.
insert
(
storeStrategy
);
return
storeStrategy
.
getSt
oreRegion
Id
();
return
storeStrategy
.
getSt
rategy
Id
();
}
@Override
...
...
gic-store-service/src/main/java/com/gic/store/service/outer/StoreStrategyApiServiceImpl.java
View file @
a16c6a5c
package
com
.
gic
.
store
.
service
.
outer
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
...
...
@@ -16,7 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author guojx
...
...
@@ -45,6 +49,9 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
if
(
storeStrategyDTO
.
getStrategyType
()
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略类型不能为空"
);
}
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getConditions
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店属性条件配置不能为空"
);
}
if
(
storeStrategyDTO
.
getStrategyType
()
==
StoreGroupConstant
.
STORE_STRATEGY_TYPE
)
{
//如果是门店状态策略类型,必须有
...
...
@@ -52,6 +59,14 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店创建方式不能为空"
);
}
}
String
conditions
=
storeStrategyDTO
.
getConditions
();
//验证conditions合法性
if
(
isConditionsSizeOver
(
conditions
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店属性条件配置超出5个"
);
}
if
(
validConditionsIsRepeatKey
(
conditions
))
{
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店属性条件每一种都不能重复"
);
}
storeStrategyDTO
.
setCreateTime
(
new
Date
());
storeStrategyDTO
.
setUpdateTime
(
new
Date
());
...
...
@@ -82,6 +97,27 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
}
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getConditions
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店属性条件配置不能为空"
);
}
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getTargetValue
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略命中值不能为空"
);
}
String
conditions
=
storeStrategyDTO
.
getConditions
();
//验证conditions合法性
if
(
isConditionsSizeOver
(
conditions
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店属性条件配置超出5个"
);
}
if
(
validConditionsIsRepeatKey
(
conditions
))
{
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店属性条件每一种都不能重复"
);
}
if
(
storeStrategy
.
getStrategyType
()
==
StoreGroupConstant
.
STORE_STRATEGY_TYPE
)
{
//如果是门店状态策略类型,必须有
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getStoreCreateType
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店创建方式不能为空"
);
}
}
storeStrategyDTO
.
setCreateTime
(
storeStrategy
.
getCreateTime
());
storeStrategyDTO
.
setUpdateTime
(
new
Date
());
storeStrategyDTO
.
setEnterpriseId
(
storeStrategy
.
getEnterpriseId
());
...
...
@@ -182,4 +218,26 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
}
return
ServiceResponse
.
success
(
Integer
.
valueOf
(
value
.
toString
()));
}
private
boolean
validConditionsIsRepeatKey
(
String
conditions
)
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
conditions
);
//每一种属性都不能一样
Map
<
String
,
String
>
validConditionsMap
=
new
HashMap
<>(
16
);
for
(
int
i
=
0
,
length
=
jsonArray
.
size
();
i
<
length
;
i
++)
{
JSONObject
object
=
jsonArray
.
getJSONObject
(
i
);
if
(
validConditionsMap
.
containsKey
(
object
.
getString
(
"key"
)))
{
return
true
;
}
validConditionsMap
.
put
(
object
.
getString
(
"key"
),
object
.
getString
(
"value"
));
}
return
false
;
}
private
boolean
isConditionsSizeOver
(
String
conditions
)
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
conditions
);
if
(
jsonArray
.
size
()
>
5
)
{
return
true
;
}
return
false
;
}
}
gic-store-service/src/main/resources/mapper/TabStoreStrategyMapper.xml
View file @
a16c6a5c
...
...
@@ -6,7 +6,7 @@
<result
column=
"strategy_name"
jdbcType=
"VARCHAR"
property=
"strategyName"
/>
<result
column=
"enterprise_id"
jdbcType=
"INTEGER"
property=
"enterpriseId"
/>
<result
column=
"store_region_id"
jdbcType=
"INTEGER"
property=
"storeRegionId"
/>
<result
column=
"condition
"
jdbcType=
"VARCHAR"
property=
"condition
"
/>
<result
column=
"condition
s"
jdbcType=
"VARCHAR"
property=
"conditions
"
/>
<result
column=
"target_value"
jdbcType=
"VARCHAR"
property=
"targetValue"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
...
...
@@ -16,7 +16,7 @@
<result
column=
"store_create_type"
jdbcType=
"VARCHAR"
property=
"storeCreateType"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
strategy_id, strategy_name, enterprise_id, store_region_id, condition
, target_value,
strategy_id, strategy_name, enterprise_id, store_region_id, condition
s, target_value,
create_time, update_time, status, strategy_type, sort, store_create_type
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
...
...
@@ -31,11 +31,11 @@
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
useGeneratedKeys=
"true"
keyProperty=
"strategyId"
>
insert into tab_store_strategy (strategy_id, strategy_name, enterprise_id,
store_region_id, condition
, target_value,
store_region_id, condition
s, target_value,
create_time, update_time, status,
strategy_type, sort, store_create_type)
values (#{strategyId,jdbcType=INTEGER}, #{strategyName,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=INTEGER},
#{storeRegionId,jdbcType=INTEGER}, #{condition
,jdbcType=VARCHAR}, #{targetValue,jdbcType=VARCHAR},
#{storeRegionId,jdbcType=INTEGER}, #{condition
s,jdbcType=VARCHAR}, #{targetValue,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
#{strategyType,jdbcType=INTEGER}, #{sort,jdbcType=DOUBLE}, #{storeCreateType,jdbcType=VARCHAR})
</insert>
...
...
@@ -54,8 +54,8 @@
<if
test=
"storeRegionId != null"
>
store_region_id,
</if>
<if
test=
"condition != null"
>
condition,
<if
test=
"condition
s
!= null"
>
condition
s
,
</if>
<if
test=
"targetValue != null"
>
target_value,
...
...
@@ -92,8 +92,8 @@
<if
test=
"storeRegionId != null"
>
#{storeRegionId,jdbcType=INTEGER},
</if>
<if
test=
"condition != null"
>
#{condition,jdbcType=VARCHAR},
<if
test=
"condition
s
!= null"
>
#{condition
s
,jdbcType=VARCHAR},
</if>
<if
test=
"targetValue != null"
>
#{targetValue,jdbcType=VARCHAR},
...
...
@@ -130,8 +130,8 @@
<if
test=
"storeRegionId != null"
>
store_region_id = #{storeRegionId,jdbcType=INTEGER},
</if>
<if
test=
"condition != null"
>
condition
= #{condition
,jdbcType=VARCHAR},
<if
test=
"condition
s
!= null"
>
condition
s = #{conditions
,jdbcType=VARCHAR},
</if>
<if
test=
"targetValue != null"
>
target_value = #{targetValue,jdbcType=VARCHAR},
...
...
@@ -162,7 +162,7 @@
set strategy_name = #{strategyName,jdbcType=VARCHAR},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
store_region_id = #{storeRegionId,jdbcType=INTEGER},
condition
= #{condition
,jdbcType=VARCHAR},
condition
s = #{conditions
,jdbcType=VARCHAR},
target_value = #{targetValue,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
...
...
@@ -176,7 +176,7 @@
<select
id=
"countRepeatStrategyName"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
resultType=
"integer"
>
select
<include
refid=
"Base_Column_List"
/>
count(1)
from tab_store_strategy
where status = 1
<if
test=
"strategyName != null"
>
...
...
gic-store-web/src/main/java/com/gic/store/web/qo/storestrategy/StoreStrategyQO.java
View file @
a16c6a5c
...
...
@@ -58,7 +58,8 @@ public class StoreStrategyQO implements Serializable{
/**
* 门店分组条件,json数组
*/
private
String
condition
;
@NotBlank
(
message
=
"门店属性条件配置不能为空"
,
groups
=
{
SaveValidView
.
class
})
private
String
conditions
;
/**
* 策略命中值;如果type为门店分组策略,对应分组id;否则为门店启用和不启用值
...
...
@@ -151,12 +152,20 @@ public class StoreStrategyQO implements Serializable{
this
.
storeRegionId
=
storeRegionId
;
}
public
String
getCondition
()
{
return
condition
;
public
String
getCondition
s
()
{
return
condition
s
;
}
public
void
setCondition
(
String
condition
)
{
this
.
condition
=
condition
;
public
void
setConditions
(
String
conditions
)
{
this
.
conditions
=
conditions
;
}
public
String
getStoreCreateType
()
{
return
storeCreateType
;
}
public
void
setStoreCreateType
(
String
storeCreateType
)
{
this
.
storeCreateType
=
storeCreateType
;
}
public
String
getTargetValue
()
{
...
...
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