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
704c711e
Commit
704c711e
authored
Jul 04, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分组策略
parent
d2add87a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
906 additions
and
33 deletions
+906
-33
TabStoreGroupStrategyWeightsMapper.java
.../store/dao/mapper/TabStoreGroupStrategyWeightsMapper.java
+61
-0
TabStoreStrategyMapper.java
...java/com/gic/store/dao/mapper/TabStoreStrategyMapper.java
+72
-0
TabStoreGroupStrategyWeights.java
...va/com/gic/store/entity/TabStoreGroupStrategyWeights.java
+74
-0
TabStoreStrategy.java
.../src/main/java/com/gic/store/entity/TabStoreStrategy.java
+24
-10
StoreGroupStrategyWeightsService.java
...m/gic/store/service/StoreGroupStrategyWeightsService.java
+30
-0
StoreStrategyService.java
...main/java/com/gic/store/service/StoreStrategyService.java
+104
-0
StoreGroupStrategyWeightsServiceImpl.java
...re/service/impl/StoreGroupStrategyWeightsServiceImpl.java
+50
-0
StoreStrategyServiceImpl.java
.../com/gic/store/service/impl/StoreStrategyServiceImpl.java
+133
-0
StoreStrategyApiServiceImpl.java
.../gic/store/service/outer/StoreStrategyApiServiceImpl.java
+128
-0
dubbo-gic-store-service.xml
...re-service/src/main/resources/dubbo-gic-store-service.xml
+4
-0
TabStoreGroupStrategyWeightsMapper.xml
...n/resources/mapper/TabStoreGroupStrategyWeightsMapper.xml
+110
-0
TabStoreStrategyMapper.xml
...vice/src/main/resources/mapper/TabStoreStrategyMapper.xml
+112
-23
dubbo-gic-store-web.xml
gic-store-web/src/main/resources/dubbo-gic-store-web.xml
+4
-0
No files found.
gic-store-service/src/main/java/com/gic/store/dao/mapper/TabStoreGroupStrategyWeightsMapper.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
dao
.
mapper
;
import
com.gic.store.entity.TabStoreGroupStrategyWeights
;
public
interface
TabStoreGroupStrategyWeightsMapper
{
/**
* 根据主键删除
*
* @param weightsId 主键
* @return 更新条目数
*/
int
deleteByPrimaryKey
(
Integer
weightsId
);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insert
(
TabStoreGroupStrategyWeights
record
);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
insertSelective
(
TabStoreGroupStrategyWeights
record
);
/**
* 根据主键查询
*
* @param weightsId 主键
* @return 实体对象
*/
TabStoreGroupStrategyWeights
selectByPrimaryKey
(
Integer
weightsId
);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKeySelective
(
TabStoreGroupStrategyWeights
record
);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabStoreGroupStrategyWeights
record
);
/**
* 查询
* @param record
* @return
*/
TabStoreGroupStrategyWeights
selectByPrimary
(
TabStoreGroupStrategyWeights
record
);
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/dao/mapper/TabStoreStrategyMapper.java
View file @
704c711e
package
com
.
gic
.
store
.
dao
.
mapper
;
import
com.gic.store.entity.TabStoreStrategy
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
TabStoreStrategyMapper
{
/**
...
...
@@ -50,4 +53,72 @@ public interface TabStoreStrategyMapper {
* @return 更新条目数
*/
int
updateByPrimaryKey
(
TabStoreStrategy
record
);
/**
*
* @param record
* @return
*/
Integer
countRepeatStrategyName
(
TabStoreStrategy
record
);
/**
* 获取下一个排序值
* @param enterpriseId
* @param sort
* @param strategyType
* @return
*/
TabStoreStrategy
selectNextByEnterpriseIdAndSort
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"sort"
)
Double
sort
,
@Param
(
"strategyType"
)
Integer
strategyType
);
/**
* 获取上一个排序值
* @param enterpriseId
* @param sort
* @param strategyType
* @return
*/
TabStoreStrategy
selectPrevByStoreFieldIdAndSort
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"sort"
)
Double
sort
,
@Param
(
"strategyType"
)
Integer
strategyType
);
/**
* 查询某字段最小排序值
* @param enterpriseId
* @param strategyType
* @return
*/
Double
getMinSort
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"strategyType"
)
Integer
strategyType
);
/**
/* *查询某字段最大排序值
*
* @param enterpriseId
* @param strategyType
* @return
*/
Double
getMaxSort
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"strategyType"
)
Integer
strategyType
);
/**
* 查询几条连续的记录
* @param strategyId
* @param start
* @param size
* @param enterpriseId
* @param strategyType
* @return
*/
List
<
TabStoreStrategy
>
listTwoElementExceptId
(
@Param
(
"strategyId"
)
Integer
strategyId
,
@Param
(
"start"
)
int
start
,
@Param
(
"size"
)
int
size
,
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"strategyType"
)
Integer
strategyType
);
/**
* 分页查询
* @param enterpriseId
* @param search
* @param strategyType
* @return
*/
List
<
TabStoreStrategy
>
listStoreStrategy
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"search"
)
String
search
,
@Param
(
"strategyType"
)
Integer
strategyType
);
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/entity/TabStoreGroupStrategyWeights.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
entity
;
import
java.util.Date
;
/**
* tab_store_group_strategy_weights
*/
public
class
TabStoreGroupStrategyWeights
{
/**
*
*/
private
Integer
weightsId
;
/**
*
*/
private
Date
createTime
;
/**
*
*/
private
Date
updateTime
;
/**
* 人为操作填写过门店分组后,门店资料更新不再执行快捷分组策略 1开启 0不开启
*/
private
Integer
status
;
/**
*
*/
private
Integer
enterpriseId
;
public
Integer
getWeightsId
()
{
return
weightsId
;
}
public
void
setWeightsId
(
Integer
weightsId
)
{
this
.
weightsId
=
weightsId
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
Integer
getEnterpriseId
()
{
return
enterpriseId
;
}
public
void
setEnterpriseId
(
Integer
enterpriseId
)
{
this
.
enterpriseId
=
enterpriseId
;
}
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/entity/TabStoreStrategy.java
View file @
704c711e
...
...
@@ -14,7 +14,7 @@ public class TabStoreStrategy {
/**
* 策略名称
*/
private
String
st
ar
tegyName
;
private
String
st
ra
tegyName
;
/**
*
...
...
@@ -54,7 +54,12 @@ public class TabStoreStrategy {
/**
* 策略类型,1门店状态策略, 2门店分组策略
*/
private
Integer
stategyType
;
private
Integer
strategyType
;
/**
* 排序字段
*/
private
Double
sort
;
public
Integer
getStrategyId
()
{
return
strategyId
;
...
...
@@ -64,12 +69,12 @@ public class TabStoreStrategy {
this
.
strategyId
=
strategyId
;
}
public
String
getSt
ar
tegyName
()
{
return
st
ar
tegyName
;
public
String
getSt
ra
tegyName
()
{
return
st
ra
tegyName
;
}
public
void
setSt
artegyName
(
String
star
tegyName
)
{
this
.
st
artegyName
=
star
tegyName
;
public
void
setSt
rategyName
(
String
stra
tegyName
)
{
this
.
st
rategyName
=
stra
tegyName
;
}
public
Integer
getEnterpriseId
()
{
...
...
@@ -128,11 +133,19 @@ public class TabStoreStrategy {
this
.
status
=
status
;
}
public
Integer
getStategyType
()
{
return
stategyType
;
public
Integer
getStrategyType
()
{
return
strategyType
;
}
public
void
setStrategyType
(
Integer
strategyType
)
{
this
.
strategyType
=
strategyType
;
}
public
Double
getSort
()
{
return
sort
;
}
public
void
setS
tategyType
(
Integer
stategyType
)
{
this
.
s
tategyType
=
stategyType
;
public
void
setS
ort
(
Double
sort
)
{
this
.
s
ort
=
sort
;
}
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/service/StoreGroupStrategyWeightsService.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
service
;
import
com.gic.store.entity.TabStoreGroupStrategyWeights
;
/**
* @author guojx
* @date 2019/7/4 9:24 AM
*/
public
interface
StoreGroupStrategyWeightsService
{
/**
* 获取分组权重
* @param enterpriseId
* @return
*/
TabStoreGroupStrategyWeights
getWeightByEnterpriseId
(
Integer
enterpriseId
);
/**
* 保存数据
* @param record
* @return
*/
int
saveOrUpdate
(
TabStoreGroupStrategyWeights
record
);
/**
* 权重是否启用,如果启用,则不执行分组策略
* @return
*/
boolean
isEnabled
(
Integer
enterpriseId
);
}
gic-store-service/src/main/java/com/gic/store/service/StoreStrategyService.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
service
;
import
com.gic.store.dto.StoreStrategyDTO
;
import
com.gic.store.entity.TabStoreStrategy
;
import
com.github.pagehelper.Page
;
/**
* @author guojx
* @date 2019/7/4 9:46 AM
*/
public
interface
StoreStrategyService
{
/**
* 新增分组策略
* @param storeStrategyDTO
* @return
*/
int
saveStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
);
/**
* 是否策略名称重复
* @param record
* @return
*/
boolean
isRepeatGroupStrategyName
(
TabStoreStrategy
record
);
/**
* 根据主键查询
* @param strategyId
* @return
*/
TabStoreStrategy
getStoreStrategyById
(
Integer
strategyId
);
/**
* 查询下一个排序值的属性值
* @param enterpriseId
* @param sort
* @param strategyType
* @return
*/
TabStoreStrategy
getNextSort
(
int
enterpriseId
,
double
sort
,
int
strategyType
);
/**
* 查询上一个排序值的属性值
* @param enterpriseId
* @param sort
* @param strategyType
* @return
*/
TabStoreStrategy
getPrevSort
(
int
enterpriseId
,
double
sort
,
int
strategyType
);
/**
* 置顶、置底,自定义序号
* @param strategyId
* @param enterpriseId
* @param setValue
* @param strategyType
*/
void
setStoreStrategySort
(
int
strategyId
,
int
enterpriseId
,
int
setValue
,
int
strategyType
);
double
getMinSort
(
int
enterpriseId
,
int
strategyType
);
/**
* 置底
* @param enterpriseId
* @param strategyId
* @param strategyType
*/
void
sortBottom
(
int
enterpriseId
,
int
strategyId
,
int
strategyType
);
/**
* 置顶
* @param enterpriseId
* @param strategyId
* @param strategyType
*/
void
sortTopping
(
int
enterpriseId
,
int
strategyId
,
int
strategyType
);
/**
* 删除分组策略(单条)
* @param strategyId
* @return
*/
int
deleteStoreGroupStrategy
(
int
strategyId
);
/**
* 修改分组策略
* @param storeStrategyDTO
* @return
*/
int
modifyStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
);
/**
* 分页查询数据
* @param enterpriseId
* @param search
* @param strategyType
* @param pageNum
* @param pageSize
* @return
*/
Page
<
TabStoreStrategy
>
listStoreStrategy
(
int
enterpriseId
,
String
search
,
int
strategyType
,
Integer
pageNum
,
Integer
pageSize
);
}
gic-store-service/src/main/java/com/gic/store/service/impl/StoreGroupStrategyWeightsServiceImpl.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
service
.
impl
;
import
com.gic.store.dao.mapper.TabStoreGroupStrategyWeightsMapper
;
import
com.gic.store.entity.TabStoreGroupStrategyWeights
;
import
com.gic.store.service.StoreGroupStrategyWeightsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
/**
* @author guojx
* @date 2019/7/4 9:26 AM
*/
@Service
(
"storeGroupStrategyWeightsService"
)
public
class
StoreGroupStrategyWeightsServiceImpl
implements
StoreGroupStrategyWeightsService
{
@Autowired
private
TabStoreGroupStrategyWeightsMapper
tabStoreGroupStrategyWeightsMapper
;
@Override
public
TabStoreGroupStrategyWeights
getWeightByEnterpriseId
(
Integer
enterpriseId
)
{
TabStoreGroupStrategyWeights
record
=
new
TabStoreGroupStrategyWeights
();
record
.
setEnterpriseId
(
enterpriseId
);
return
tabStoreGroupStrategyWeightsMapper
.
selectByPrimary
(
record
);
}
@Override
public
int
saveOrUpdate
(
TabStoreGroupStrategyWeights
record
)
{
TabStoreGroupStrategyWeights
old
=
getWeightByEnterpriseId
(
record
.
getEnterpriseId
());
record
.
setUpdateTime
(
new
Date
());
if
(
old
!=
null
)
{
record
.
setCreateTime
(
old
.
getCreateTime
());
record
.
setWeightsId
(
old
.
getWeightsId
());
return
tabStoreGroupStrategyWeightsMapper
.
updateByPrimaryKeySelective
(
record
);
}
else
{
record
.
setCreateTime
(
new
Date
());
return
tabStoreGroupStrategyWeightsMapper
.
insert
(
record
);
}
}
@Override
public
boolean
isEnabled
(
Integer
enterpriseId
)
{
TabStoreGroupStrategyWeights
old
=
getWeightByEnterpriseId
(
enterpriseId
);
if
(
old
!=
null
&&
old
.
getStatus
()
!=
null
&&
old
.
getStatus
().
intValue
()
==
1
)
{
return
true
;
}
return
false
;
}
}
gic-store-service/src/main/java/com/gic/store/service/impl/StoreStrategyServiceImpl.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
service
.
impl
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.store.dao.mapper.TabStoreStrategyMapper
;
import
com.gic.store.dto.StoreStrategyDTO
;
import
com.gic.store.entity.TabStoreStrategy
;
import
com.gic.store.service.StoreStrategyService
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/4 9:47 AM
*/
@Service
(
"storeStrategyService"
)
public
class
StoreStrategyServiceImpl
implements
StoreStrategyService
{
@Autowired
private
TabStoreStrategyMapper
tabStoreStrategyMapper
;
@Override
public
int
saveStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
TabStoreStrategy
storeStrategy
=
EntityUtil
.
changeEntityNew
(
TabStoreStrategy
.
class
,
storeStrategyDTO
);
tabStoreStrategyMapper
.
insert
(
storeStrategy
);
return
storeStrategy
.
getStoreRegionId
();
}
@Override
public
boolean
isRepeatGroupStrategyName
(
TabStoreStrategy
record
)
{
Integer
count
=
tabStoreStrategyMapper
.
countRepeatStrategyName
(
record
);
if
(
count
!=
null
&&
count
>
0
)
{
return
true
;
}
return
false
;
}
@Override
public
TabStoreStrategy
getStoreStrategyById
(
Integer
strategyId
)
{
return
tabStoreStrategyMapper
.
selectByPrimaryKey
(
strategyId
);
}
@Override
public
TabStoreStrategy
getNextSort
(
int
enterpriseId
,
double
sort
,
int
strategyType
)
{
return
tabStoreStrategyMapper
.
selectNextByEnterpriseIdAndSort
(
enterpriseId
,
sort
,
strategyType
);
}
@Override
public
TabStoreStrategy
getPrevSort
(
int
enterpriseId
,
double
sort
,
int
strategyType
)
{
return
tabStoreStrategyMapper
.
selectPrevByStoreFieldIdAndSort
(
enterpriseId
,
sort
,
strategyType
);
}
@Override
public
void
setStoreStrategySort
(
int
strategyId
,
int
enterpriseId
,
int
setValue
,
int
strategyType
)
{
if
(
setValue
<=
1
)
{
// 相当于置顶
sortTopping
(
enterpriseId
,
strategyId
,
strategyType
);
}
else
{
int
start
=
setValue
-
2
;
int
size
=
2
;
List
<
TabStoreStrategy
>
list
=
tabStoreStrategyMapper
.
listTwoElementExceptId
(
strategyId
,
start
,
size
,
enterpriseId
,
strategyType
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
// 置底
sortBottom
(
enterpriseId
,
strategyId
,
strategyType
);
}
else
{
Double
sort
;
if
(
list
.
size
()
==
1
)
{
// 置底
sort
=
list
.
get
(
0
).
getSort
()
+
1
d
;
}
else
{
sort
=
(
list
.
get
(
0
).
getSort
()
+
list
.
get
(
1
).
getSort
())
/
2
d
;
}
updateSortById
(
strategyId
,
sort
);
}
}
}
@Override
public
double
getMinSort
(
int
enterpriseId
,
int
strategyType
)
{
Double
sort
=
tabStoreStrategyMapper
.
getMinSort
(
enterpriseId
,
strategyType
);
return
sort
==
null
?
1
d
:
sort
;
}
@Override
public
void
sortBottom
(
int
enterpriseId
,
int
strategyId
,
int
strategyType
)
{
Double
sort
=
getMaxSort
(
enterpriseId
,
strategyType
);
updateSortById
(
strategyId
,
sort
+
1
d
);
}
@Override
public
void
sortTopping
(
int
enterpriseId
,
int
strategyId
,
int
strategyType
)
{
Double
sort
=
getMinSort
(
enterpriseId
,
strategyType
);
updateSortById
(
strategyId
,
sort
-
1
d
);
}
@Override
public
int
deleteStoreGroupStrategy
(
int
strategyId
)
{
TabStoreStrategy
storeStrategy
=
new
TabStoreStrategy
();
storeStrategy
.
setStrategyId
(
strategyId
);
storeStrategy
.
setStatus
(
0
);
return
tabStoreStrategyMapper
.
updateByPrimaryKeySelective
(
storeStrategy
);
}
@Override
public
int
modifyStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
return
tabStoreStrategyMapper
.
updateByPrimaryKeySelective
(
EntityUtil
.
changeEntityNew
(
TabStoreStrategy
.
class
,
storeStrategyDTO
));
}
@Override
public
Page
<
TabStoreStrategy
>
listStoreStrategy
(
int
enterpriseId
,
String
search
,
int
strategyType
,
Integer
pageNum
,
Integer
pageSize
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
List
<
TabStoreStrategy
>
list
=
tabStoreStrategyMapper
.
listStoreStrategy
(
enterpriseId
,
search
,
strategyType
);
return
(
Page
<
TabStoreStrategy
>)
list
;
}
public
double
getMaxSort
(
int
enterpriseId
,
int
strategyType
)
{
Double
sort
=
tabStoreStrategyMapper
.
getMaxSort
(
enterpriseId
,
strategyType
);
return
sort
==
null
?
1
d
:
sort
;
}
private
void
updateSortById
(
int
strategyId
,
double
sort
)
{
TabStoreStrategy
storeStrategy
=
new
TabStoreStrategy
();
storeStrategy
.
setStrategyId
(
strategyId
);
storeStrategy
.
setSort
(
sort
);
tabStoreStrategyMapper
.
updateByPrimaryKeySelective
(
storeStrategy
);
}
}
gic-store-service/src/main/java/com/gic/store/service/outer/StoreStrategyApiServiceImpl.java
0 → 100644
View file @
704c711e
package
com
.
gic
.
store
.
service
.
outer
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.store.constant.StoreGroupConstant
;
import
com.gic.store.dto.StoreStrategyDTO
;
import
com.gic.store.entity.TabStoreStrategy
;
import
com.gic.store.service.StoreStrategyApiService
;
import
com.gic.store.service.StoreStrategyService
;
import
com.gic.store.utils.ErrorCode
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/4 10:10 AM
*/
@Service
(
"storeStrategyApiService"
)
public
class
StoreStrategyApiServiceImpl
implements
StoreStrategyApiService
{
@Autowired
private
StoreStrategyService
storeStrategyService
;
@Override
public
ServiceResponse
<
Integer
>
saveStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getStrategyName
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略名称不能为空"
);
}
if
(
storeStrategyDTO
.
getStoreRegionId
()
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"门店域不能为空"
);
}
if
(
storeStrategyDTO
.
getEnterpriseId
()
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"企业ID不能为空"
);
}
if
(
StringUtils
.
isBlank
(
storeStrategyDTO
.
getTargetValue
()))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略命中值不能为空"
);
}
//分组策略
storeStrategyDTO
.
setStrategyType
(
StoreGroupConstant
.
STORE_GROUP_STRATEGY_TYPE
);
storeStrategyDTO
.
setCreateTime
(
new
Date
());
storeStrategyDTO
.
setUpdateTime
(
new
Date
());
storeStrategyDTO
.
setStatus
(
1
);
//sort
storeStrategyDTO
.
setSort
(
storeStrategyService
.
getMinSort
(
storeStrategyDTO
.
getEnterpriseId
(),
storeStrategyDTO
.
getStrategyType
())
-
1
d
);
TabStoreStrategy
record
=
EntityUtil
.
changeEntityNew
(
TabStoreStrategy
.
class
,
storeStrategyDTO
);
if
(
storeStrategyService
.
isRepeatGroupStrategyName
(
record
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略名称不能重复"
);
}
return
ServiceResponse
.
success
(
storeStrategyService
.
saveStoreGroupStrategy
(
storeStrategyDTO
));
}
@Override
public
ServiceResponse
<
Integer
>
deleteStoreGroupStrategy
(
int
strategyId
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
strategyId
);
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
}
return
ServiceResponse
.
success
(
storeStrategyService
.
deleteStoreGroupStrategy
(
strategyId
));
}
@Override
public
ServiceResponse
<
Integer
>
modifyStoreGroupStrategy
(
StoreStrategyDTO
storeStrategyDTO
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
storeStrategyDTO
.
getStrategyId
());
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
}
storeStrategyDTO
.
setCreateTime
(
storeStrategy
.
getCreateTime
());
storeStrategyDTO
.
setUpdateTime
(
new
Date
());
storeStrategyDTO
.
setEnterpriseId
(
storeStrategy
.
getEnterpriseId
());
storeStrategyDTO
.
setStrategyType
(
storeStrategy
.
getStrategyType
());
TabStoreStrategy
record
=
EntityUtil
.
changeEntityNew
(
TabStoreStrategy
.
class
,
storeStrategyDTO
);
if
(
storeStrategyService
.
isRepeatGroupStrategyName
(
record
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略名称不能重复"
);
}
return
ServiceResponse
.
success
(
storeStrategyService
.
modifyStoreGroupStrategy
(
storeStrategyDTO
));
}
@Override
public
ServiceResponse
<
Integer
>
sortBottom
(
int
strategyId
,
int
strategyType
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
strategyId
);
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
}
storeStrategyService
.
sortBottom
(
storeStrategy
.
getEnterpriseId
(),
strategyId
,
strategyType
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Integer
>
sortTopping
(
int
strategyId
,
int
strategyType
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
strategyId
);
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
}
storeStrategyService
.
sortTopping
(
storeStrategy
.
getEnterpriseId
(),
strategyId
,
strategyType
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Integer
>
setStoreStrategySort
(
int
strategyId
,
int
setValue
,
int
strategyType
)
{
TabStoreStrategy
storeStrategy
=
storeStrategyService
.
getStoreStrategyById
(
strategyId
);
if
(
storeStrategy
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"策略主键ID错误,查询不到数据"
);
}
storeStrategyService
.
setStoreStrategySort
(
strategyId
,
storeStrategy
.
getEnterpriseId
(),
setValue
,
strategyType
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Page
<
StoreStrategyDTO
>>
listStoreField
(
int
enterpriseId
,
String
search
,
int
strategyType
,
Integer
pageNum
,
Integer
pageSize
)
{
com
.
github
.
pagehelper
.
Page
storeStrategies
=
storeStrategyService
.
listStoreStrategy
(
enterpriseId
,
search
,
strategyType
,
pageNum
,
pageSize
);
Page
<
StoreStrategyDTO
>
page
=
PageHelperUtils
.
changePageHelperToCurrentPage
(
storeStrategies
,
StoreStrategyDTO
.
class
);
List
<
StoreStrategyDTO
>
strategyDTOList
=
page
.
getResult
();
int
index
=
(
pageNum
-
1
)
*
pageSize
+
1
;
for
(
int
i
=
0
,
length
=
strategyDTOList
.
size
();
i
<
length
;
i
++)
{
strategyDTOList
.
get
(
i
).
setSeq
(
index
+
i
);
}
return
ServiceResponse
.
success
(
page
);
}
}
gic-store-service/src/main/resources/dubbo-gic-store-service.xml
View file @
704c711e
...
...
@@ -30,4 +30,8 @@
<!--门店-->
<dubbo:service
interface=
"com.gic.store.service.StoreApiService"
ref=
"storeApiService"
timeout=
"60000"
/>
<dubbo:service
interface=
"com.gic.store.service.ProvincesApiService"
ref=
"provincesApiService"
timeout=
"60000"
/>
<!--分组策略-->
<dubbo:service
interface=
"com.gic.store.service.StoreStrategyApiService"
ref=
"storeStrategyApiService"
timeout=
"60000"
/>
</beans>
gic-store-service/src/main/resources/mapper/TabStoreGroupStrategyWeightsMapper.xml
0 → 100644
View file @
704c711e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.gic.store.dao.mapper.TabStoreGroupStrategyWeightsMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.store.entity.TabStoreGroupStrategyWeights"
>
<id
column=
"weights_id"
jdbcType=
"INTEGER"
property=
"weightsId"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"enterprise_id"
jdbcType=
"INTEGER"
property=
"enterpriseId"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
weights_id, create_time, update_time, status, enterprise_id
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_group_strategy_weights
where weights_id = #{weightsId,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from tab_store_group_strategy_weights
where weights_id = #{weightsId,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.store.entity.TabStoreGroupStrategyWeights"
>
insert into tab_store_group_strategy_weights (weights_id, create_time, update_time,
status, enterprise_id)
values (#{weightsId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{status,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.store.entity.TabStoreGroupStrategyWeights"
>
insert into tab_store_group_strategy_weights
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"weightsId != null"
>
weights_id,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"status != null"
>
status,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"weightsId != null"
>
#{weightsId,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"status != null"
>
#{status,jdbcType=INTEGER},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.store.entity.TabStoreGroupStrategyWeights"
>
update tab_store_group_strategy_weights
<set>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"status != null"
>
status = #{status,jdbcType=INTEGER},
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
</set>
where weights_id = #{weightsId,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.store.entity.TabStoreGroupStrategyWeights"
>
update tab_store_group_strategy_weights
set create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
enterprise_id = #{enterpriseId,jdbcType=INTEGER}
where weights_id = #{weightsId,jdbcType=INTEGER}
</update>
<select
id=
"selectByPrimary"
parameterType=
"com.gic.store.entity.TabStoreGroupStrategyWeights"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_group_strategy_weights
where 1 = 1
<if
test=
"weightsId != null"
>
and weights_id = #{weightsId}
</if>
<if
test=
"status != null"
>
and status = #{status}
</if>
<if
test=
"enterpriseId != null"
>
and enterprise_id = #{enterpriseId}
</if>
</select>
</mapper>
\ No newline at end of file
gic-store-service/src/main/resources/mapper/TabStoreStrategyMapper.xml
View file @
704c711e
...
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"com.gic.store.dao.mapper.TabStoreStrategyMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.gic.store.entity.TabStoreStrategy"
>
<id
column=
"strategy_id"
jdbcType=
"INTEGER"
property=
"strategyId"
/>
<result
column=
"st
artegy_name"
jdbcType=
"VARCHAR"
property=
"star
tegyName"
/>
<result
column=
"st
rategy_name"
jdbcType=
"VARCHAR"
property=
"stra
tegyName"
/>
<result
column=
"enterprise_id"
jdbcType=
"INTEGER"
property=
"enterpriseId"
/>
<result
column=
"store_region_id"
jdbcType=
"INTEGER"
property=
"storeRegionId"
/>
<result
column=
"condition"
jdbcType=
"VARCHAR"
property=
"condition"
/>
...
...
@@ -11,11 +11,12 @@
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"stategy_type"
jdbcType=
"INTEGER"
property=
"stategyType"
/>
<result
column=
"strategy_type"
jdbcType=
"INTEGER"
property=
"strategyType"
/>
<result
column=
"sort"
jdbcType=
"DOUBLE"
property=
"sort"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
strategy_id, st
ar
tegy_name, enterprise_id, store_region_id, condition, target_value,
create_time, update_time, status, st
ategy_type
strategy_id, st
ra
tegy_name, enterprise_id, store_region_id, condition, target_value,
create_time, update_time, status, st
rategy_type, sort
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -27,15 +28,15 @@
delete from tab_store_strategy
where strategy_id = #{strategyId,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
>
insert into tab_store_strategy (strategy_id, st
ar
tegy_name, enterprise_id,
<insert
id=
"insert"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
useGeneratedKeys=
"true"
keyProperty=
"strategyId"
>
insert into tab_store_strategy (strategy_id, st
ra
tegy_name, enterprise_id,
store_region_id, condition, target_value,
create_time, update_time, status,
st
ategy_type
)
values (#{strategyId,jdbcType=INTEGER}, #{st
ar
tegyName,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=INTEGER},
st
rategy_type, sort
)
values (#{strategyId,jdbcType=INTEGER}, #{st
ra
tegyName,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=INTEGER},
#{storeRegionId,jdbcType=INTEGER}, #{condition,jdbcType=VARCHAR}, #{targetValue,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
#{st
ategyType,jdbcType=INTEGER
})
#{st
rategyType,jdbcType=INTEGER}, #{sort,jdbcType=DOUBLE
})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
>
insert into tab_store_strategy
...
...
@@ -43,8 +44,8 @@
<if
test=
"strategyId != null"
>
strategy_id,
</if>
<if
test=
"st
ar
tegyName != null"
>
st
ar
tegy_name,
<if
test=
"st
ra
tegyName != null"
>
st
ra
tegy_name,
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id,
...
...
@@ -67,16 +68,19 @@
<if
test=
"status != null"
>
status,
</if>
<if
test=
"stategyType != null"
>
stategy_type,
<if
test=
"strategyType != null"
>
strategy_type,
</if>
<if
test=
"sort != null"
>
sort,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"strategyId != null"
>
#{strategyId,jdbcType=INTEGER},
</if>
<if
test=
"st
ar
tegyName != null"
>
#{st
ar
tegyName,jdbcType=VARCHAR},
<if
test=
"st
ra
tegyName != null"
>
#{st
ra
tegyName,jdbcType=VARCHAR},
</if>
<if
test=
"enterpriseId != null"
>
#{enterpriseId,jdbcType=INTEGER},
...
...
@@ -99,16 +103,19 @@
<if
test=
"status != null"
>
#{status,jdbcType=INTEGER},
</if>
<if
test=
"stategyType != null"
>
#{stategyType,jdbcType=INTEGER},
<if
test=
"strategyType != null"
>
#{strategyType,jdbcType=INTEGER},
</if>
<if
test=
"sort != null"
>
#{sort,jdbcType=DOUBLE},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
>
update tab_store_strategy
<set>
<if
test=
"st
ar
tegyName != null"
>
st
artegy_name = #{star
tegyName,jdbcType=VARCHAR},
<if
test=
"st
ra
tegyName != null"
>
st
rategy_name = #{stra
tegyName,jdbcType=VARCHAR},
</if>
<if
test=
"enterpriseId != null"
>
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
...
...
@@ -131,15 +138,18 @@
<if
test=
"status != null"
>
status = #{status,jdbcType=INTEGER},
</if>
<if
test=
"stategyType != null"
>
stategy_type = #{stategyType,jdbcType=INTEGER},
<if
test=
"strategyType != null"
>
strategy_type = #{strategyType,jdbcType=INTEGER},
</if>
<if
test=
"sort != null"
>
sort = #{sort,jdbcType=DOUBLE},
</if>
</set>
where strategy_id = #{strategyId,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
>
update tab_store_strategy
set st
artegy_name = #{star
tegyName,jdbcType=VARCHAR},
set st
rategy_name = #{stra
tegyName,jdbcType=VARCHAR},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
store_region_id = #{storeRegionId,jdbcType=INTEGER},
condition = #{condition,jdbcType=VARCHAR},
...
...
@@ -147,7 +157,85 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
stategy_type = #{stategyType,jdbcType=INTEGER}
strategy_type = #{strategyType,jdbcType=INTEGER},
sort = #{sort,jdbcType=DOUBLE}
where strategy_id = #{strategyId,jdbcType=INTEGER}
</update>
<select
id=
"countRepeatStrategyName"
parameterType=
"com.gic.store.entity.TabStoreStrategy"
resultType=
"integer"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_strategy
where status = 1
<if
test=
"strategyName != null"
>
and strategy_name = #{strategyName,jdbcType=VARCHAR}
</if>
<if
test=
"enterpriseId != null"
>
and enterprise_id = #{enterpriseId,jdbcType=INTEGER}
</if>
<if
test=
"strategyType != null"
>
and strategy_type = #{strategyType,jdbcType=INTEGER}
</if>
<if
test=
"strategyId != null"
>
and strategy_id
<>
#{strategyId}
</if>
</select>
<select
id=
"selectNextByEnterpriseIdAndSort"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_strategy
where enterprise_id = #{enterpriseId}
and strategy_type = #{strategyType}
and sort > #{sort}
and status = 1
order by sort
limit 1
</select>
<select
id=
"selectPrevByStoreFieldIdAndSort"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_strategy
where enterprise_id = #{enterpriseId}
and strategy_type = #{strategyType}
and sort
<
#{sort}
and status = 1
order by sort
limit 1
</select>
<select
id=
"getMinSort"
resultType=
"java.lang.Double"
>
select sort from tab_store_strategy where enterprise_id = #{enterpriseId} and strategy_type = #{strategyType} and status = 1 order by sort limit 0, 1
</select>
<select
id=
"getMaxSort"
resultType=
"java.lang.Double"
>
select sort from tab_store_strategy where enterprise_id = #{enterpriseId} and strategy_type = #{strategyType} and status = 1 order by sort desc limit 0, 1
</select>
<select
id=
"listTwoElementExceptId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_strategy
where strategy_id
<>
#{strategyId}
and enterprise_id = #{enterpriseId}
and strategy_type = #{strategyType}
and status = 1
order by sort
limit #{start}, #{size}
</select>
<select
id=
"listStoreStrategy"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_store_strategy
where enterprise_id = #{enterpriseId}
and strategy_type = #{strategyType}
<if
test=
"search != null and search != '' "
>
and strategy_name like concat('%', #{search}, '%')
</if>
and status = 1
order by sort
</select>
</mapper>
\ No newline at end of file
gic-store-web/src/main/resources/dubbo-gic-store-web.xml
View file @
704c711e
...
...
@@ -26,4 +26,7 @@
<!--门店-->
<dubbo:reference
interface=
"com.gic.store.service.StoreApiService"
id=
"storeApiService"
timeout=
"60000"
retries=
"0"
/>
<!--分组策略-->
<dubbo:reference
interface=
"com.gic.store.service.StoreStrategyApiService"
id=
"storeStrategyApiService"
timeout=
"60000"
retries=
"0"
/>
</beans>
\ No newline at end of file
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