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
f1c62211
Commit
f1c62211
authored
Sep 04, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交换商品后扣减库存
parent
bc3fcaff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
2 deletions
+32
-2
ch-dao/src/main/java/com/wwdz/ch/db/dao/distribution/ExchangeOrderSnapshotDao.java
...wwdz/ch/db/dao/distribution/ExchangeOrderSnapshotDao.java
+2
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/ExchangeOrderSnapshotDaoImpl.java
...ch/db/impl/distribution/ExchangeOrderSnapshotDaoImpl.java
+10
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/SupplierItemDaoImpl.java
...com/wwdz/ch/db/impl/distribution/SupplierItemDaoImpl.java
+1
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeServiceImpl.java
...com/wwdz/ch/wx/impl/distribution/ExchangeServiceImpl.java
+13
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
...wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
+6
-0
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/distribution/ExchangeOrderSnapshotDao.java
View file @
f1c62211
...
@@ -11,4 +11,6 @@ public interface ExchangeOrderSnapshotDao {
...
@@ -11,4 +11,6 @@ public interface ExchangeOrderSnapshotDao {
boolean
update
(
ExchangeOrderSnapshot
exchangeOrderSnapshot
);
boolean
update
(
ExchangeOrderSnapshot
exchangeOrderSnapshot
);
List
<
ExchangeOrderSnapshot
>
findByOrderId
(
String
orderId
);
List
<
ExchangeOrderSnapshot
>
findByOrderId
(
String
orderId
);
List
<
ExchangeOrderSnapshot
>
findByUserId
(
long
userId
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/ExchangeOrderSnapshotDaoImpl.java
View file @
f1c62211
...
@@ -34,6 +34,16 @@ public class ExchangeOrderSnapshotDaoImpl implements ExchangeOrderSnapshotDao {
...
@@ -34,6 +34,16 @@ public class ExchangeOrderSnapshotDaoImpl implements ExchangeOrderSnapshotDao {
ExchangeOrderSnapshotExample
example
=
new
ExchangeOrderSnapshotExample
();
ExchangeOrderSnapshotExample
example
=
new
ExchangeOrderSnapshotExample
();
ExchangeOrderSnapshotExample
.
Criteria
criteria
=
example
.
createCriteria
();
ExchangeOrderSnapshotExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andDistributionOrderIdEqualTo
(
orderId
);
criteria
.
andDistributionOrderIdEqualTo
(
orderId
);
criteria
.
andIsValidEqualTo
(
true
);
return
exchangeOrderSnapshotMapper
.
selectByExampleWithBLOBs
(
example
);
}
@Override
public
List
<
ExchangeOrderSnapshot
>
findByUserId
(
long
userId
)
{
ExchangeOrderSnapshotExample
example
=
new
ExchangeOrderSnapshotExample
();
ExchangeOrderSnapshotExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andCreatorIdEqualTo
(
userId
);
criteria
.
andIsValidEqualTo
(
true
);
return
exchangeOrderSnapshotMapper
.
selectByExampleWithBLOBs
(
example
);
return
exchangeOrderSnapshotMapper
.
selectByExampleWithBLOBs
(
example
);
}
}
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/SupplierItemDaoImpl.java
View file @
f1c62211
...
@@ -33,6 +33,7 @@ public class SupplierItemDaoImpl implements SupplierItemDao {
...
@@ -33,6 +33,7 @@ public class SupplierItemDaoImpl implements SupplierItemDao {
SupplierItemExample
.
Criteria
criteria
=
supplierItemExample
.
createCriteria
();
SupplierItemExample
.
Criteria
criteria
=
supplierItemExample
.
createCriteria
();
JdbcHelper
.
ifPresent
(
dto
.
getId
(),
criteria:
:
andIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getId
(),
criteria:
:
andIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getIds
(),
criteria:
:
andIdIn
);
JdbcHelper
.
ifPresent
(
dto
.
getIds
(),
criteria:
:
andIdIn
);
JdbcHelper
.
ifPresent
(
dto
.
getFilterIds
(),
criteria:
:
andIdNotIn
);
if
(
StringUtils
.
hasLength
(
dto
.
getName
()))
{
if
(
StringUtils
.
hasLength
(
dto
.
getName
()))
{
criteria
.
andNameLike
(
"%"
+
dto
.
getName
()
+
"%"
);
criteria
.
andNameLike
(
"%"
+
dto
.
getName
()
+
"%"
);
}
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeServiceImpl.java
View file @
f1c62211
...
@@ -17,6 +17,7 @@ import com.wwdz.ch.wx.constant.CollectionBookConstants;
...
@@ -17,6 +17,7 @@ import com.wwdz.ch.wx.constant.CollectionBookConstants;
import
com.wwdz.ch.wx.entity.request.ExchangeRequestDto
;
import
com.wwdz.ch.wx.entity.request.ExchangeRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemSimpleDto
;
import
com.wwdz.ch.wx.entity.request.ItemSimpleDto
;
import
com.wwdz.ch.wx.service.distribution.ExchangeService
;
import
com.wwdz.ch.wx.service.distribution.ExchangeService
;
import
com.wwdz.ch.wx.service.distribution.SupplierItemService
;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.StringUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -54,6 +55,9 @@ public class ExchangeServiceImpl implements ExchangeService {
...
@@ -54,6 +55,9 @@ public class ExchangeServiceImpl implements ExchangeService {
@Autowired
@Autowired
ExchangeOrderSnapshotDao
exchangeOrderSnapshotDao
;
ExchangeOrderSnapshotDao
exchangeOrderSnapshotDao
;
@Autowired
SupplierItemService
supplierItemService
;
@Override
@Override
public
Result
checkEnoughItem
(
ExchangeRequestDto
dto
)
{
public
Result
checkEnoughItem
(
ExchangeRequestDto
dto
)
{
try
{
try
{
...
@@ -87,8 +91,9 @@ public class ExchangeServiceImpl implements ExchangeService {
...
@@ -87,8 +91,9 @@ public class ExchangeServiceImpl implements ExchangeService {
Long
targetUserId
=
dto
.
getUserId
();
Long
targetUserId
=
dto
.
getUserId
();
//查询用户已经交换的商品,在列表中去除
//查询用户已经交换的商品,在列表中去除
// List<ExchangeOrderSnapshot> exchangeOrderSnapshotList = exchangeOrderSnapshotDao.findByOrderId();
List
<
ExchangeOrderSnapshot
>
exchangeOrderSnapshotList
=
exchangeOrderSnapshotDao
.
findByUserId
(
dto
.
getUserId
());
List
<
Long
>
filterItemList
=
exchangeOrderSnapshotList
.
stream
().
map
(
ExchangeOrderSnapshot:
:
getItemId
).
distinct
().
collect
(
Collectors
.
toList
());
supplierItemRequestDto
.
setFilterIds
(
filterItemList
);
//标签id为空则查询所有的藏品
//标签id为空则查询所有的藏品
if
(
dto
.
getCollectionBookId
()
==
null
)
{
if
(
dto
.
getCollectionBookId
()
==
null
)
{
...
@@ -218,6 +223,9 @@ public class ExchangeServiceImpl implements ExchangeService {
...
@@ -218,6 +223,9 @@ public class ExchangeServiceImpl implements ExchangeService {
long
exchangeItemId
=
dto
.
getExchangeItemId
();
long
exchangeItemId
=
dto
.
getExchangeItemId
();
//查询交换的商品价值
//查询交换的商品价值
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
exchangeItemId
);
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
exchangeItemId
);
if
(
supplierItem
.
getStock
()
<
dto
.
getExchangeItemNum
())
{
return
Result
.
failed
(
"库存不足"
);
}
long
exchangeItemPrice
=
supplierItem
.
getOfficialEstimatedPrice
()
*
dto
.
getExchangeItemNum
();
long
exchangeItemPrice
=
supplierItem
.
getOfficialEstimatedPrice
()
*
dto
.
getExchangeItemNum
();
List
<
ItemSimpleDto
>
itemSimpleDtoList
=
dto
.
getItemList
();
List
<
ItemSimpleDto
>
itemSimpleDtoList
=
dto
.
getItemList
();
//查询用户藏品的价值
//查询用户藏品的价值
...
@@ -266,6 +274,9 @@ public class ExchangeServiceImpl implements ExchangeService {
...
@@ -266,6 +274,9 @@ public class ExchangeServiceImpl implements ExchangeService {
exchangeOrderSnapshot
.
setUpdateTime
(
new
Date
());
exchangeOrderSnapshot
.
setUpdateTime
(
new
Date
());
exchangeOrderSnapshotDao
.
insert
(
exchangeOrderSnapshot
);
exchangeOrderSnapshotDao
.
insert
(
exchangeOrderSnapshot
);
}
}
//减少库存
supplierItemService
.
reduceStock
(
exchangeItemId
,
dto
.
getExchangeItemNum
());
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"distributionOrderId"
,
distributionOrderId
);
map
.
put
(
"distributionOrderId"
,
distributionOrderId
);
return
Result
.
success
(
map
);
return
Result
.
success
(
map
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
View file @
f1c62211
...
@@ -212,6 +212,12 @@ public class SupplierItemServiceImpl implements SupplierItemService {
...
@@ -212,6 +212,12 @@ public class SupplierItemServiceImpl implements SupplierItemService {
public
Result
findItemList
(
SupplierItemRequestDto
dto
)
{
public
Result
findItemList
(
SupplierItemRequestDto
dto
)
{
try
{
try
{
List
<
SupplierItemVo
>
supplierItemVos
=
new
ArrayList
<>();
List
<
SupplierItemVo
>
supplierItemVos
=
new
ArrayList
<>();
if
(
dto
.
getType
()
!=
null
&&
dto
.
getType
()
==
DistributionEnum
.
DistributionTypeEnum
.
EXCHANGE
.
getCode
())
{
//库存要大于0
dto
.
setStock
(
0
);
//必须要有官方估价才能展示在交换列表
dto
.
setOfficialEstimatedPriceNotNull
(
true
);
}
List
<
SupplierItem
>
supplierItemList
=
supplierItemDao
.
findListForSort
(
dto
);
List
<
SupplierItem
>
supplierItemList
=
supplierItemDao
.
findListForSort
(
dto
);
PageInfo
pageInfo
=
new
PageInfo
(
supplierItemList
);
PageInfo
pageInfo
=
new
PageInfo
(
supplierItemList
);
for
(
SupplierItem
supplierItem
:
supplierItemList
)
{
for
(
SupplierItem
supplierItem
:
supplierItemList
)
{
...
...
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