Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
a2f77152
Unverified
Commit
a2f77152
authored
Jun 08, 2020
by
Tyson
Committed by
GitHub
Jun 08, 2020
Browse files
修复订单取消/退款之后优惠券没有返还问题 (#397)
parent
acb459a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/AdminOrderService.java
View file @
a2f77152
...
...
@@ -10,11 +10,9 @@ import org.linlinjava.litemall.core.notify.NotifyService;
import
org.linlinjava.litemall.core.notify.NotifyType
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallComment
;
import
org.linlinjava.litemall.db.domain.LitemallOrder
;
import
org.linlinjava.litemall.db.domain.LitemallOrderGoods
;
import
org.linlinjava.litemall.db.domain.UserVo
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.db.util.CouponUserConstant
;
import
org.linlinjava.litemall.db.util.OrderUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -50,6 +48,8 @@ public class AdminOrderService {
private
NotifyService
notifyService
;
@Autowired
private
LogHelper
logHelper
;
@Autowired
private
LitemallCouponUserService
couponUserService
;
public
Object
list
(
Integer
userId
,
String
orderSn
,
LocalDateTime
start
,
LocalDateTime
end
,
List
<
Short
>
orderStatusArray
,
Integer
page
,
Integer
limit
,
String
sort
,
String
order
)
{
...
...
@@ -159,6 +159,15 @@ public class AdminOrderService {
}
}
// 返还优惠券
List
<
LitemallCouponUser
>
couponUsers
=
couponUserService
.
findByOid
(
orderId
);
for
(
LitemallCouponUser
couponUser:
couponUsers
)
{
// 优惠券状态设置为可使用
couponUser
.
setStatus
(
CouponUserConstant
.
STATUS_USABLE
);
couponUser
.
setUpdateTime
(
LocalDateTime
.
now
());
couponUserService
.
update
(
couponUser
);
}
//TODO 发送邮件和短信通知,这里采用异步发送
// 退款成功通知用户, 例如“您申请的订单退款 [ 单号:{1} ] 已成功,请耐心等待到账。”
// 注意订单号只发后6位
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCouponUserService.java
View file @
a2f77152
...
...
@@ -91,4 +91,10 @@ public class LitemallCouponUserService {
example
.
or
().
andStatusEqualTo
(
CouponUserConstant
.
STATUS_USABLE
).
andEndTimeLessThan
(
LocalDateTime
.
now
()).
andDeletedEqualTo
(
false
);
return
couponUserMapper
.
selectByExample
(
example
);
}
public
List
<
LitemallCouponUser
>
findByOid
(
Integer
orderId
)
{
LitemallCouponUserExample
example
=
new
LitemallCouponUserExample
();
example
.
or
().
andOrderIdEqualTo
(
orderId
).
andDeletedEqualTo
(
false
);
return
couponUserMapper
.
selectByExample
(
example
);
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java
View file @
a2f77152
...
...
@@ -534,6 +534,9 @@ public class WxOrderService {
}
}
// 返还优惠券
releaseCoupon
(
orderId
);
return
ResponseUtil
.
ok
();
}
...
...
@@ -1013,4 +1016,21 @@ public class WxOrderService {
return
ResponseUtil
.
ok
();
}
/**
* 取消订单/退款返还优惠券
* <br/>
* @param orderId
* @return void
* @author Tyson
* @date 2020/6/8/0008 1:41
*/
public
void
releaseCoupon
(
Integer
orderId
)
{
List
<
LitemallCouponUser
>
couponUsers
=
couponUserService
.
findByOid
(
orderId
);
for
(
LitemallCouponUser
couponUser:
couponUsers
)
{
// 优惠券状态设置为可使用
couponUser
.
setStatus
(
CouponUserConstant
.
STATUS_USABLE
);
couponUser
.
setUpdateTime
(
LocalDateTime
.
now
());
couponUserService
.
update
(
couponUser
);
}
}
}
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/task/OrderUnpaidTask.java
View file @
a2f77152
...
...
@@ -11,6 +11,7 @@ import org.linlinjava.litemall.db.service.LitemallGoodsProductService;
import
org.linlinjava.litemall.db.service.LitemallOrderGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallOrderService
;
import
org.linlinjava.litemall.db.util.OrderUtil
;
import
org.linlinjava.litemall.wx.service.WxOrderService
;
import
java.time.LocalDateTime
;
import
java.util.List
;
...
...
@@ -36,6 +37,7 @@ public class OrderUnpaidTask extends Task {
LitemallOrderService
orderService
=
BeanUtil
.
getBean
(
LitemallOrderService
.
class
);
LitemallOrderGoodsService
orderGoodsService
=
BeanUtil
.
getBean
(
LitemallOrderGoodsService
.
class
);
LitemallGoodsProductService
productService
=
BeanUtil
.
getBean
(
LitemallGoodsProductService
.
class
);
WxOrderService
wxOrderService
=
BeanUtil
.
getBean
(
WxOrderService
.
class
);
LitemallOrder
order
=
orderService
.
findById
(
this
.
orderId
);
if
(
order
==
null
){
...
...
@@ -62,6 +64,10 @@ public class OrderUnpaidTask extends Task {
throw
new
RuntimeException
(
"商品货品库存增加失败"
);
}
}
//返还优惠券
wxOrderService
.
releaseCoupon
(
orderId
);
logger
.
info
(
"系统结束处理延时任务---订单超时未付款---"
+
this
.
orderId
);
}
}
Write
Preview
Supports
Markdown
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