Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
50065c7d
Commit
50065c7d
authored
Sep 12, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交换单列表
parent
62751711
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
359 additions
and
68 deletions
+359
-68
ch-admin-api/src/main/java/com/wwdz/ch/admin/job/SynItemToEsJob.java
...i/src/main/java/com/wwdz/ch/admin/job/SynItemToEsJob.java
+2
-0
ch-core/src/main/java/com/wwdz/ch/core/config/ElasticSearchConfig.java
...ain/java/com/wwdz/ch/core/config/ElasticSearchConfig.java
+1
-2
ch-core/src/main/java/com/wwdz/ch/core/consts/ExchangeApplyOrderEnum.java
.../java/com/wwdz/ch/core/consts/ExchangeApplyOrderEnum.java
+2
-1
ch-core/src/main/java/com/wwdz/ch/core/entity/SupplierItemVo.java
...src/main/java/com/wwdz/ch/core/entity/SupplierItemVo.java
+5
-0
ch-core/src/main/java/com/wwdz/ch/core/entity/exchange/ExchangeApplyOrderVo.java
...om/wwdz/ch/core/entity/exchange/ExchangeApplyOrderVo.java
+13
-2
ch-core/src/main/resources/application-dev.yml
ch-core/src/main/resources/application-dev.yml
+1
-1
ch-core/src/main/resources/application-prod.yml
ch-core/src/main/resources/application-prod.yml
+1
-1
ch-dao/src/main/java/com/wwdz/ch/db/dao/distribution/SupplierItemDao.java
...java/com/wwdz/ch/db/dao/distribution/SupplierItemDao.java
+8
-0
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/exchange/ExchangeApplyOrderRequestDto.java
...db/dto/request/exchange/ExchangeApplyOrderRequestDto.java
+5
-3
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/SupplierItemDaoImpl.java
...com/wwdz/ch/db/impl/distribution/SupplierItemDaoImpl.java
+11
-1
ch-dao/src/main/java/com/wwdz/ch/db/impl/exchange/ExchangeApplyOrderDaoImpl.java
...m/wwdz/ch/db/impl/exchange/ExchangeApplyOrderDaoImpl.java
+2
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
.../main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/request/ExchangeRequestDto.java
...ava/com/wwdz/ch/wx/entity/request/ExchangeRequestDto.java
+5
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+2
-7
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeApplyOrderServiceImpl.java
...h/wx/impl/distribution/ExchangeApplyOrderServiceImpl.java
+168
-15
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeServiceImpl.java
...com/wwdz/ch/wx/impl/distribution/ExchangeServiceImpl.java
+42
-22
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
...wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
+21
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/ExchangeApplyOrderService.java
...ch/wx/service/distribution/ExchangeApplyOrderService.java
+18
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/ExchangeApplyOrderController.java
.../ch/wx/web/distribution/ExchangeApplyOrderController.java
+51
-10
No files found.
ch-admin-api/src/main/java/com/wwdz/ch/admin/job/SynItemToEsJob.java
View file @
50065c7d
...
...
@@ -154,6 +154,8 @@ public class SynItemToEsJob {
supplierItemRequestDto
.
setPage
(
1
);
supplierItemRequestDto
.
setLimit
(
100
);
List
<
SupplierItem
>
list
=
supplierItemDao
.
findListByPage
(
supplierItemRequestDto
);
itemEsDao
.
create
(
list
);
logger
.
info
(
">>>>>>>>>>>>>>>>>11111111 <<<<<<<<<<<<<<<<<"
);
PageInfo
<
SupplierItem
>
pageInfo
=
new
PageInfo
<>(
list
);
int
totalPageNum
=
pageInfo
.
getPages
();
logger
.
info
(
"total page : {}, total : {}"
,
totalPageNum
,
pageInfo
.
getTotal
());
...
...
ch-core/src/main/java/com/wwdz/ch/core/config/ElasticSearchConfig.java
View file @
50065c7d
...
...
@@ -65,8 +65,7 @@ public class ElasticSearchConfig {
HttpHost
httpHost
;
for
(
int
i
=
0
;
i
<
hostArray
.
length
;
i
++)
{
String
[]
strings
=
hostArray
[
i
].
split
(
":"
);
// httpHost = new HttpHost(strings[0], Integer.parseInt(strings[1]), "https");
httpHost
=
new
HttpHost
(
strings
[
0
]);
httpHost
=
new
HttpHost
(
strings
[
0
],
Integer
.
parseInt
(
strings
[
1
]),
"http"
);
httpHosts
[
i
]
=
httpHost
;
}
return
httpHosts
;
...
...
ch-core/src/main/java/com/wwdz/ch/core/consts/ExchangeApplyOrderEnum.java
View file @
50065c7d
...
...
@@ -6,6 +6,8 @@ public class ExchangeApplyOrderEnum {
PRE_HANDLE
(
0
,
"待处理"
),
AGREE
(
1
,
"同意"
),
DISAGREE
(
2
,
"拒绝"
),
SYSTEM_DISAGREE
(
3
,
"平台鉴定后拒绝"
),
CANCEL
(-
1
,
"取消"
),
;
private
int
code
;
...
...
@@ -17,7 +19,6 @@ public class ExchangeApplyOrderEnum {
}
public
static
String
getNameByCode
(
int
code
)
{
for
(
ExchangeApplyOrderEnum
.
StateEnum
stateEnum
:
ExchangeApplyOrderEnum
.
StateEnum
.
values
())
{
if
(
code
==
stateEnum
.
getCode
())
{
return
stateEnum
.
getDes
();
...
...
ch-core/src/main/java/com/wwdz/ch/core/entity/SupplierItemVo.java
View file @
50065c7d
...
...
@@ -398,4 +398,9 @@ public class SupplierItemVo implements Entity {
*/
private
String
groupPurchaseStateName
;
/**
* 是否为平台商品
*/
private
Boolean
isOfficialItem
=
false
;
}
ch-core/src/main/java/com/wwdz/ch/core/entity/exchange/ExchangeApplyOrderVo.java
View file @
50065c7d
package
com.wwdz.ch.core.entity.exchange
;
import
com.wwdz.ch.core.consts.ExchangeApplyOrderEnum
;
import
com.wwdz.ch.core.entity.SupplierItemVo
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
...
...
@@ -12,7 +13,7 @@ public class ExchangeApplyOrderVo implements Entity {
/**
* 申请交换单
*/
private
String
exchangeAppl
u
OrderId
;
private
String
exchangeAppl
y
OrderId
;
/**
* 用户id
...
...
@@ -69,5 +70,15 @@ public class ExchangeApplyOrderVo implements Entity {
/**
* 我收到的,我提交的
*/
private
String
orderType
;
private
Integer
orderType
;
/**
* 我收到的,我提交的
*/
private
String
orderTypeName
;
public
void
setState
(
Integer
state
)
{
this
.
state
=
state
;
this
.
stateName
=
ExchangeApplyOrderEnum
.
StateEnum
.
getNameByCode
(
state
);
}
}
ch-core/src/main/resources/application-dev.yml
View file @
50065c7d
...
...
@@ -220,7 +220,7 @@ spring:
elasticsearch
:
rest
:
uris
:
es-cn-
ot93wtaf300091bf7.elasticsearch.aliyuncs.com
uris
:
es-cn-
em93wv4oh000dc18k.elasticsearch.aliyuncs.com:9200
username
:
elastic
password
:
hP9gB7aM0oS9oS6k
index
:
quanku_dev
...
...
ch-core/src/main/resources/application-prod.yml
View file @
50065c7d
...
...
@@ -214,7 +214,7 @@ spring:
elasticsearch
:
rest
:
uris
:
es-cn-
ot93wtaf300091bf7.elasticsearch.aliyuncs.com
uris
:
es-cn-
em93wv4oh000dc18k.elasticsearch.aliyuncs.com:9200
username
:
elastic
password
:
hP9gB7aM0oS9oS6k
index
:
quanku_prod
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dao/distribution/SupplierItemDao.java
View file @
50065c7d
...
...
@@ -8,6 +8,7 @@ import com.wwdz.ch.db.dto.request.CoinRequestDto;
import
com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto
;
import
com.xxdxxs.db.component.JdbcHelper
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -88,6 +89,13 @@ public interface SupplierItemDao {
List
<
SupplierItem
>
findByCreatorId
(
long
creatorId
);
/**
* 查询用户发的商品数量
* @param creatorId
* @return
*/
long
countAllItemByCreatorId
(
long
creatorId
,
Date
queryTime
);
/**
* 统计上新商品的数量
* @param supplierItemRequestDto
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/exchange/ExchangeApplyOrderRequestDto.java
View file @
50065c7d
...
...
@@ -14,7 +14,7 @@ public class ExchangeApplyOrderRequestDto extends BaseRequestDto implements Enti
/**
* 申请交换单
*/
private
String
exchangeAppl
u
OrderId
;
private
String
exchangeAppl
y
OrderId
;
/**
* 用户id
...
...
@@ -67,7 +67,9 @@ public class ExchangeApplyOrderRequestDto extends BaseRequestDto implements Enti
private
String
targetUserOrderId
;
/**
* 1同意2拒绝
* RECEIVE(1, "我收到的"),
* COMMIT(2, "我提交的"),
*/
private
Integer
isAgree
;
private
Integer
type
;
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/SupplierItemDaoImpl.java
View file @
50065c7d
...
...
@@ -228,6 +228,16 @@ public class SupplierItemDaoImpl implements SupplierItemDao {
}
@Override
public
long
countAllItemByCreatorId
(
long
creatorId
,
Date
queryTime
)
{
SupplierItemExample
supplierItemExample
=
new
SupplierItemExample
();
SupplierItemExample
.
Criteria
criteria
=
supplierItemExample
.
createCriteria
();
criteria
.
andCreatorIdEqualTo
(
creatorId
);
criteria
.
andIsDeletedEqualTo
(
false
);
JdbcHelper
.
ifPresent
(
queryTime
,
criteria:
:
andCreateTimeGreaterThanOrEqualTo
);
return
supplierItemMapper
.
countByExample
(
supplierItemExample
);
}
@Override
public
long
countOfNewItem
(
SupplierItemRequestDto
supplierItemRequestDto
)
{
SupplierItemExample
supplierItemExample
=
new
SupplierItemExample
();
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/exchange/ExchangeApplyOrderDaoImpl.java
View file @
50065c7d
...
...
@@ -29,7 +29,7 @@ public class ExchangeApplyOrderDaoImpl implements ExchangeApplyOrderDao {
public
List
<
ExchangeApplyOrder
>
findByPage
(
ExchangeApplyOrderRequestDto
dto
)
{
ExchangeApplyOrderExample
example
=
new
ExchangeApplyOrderExample
();
ExchangeApplyOrderExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
dto
.
getExchangeAppl
u
OrderId
(),
criteria:
:
andExchangeApplyOrderIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getExchangeAppl
y
OrderId
(),
criteria:
:
andExchangeApplyOrderIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getUserId
(),
criteria:
:
andUserIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getTargetUserId
(),
criteria:
:
andTargetUserIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getState
(),
criteria:
:
andStateEqualTo
);
...
...
@@ -69,6 +69,7 @@ public class ExchangeApplyOrderDaoImpl implements ExchangeApplyOrderDao {
public
int
update
(
ExchangeApplyOrder
exchangeApplyOrder
)
{
ExchangeApplyOrderExample
example
=
new
ExchangeApplyOrderExample
();
ExchangeApplyOrderExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andExchangeApplyOrderIdEqualTo
(
exchangeApplyOrder
.
getExchangeApplyOrderId
());
return
exchangeApplyOrderMapper
.
updateByExampleSelective
(
exchangeApplyOrder
,
example
);
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
View file @
50065c7d
...
...
@@ -49,7 +49,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
"/wx/supplierItem/**"
,
"/wx/specialPerformance/**"
,
"/wx/groupPurchase/**"
,
"/wx/disposableSubscribeRecord/**"
,
"/wx/auctionRecord/findList"
,
"/wx/selfPage/countIntroduceAmount"
,
"/wx/exchange/findExchangeItem"
,
"/wx/specialPerformance/findInfos"
,
"/wx/specialPerformance/findItemList"
,
"/wx/groupPurchase/findList"
,
"/wx/groupPurchase/findItemDetail"
"/wx/groupPurchase/findList"
,
"/wx/groupPurchase/findItemDetail"
,
"/wx/**/"
//下列路径上线注释
/* ,"/wx/specialPerformance/**"
, "/wx/supplierItem/**", "/wx/shareRecord/**", "/wx/distributionOrder/**", "/wx/selfPage/**", "/wx/auctionRecord/**",
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/request/ExchangeRequestDto.java
View file @
50065c7d
...
...
@@ -94,4 +94,9 @@ public class ExchangeRequestDto extends BaseRequestDto implements Entity {
*/
private
Boolean
isMultiple
=
false
;
/**
* 要交换的是否是官方的商品
*/
private
Boolean
isOfficialItem
=
true
;
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
50065c7d
...
...
@@ -222,11 +222,9 @@ public class ItemServiceImpl implements ItemService {
// 设置基本信息
itemResponseVo
.
setId
(
es
.
getId
());
itemResponseVo
.
setName
(
es
.
getName
());
itemResponseVo
.
setDetail
(
es
.
getDetail
());
itemResponseVo
.
setSourceType
(
es
.
getSourceType
());
itemResponseVo
.
setViewPermission
(
0
);
/* itemResponseVo.setDetail(es.getDetail());
// 设置价格
itemResponseVo
.
setPrice
(
getPrice
(
es
.
getPrice
()));
itemResponseVo.setPrice(getPrice(es.getPrice()));
*/
// 设置图片或视频
itemResponseVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
es
.
getImages
(),
es
.
getVideos
()));
// 设置是否收藏和是否是自己发布的
...
...
@@ -459,12 +457,9 @@ public class ItemServiceImpl implements ItemService {
// 设置基本信息
itemResponseVo
.
setId
(
es
.
getId
());
itemResponseVo
.
setName
(
es
.
getName
());
itemResponseVo
.
setDetail
(
es
.
getDetail
());
itemResponseVo
.
setSourceType
(
es
.
getSourceType
());
itemResponseVo
.
setViewPermission
(
0
);
itemResponseVo
.
setIsOnSale
(
es
.
getIsOnSale
());
// 设置价格
itemResponseVo
.
setPrice
(
getPrice
(
es
.
getPrice
()));
// 设置图片或视频
itemResponseVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
es
.
getImages
(),
es
.
getVideos
()));
// 设置是否收藏和是否是自己发布的
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeApplyOrderServiceImpl.java
View file @
50065c7d
package
com.wwdz.ch.wx.impl.distribution
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.consts.DistributionEnum
;
import
com.wwdz.ch.core.consts.ExchangeApplyOrderEnum
;
import
com.wwdz.ch.core.entity.SupplierItemVo
;
import
com.wwdz.ch.core.entity.exchange.ExchangeApplyOrderVo
;
import
com.wwdz.ch.core.type.PageSearchResult
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.CacheUtil
;
import
com.wwdz.ch.core.util.IdUtils
;
import
com.wwdz.ch.core.util.MediaUtil
;
import
com.wwdz.ch.core.util.PriceUtil
;
import
com.wwdz.ch.db.dao.distribution.ExchangeOrderSnapshotDao
;
import
com.wwdz.ch.db.dao.distribution.SupplierItemDao
;
import
com.wwdz.ch.db.dao.exchange.ExchangeApplyOrderDao
;
...
...
@@ -27,6 +32,8 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.CollectionUtils
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -110,20 +117,20 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
return
Result
.
failed
();
}
@Transactional
@Override
public
Result
handleApplyOrder
(
ExchangeApplyOrderRequestDto
dto
)
{
try
{
String
orderId
=
dto
.
getExchangeAppl
u
OrderId
();
String
orderId
=
dto
.
getExchangeAppl
y
OrderId
();
ExchangeApplyOrder
exchangeApplyOrder
=
exchangeApplyOrderDao
.
findByOrderId
(
orderId
);
if
(
ExchangeApplyOrderEnum
.
StateEnum
.
AGREE
.
getCode
()
==
dto
.
get
IsAgre
e
())
{
if
(
ExchangeApplyOrderEnum
.
StateEnum
.
AGREE
.
getCode
()
==
dto
.
get
Stat
e
())
{
//同意交换申请,则为交换双方创建订单
//为提交方创建订单
ExchangeRequestDto
commitExchangeDto
=
new
ExchangeRequestDto
();
//无需校验官方价格
commitExchangeDto
.
setCheckPrice
(
false
);
//按多个商品来处理
commitExchangeDto
.
setIsMultiple
(
tru
e
);
//
是否
按多个商品来处理
commitExchangeDto
.
setIsMultiple
(
fals
e
);
commitExchangeDto
.
setExchangeItemId
(
exchangeApplyOrder
.
getTargetItemId
());
commitExchangeDto
.
setExchangeItemNum
(
exchangeApplyOrder
.
getTargetItemNum
());
List
<
ItemSimpleDto
>
itemSimpleDtoList
=
new
ArrayList
<>();
...
...
@@ -141,7 +148,8 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
commitExchangeDto
.
setUserOpenId
(
user
.
getWeixinOpenid
());
Result
commitExchangeOrderResult
=
exchangeService
.
exchange
(
commitExchangeDto
);
if
(!
commitExchangeOrderResult
.
getSuccess
())
{
return
Result
.
failed
(
"创建交换订单失败"
);
logger
.
error
(
">>>>>>> 创建申请方交换订单失败 <<<<<<<"
);
throw
new
Exception
(
"创建申请方交换订单失败"
);
}
//为受理方创建订单
...
...
@@ -170,27 +178,172 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
receiveExchangeDto
.
setItemList
(
receiveItemSimpleDtoList
);
receiveExchangeDto
.
setUserId
(
exchangeApplyOrder
.
getUserId
());
User
receiveUser
=
cacheUtil
.
getAppletUserById
(
exchangeApplyOrder
.
getTargetUserId
());
commit
ExchangeDto
.
setUserOpenId
(
receiveUser
.
getWeixinOpenid
());
Result
receiveExchangeOrderResult
=
exchangeService
.
exchange
(
commit
ExchangeDto
);
receive
ExchangeDto
.
setUserOpenId
(
receiveUser
.
getWeixinOpenid
());
Result
receiveExchangeOrderResult
=
exchangeService
.
exchange
(
receive
ExchangeDto
);
if
(!
receiveExchangeOrderResult
.
getSuccess
())
{
return
Result
.
failed
(
"创建交换订单失败"
);
logger
.
error
(
">>>>>>>> 创建接收方方交换订单失败 <<<<<<<<"
);
throw
new
Exception
(
"创建接收方方交换订单失败"
);
}
ExchangeApplyOrder
updateExchangeApplyOrder
=
new
ExchangeApplyOrder
();
updateExchangeApplyOrder
.
setExchangeApplyOrderId
(
orderId
);
updateExchangeApplyOrder
.
setTargetUserOrderId
(((
Map
)
receiveExchangeOrderResult
.
getData
()).
get
(
"distributionOrderId"
).
toString
());
updateExchangeApplyOrder
.
setUserOrderId
(((
Map
)
commitExchangeOrderResult
.
getData
()).
get
(
"distributionOrderId"
).
toString
());
String
targetUserOrderId
=
((
Map
)
receiveExchangeOrderResult
.
getData
()).
get
(
"distributionOrderId"
).
toString
();
String
userOrderId
=
((
Map
)
commitExchangeOrderResult
.
getData
()).
get
(
"distributionOrderId"
).
toString
();
updateExchangeApplyOrder
.
setTargetUserOrderId
(
targetUserOrderId
);
updateExchangeApplyOrder
.
setUserOrderId
(
userOrderId
);
updateExchangeApplyOrder
.
setState
(
ExchangeApplyOrderEnum
.
StateEnum
.
AGREE
.
getCode
());
exchangeApplyOrderDao
.
update
(
updateExchangeApplyOrder
);
logger
.
info
(
"************* 交换达成, 交换单号:{}, 申请人的订单号:{}, 受理人的订单号;{} *************"
,
orderId
,
userOrderId
,
targetUserOrderId
);
}
else
{
//接收方拒绝交换
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao
.
updateState
(
orderId
,
ExchangeApplyOrderEnum
.
StateEnum
.
DISAGREE
.
getCode
());
exchangeApplyOrderDetailDao
.
updateInValid
(
orderId
);
}
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"处理换物申请单 error:{}"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
}
return
Result
.
failed
();
}
@Override
public
Result
cancel
(
ExchangeApplyOrderRequestDto
dto
)
{
return
null
;
try
{
String
orderId
=
dto
.
getExchangeApplyOrderId
();
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao
.
updateState
(
orderId
,
ExchangeApplyOrderEnum
.
StateEnum
.
CANCEL
.
getCode
());
exchangeApplyOrderDetailDao
.
updateInValid
(
orderId
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"取消换物申请单 error:{}"
,
e
);
}
return
Result
.
failed
();
}
@Override
public
Result
findList
(
ExchangeApplyOrderRequestDto
dto
)
{
try
{
ExchangeApplyOrderRequestDto
queryDto
=
new
ExchangeApplyOrderRequestDto
();
//我收到的申请单
if
(
dto
.
getType
()
==
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getCode
())
{
queryDto
.
setTargetUserId
(
dto
.
getUserId
());
}
else
{
//我申请的
queryDto
.
setUserId
(
dto
.
getUserId
());
}
queryDto
.
setPage
(
dto
.
getPage
());
queryDto
.
setLimit
(
dto
.
getLimit
());
List
<
ExchangeApplyOrder
>
exchangeApplyOrderList
=
exchangeApplyOrderDao
.
findByPage
(
queryDto
);
PageInfo
pageInfo
=
new
PageInfo
<>(
exchangeApplyOrderList
);
List
<
ExchangeApplyOrderVo
>
exchangeApplyOrderVoList
=
new
ArrayList
<>();
for
(
ExchangeApplyOrder
exchangeApplyOrder
:
exchangeApplyOrderList
)
{
ExchangeApplyOrderVo
exchangeApplyOrderVo
=
new
ExchangeApplyOrderVo
();
EntityMapper
.
copyAttribute
(
exchangeApplyOrder
,
exchangeApplyOrderVo
);
//交换的目标商品
long
targetItemId
=
exchangeApplyOrder
.
getTargetItemId
();
SupplierItem
targetItem
=
supplierItemDao
.
findById
(
targetItemId
);
SupplierItemVo
targetItemVo
=
new
SupplierItemVo
();
EntityMapper
.
copyAttribute
(
targetItem
,
targetItemVo
);
targetItemVo
.
setItemId
(
targetItemId
);
targetItemVo
.
setName
(
targetItem
.
getName
());
targetItemVo
.
setItemNum
(
exchangeApplyOrder
.
getTargetItemNum
());
targetItemVo
.
setDistributionPrice
(
PriceUtil
.
convertPriceFenToYuan
(
targetItem
.
getDistributionPrice
()));
targetItemVo
.
setOfficialEstimatedPrice
(
PriceUtil
.
convertPriceFenToYuan
(
targetItem
.
getOfficialEstimatedPrice
()));
targetItemVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
targetItem
.
getImages
(),
targetItem
.
getVideos
()));
exchangeApplyOrderVo
.
setTargetItemInfo
(
targetItemVo
);
List
<
ExchangeApplyOrderDetail
>
detailList
=
exchangeApplyOrderDetailDao
.
findByOrderId
(
exchangeApplyOrder
.
getExchangeApplyOrderId
());
List
<
SupplierItemVo
>
userItemList
=
new
ArrayList
<>();
//用户用来交换的商品
for
(
ExchangeApplyOrderDetail
exchangeApplyOrderDetail
:
detailList
)
{
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
exchangeApplyOrderDetail
.
getItemId
());
SupplierItemVo
supplierItemVo
=
new
SupplierItemVo
();
supplierItemVo
.
setItemId
(
exchangeApplyOrderDetail
.
getItemId
());
supplierItemVo
.
setName
(
supplierItem
.
getName
());
supplierItemVo
.
setItemNum
(
exchangeApplyOrderDetail
.
getItemNum
());
supplierItemVo
.
setDistributionPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getDistributionPrice
()));
supplierItemVo
.
setOfficialEstimatedPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getOfficialEstimatedPrice
()));
supplierItemVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
supplierItem
.
getImages
(),
supplierItem
.
getVideos
()));
userItemList
.
add
(
supplierItemVo
);
}
exchangeApplyOrderVo
.
setUserItemList
(
userItemList
);
if
(
dto
.
getType
()
==
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getCode
())
{
exchangeApplyOrderVo
.
setOrderType
(
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getCode
());
exchangeApplyOrderVo
.
setOrderTypeName
(
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getDes
());
}
else
{
//我申请的
exchangeApplyOrderVo
.
setOrderType
(
ExchangeApplyOrderEnum
.
TypeEnum
.
COMMIT
.
getCode
());
exchangeApplyOrderVo
.
setOrderTypeName
(
ExchangeApplyOrderEnum
.
TypeEnum
.
COMMIT
.
getDes
());
}
//处理申请的截止时间 48小时内
Date
now
=
new
Date
();
Instant
instant
=
now
.
toInstant
().
plus
(
Duration
.
ofHours
(
48
));
Date
time
=
Date
.
from
(
instant
);
exchangeApplyOrderVo
.
setExpireTime
(
time
);
exchangeApplyOrderVoList
.
add
(
exchangeApplyOrderVo
);
}
return
Result
.
success
(
PageSearchResult
.
of
(
pageInfo
,
exchangeApplyOrderVoList
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询交换单列表 error:{}"
,
e
);
}
return
Result
.
failed
();
}
@Override
public
Result
findDetail
(
ExchangeApplyOrderRequestDto
dto
)
{
try
{
ExchangeApplyOrder
exchangeApplyOrder
=
exchangeApplyOrderDao
.
findByOrderId
(
dto
.
getExchangeApplyOrderId
());
ExchangeApplyOrderVo
exchangeApplyOrderVo
=
new
ExchangeApplyOrderVo
();
EntityMapper
.
copyAttribute
(
exchangeApplyOrder
,
exchangeApplyOrderVo
);
//交换的目标商品
long
targetItemId
=
exchangeApplyOrder
.
getTargetItemId
();
SupplierItem
targetItem
=
supplierItemDao
.
findById
(
targetItemId
);
SupplierItemVo
targetItemVo
=
new
SupplierItemVo
();
EntityMapper
.
copyAttribute
(
targetItem
,
targetItemVo
);
targetItemVo
.
setItemId
(
targetItemId
);
targetItemVo
.
setName
(
targetItem
.
getName
());
targetItemVo
.
setItemNum
(
exchangeApplyOrder
.
getTargetItemNum
());
targetItemVo
.
setDistributionPrice
(
PriceUtil
.
convertPriceFenToYuan
(
targetItem
.
getDistributionPrice
()));
targetItemVo
.
setOfficialEstimatedPrice
(
PriceUtil
.
convertPriceFenToYuan
(
targetItem
.
getOfficialEstimatedPrice
()));
targetItemVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
targetItem
.
getImages
(),
targetItem
.
getVideos
()));
exchangeApplyOrderVo
.
setTargetItemInfo
(
targetItemVo
);
List
<
ExchangeApplyOrderDetail
>
detailList
=
exchangeApplyOrderDetailDao
.
findByOrderId
(
exchangeApplyOrder
.
getExchangeApplyOrderId
());
List
<
SupplierItemVo
>
userItemList
=
new
ArrayList
<>();
//用户用来交换的商品
for
(
ExchangeApplyOrderDetail
exchangeApplyOrderDetail
:
detailList
)
{
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
exchangeApplyOrderDetail
.
getItemId
());
SupplierItemVo
supplierItemVo
=
new
SupplierItemVo
();
supplierItemVo
.
setItemId
(
exchangeApplyOrderDetail
.
getItemId
());
supplierItemVo
.
setName
(
supplierItem
.
getName
());
supplierItemVo
.
setItemNum
(
exchangeApplyOrderDetail
.
getItemNum
());
supplierItemVo
.
setDistributionPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getDistributionPrice
()));
supplierItemVo
.
setOfficialEstimatedPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getOfficialEstimatedPrice
()));
supplierItemVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
supplierItem
.
getImages
(),
supplierItem
.
getVideos
()));
userItemList
.
add
(
supplierItemVo
);
}
exchangeApplyOrderVo
.
setUserItemList
(
userItemList
);
if
(
dto
.
getUserId
()
==
exchangeApplyOrder
.
getTargetUserId
().
longValue
())
{
exchangeApplyOrderVo
.
setOrderType
(
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getCode
());
exchangeApplyOrderVo
.
setOrderTypeName
(
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getDes
());
}
else
{
exchangeApplyOrderVo
.
setOrderType
(
ExchangeApplyOrderEnum
.
TypeEnum
.
COMMIT
.
getCode
());
exchangeApplyOrderVo
.
setOrderTypeName
(
ExchangeApplyOrderEnum
.
TypeEnum
.
COMMIT
.
getDes
());
}
//处理申请的截止时间 48小时内
Date
now
=
new
Date
();
Instant
instant
=
now
.
toInstant
().
plus
(
Duration
.
ofHours
(
48
));
Date
time
=
Date
.
from
(
instant
);
exchangeApplyOrderVo
.
setExpireTime
(
time
);
return
Result
.
success
(
exchangeApplyOrderVo
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询交换单详情 error:{}"
,
e
);
}
return
Result
.
failed
();
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeServiceImpl.java
View file @
50065c7d
...
...
@@ -69,8 +69,10 @@ public class ExchangeServiceImpl implements ExchangeService {
List
<
ExchangeOrderSnapshot
>
exchangeOrderSnapshotList
=
exchangeOrderSnapshotDao
.
findByUserId
(
dto
.
getUserId
());
List
<
Long
>
filterItemList
=
exchangeOrderSnapshotList
.
stream
().
map
(
ExchangeOrderSnapshot:
:
getItemId
).
distinct
().
collect
(
Collectors
.
toList
());
supplierItemRequestDto
.
setFilterIds
(
filterItemList
);
//必须要有官方预估价
//想要交换官方的商品,用户自己的商品必须要有官方预估价
if
(
dto
.
getIsOfficialItem
())
{
supplierItemRequestDto
.
setOfficialEstimatedPriceNotNull
(
true
);
}
supplierItemRequestDto
.
setIsDeleted
(
false
);
List
<
SupplierItem
>
supplierItemList
=
supplierItemDao
.
findList
(
supplierItemRequestDto
);
if
(
CollectionUtils
.
isEmpty
(
supplierItemList
))
{
...
...
@@ -88,8 +90,11 @@ public class ExchangeServiceImpl implements ExchangeService {
public
Result
findItemList
(
ExchangeRequestDto
dto
)
{
try
{
SupplierItemRequestDto
supplierItemRequestDto
=
new
SupplierItemRequestDto
();
//想要交换官方的商品,用户自己的商品必须要有官方预估价
if
(
dto
.
getIsOfficialItem
())
{
//必须要有官方预估价
supplierItemRequestDto
.
setOfficialEstimatedPriceNotNull
(
true
);
}
supplierItemRequestDto
.
setPage
(
dto
.
getPage
());
supplierItemRequestDto
.
setLimit
(
dto
.
getLimit
());
List
<
SupplierItem
>
supplierItemList
=
new
ArrayList
<>();
...
...
@@ -226,31 +231,48 @@ public class ExchangeServiceImpl implements ExchangeService {
@Override
public
Result
exchange
(
ExchangeRequestDto
dto
)
{
try
{
long
exchangeItemId
=
dto
.
getExchangeItemId
();
Long
exchangeItemId
=
null
;
long
exchangeItemPrice
=
0
;
if
(
dto
.
getIsMultiple
())
{
//多商品场景在受理方订单中出现,别人用多件商品换受理方的一件商品,对于受理方而言等于是一个订单买了多件商品,
// 由于在创建申请方订单时已经扣除过库存,所以这里无需扣减库存,也不校验库存
List
<
ItemSimpleDto
>
exchangeItemList
=
dto
.
getExchangeItemList
();
for
(
ItemSimpleDto
itemSimpleDto
:
exchangeItemList
)
{
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
itemSimpleDto
.
getItemId
());
exchangeItemId
=
itemSimpleDto
.
getItemId
();
}
}
else
{
exchangeItemId
=
dto
.
getExchangeItemId
();
//查询交换的商品价值
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
exchangeItemId
);
if
(
supplierItem
.
getStock
()
<
dto
.
getExchangeItemNum
())
{
logger
.
info
(
"商品id:{}, 库存不足"
,
exchangeItemId
);
return
Result
.
failed
(
"库存不足"
);
}
long
exchangeItemPrice
=
supplierItem
.
getOfficialEstimatedPrice
()
*
dto
.
getExchangeItemNum
();
exchangeItemPrice
=
supplierItem
.
getOfficialEstimatedPrice
()
*
dto
.
getExchangeItemNum
();
}
List
<
ItemSimpleDto
>
itemSimpleDtoList
=
dto
.
getItemList
();
//查询用户藏品的价值
long
userItemPrice
=
0
;
if
(
dto
.
getCheckPrice
())
{
for
(
ItemSimpleDto
itemSimpleDto
:
itemSimpleDtoList
)
{
SupplierItem
userItem
=
supplierItemDao
.
findById
(
itemSimpleDto
.
getItemId
());
userItemPrice
=
userItemPrice
+
userItem
.
getOfficialEstimatedPrice
()
*
itemSimpleDto
.
getItemNum
();
}
if
(
dto
.
getCheckPrice
())
{
if
(
exchangeItemPrice
>
userItemPrice
)
{
return
Result
.
failed
(
"您的藏品价格低于交换的商品价值,不支持换藏"
);
}
}
//可以换藏,则创建订单
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
exchangeItemId
);
String
distributionOrderId
=
IdUtils
.
getOrderNumber
(
CommConsts
.
DISTRIBUTION_ORDER_PREFIX
);
DistributionOrder
distributionOrder
=
new
DistributionOrder
();
distributionOrder
.
setItemId
(
exchangeItemId
);
if
(
dto
.
getIsMultiple
())
{
distributionOrder
.
setItemNum
(
1
);
}
else
{
distributionOrder
.
setItemNum
(
dto
.
getExchangeItemNum
());
}
distributionOrder
.
setDistributionOrderId
(
distributionOrderId
);
distributionOrder
.
setBuyerId
(
dto
.
getUserId
());
distributionOrder
.
setBuyerOpenid
(
dto
.
getUserOpenId
());
...
...
@@ -269,7 +291,7 @@ public class ExchangeServiceImpl implements ExchangeService {
distributionOrder
.
setState
(
DistributionEnum
.
DistributionOrderStateEnum
.
PRE_EXCHANGE
.
getCode
());
distributionOrderDao
.
insert
(
distributionOrder
);
//商品信息保存在订单详情中
//
多商品订单,
商品信息保存在订单详情中
if
(
dto
.
getIsMultiple
())
{
List
<
ItemSimpleDto
>
exchangeItemList
=
dto
.
getExchangeItemList
();
for
(
ItemSimpleDto
exchangeItemSimpleDto
:
exchangeItemList
)
{
...
...
@@ -283,8 +305,6 @@ public class ExchangeServiceImpl implements ExchangeService {
distributionOrder
.
setBuyerId
(
dto
.
getUserId
());
distributionOrder
.
setSellerId
(
supplierItem
.
getCreatorId
());
distributionOrderDetailDao
.
insert
(
distributionOrderDetail
);
//减少库存
supplierItemService
.
reduceStock
(
exchangeItemSimpleDto
.
getItemId
(),
exchangeItemSimpleDto
.
getItemNum
());
}
}
else
{
DistributionOrderDetail
distributionOrderDetail
=
new
DistributionOrderDetail
();
...
...
@@ -300,7 +320,6 @@ public class ExchangeServiceImpl implements ExchangeService {
supplierItemService
.
reduceStock
(
exchangeItemId
,
dto
.
getExchangeItemNum
());
}
//保存订单中用户交换商品快照
for
(
ItemSimpleDto
itemSimpleDto
:
itemSimpleDtoList
)
{
SupplierItem
userItem
=
supplierItemDao
.
findById
(
itemSimpleDto
.
getItemId
());
...
...
@@ -315,9 +334,10 @@ public class ExchangeServiceImpl implements ExchangeService {
exchangeOrderSnapshot
.
setCreateTime
(
new
Date
());
exchangeOrderSnapshot
.
setUpdateTime
(
new
Date
());
exchangeOrderSnapshotDao
.
insert
(
exchangeOrderSnapshot
);
if
(!
dto
.
getIsMultiple
())
{
supplierItemService
.
reduceStock
(
itemSimpleDto
.
getItemId
(),
itemSimpleDto
.
getItemNum
());
}
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"distributionOrderId"
,
distributionOrderId
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
View file @
50065c7d
...
...
@@ -50,10 +50,13 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.lang.System
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
...
...
@@ -249,6 +252,9 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo
.
setDistributionPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getDistributionPrice
()));
supplierItemVo
.
setOfficialEstimatedPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getOfficialEstimatedPrice
()));
supplierItemVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
supplierItem
.
getImages
(),
supplierItem
.
getVideos
()));
if
(
CommConsts
.
SELF_SUPPORT_ACCOUNT
.
longValue
()
==
supplierItem
.
getCreatorId
())
{
supplierItemVo
.
setIsOfficialItem
(
true
);
}
supplierItemVos
.
add
(
supplierItemVo
);
}
return
Result
.
success
(
PageSearchResult
.
of
(
pageInfo
,
supplierItemVos
));
...
...
@@ -779,6 +785,20 @@ public class SupplierItemServiceImpl implements SupplierItemService {
if
(!
lock
.
tryLock
(
0
,
1
,
TimeUnit
.
SECONDS
))
{
return
Result
.
failed
(
"操作过快,稍后再试"
);
}
//不在白名单中的用户,上传商品数量有限制
if
(!
collectorWhiteListDao
.
isExisted
(
dto
.
getUserId
()))
{
//检查用户历史上传的
if
(
supplierItemDao
.
countAllItemByCreatorId
(
dto
.
getUserId
(),
null
)
>=
100
)
{
return
Result
.
failed
(
"普通用户最多上传100件商品"
);
}
//用户每天上传商品不可超过10件
LocalDate
today
=
LocalDate
.
now
();
LocalDateTime
startOfDay
=
today
.
atStartOfDay
();
if
(
supplierItemDao
.
countAllItemByCreatorId
(
dto
.
getUserId
(),
DateUtils
.
fromLocalDateTime
(
startOfDay
))
>=
10
)
{
return
Result
.
failed
(
"普通用户每天最多上传10件商品"
);
}
}
SupplierItem
supplierItem
=
new
SupplierItem
();
EntityMapper
.
copyAttribute
(
dto
,
supplierItem
);
supplierItem
.
setDistributionPrice
(
PriceUtil
.
convertPriceFromStr
(
StringUtils
.
isEmpty
(
dto
.
getDistributionPrice
())?
"0"
:
dto
.
getDistributionPrice
()));
...
...
@@ -835,7 +855,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItem
.
setDistributionPrice
(
PriceUtil
.
convertPriceFromStr
(
StringUtils
.
isEmpty
(
dto
.
getDistributionPrice
())?
"0"
:
dto
.
getDistributionPrice
()));
supplierItem
.
setImages
(
dto
.
getImages
());
supplierItem
.
setOfficialEstimatedPrice
(
null
);
supplierItem
.
setType
(
oldItem
.
getType
());
supplierItem
.
setType
(
dto
.
getType
()
==
null
?
oldItem
.
getType
()
:
dto
.
getType
());
supplierItem
.
setCreatorId
(
oldItem
.
getCreatorId
());
supplierItem
.
setRebate
(
oldItem
.
getRebate
());
supplierItem
.
setSupplierId
(
oldItem
.
getSupplierId
());
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/ExchangeApplyOrderService.java
View file @
50065c7d
...
...
@@ -27,4 +27,22 @@ public interface ExchangeApplyOrderService {
* @return
*/
Result
cancel
(
ExchangeApplyOrderRequestDto
dto
);
/**
* 查询交换单列表
* type RECEIVE(1, "我收到的"),
* COMMIT(2, "我提交的"),
* @param dto
* @return
*/
Result
findList
(
ExchangeApplyOrderRequestDto
dto
);
/**
* 查询交换单详情
* @param dto
* @return
*/
Result
findDetail
(
ExchangeApplyOrderRequestDto
dto
);
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/ExchangeApplyOrderController.java
View file @
50065c7d
...
...
@@ -3,9 +3,7 @@ package com.wwdz.ch.wx.web.distribution;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.domain.distribution.ExchangeApplyOrder
;
import
com.wwdz.ch.db.dto.request.exchange.ExchangeApplyOrderRequestDto
;
import
com.wwdz.ch.wx.entity.request.ExchangeRequestDto
;
import
com.wwdz.ch.wx.service.distribution.ExchangeApplyOrderService
;
import
com.xxdxxs.service.FormHandler
;
import
com.xxdxxs.validation.Validator
;
...
...
@@ -30,8 +28,8 @@ public class ExchangeApplyOrderController {
@ApiOperation
(
value
=
"用户申请以物换物"
)
@PostMapping
(
"/
checkEnoughItem
"
)
public
Result
checkEnoughItem
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
@PostMapping
(
"/
applyExchange
"
)
public
Result
applyExchange
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
logger
.
info
(
"用户申请以物换物,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户id"
).
must
().
number
()
...
...
@@ -44,18 +42,61 @@ public class ExchangeApplyOrderController {
}
@ApiOperation
(
value
=
"同意申请"
)
@PostMapping
(
"/agree"
)
public
Result
agree
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
@ApiOperation
(
value
=
"处理申请单"
)
@PostMapping
(
"/handleApplyOrder"
)
public
Result
handleApplyOrder
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
logger
.
info
(
"处理申请单,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"exchangeApplyOrderId"
,
"交换申请单号"
).
must
().
string
()
.
set
(
"state"
,
"状态"
).
must
().
number
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
validator
.
getErrorInfo
());
}
return
exchangeApplyOrderService
.
handleApplyOrder
(
dto
);
}
@ApiOperation
(
value
=
"用户取消交换申请"
)
@PostMapping
(
"/cancel"
)
public
Result
cancel
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
logger
.
info
(
"用户申请以物换物,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户id"
).
must
().
number
()
.
set
(
"targetItemId"
,
"想换的目标商品id"
).
must
().
number
()
validator
.
set
(
"exchangeApplyOrderId"
,
"交换申请单号"
).
must
().
string
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
validator
.
getErrorInfo
());
}
return
exchangeApplyOrderService
.
applyExchange
(
dto
);
return
exchangeApplyOrderService
.
cancel
(
dto
);
}
@ApiOperation
(
value
=
"查询交换单列表"
)
@PostMapping
(
"/findList"
)
public
Result
findList
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
logger
.
info
(
"用户申请以物换物,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户ID"
).
must
().
number
()
.
set
(
"type"
,
"类型"
).
must
().
number
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
validator
.
getErrorInfo
());
}
return
exchangeApplyOrderService
.
findList
(
dto
);
}
@ApiOperation
(
value
=
"查询交换单详情"
)
@PostMapping
(
"/findDetail"
)
public
Result
findDetail
(
@RequestBody
ExchangeApplyOrderRequestDto
dto
)
{
logger
.
info
(
"查询交换单详情,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"exchangeApplyOrderId"
,
"交换申请单号"
).
must
().
string
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
validator
.
getErrorInfo
());
}
return
exchangeApplyOrderService
.
findDetail
(
dto
);
}
}
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