Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
ms
soss
Commits
dbe80723
Commit
dbe80723
authored
Oct 22, 2022
by
caiyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复优惠券支付未同步机器问题
parent
d0b07205
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
44 deletions
+47
-44
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
+27
-5
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponController.java
+1
-1
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+2
-2
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+17
-36
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
View file @
dbe80723
...
@@ -8,15 +8,18 @@ import com.soss.common.core.domain.AjaxResult;
...
@@ -8,15 +8,18 @@ import com.soss.common.core.domain.AjaxResult;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.core.page.TableDataInfo
;
import
com.soss.common.core.page.TableDataInfo
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.common.enums.MachineState
;
import
com.soss.common.exception.ServiceException
;
import
com.soss.common.exception.ServiceException
;
import
com.soss.framework.web.service.TokenService
;
import
com.soss.framework.web.service.TokenService
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.system.constants.OrderStatusConstant
;
import
com.soss.system.constants.OrderStatusConstant
;
import
com.soss.system.domain.Machine
;
import
com.soss.system.domain.Order
;
import
com.soss.system.domain.Order
;
import
com.soss.system.domain.vo.CouponVo
;
import
com.soss.system.domain.vo.CouponVo
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.service.ICouponUserService
;
import
com.soss.system.service.ICouponUserService
;
import
com.soss.system.service.IGoodsService
;
import
com.soss.system.service.IGoodsService
;
import
com.soss.system.service.IMachineService
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -28,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -28,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -45,6 +49,8 @@ public class OrderController extends BaseController {
...
@@ -45,6 +49,8 @@ public class OrderController extends BaseController {
@Autowired
@Autowired
private
OrderServiceImpl
orderService
;
private
OrderServiceImpl
orderService
;
@Autowired
@Autowired
private
IMachineService
machineService
;
@Autowired
private
TokenService
tokenService
;
private
TokenService
tokenService
;
@Autowired
@Autowired
private
WeixinServiceImpl
weixinService
;
private
WeixinServiceImpl
weixinService
;
...
@@ -124,6 +130,22 @@ public class OrderController extends BaseController {
...
@@ -124,6 +130,22 @@ public class OrderController extends BaseController {
return
AjaxResult
.
error
(
e
.
getMessage
());
return
AjaxResult
.
error
(
e
.
getMessage
());
}
}
if
(
StringUtils
.
isEmpty
(
order
.
getMachineId
()))
{
Machine
machine
=
new
Machine
();
machine
.
setShopId
(
order
.
getShopId
());
List
<
Machine
>
machines
=
machineService
.
selectMachineList
(
machine
);
if
(
machines
!=
null
&&
!
machines
.
isEmpty
())
{
Machine
machine1
=
machines
.
get
(
0
);
if
(!
MachineState
.
RUNNING
.
getState
().
equals
(
machine1
.
getState
()))
{
return
AjaxResult
.
error
(
"机器暂时不可用"
);
}
String
machineId
=
machine1
.
getId
();
order
.
setMachineId
(
machineId
);
}
else
{
return
AjaxResult
.
error
(
"该店铺暂无绑定机器"
);
}
}
Integer
couponUserId
=
order
.
getCouponId
();
Integer
couponUserId
=
order
.
getCouponId
();
if
(
couponUserId
!=
null
)
{
if
(
couponUserId
!=
null
)
{
List
<
CouponVo
>
couponVos
=
couponUserService
.
listCustAvailableCoupon
(
loginUser
.
getOpenId
(),
couponUserId
);
List
<
CouponVo
>
couponVos
=
couponUserService
.
listCustAvailableCoupon
(
loginUser
.
getOpenId
(),
couponUserId
);
...
@@ -143,17 +165,17 @@ public class OrderController extends BaseController {
...
@@ -143,17 +165,17 @@ public class OrderController extends BaseController {
couponUserService
.
orderDetailCheckAndAssign
(
order
.
getOrderDetails
());
couponUserService
.
orderDetailCheckAndAssign
(
order
.
getOrderDetails
());
}
}
int
amount
=
order
.
getPaidAmount
().
movePointRight
(
2
).
intValue
();
if
(
amount
==
0
)
{
order
.
setPickCode
(
weixinService
.
generatePickCode
(
order
));
}
AjaxResult
ajaxResult
=
orderService
.
insertOrder
(
loginUser
,
order
,
couponUserId
);
AjaxResult
ajaxResult
=
orderService
.
insertOrder
(
loginUser
,
order
,
couponUserId
);
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
ajaxResult
.
get
(
AjaxResult
.
CODE_TAG
))
{
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
ajaxResult
.
get
(
AjaxResult
.
CODE_TAG
))
{
return
ajaxResult
;
return
ajaxResult
;
}
}
int
amount
=
order
.
getPaidAmount
().
movePointRight
(
2
).
intValue
();
if
(
amount
==
0
)
{
if
(
amount
==
0
)
{
order
.
setPickCode
(
weixinService
.
generatePickCode
(
order
));
order
.
setPayTime
(
new
Date
());
order
.
setState
(
OrderStatusConstant
.
Paid
);
orderService
.
updateOrder
(
order
);
return
AjaxResult
.
success
(
order
.
getId
());
return
AjaxResult
.
success
(
order
.
getId
());
}
}
...
...
soss-admin/src/main/java/com/soss/web/controller/coupon/CouponController.java
View file @
dbe80723
...
@@ -192,7 +192,7 @@ public class CouponController extends BaseController {
...
@@ -192,7 +192,7 @@ public class CouponController extends BaseController {
/**
/**
* 获取当前有效的规则集合
* 获取当前有效的规则集合
*/
*/
@PreAuthorize
(
"@ss.hasPermi('coupon:list:effective')"
)
//
@PreAuthorize("@ss.hasPermi('coupon:list:effective')")
@GetMapping
(
"/list/effective"
)
@GetMapping
(
"/list/effective"
)
@ApiOperation
(
"获取当前有效的规则集合"
)
@ApiOperation
(
"获取当前有效的规则集合"
)
public
TableDataInfo
listEffective
()
{
public
TableDataInfo
listEffective
()
{
...
...
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
dbe80723
...
@@ -416,10 +416,10 @@ public class WeixinServiceImpl {
...
@@ -416,10 +416,10 @@ public class WeixinServiceImpl {
//处理重复的通知
//处理重复的通知
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
//接口调用的幂等性:无论接口被调用多少次,产生的结果是一致的。
String
orderStatus
=
order
.
getState
();
String
orderStatus
=
order
.
getState
();
if
(
"1"
.
equals
(
orderStatus
))
{
if
(
OrderStatusConstant
.
Unpaid
.
equals
(
orderStatus
))
{
//更新订单状态
//更新订单状态
order
.
setPayTime
(
new
Date
());
order
.
setPayTime
(
new
Date
());
order
.
setState
(
"2"
);
order
.
setState
(
OrderStatusConstant
.
Paid
);
order
.
setPickCode
(
generatePickCode
(
order
));
order
.
setPickCode
(
generatePickCode
(
order
));
orderService
.
updateOrder
(
order
);
orderService
.
updateOrder
(
order
);
}
}
...
...
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
dbe80723
...
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.enums.CouponUserState
;
import
com.soss.common.enums.CouponUserState
;
import
com.soss.common.enums.MachineState
;
import
com.soss.common.exception.ServiceException
;
import
com.soss.common.exception.ServiceException
;
import
com.soss.common.utils.DateUtils
;
import
com.soss.common.utils.DateUtils
;
import
com.soss.common.utils.StringUtils
;
import
com.soss.common.utils.StringUtils
;
...
@@ -142,11 +141,7 @@ public class OrderServiceImpl implements IOrderService {
...
@@ -142,11 +141,7 @@ public class OrderServiceImpl implements IOrderService {
@Override
@Override
@Transactional
@Transactional
public
AjaxResult
insertOrder
(
LoginUser
loginUser
,
Order
order
,
Integer
couponUserId
)
{
public
AjaxResult
insertOrder
(
LoginUser
loginUser
,
Order
order
,
Integer
couponUserId
)
{
if
(
order
.
getPaidAmount
().
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
order
.
setState
(
OrderStatusConstant
.
Paid
);
}
else
{
order
.
setState
(
OrderStatusConstant
.
Unpaid
);
order
.
setState
(
OrderStatusConstant
.
Unpaid
);
}
order
.
setUserId
(
loginUser
.
getOpenId
());
order
.
setUserId
(
loginUser
.
getOpenId
());
order
.
setUserName
(
loginUser
.
getUsername
());
order
.
setUserName
(
loginUser
.
getUsername
());
order
.
setUserPhone
(
loginUser
.
getUser
().
getPhonenumber
());
order
.
setUserPhone
(
loginUser
.
getUser
().
getPhonenumber
());
...
@@ -154,32 +149,32 @@ public class OrderServiceImpl implements IOrderService {
...
@@ -154,32 +149,32 @@ public class OrderServiceImpl implements IOrderService {
order
.
setOrderNum
(
getOrderNum
(
order
.
getShopId
()));
order
.
setOrderNum
(
getOrderNum
(
order
.
getShopId
()));
order
.
setOrderNo
(
getOrderNo
(
order
.
getSource
()));
order
.
setOrderNo
(
getOrderNo
(
order
.
getSource
()));
order
.
setUpdatedAt
(
new
Date
());
order
.
setUpdatedAt
(
new
Date
());
String
machineId
=
null
;
orderMapper
.
insertOrder
(
order
);
if
(
StringUtils
.
isEmpty
(
order
.
getMachineId
()))
{
Machine
machine
=
new
Machine
();
this
.
orderDetailSplit
(
order
);
machine
.
setShopId
(
order
.
getShopId
());
orderDetailMapper
.
insertBatch
(
order
.
getOrderDetails
());
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
if
(
machines
!=
null
&&
!
machines
.
isEmpty
())
{
// 更新用户的优惠券状态
Machine
machine1
=
machines
.
get
(
0
);
if
(
couponUserId
!=
null
)
{
if
(!
MachineState
.
RUNNING
.
getState
().
equals
(
machine1
.
getState
()))
{
CouponUser
couponUser
=
new
CouponUser
(
couponUserId
,
order
.
getId
(),
order
.
getOrderNo
(),
CouponUserState
.
USED
.
getState
());
return
AjaxResult
.
error
(
"机器暂时不可用"
);
couponUserMapper
.
updateCouponUser
(
couponUser
);
}
machineId
=
machine1
.
getId
();
order
.
setMachineId
(
machineId
);
}
else
{
return
AjaxResult
.
error
(
"该店铺暂无绑定机器"
);
}
}
}
orderMapper
.
insertOrder
(
order
);
orderOperationLogService
.
insertOrderOperationLog
(
order
);
orderSnapshotService
.
saveOrderSnapshot
(
order
);
//发送数据给机器
machineApiService
.
createOrder
(
order
);
return
AjaxResult
.
success
(
order
.
getOrderNo
());
}
private
void
orderDetailSplit
(
Order
order
)
{
List
<
OrderDetail
>
orderDetails
=
order
.
getOrderDetails
();
List
<
OrderDetail
>
orderDetails
=
order
.
getOrderDetails
();
List
<
OrderDetail
>
detailsSave
=
new
LinkedList
<>();
List
<
OrderDetail
>
detailsSave
=
new
LinkedList
<>();
for
(
OrderDetail
orderDetail
:
orderDetails
)
{
for
(
OrderDetail
orderDetail
:
orderDetails
)
{
orderDetail
.
setOrderId
(
order
.
getId
());
orderDetail
.
setOrderId
(
order
.
getId
());
orderDetail
.
setCreatedAt
(
new
Date
());
orderDetail
.
setCreatedAt
(
new
Date
());
orderDetail
.
setUpdatedAt
(
new
Date
());
orderDetail
.
setUpdatedAt
(
new
Date
());
orderDetail
.
setMachineId
(
machineId
);
orderDetail
.
setMachineId
(
order
.
getMachineId
()
);
BigDecimal
amountShould
=
orderDetail
.
getAmountShould
();
BigDecimal
amountShould
=
orderDetail
.
getAmountShould
();
BigDecimal
couponAmount
=
orderDetail
.
getCouponAmount
();
BigDecimal
couponAmount
=
orderDetail
.
getCouponAmount
();
...
@@ -210,20 +205,6 @@ public class OrderServiceImpl implements IOrderService {
...
@@ -210,20 +205,6 @@ public class OrderServiceImpl implements IOrderService {
}
}
}
}
order
.
setOrderDetails
(
detailsSave
);
order
.
setOrderDetails
(
detailsSave
);
orderDetailMapper
.
insertBatch
(
detailsSave
);
// 更新用户的优惠券状态
if
(
couponUserId
!=
null
)
{
CouponUser
couponUser
=
new
CouponUser
(
couponUserId
,
order
.
getId
(),
order
.
getOrderNo
(),
CouponUserState
.
USED
.
getState
());
couponUserMapper
.
updateCouponUser
(
couponUser
);
}
// }
//发送数据给机器
machineApiService
.
createOrder
(
order
);
orderOperationLogService
.
insertOrderOperationLog
(
order
);
orderSnapshotService
.
saveOrderSnapshot
(
order
);
return
AjaxResult
.
success
(
order
.
getOrderNo
());
}
}
@Override
@Override
...
...
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