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
61ad46f3
Commit
61ad46f3
authored
Dec 04, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
寄售已发布的商品
parent
78d9c246
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
15 deletions
+130
-15
ch-admin-api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
...api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
+7
-1
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/ConsignSaleServiceImpl.java
...n/java/com/wwdz/ch/admin/impl/ConsignSaleServiceImpl.java
+53
-11
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/ItemServiceImpl.java
...src/main/java/com/wwdz/ch/admin/impl/ItemServiceImpl.java
+4
-1
ch-core/src/main/java/com/wwdz/ch/core/consts/ConsignSaleEnum.java
...rc/main/java/com/wwdz/ch/core/consts/ConsignSaleEnum.java
+2
-1
ch-core/src/main/java/com/wwdz/ch/core/entity/ConsignSaleVo.java
.../src/main/java/com/wwdz/ch/core/entity/ConsignSaleVo.java
+5
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ConsignSaleServiceImpl.java
...main/java/com/wwdz/ch/wx/impl/ConsignSaleServiceImpl.java
+30
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ConsignSaleService.java
.../main/java/com/wwdz/ch/wx/service/ConsignSaleService.java
+8
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/ConsignSaleController.java
...c/main/java/com/wwdz/ch/wx/web/ConsignSaleController.java
+21
-0
No files found.
ch-admin-api/src/main/java/com/wwdz/ch/admin/entity/vo/CoinVo.java
View file @
61ad46f3
...
...
@@ -12,7 +12,7 @@ public class CoinVo implements Entity {
private
Long
id
;
/**
*
钱币
名称
*
商品
名称
*/
private
String
name
;
...
...
@@ -129,4 +129,10 @@ public class CoinVo implements Entity {
*/
private
List
<
Integer
>
categoryIds
;
/**
* 对应的分类
*
*/
private
List
<
String
>
categoryNames
;
}
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/ConsignSaleServiceImpl.java
View file @
61ad46f3
...
...
@@ -2,15 +2,19 @@ package com.wwdz.ch.admin.impl;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.admin.service.ConsignSaleService
;
import
com.wwdz.ch.admin.service.ItemService
;
import
com.wwdz.ch.core.consts.ConsignSaleEnum
;
import
com.wwdz.ch.core.entity.ConsignSaleVo
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.IdUtils
;
import
com.wwdz.ch.core.util.MediaUtil
;
import
com.wwdz.ch.db.dao.ConsignSaleDao
;
import
com.wwdz.ch.db.dao.ConsignSaleRecordDao
;
import
com.wwdz.ch.db.dao.ItemDao
;
import
com.wwdz.ch.db.domain.ConsignSale
;
import
com.wwdz.ch.db.domain.ConsignSaleRecord
;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.wwdz.ch.db.dto.request.ConsignSaleRecordRequestDto
;
import
com.wwdz.ch.db.dto.request.ConsignSaleRequestDto
;
import
com.xxdxxs.utils.EntityMapper
;
...
...
@@ -20,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -41,9 +46,13 @@ public class ConsignSaleServiceImpl implements ConsignSaleService {
@Autowired
ItemDao
itemDao
;
@Autowired
ItemService
itemService
;
@Override
public
Result
findList
(
ConsignSaleRequestDto
dto
)
{
try
{
List
<
ConsignSale
>
list
=
consignSaleDao
.
find
(
dto
);
PageInfo
<
ConsignSale
>
pageInfo
=
new
PageInfo
<>(
list
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
...
...
@@ -53,12 +62,44 @@ public class ConsignSaleServiceImpl implements ConsignSaleService {
//查询商品的信息
List
<
Item
>
itemList
=
itemDao
.
findDetails
(
itemIds
);
Map
<
Long
,
Item
>
itemMap
=
itemList
.
stream
().
collect
(
Collectors
.
toMap
(
Item:
:
getId
,
Function
.
identity
()));
return
null
;
List
<
ConsignSaleVo
>
consignSaleVoList
=
new
ArrayList
<>();
list
.
forEach
(
consignSale
->
{
Item
item
=
itemMap
.
get
(
consignSale
.
getItemId
());
ConsignSaleVo
consignSaleVo
=
new
ConsignSaleVo
();
consignSaleVo
.
setSaleId
(
consignSale
.
getSaleId
());
consignSaleVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
item
.
getImages
(),
item
.
getVideos
()));
consignSaleVo
.
setItemName
(
item
.
getName
());
consignSaleVo
.
setSystemState
(
consignSale
.
getSystemState
());
consignSaleVo
.
setSystemStateName
(
ConsignSaleEnum
.
SaleForSysStateEnum
.
getNameByCode
(
consignSale
.
getSystemState
()));
consignSaleVo
.
setSaleTime
(
consignSale
.
getSaleTime
());
if
(
consignSale
.
getSystemState
().
intValue
()
==
ConsignSaleEnum
.
SaleForSysStateEnum
.
CANCEL
.
getCode
())
{
List
<
ConsignSaleRecord
>
consignSaleRecords
=
consignSaleRecordDao
.
find
(
consignSale
.
getSaleId
());
List
<
Integer
>
operateType
=
consignSaleRecords
.
stream
().
map
(
ConsignSaleRecord:
:
getType
).
collect
(
Collectors
.
toList
());
if
(
operateType
.
contains
(
ConsignSaleEnum
.
OperateTypeEnum
.
CUSTOM_CANCEL
.
getCode
()))
{
consignSaleVo
.
setCancelType
(
ConsignSaleEnum
.
OperateTypeEnum
.
CUSTOM_CANCEL
.
getDes
());
}
else
{
consignSaleVo
.
setCancelType
(
ConsignSaleEnum
.
OperateTypeEnum
.
SYS_CANCEL
.
getDes
());
}
}
consignSaleVoList
.
add
(
consignSaleVo
);
});
return
Result
.
success
(
consignSaleVoList
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询寄售单列表 error:{}"
,
e
);
}
return
Result
.
failed
();
}
@Override
public
Result
findDetail
(
ConsignSaleRequestDto
dto
)
{
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setId
(
dto
.
getItemId
());
Result
itemResult
=
itemService
.
findDetails
(
coinRequestDto
);
if
(!
itemResult
.
getSuccess
())
{
return
itemResult
;
}
return
null
;
}
...
...
@@ -114,6 +155,7 @@ public class ConsignSaleServiceImpl implements ConsignSaleService {
ConsignSale
consignSale
=
new
ConsignSale
();
consignSale
.
setDealPrice
(
dto
.
getDealPrice
());
consignSale
.
setSaleId
(
dto
.
getSaleId
());
consignSale
.
setCustomState
(
ConsignSaleEnum
.
SaleForUserStateEnum
.
FINISH
.
getCode
());
consignSale
.
setSystemState
(
ConsignSaleEnum
.
SaleForSysStateEnum
.
FINISH
.
getCode
());
consignSaleDao
.
update
(
consignSale
);
//插入操作记录
...
...
@@ -148,7 +190,7 @@ public class ConsignSaleServiceImpl implements ConsignSaleService {
consignSaleRecord
.
setCreateTime
(
new
Date
());
consignSaleRecord
.
setContent
(
"取消类型:"
+
dto
.
getContent
());
consignSaleRecord
.
setRemark
(
dto
.
getRemark
());
consignSaleRecord
.
setType
(
ConsignSaleEnum
.
OperateTypeEnum
.
CANCEL
.
getCode
());
consignSaleRecord
.
setType
(
ConsignSaleEnum
.
OperateTypeEnum
.
SYS_
CANCEL
.
getCode
());
consignSaleRecordDao
.
insert
(
consignSaleRecord
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
...
...
ch-admin-api/src/main/java/com/wwdz/ch/admin/impl/ItemServiceImpl.java
View file @
61ad46f3
...
...
@@ -97,12 +97,15 @@ public class ItemServiceImpl implements ItemService {
Integer
categoryId
=
item
.
getCid
();
Category
category
=
categoryDao
.
findById
(
categoryId
);
List
<
Integer
>
categoryIds
=
new
ArrayList
<>();
List
<
String
>
categoryNames
=
new
ArrayList
<>();
if
(
null
!=
category
)
{
categoryIds
.
add
(
0
,
category
.
getId
());
categoryNames
.
add
(
0
,
category
.
getName
());
Integer
pid
=
category
.
getPid
();
while
(
pid
!=
0
)
{
categoryIds
.
add
(
0
,
pid
);
Category
pCategory
=
categoryDao
.
findById
(
pid
);
categoryNames
.
add
(
0
,
pCategory
.
getName
());
if
(
null
!=
pCategory
)
{
pid
=
pCategory
.
getPid
();
}
else
{
...
...
@@ -113,7 +116,7 @@ public class ItemServiceImpl implements ItemService {
coinVo
.
setCategoryIds
(
categoryIds
);
return
Result
.
success
(
coinVo
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"
钱币设置
查询明细 error : {}"
,
e
);
logger
.
error
(
"
商品
查询明细 error : {}"
,
e
);
}
return
Result
.
failed
();
}
...
...
ch-core/src/main/java/com/wwdz/ch/core/consts/ConsignSaleEnum.java
View file @
61ad46f3
...
...
@@ -91,7 +91,8 @@ public class ConsignSaleEnum {
VALUATE
(
1
,
"图文估价"
),
IDENTIFY
(
4
,
"实物鉴定"
),
WAIT_TAKE
(
10
,
"寄售单完成"
),
CANCEL
(
20
,
"寄售单取消"
),
CUSTOM_CANCEL
(
20
,
"用户取消寄售"
),
SYS_CANCEL
(
21
,
"平台取消寄售"
),
;
private
int
code
;
...
...
ch-core/src/main/java/com/wwdz/ch/core/entity/ConsignSaleVo.java
View file @
61ad46f3
...
...
@@ -91,4 +91,9 @@ public class ConsignSaleVo implements Entity {
* 更新时间
*/
private
Date
updateTime
;
/**
* 如果是取消的状态显示取消类型
*/
private
String
cancelType
;
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ConsignSaleServiceImpl.java
View file @
61ad46f3
...
...
@@ -23,7 +23,10 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
...
...
@@ -74,6 +77,32 @@ public class ConsignSaleServiceImpl implements ConsignSaleService {
return
Result
.
failed
();
}
@Transactional
@Override
public
Result
saleReleaseItem
(
ConsignSaleRequestDto
dto
)
{
try
{
//修改商品状态为寄售中
Item
item
=
new
Item
();
item
.
setId
(
dto
.
getItemId
());
item
.
setIsOnSale
(
true
);
itemDao
.
updateById
(
item
);
Item
itemInfo
=
itemDao
.
findById
(
dto
.
getItemId
());
if
(!
ObjectUtils
.
isEmpty
(
itemInfo
.
getPrice
()))
{
dto
.
setUserPrice
((
int
)
(
itemInfo
.
getPrice
()/
100
));
}
Result
result
=
createConsignSaleOrder
(
dto
);
if
(!
result
.
getSuccess
())
{
throw
new
RuntimeException
(
"创建寄售单失败"
);
}
return
result
;
}
catch
(
Exception
e
)
{
logger
.
info
(
"商品id: {}, 寄售已发布商品失败 : {}"
,
dto
.
getItemId
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
}
return
Result
.
failed
();
}
@Override
public
Result
findList
(
ConsignSaleRequestDto
dto
)
{
try
{
...
...
@@ -143,7 +172,7 @@ public class ConsignSaleServiceImpl implements ConsignSaleService {
consignSaleRecord
.
setSaleId
(
dto
.
getSaleId
());
consignSaleRecord
.
setCreateTime
(
new
Date
());
consignSaleRecord
.
setContent
(
"取消类型:用户主动取消"
);
consignSaleRecord
.
setType
(
ConsignSaleEnum
.
OperateTypeEnum
.
CANCEL
.
getCode
());
consignSaleRecord
.
setType
(
ConsignSaleEnum
.
OperateTypeEnum
.
C
USTOM_C
ANCEL
.
getCode
());
consignSaleRecordDao
.
insert
(
consignSaleRecord
);
return
Result
.
success
();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ConsignSaleService.java
View file @
61ad46f3
...
...
@@ -13,6 +13,14 @@ public interface ConsignSaleService {
Result
createConsignSaleOrder
(
ConsignSaleRequestDto
dto
);
/**
* 寄售已发布商品
* @param dto
* @return
*/
Result
saleReleaseItem
(
ConsignSaleRequestDto
dto
);
/**
* 查询寄售单
* @param dto
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/ConsignSaleController.java
View file @
61ad46f3
...
...
@@ -70,6 +70,27 @@ public class ConsignSaleController {
}
@ApiOperation
(
value
=
"寄售已发布商品"
)
@PostMapping
(
"/saleReleaseItem"
)
public
Result
saleReleaseItem
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】寄售已发布商品,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户ID"
).
must
().
number
()
.
set
(
"itemId"
,
"商品id"
).
must
().
number
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
ResultCode
.
PARAM_ERROR
.
getCode
(),
validator
.
getErrorInfo
());
}
//为发布的商品创建寄售单
ConsignSaleRequestDto
consignSaleRequestDto
=
new
ConsignSaleRequestDto
();
consignSaleRequestDto
.
setUserId
(
dto
.
getUserId
());
consignSaleRequestDto
.
setItemId
(
dto
.
getItemId
());
return
consignSaleService
.
saleReleaseItem
(
consignSaleRequestDto
);
}
@ApiOperation
(
value
=
"用户查询寄售单"
)
@PostMapping
(
"/findList"
)
public
Result
findList
(
@RequestBody
ConsignSaleRequestDto
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