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
cc090883
Commit
cc090883
authored
Sep 14, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
换货审批单
parent
1d839d01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
5 deletions
+73
-5
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeApplyOrderServiceImpl.java
...h/wx/impl/distribution/ExchangeApplyOrderServiceImpl.java
+72
-4
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
...wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
+1
-1
No files found.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/ExchangeApplyOrderServiceImpl.java
View file @
cc090883
package
com.wwdz.ch.wx.impl.distribution
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.api.WxAppletApi
;
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.notify.AliSmsSender
;
import
com.wwdz.ch.core.type.PageSearchResult
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.CacheUtil
;
...
...
@@ -18,6 +21,7 @@ import com.wwdz.ch.db.dao.exchange.ExchangeApplyOrderDetailDao;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.db.domain.distribution.*
;
import
com.wwdz.ch.db.dto.request.ItemSimpleDto
;
import
com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto
;
import
com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto
;
import
com.wwdz.ch.db.dto.request.exchange.ExchangeApplyOrderRequestDto
;
import
com.wwdz.ch.wx.entity.request.ExchangeRequestDto
;
...
...
@@ -60,6 +64,12 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
@Autowired
CacheUtil
cacheUtil
;
@Autowired
AliSmsSender
aliSmsSender
;
@Autowired
WxAppletApi
wxAppletApi
;
@Transactional
@Override
public
Result
applyExchange
(
ExchangeApplyOrderRequestDto
dto
)
{
...
...
@@ -105,6 +115,15 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
exchangeApplyOrderDetail
.
setUpdateTime
(
now
);
exchangeApplyOrderDetailDao
.
insert
(
exchangeApplyOrderDetail
);
}
//发短信通知受理方
try
{
String
url
=
wxAppletApi
.
getUrlLink
(
"/pages/saleExchangeApplyOrder/index"
,
null
);
String
msg
=
"您有一个换货申请待审批,"
+
"请前往"
+
url
+
"查看"
;
aliSmsSender
.
sendSms
(
dto
.
getTargetUserId
(),
msg
);
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>> 用户id:{}, 发送换货申请待审批通知短信失败 <<<<<<<<<"
,
dto
.
getTargetUserId
());
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"exchangeApplyOrderId"
,
exchangeApplyOrderId
);
return
Result
.
success
(
map
);
...
...
@@ -223,6 +242,8 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
@Override
public
Result
findList
(
ExchangeApplyOrderRequestDto
dto
)
{
try
{
//检查用户是否有未审批的申请单
checkHandleTimeOut
(
dto
.
getUserId
());
ExchangeApplyOrderRequestDto
queryDto
=
new
ExchangeApplyOrderRequestDto
();
//我收到的申请单
if
(
dto
.
getType
()
==
ExchangeApplyOrderEnum
.
TypeEnum
.
RECEIVE
.
getCode
())
{
...
...
@@ -237,6 +258,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
PageInfo
pageInfo
=
new
PageInfo
<>(
exchangeApplyOrderList
);
List
<
ExchangeApplyOrderVo
>
exchangeApplyOrderVoList
=
new
ArrayList
<>();
for
(
ExchangeApplyOrder
exchangeApplyOrder
:
exchangeApplyOrderList
)
{
checkHandleTimeOutByOrderId
(
exchangeApplyOrder
.
getExchangeApplyOrderId
());
ExchangeApplyOrderVo
exchangeApplyOrderVo
=
new
ExchangeApplyOrderVo
();
EntityMapper
.
copyAttribute
(
exchangeApplyOrder
,
exchangeApplyOrderVo
);
//交换的目标商品
...
...
@@ -304,8 +326,8 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
exchangeApplyOrderVo
.
setStateLinkDesc
(
"前往订单详情"
);
}
//处理申请的截止时间 48小时内
Date
now
=
new
Dat
e
();
Instant
instant
=
now
.
toInstant
().
plus
(
Duration
.
ofHours
(
48
));
Date
date
=
exchangeApplyOrder
.
getCreateTim
e
();
Instant
instant
=
date
.
toInstant
().
plus
(
Duration
.
ofHours
(
48
));
Date
time
=
Date
.
from
(
instant
);
exchangeApplyOrderVo
.
setExpireTime
(
time
);
exchangeApplyOrderVoList
.
add
(
exchangeApplyOrderVo
);
...
...
@@ -321,6 +343,8 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
@Override
public
Result
findDetail
(
ExchangeApplyOrderRequestDto
dto
)
{
try
{
//检查该订单是否超时未审批
checkHandleTimeOutByOrderId
(
dto
.
getExchangeApplyOrderId
());
ExchangeApplyOrder
exchangeApplyOrder
=
exchangeApplyOrderDao
.
findByOrderId
(
dto
.
getExchangeApplyOrderId
());
ExchangeApplyOrderVo
exchangeApplyOrderVo
=
new
ExchangeApplyOrderVo
();
EntityMapper
.
copyAttribute
(
exchangeApplyOrder
,
exchangeApplyOrderVo
);
...
...
@@ -391,8 +415,8 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
}
//处理申请的截止时间 48小时内
Date
now
=
new
Dat
e
();
Instant
instant
=
now
.
toInstant
().
plus
(
Duration
.
ofHours
(
48
));
Date
date
=
exchangeApplyOrder
.
getCreateTim
e
();
Instant
instant
=
date
.
toInstant
().
plus
(
Duration
.
ofHours
(
48
));
Date
time
=
Date
.
from
(
instant
);
exchangeApplyOrderVo
.
setExpireTime
(
time
);
return
Result
.
success
(
exchangeApplyOrderVo
);
...
...
@@ -401,4 +425,48 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
}
return
Result
.
failed
();
}
/**
* 检查受理方是否有超时未审批的订单,自动取消
* @param userId
*/
private
void
checkHandleTimeOut
(
Long
userId
){
ExchangeApplyOrderRequestDto
queryDto
=
new
ExchangeApplyOrderRequestDto
();
queryDto
.
setTargetUserId
(
userId
);
queryDto
.
setState
(
ExchangeApplyOrderEnum
.
StateEnum
.
PRE_HANDLE
.
getCode
());
List
<
ExchangeApplyOrder
>
exchangeApplyOrderList
=
exchangeApplyOrderDao
.
findByPage
(
queryDto
);
exchangeApplyOrderList
.
forEach
(
exchangeApplyOrder
->
{
String
orderId
=
exchangeApplyOrder
.
getExchangeApplyOrderId
();
long
diffInMillies
=
Math
.
abs
(
new
Date
().
getTime
()
-
exchangeApplyOrder
.
getCreateTime
().
getTime
());
//超出48小时未处理审批单,订单取消
long
diffInHours
=
diffInMillies
/
(
60
*
1000
*
60
);
if
(
diffInHours
>=
48
)
{
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao
.
updateState
(
orderId
,
ExchangeApplyOrderEnum
.
StateEnum
.
DISAGREE
.
getCode
());
exchangeApplyOrderDetailDao
.
updateInValid
(
orderId
);
}
});
}
/**
* 检查该订单是否超时未审批,自动取消
* @param exchangeApplyOrderId
*/
private
void
checkHandleTimeOutByOrderId
(
String
exchangeApplyOrderId
){
ExchangeApplyOrderRequestDto
queryDto
=
new
ExchangeApplyOrderRequestDto
();
queryDto
.
setExchangeApplyOrderId
(
exchangeApplyOrderId
);
ExchangeApplyOrder
exchangeApplyOrder
=
exchangeApplyOrderDao
.
findByExchangeOrderId
(
exchangeApplyOrderId
);
if
(
exchangeApplyOrder
.
getState
()
==
ExchangeApplyOrderEnum
.
StateEnum
.
PRE_HANDLE
.
getCode
())
{
long
diffInMillies
=
Math
.
abs
(
new
Date
().
getTime
()
-
exchangeApplyOrder
.
getCreateTime
().
getTime
());
//超出48小时未处理审批单,订单取消
long
diffInHours
=
diffInMillies
/
(
60
*
1000
*
60
);
if
(
diffInHours
>=
48
)
{
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao
.
updateState
(
exchangeApplyOrderId
,
ExchangeApplyOrderEnum
.
StateEnum
.
DISAGREE
.
getCode
());
exchangeApplyOrderDetailDao
.
updateInValid
(
exchangeApplyOrderId
);
}
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
View file @
cc090883
...
...
@@ -220,7 +220,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
//库存要大于0
dto
.
setStock
(
0
);
//必须要有官方估价才能展示在交换列表
dto
.
setOfficialEstimatedPriceNotNull
(
true
);
//
dto.setOfficialEstimatedPriceNotNull(true);
}
String
viewKey
=
dto
.
getUserId
()
+
":exchangeItemList"
;
if
(
dto
.
getPage
()
==
1
)
{
...
...
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