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
f45e0f2a
Commit
f45e0f2a
authored
Jul 11, 2022
by
weijiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下单时校验订单中sku数量
parent
ff201708
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
175 deletions
+170
-175
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
+32
-45
soss-framework/src/main/java/com/soss/framework/web/service/TokenService.java
+4
-0
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+134
-130
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
View file @
f45e0f2a
package
com
.
soss
.
web
.
controller
.
coffee
;
package
com
.
soss
.
web
.
controller
.
coffee
;
import
java.util.List
;
import
com.soss.common.annotation.Log
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
com.soss.common.constant.HttpStatus
;
import
com.soss.common.constant.HttpStatus
;
import
com.soss.common.core.controller.BaseController
;
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.enums.BusinessType
;
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.domain.Order
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.service.impl.CustomerServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.util.Map
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.soss.common.annotation.Log
;
import
com.soss.common.core.controller.BaseController
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.system.domain.Order
;
import
com.soss.system.service.IOrderService
;
import
com.soss.common.core.page.TableDataInfo
;
/**
/**
* 订单Controller
* 订单Controller
*
*
* @author zxq
* @author zxq
* @date 2022-04-28
* @date 2022-04-28
*/
*/
@RestController
@RestController
@RequestMapping
(
"/order"
)
@RequestMapping
(
"/order"
)
public
class
OrderController
extends
BaseController
public
class
OrderController
extends
BaseController
{
{
@Autowired
@Autowired
private
OrderServiceImpl
orderService
;
private
OrderServiceImpl
orderService
;
@Autowired
@Autowired
...
@@ -51,8 +42,7 @@ public class OrderController extends BaseController
...
@@ -51,8 +42,7 @@ public class OrderController extends BaseController
*/
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:list')"
)
@PreAuthorize
(
"@ss.hasPermi('system:order:list')"
)
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
OrderQuery
orderQuery
)
public
TableDataInfo
list
(
OrderQuery
orderQuery
)
{
{
startPage
();
startPage
();
List
<
Order
>
list
=
orderService
.
selectOrderList
(
orderQuery
);
List
<
Order
>
list
=
orderService
.
selectOrderList
(
orderQuery
);
return
getDataTable
(
list
);
return
getDataTable
(
list
);
...
@@ -63,15 +53,13 @@ public class OrderController extends BaseController
...
@@ -63,15 +53,13 @@ public class OrderController extends BaseController
* 获取订单详细信息
* 获取订单详细信息
*/
*/
@GetMapping
(
value
=
"/{id}"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
String
id
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
String
id
)
{
{
return
AjaxResult
.
success
(
orderService
.
selectOrderById
(
id
));
return
AjaxResult
.
success
(
orderService
.
selectOrderById
(
id
));
}
}
@PostMapping
(
"/check"
)
@PostMapping
(
"/check"
)
public
AjaxResult
check
(
@RequestBody
Order
order
)
public
AjaxResult
check
(
@RequestBody
Order
order
)
{
{
return
orderService
.
check
(
order
);
return
orderService
.
check
(
order
);
}
}
...
@@ -80,34 +68,34 @@ public class OrderController extends BaseController
...
@@ -80,34 +68,34 @@ public class OrderController extends BaseController
*/
*/
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
INSERT
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
@PostMapping
public
AjaxResult
add
(
HttpServletRequest
request
,
@RequestBody
Order
order
)
public
AjaxResult
add
(
HttpServletRequest
request
,
@RequestBody
Order
order
)
{
{
LoginUser
loginUser
=
tokenService
.
getLoginUser
(
request
);
LoginUser
loginUser
=
tokenService
.
getLoginUser
(
request
);
AjaxResult
ajaxResult
=
orderService
.
insertOrder
(
loginUser
,
order
);
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
ajaxResult
.
get
(
AjaxResult
.
CODE_TAG
)){
AjaxResult
ajaxResult
=
orderService
.
insertOrder
(
loginUser
,
order
);
return
ajaxResult
;
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
ajaxResult
.
get
(
AjaxResult
.
CODE_TAG
))
{
return
ajaxResult
;
}
}
int
amount
=
order
.
getAmount
().
movePointRight
(
2
).
intValue
();
int
amount
=
order
.
getAmount
().
movePointRight
(
2
).
intValue
();
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
if
(
payInfo
!=
null
)
{
if
(
payInfo
!=
null
)
{
payInfo
.
put
(
"orderId"
,
order
.
getId
());
payInfo
.
put
(
"orderId"
,
order
.
getId
());
return
AjaxResult
.
success
(
payInfo
);
return
AjaxResult
.
success
(
payInfo
);
}
else
{
}
else
{
throw
new
ServiceException
(
"微信支付发生异常"
);
throw
new
ServiceException
(
"微信支付发生异常"
);
}
}
}
}
@RequestMapping
(
"/payOrder"
)
@RequestMapping
(
"/payOrder"
)
public
AjaxResult
cancel
(
HttpServletRequest
request
,
String
orderId
)
public
AjaxResult
cancel
(
HttpServletRequest
request
,
String
orderId
)
{
{
Order
order
=
orderService
.
selectOrderById
(
orderId
);
Order
order
=
orderService
.
selectOrderById
(
orderId
);
order
.
setOrderNo
(
orderService
.
getOrderNo
(
order
.
getSource
()));
order
.
setOrderNo
(
orderService
.
getOrderNo
(
order
.
getSource
()));
orderService
.
updateOrder
(
order
);
orderService
.
updateOrder
(
order
);
int
amount
=
order
.
getAmount
().
movePointRight
(
2
).
intValue
();
int
amount
=
order
.
getAmount
().
movePointRight
(
2
).
intValue
();
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
if
(
payInfo
!=
null
)
{
if
(
payInfo
!=
null
)
{
return
AjaxResult
.
success
(
payInfo
);
return
AjaxResult
.
success
(
payInfo
);
}
else
{
}
else
{
throw
new
ServiceException
(
"微信支付发生异常"
);
throw
new
ServiceException
(
"微信支付发生异常"
);
}
}
}
}
...
@@ -119,13 +107,12 @@ public class OrderController extends BaseController
...
@@ -119,13 +107,12 @@ public class OrderController extends BaseController
@PreAuthorize
(
"@ss.hasPermi('system:order:edit')"
)
@PreAuthorize
(
"@ss.hasPermi('system:order:edit')"
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
UPDATE
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
@PutMapping
public
AjaxResult
edit
(
@RequestBody
Order
order
)
public
AjaxResult
edit
(
@RequestBody
Order
order
)
{
{
return
toAjax
(
orderService
.
updateOrder
(
order
));
return
toAjax
(
orderService
.
updateOrder
(
order
));
}
}
@RequestMapping
(
"/cancel"
)
@RequestMapping
(
"/cancel"
)
public
AjaxResult
cancel
(
String
orderId
)
public
AjaxResult
cancel
(
String
orderId
)
{
{
return
toAjax
(
orderService
.
cancel
(
orderId
));
return
toAjax
(
orderService
.
cancel
(
orderId
));
}
}
...
...
soss-framework/src/main/java/com/soss/framework/web/service/TokenService.java
View file @
f45e0f2a
...
@@ -4,6 +4,8 @@ import java.util.HashMap;
...
@@ -4,6 +4,8 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -26,6 +28,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
...
@@ -26,6 +28,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
* @author zxq
* @author zxq
*/
*/
@Component
@Component
@Slf4j
public
class
TokenService
public
class
TokenService
{
{
// 令牌自定义标识
// 令牌自定义标识
...
@@ -71,6 +74,7 @@ public class TokenService
...
@@ -71,6 +74,7 @@ public class TokenService
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
log
.
error
(
""
,
e
);
}
}
}
}
return
null
;
return
null
;
...
...
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
f45e0f2a
package
com
.
soss
.
system
.
service
.
impl
;
package
com
.
soss
.
system
.
service
.
impl
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.soss.common.constant.HttpStatus
;
import
com.soss.common.constant.HttpStatus
;
...
@@ -16,34 +10,36 @@ import com.soss.common.utils.StringUtils;
...
@@ -16,34 +10,36 @@ import com.soss.common.utils.StringUtils;
import
com.soss.common.utils.spring.SpringUtils
;
import
com.soss.common.utils.spring.SpringUtils
;
import
com.soss.system.constants.OrderStatusConstant
;
import
com.soss.system.constants.OrderStatusConstant
;
import
com.soss.system.domain.*
;
import
com.soss.system.domain.*
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.domain.vo.orderTaking.CategoryVo
;
import
com.soss.system.domain.vo.orderTaking.CategoryVo
;
import
com.soss.system.domain.vo.orderTaking.GoodsVo
;
import
com.soss.system.domain.vo.orderTaking.GoodsVo
;
import
com.soss.system.domain.vo.orderTaking.OrderTakingVo
;
import
com.soss.system.domain.vo.orderTaking.OrderTakingVo
;
import
com.soss.system.domain.vo.orderTaking.SkuVo
;
import
com.soss.system.domain.vo.orderTaking.SkuVo
;
import
com.soss.system.jiguang.impl.JiGuangPushServiceImpl
;
import
com.soss.system.jiguang.impl.JiGuangPushServiceImpl
;
import
com.soss.system.service.IOrderService
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.mapper.*
;
import
com.soss.system.mapper.*
;
import
com.soss.system.service.IOrderService
;
import
com.soss.system.utils.SendSmsUtil
;
import
com.soss.system.utils.SendSmsUtil
;
import
com.soss.system.weixin.util.SendMessageUtils
;
import
com.soss.system.weixin.util.SendMessageUtils
;
import
org.aspectj.weaver.ast.Or
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.support.atomic.RedisAtomicInteger
;
import
org.springframework.data.redis.support.atomic.RedisAtomicInteger
;
import
org.springframework.security.core.token.TokenService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
/**
* 订单Service业务层处理
* 订单Service业务层处理
*
*
* @author zxq
* @author zxq
* @date 2022-04-28
* @date 2022-04-28
*/
*/
@Service
@Service
public
class
OrderServiceImpl
implements
IOrderService
public
class
OrderServiceImpl
implements
IOrderService
{
{
@Autowired
@Autowired
private
OrderMapper
orderMapper
;
private
OrderMapper
orderMapper
;
@Autowired
@Autowired
...
@@ -72,19 +68,20 @@ public class OrderServiceImpl implements IOrderService
...
@@ -72,19 +68,20 @@ public class OrderServiceImpl implements IOrderService
private
OrderTakingServiceImpl
orderTakingService
;
private
OrderTakingServiceImpl
orderTakingService
;
@Autowired
@Autowired
private
CustomerMapper
customerMapper
;
private
CustomerMapper
customerMapper
;
@Autowired
private
SysConfigServiceImpl
sysConfigService
;
@Autowired
@Autowired
SendSmsUtil
sendSmsUtil
;
SendSmsUtil
sendSmsUtil
;
/**
/**
* 查询订单
* 查询订单
*
*
* @param id 订单主键
* @param id 订单主键
* @return 订单
* @return 订单
*/
*/
@Override
@Override
public
Order
selectOrderById
(
String
id
)
public
Order
selectOrderById
(
String
id
)
{
{
Order
order
=
orderMapper
.
selectOrderById
(
id
);
Order
order
=
orderMapper
.
selectOrderById
(
id
);
order
.
setShop
(
shopMapper
.
selectShopById
(
order
.
getShopId
()));
order
.
setShop
(
shopMapper
.
selectShopById
(
order
.
getShopId
()));
OrderSnapshot
orderSnapshot
=
orderSnapshotService
.
selectOrderSnapshotByOrderId
(
order
.
getId
());
OrderSnapshot
orderSnapshot
=
orderSnapshotService
.
selectOrderSnapshotByOrderId
(
order
.
getId
());
...
@@ -94,27 +91,26 @@ public class OrderServiceImpl implements IOrderService
...
@@ -94,27 +91,26 @@ public class OrderServiceImpl implements IOrderService
return
order
;
return
order
;
}
}
public
Order
selectById
(
String
id
){
public
Order
selectById
(
String
id
)
{
return
orderMapper
.
selectOrderById
(
id
);
return
orderMapper
.
selectOrderById
(
id
);
}
}
/**
/**
* 查询订单列表
* 查询订单列表
*
*
* @param order 订单
* @param order 订单
* @return 订单
* @return 订单
*/
*/
@Override
@Override
public
List
<
Order
>
selectOrderList
(
OrderQuery
order
)
public
List
<
Order
>
selectOrderList
(
OrderQuery
order
)
{
{
List
<
Order
>
orders
=
orderMapper
.
selectOrderByQuery
(
order
);
List
<
Order
>
orders
=
orderMapper
.
selectOrderByQuery
(
order
);
for
(
Order
order1
:
orders
)
{
for
(
Order
order1
:
orders
)
{
order1
.
setShop
(
shopMapper
.
selectShopById
(
order1
.
getShopId
()));
order1
.
setShop
(
shopMapper
.
selectShopById
(
order1
.
getShopId
()));
}
}
return
orders
;
return
orders
;
}
}
public
List
<
Order
>
selectOrderList
(
Order
order
)
{
public
List
<
Order
>
selectOrderList
(
Order
order
)
{
List
<
Order
>
orders
=
orderMapper
.
selectOrderList
(
order
);
List
<
Order
>
orders
=
orderMapper
.
selectOrderList
(
order
);
return
orders
;
return
orders
;
...
@@ -122,27 +118,24 @@ public class OrderServiceImpl implements IOrderService
...
@@ -122,27 +118,24 @@ public class OrderServiceImpl implements IOrderService
/**
/**
* 新增订单
* 新增订单
*
*
*
* @param loginUser
* @param loginUser
* @param order 订单
* @param order
订单
* @return 结果
* @return 结果
*/
*/
@Override
@Override
@Transactional
@Transactional
public
AjaxResult
insertOrder
(
LoginUser
loginUser
,
Order
order
)
public
AjaxResult
insertOrder
(
LoginUser
loginUser
,
Order
order
)
{
{
AjaxResult
result
=
check
(
order
);
AjaxResult
result
=
check
(
order
);
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
result
.
get
(
result
.
CODE_TAG
))
{
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
result
.
get
(
result
.
CODE_TAG
))
{
return
result
;
return
result
;
}
}
try
{
try
{
checkBusinessTime
(
order
.
getShopId
());
checkBusinessTime
(
order
.
getShopId
());
}
catch
(
ServiceException
e
)
{
}
catch
(
ServiceException
e
)
{
return
AjaxResult
.
error
(
e
.
getMessage
());
return
AjaxResult
.
error
(
e
.
getMessage
());
}
}
order
.
setState
(
OrderStatusConstant
.
Unpaid
);
order
.
setState
(
OrderStatusConstant
.
Unpaid
);
order
.
setUserId
(
loginUser
.
getOpenId
());
order
.
setUserId
(
loginUser
.
getOpenId
());
...
@@ -153,24 +146,24 @@ public class OrderServiceImpl implements IOrderService
...
@@ -153,24 +146,24 @@ public class OrderServiceImpl implements IOrderService
order
.
setOrderNo
(
getOrderNo
(
order
.
getSource
()));
order
.
setOrderNo
(
getOrderNo
(
order
.
getSource
()));
order
.
setUpdatedAt
(
new
Date
());
order
.
setUpdatedAt
(
new
Date
());
String
machineId
=
null
;
String
machineId
=
null
;
if
(
StringUtils
.
isEmpty
(
order
.
getMachineId
()))
{
if
(
StringUtils
.
isEmpty
(
order
.
getMachineId
()))
{
Machine
machine
=
new
Machine
();
Machine
machine
=
new
Machine
();
machine
.
setShopId
(
Long
.
parseLong
(
order
.
getShopId
()));
machine
.
setShopId
(
Long
.
parseLong
(
order
.
getShopId
()));
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
if
(
machines
!=
null
&&!
machines
.
isEmpty
())
{
if
(
machines
!=
null
&&
!
machines
.
isEmpty
())
{
Machine
machine1
=
machines
.
get
(
0
);
Machine
machine1
=
machines
.
get
(
0
);
if
(!
"1"
.
equals
(
machine1
.
getState
()))
{
if
(!
"1"
.
equals
(
machine1
.
getState
()))
{
return
AjaxResult
.
error
(
"机器暂时不可用"
);
return
AjaxResult
.
error
(
"机器暂时不可用"
);
}
}
machineId
=
machine1
.
getId
();
machineId
=
machine1
.
getId
();
order
.
setMachineId
(
machineId
);
order
.
setMachineId
(
machineId
);
}
else
{
}
else
{
return
AjaxResult
.
error
(
"该店铺暂无绑定机器"
);
return
AjaxResult
.
error
(
"该店铺暂无绑定机器"
);
}
}
}
}
List
<
OrderDetail
>
orderDetails
=
order
.
getOrderDetails
();
List
<
OrderDetail
>
orderDetails
=
order
.
getOrderDetails
();
if
(
orderDetails
!=
null
&&
!
orderDetails
.
isEmpty
())
{
if
(
orderDetails
!=
null
&&
!
orderDetails
.
isEmpty
())
{
// BigDecimal bigDecimal = new BigDecimal(0);
// BigDecimal bigDecimal = new BigDecimal(0);
// for (OrderDetail orderDetail : orderDetails) {
// for (OrderDetail orderDetail : orderDetails) {
// bigDecimal = bigDecimal.add(orderDetail.getRealAmount().multiply( new BigDecimal(orderDetail.getNum())));
// bigDecimal = bigDecimal.add(orderDetail.getRealAmount().multiply( new BigDecimal(orderDetail.getNum())));
...
@@ -179,7 +172,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -179,7 +172,7 @@ public class OrderServiceImpl implements IOrderService
// throw new ServiceException("价格计算出现了问题,请重新计算"+ bigDecimal.stripTrailingZeros().toString() );
// throw new ServiceException("价格计算出现了问题,请重新计算"+ bigDecimal.stripTrailingZeros().toString() );
// }
// }
// order.setAmount(bigDecimal);
// order.setAmount(bigDecimal);
int
i
=
orderMapper
.
insertOrder
(
order
);
int
i
=
orderMapper
.
insertOrder
(
order
);
for
(
OrderDetail
orderDetail
:
orderDetails
)
{
for
(
OrderDetail
orderDetail
:
orderDetails
)
{
orderDetail
.
setOrderId
(
order
.
getId
());
orderDetail
.
setOrderId
(
order
.
getId
());
orderDetail
.
setCreatedAt
(
new
Date
());
orderDetail
.
setCreatedAt
(
new
Date
());
...
@@ -204,13 +197,13 @@ public class OrderServiceImpl implements IOrderService
...
@@ -204,13 +197,13 @@ public class OrderServiceImpl implements IOrderService
String
[]
split
=
startTime
.
split
(
":"
);
String
[]
split
=
startTime
.
split
(
":"
);
String
[]
split1
=
endTime
.
split
(
":"
);
String
[]
split1
=
endTime
.
split
(
":"
);
Calendar
startBusiness
=
Calendar
.
getInstance
();
Calendar
startBusiness
=
Calendar
.
getInstance
();
startBusiness
.
set
(
Calendar
.
HOUR_OF_DAY
,
Integer
.
parseInt
(
split
[
0
]));
startBusiness
.
set
(
Calendar
.
HOUR_OF_DAY
,
Integer
.
parseInt
(
split
[
0
]));
startBusiness
.
set
(
Calendar
.
MINUTE
,
Integer
.
parseInt
(
split
[
1
]));
startBusiness
.
set
(
Calendar
.
MINUTE
,
Integer
.
parseInt
(
split
[
1
]));
Calendar
endBusiness
=
Calendar
.
getInstance
();
Calendar
endBusiness
=
Calendar
.
getInstance
();
endBusiness
.
set
(
Calendar
.
HOUR_OF_DAY
,
Integer
.
parseInt
(
split1
[
0
]));
endBusiness
.
set
(
Calendar
.
HOUR_OF_DAY
,
Integer
.
parseInt
(
split1
[
0
]));
endBusiness
.
set
(
Calendar
.
MINUTE
,
Integer
.
parseInt
(
split1
[
1
]));
endBusiness
.
set
(
Calendar
.
MINUTE
,
Integer
.
parseInt
(
split1
[
1
]));
long
l
=
System
.
currentTimeMillis
();
long
l
=
System
.
currentTimeMillis
();
if
(
startBusiness
.
getTimeInMillis
()>
l
||
endBusiness
.
getTimeInMillis
()<
l
)
{
if
(
startBusiness
.
getTimeInMillis
()
>
l
||
endBusiness
.
getTimeInMillis
()
<
l
)
{
throw
new
ServiceException
(
"当前时间本店休息中,暂停点单~"
);
throw
new
ServiceException
(
"当前时间本店休息中,暂停点单~"
);
}
}
...
@@ -218,13 +211,12 @@ public class OrderServiceImpl implements IOrderService
...
@@ -218,13 +211,12 @@ public class OrderServiceImpl implements IOrderService
}
}
/**
/**
*订单重写从这里开始,这里要承担大部分的业务逻辑,逻辑集中化处理
*
订单重写从这里开始,这里要承担大部分的业务逻辑,逻辑集中化处理
*/
*/
@Override
@Override
public
int
updateOrder
(
Order
order
)
public
int
updateOrder
(
Order
order
)
{
{
String
state
=
order
.
getState
();
String
state
=
order
.
getState
();
switch
(
state
){
switch
(
state
)
{
case
OrderStatusConstant
.
Paid
:
case
OrderStatusConstant
.
Paid
:
paidState
(
order
);
paidState
(
order
);
break
;
break
;
...
@@ -266,6 +258,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -266,6 +258,7 @@ public class OrderServiceImpl implements IOrderService
/**
/**
* 部分退款
* 部分退款
*
* @param order
* @param order
*/
*/
private
void
partialRefundState
(
Order
order
)
{
private
void
partialRefundState
(
Order
order
)
{
...
@@ -277,6 +270,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -277,6 +270,7 @@ public class OrderServiceImpl implements IOrderService
* 制作完成 机器给我们
* 制作完成 机器给我们
* 记录日志
* 记录日志
* 极光推送
* 极光推送
*
* @param order
* @param order
*/
*/
private
void
completedState
(
Order
order
)
{
private
void
completedState
(
Order
order
)
{
...
@@ -292,6 +286,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -292,6 +286,7 @@ public class OrderServiceImpl implements IOrderService
* 退款中
* 退款中
* 极光推送
* 极光推送
* 推送给机器
* 推送给机器
*
* @param order
* @param order
*/
*/
private
void
refundingState
(
Order
order
)
{
private
void
refundingState
(
Order
order
)
{
...
@@ -304,6 +299,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -304,6 +299,7 @@ public class OrderServiceImpl implements IOrderService
* 记录日志
* 记录日志
* 发送给机器
* 发送给机器
* 极光推送
* 极光推送
*
* @param order
* @param order
*/
*/
private
void
unpaidCancelState
(
Order
order
)
{
private
void
unpaidCancelState
(
Order
order
)
{
...
@@ -316,6 +312,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -316,6 +312,7 @@ public class OrderServiceImpl implements IOrderService
/**
/**
* 取餐中
* 取餐中
* 极光推送
* 极光推送
*
* @param order
* @param order
*/
*/
private
void
takingState
(
Order
order
)
{
private
void
takingState
(
Order
order
)
{
...
@@ -329,16 +326,17 @@ public class OrderServiceImpl implements IOrderService
...
@@ -329,16 +326,17 @@ public class OrderServiceImpl implements IOrderService
* 极光推送
* 极光推送
* 消息记录
* 消息记录
* 发送推送消息
* 发送推送消息
*
* @param order
* @param order
*/
*/
private
void
productionCompletedState
(
Order
order
)
{
private
void
productionCompletedState
(
Order
order
)
{
orderOperationLogService
.
insertOrderOperationLog
(
order
);
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"制作完成,您的订单已经制作完成,现在可以去取餐啦!"
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"制作完成,您的订单已经制作完成,现在可以去取餐啦!"
);
sendMessageUtils
.
sendWxMsg
(
order
);
sendMessageUtils
.
sendWxMsg
(
order
);
Customer
customer
=
customerMapper
.
selectCustomerById
(
order
.
getUserId
());
Customer
customer
=
customerMapper
.
selectCustomerById
(
order
.
getUserId
());
if
(!
"1"
.
equals
(
customer
.
getAllow
()))
{
if
(!
"1"
.
equals
(
customer
.
getAllow
()))
{
sendSmsUtil
.
sendSms
(
order
.
getUserPhone
(),
"SMS_243650242"
,
null
);
sendSmsUtil
.
sendSms
(
order
.
getUserPhone
(),
"SMS_243650242"
,
null
);
}
}
}
}
...
@@ -349,12 +347,13 @@ public class OrderServiceImpl implements IOrderService
...
@@ -349,12 +347,13 @@ public class OrderServiceImpl implements IOrderService
* 发送消息给安卓
* 发送消息给安卓
* 消息记录
* 消息记录
* 发送推送消息
* 发送推送消息
*
* @param order
* @param order
*/
*/
private
void
productionState
(
Order
order
)
{
private
void
productionState
(
Order
order
)
{
orderOperationLogService
.
insertOrderOperationLog
(
order
);
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"制作提醒,您的订单已经开始制作,马上就能享受美味了!"
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"制作提醒,您的订单已经开始制作,马上就能享受美味了!"
);
sendMessageUtils
.
sendWxMsg
(
order
);
sendMessageUtils
.
sendWxMsg
(
order
);
}
}
...
@@ -366,6 +365,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -366,6 +365,7 @@ public class OrderServiceImpl implements IOrderService
* 发送给安卓
* 发送给安卓
* 消息记录
* 消息记录
* 发送推送消息
* 发送推送消息
*
* @param order
* @param order
*/
*/
private
void
paidState
(
Order
order
)
{
private
void
paidState
(
Order
order
)
{
...
@@ -373,31 +373,29 @@ public class OrderServiceImpl implements IOrderService
...
@@ -373,31 +373,29 @@ public class OrderServiceImpl implements IOrderService
machineApiService
.
updateOrder
(
order
);
machineApiService
.
updateOrder
(
order
);
//极光推送
//极光推送
jiGuangPushService
.
pushOrderState
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"下单成功,您已经下单成功了~"
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"下单成功,您已经下单成功了~"
);
sendMessageUtils
.
sendWxMsg
(
order
);
sendMessageUtils
.
sendWxMsg
(
order
);
}
}
/**
/**
* 批量删除订单
* 批量删除订单
*
*
* @param ids 需要删除的订单主键
* @param ids 需要删除的订单主键
* @return 结果
* @return 结果
*/
*/
@Override
@Override
public
int
deleteOrderByIds
(
String
[]
ids
)
public
int
deleteOrderByIds
(
String
[]
ids
)
{
{
return
orderMapper
.
deleteOrderByIds
(
ids
);
return
orderMapper
.
deleteOrderByIds
(
ids
);
}
}
/**
/**
* 删除订单信息
* 删除订单信息
*
*
* @param id 订单主键
* @param id 订单主键
* @return 结果
* @return 结果
*/
*/
@Override
@Override
public
int
deleteOrderById
(
String
id
)
public
int
deleteOrderById
(
String
id
)
{
{
return
orderMapper
.
deleteOrderById
(
id
);
return
orderMapper
.
deleteOrderById
(
id
);
}
}
...
@@ -405,22 +403,28 @@ public class OrderServiceImpl implements IOrderService
...
@@ -405,22 +403,28 @@ public class OrderServiceImpl implements IOrderService
public
AjaxResult
check
(
Order
order
)
{
public
AjaxResult
check
(
Order
order
)
{
//验证订单状态
//验证订单状态
List
<
OrderDetail
>
orderDetails
=
order
.
getOrderDetails
();
List
<
OrderDetail
>
orderDetails
=
order
.
getOrderDetails
();
if
(
orderDetails
==
null
||
orderDetails
.
isEmpty
())
{
if
(
orderDetails
==
null
||
orderDetails
.
isEmpty
())
{
return
AjaxResult
.
error
(
"订单信息不能为空"
);
return
AjaxResult
.
error
(
"订单信息不能为空"
);
}
}
String
orderLimit
=
sysConfigService
.
selectConfigByKey
(
"goods.limit"
);
int
countOfOrder
=
StringUtils
.
isEmpty
(
orderLimit
)
?
9
:
Integer
.
parseInt
(
orderLimit
);
if
(
orderDetails
.
size
()
>
countOfOrder
)
{
return
AjaxResult
.
error
(
String
.
format
(
"单次最多购买%s杯,请结算后再次下单"
,
countOfOrder
));
}
for
(
OrderDetail
orderDetail
:
orderDetails
)
{
for
(
OrderDetail
orderDetail
:
orderDetails
)
{
ShopGoodsSku
shopGoodsSku
=
new
ShopGoodsSku
();
ShopGoodsSku
shopGoodsSku
=
new
ShopGoodsSku
();
shopGoodsSku
.
setSkuId
(
Long
.
parseLong
(
orderDetail
.
getSkuId
()));
shopGoodsSku
.
setSkuId
(
Long
.
parseLong
(
orderDetail
.
getSkuId
()));
shopGoodsSku
.
setShopId
(
Long
.
valueOf
(
order
.
getShopId
()));
shopGoodsSku
.
setShopId
(
Long
.
valueOf
(
order
.
getShopId
()));
shopGoodsSku
.
setIsDeleted
(
"0"
);
shopGoodsSku
.
setIsDeleted
(
"0"
);
List
<
ShopGoodsSku
>
shopGoodsSkus
=
shopGoodsSkuMapper
.
selectShopGoodsSkuList
(
shopGoodsSku
);
List
<
ShopGoodsSku
>
shopGoodsSkus
=
shopGoodsSkuMapper
.
selectShopGoodsSkuList
(
shopGoodsSku
);
if
(
shopGoodsSkus
==
null
||
shopGoodsSkus
.
isEmpty
())
{
if
(
shopGoodsSkus
==
null
||
shopGoodsSkus
.
isEmpty
())
{
return
AjaxResult
.
error
(
"
该商品已不存在:"
+
orderDetail
.
getGoodsName
());
return
AjaxResult
.
error
(
"
本商品已不存在:"
+
orderDetail
.
getGoodsName
());
}
}
ShopGoodsSku
shopGoodsSku1
=
shopGoodsSkus
.
get
(
0
);
ShopGoodsSku
shopGoodsSku1
=
shopGoodsSkus
.
get
(
0
);
if
(!
"1"
.
equals
(
shopGoodsSku1
.
getState
()))
{
if
(!
"1"
.
equals
(
shopGoodsSku1
.
getState
()))
{
return
AjaxResult
.
error
(
"
该商品所选种类已经告罄,请重新进行选择:"
+
orderDetail
.
getGoodsName
());
return
AjaxResult
.
error
(
"
本商品已售罄或已经下架:"
+
orderDetail
.
getGoodsName
());
}
}
}
}
return
AjaxResult
.
success
();
return
AjaxResult
.
success
();
...
@@ -433,7 +437,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -433,7 +437,7 @@ public class OrderServiceImpl implements IOrderService
for
(
Order
order
:
orders
)
{
for
(
Order
order
:
orders
)
{
order
.
setShop
(
shopMapper
.
selectShopById
(
order
.
getShopId
()));
order
.
setShop
(
shopMapper
.
selectShopById
(
order
.
getShopId
()));
OrderSnapshot
orderSnapshot
=
orderSnapshotService
.
selectOrderSnapshotByOrderId
(
order
.
getId
());
OrderSnapshot
orderSnapshot
=
orderSnapshotService
.
selectOrderSnapshotByOrderId
(
order
.
getId
());
order
.
setOrderDetails
(
JSONArray
.
parseArray
(
orderSnapshot
.
getSnapshot
(),
OrderDetail
.
class
));
order
.
setOrderDetails
(
JSONArray
.
parseArray
(
orderSnapshot
.
getSnapshot
(),
OrderDetail
.
class
));
}
}
return
orders
;
return
orders
;
}
}
...
@@ -442,16 +446,16 @@ public class OrderServiceImpl implements IOrderService
...
@@ -442,16 +446,16 @@ public class OrderServiceImpl implements IOrderService
@Transactional
@Transactional
public
int
cancel
(
String
orderId
)
{
public
int
cancel
(
String
orderId
)
{
Order
order
=
orderMapper
.
selectOrderById
(
orderId
);
Order
order
=
orderMapper
.
selectOrderById
(
orderId
);
if
(
OrderStatusConstant
.
Unpaid
.
equals
(
order
.
getState
()))
{
if
(
OrderStatusConstant
.
Unpaid
.
equals
(
order
.
getState
()))
{
order
.
setState
(
"8"
);
order
.
setState
(
"8"
);
order
.
setUpdatedAt
(
new
Date
());
order
.
setUpdatedAt
(
new
Date
());
this
.
updateOrder
(
order
);
this
.
updateOrder
(
order
);
}
else
if
(
OrderStatusConstant
.
Paid
.
equals
(
order
.
getState
()))
{
}
else
if
(
OrderStatusConstant
.
Paid
.
equals
(
order
.
getState
()))
{
order
.
setState
(
"9"
);
order
.
setState
(
"9"
);
order
.
setUpdatedAt
(
new
Date
());
order
.
setUpdatedAt
(
new
Date
());
this
.
updateOrder
(
order
);
this
.
updateOrder
(
order
);
}
else
{
}
else
{
throw
new
ServiceException
(
"该订单不允许取消"
);
throw
new
ServiceException
(
"该订单不允许取消"
);
}
}
...
@@ -459,70 +463,71 @@ public class OrderServiceImpl implements IOrderService
...
@@ -459,70 +463,71 @@ public class OrderServiceImpl implements IOrderService
}
}
/**
/**
* 获取机器顺序号
* 获取机器顺序号
*
* @param shopId
* @param shopId
* @return
* @return
*/
*/
private
String
getOrderNum
(
String
shopId
){
private
String
getOrderNum
(
String
shopId
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
String
key
=
calendar
.
getTime
().
toString
().
substring
(
0
,
3
);
String
key
=
calendar
.
getTime
().
toString
().
substring
(
0
,
3
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
format
=
simpleDateFormat
.
format
(
new
Date
());
String
format
=
simpleDateFormat
.
format
(
new
Date
());
String
redisKey
=
"shopId"
+
format
+
shopId
;
String
redisKey
=
"shopId"
+
format
+
shopId
;
RedisAtomicInteger
redisAtomicInteger
=
new
RedisAtomicInteger
(
redisKey
,
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
).
getConnectionFactory
());
RedisAtomicInteger
redisAtomicInteger
=
new
RedisAtomicInteger
(
redisKey
,
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
).
getConnectionFactory
());
if
(
0
==
redisAtomicInteger
.
get
())
{
if
(
0
==
redisAtomicInteger
.
get
())
{
redisAtomicInteger
.
set
((
int
)
(
1000
*
Math
.
random
()));
redisAtomicInteger
.
set
((
int
)
(
1000
*
Math
.
random
()));
}
}
redisAtomicInteger
.
expire
(
1
,
TimeUnit
.
DAYS
);
redisAtomicInteger
.
expire
(
1
,
TimeUnit
.
DAYS
);
int
andIncrement
=
redisAtomicInteger
.
getAndAdd
(
3
);
int
andIncrement
=
redisAtomicInteger
.
getAndAdd
(
3
);
return
key
+
String
.
format
(
"%03d"
,
andIncrement
);
return
key
+
String
.
format
(
"%03d"
,
andIncrement
);
}
}
//获取订单号
//获取订单号
public
String
getOrderNo
(
Integer
source
){
public
String
getOrderNo
(
Integer
source
)
{
String
channel
=
"M"
;
String
channel
=
"M"
;
if
(
source
!=
null
)
{
if
(
source
!=
null
)
{
if
(
source
==
1
)
{
if
(
source
==
1
)
{
channel
=
"A"
;
channel
=
"A"
;
}
else
if
(
source
==
2
)
{
}
else
if
(
source
==
2
)
{
channel
=
"B"
;
channel
=
"B"
;
}
}
}
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
String
format
=
simpleDateFormat
.
format
(
new
Date
());
String
format
=
simpleDateFormat
.
format
(
new
Date
());
format
=
format
.
substring
(
2
);
format
=
format
.
substring
(
2
);
String
key
=
"orderNo"
;
String
key
=
"orderNo"
;
RedisAtomicInteger
redisAtomicInteger
=
new
RedisAtomicInteger
(
key
,
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
).
getConnectionFactory
());
RedisAtomicInteger
redisAtomicInteger
=
new
RedisAtomicInteger
(
key
,
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
).
getConnectionFactory
());
int
andIncrement
=
redisAtomicInteger
.
getAndIncrement
();
int
andIncrement
=
redisAtomicInteger
.
getAndIncrement
();
if
(
andIncrement
>
9999
)
{
if
(
andIncrement
>
9999
)
{
redisAtomicInteger
.
set
(
0
);
redisAtomicInteger
.
set
(
0
);
andIncrement
=
0
;
andIncrement
=
0
;
}
}
String
format1
=
String
.
format
(
"%04d"
,
andIncrement
);
String
format1
=
String
.
format
(
"%04d"
,
andIncrement
);
int
randomNumber
=
new
Random
().
nextInt
(
99
);
int
randomNumber
=
new
Random
().
nextInt
(
99
);
return
"N"
+
format
+
channel
+
format1
+
randomNumber
;
return
"N"
+
format
+
channel
+
format1
+
randomNumber
;
}
}
public
List
<
JSONObject
>
getOrderInfo
(
String
machineCode
)
{
public
List
<
JSONObject
>
getOrderInfo
(
String
machineCode
)
{
Machine
machine
=
machineMapper
.
selectMachineByCode
(
machineCode
);
Machine
machine
=
machineMapper
.
selectMachineByCode
(
machineCode
);
List
<
String
>
status
=
Arrays
.
asList
(
"2"
,
"3"
,
"4"
);
List
<
String
>
status
=
Arrays
.
asList
(
"2"
,
"3"
,
"4"
);
List
<
Order
>
orders
=
orderMapper
.
selectOrder
(
status
,
machine
.
getId
());
List
<
Order
>
orders
=
orderMapper
.
selectOrder
(
status
,
machine
.
getId
());
Map
<
String
,
List
<
Order
>>
collect
=
orders
.
stream
().
collect
(
Collectors
.
groupingBy
(
Order:
:
getState
));
Map
<
String
,
List
<
Order
>>
collect
=
orders
.
stream
().
collect
(
Collectors
.
groupingBy
(
Order:
:
getState
));
List
<
JSONObject
>
objects
=
new
ArrayList
<>();
List
<
JSONObject
>
objects
=
new
ArrayList
<>();
for
(
String
key:
collect
.
keySet
())
{
for
(
String
key
:
collect
.
keySet
())
{
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
objects
.
add
(
jsonObject
);
objects
.
add
(
jsonObject
);
jsonObject
.
put
(
"state"
,
key
);
jsonObject
.
put
(
"state"
,
key
);
List
<
Order
>
orders1
=
collect
.
get
(
key
);
List
<
Order
>
orders1
=
collect
.
get
(
key
);
List
<
JSONObject
>
jsonObjects
=
new
ArrayList
<>();
List
<
JSONObject
>
jsonObjects
=
new
ArrayList
<>();
jsonObject
.
put
(
"orders"
,
jsonObjects
);
jsonObject
.
put
(
"orders"
,
jsonObjects
);
for
(
Order
order
:
orders1
)
{
for
(
Order
order
:
orders1
)
{
JSONObject
jsonObject1
=
new
JSONObject
();
JSONObject
jsonObject1
=
new
JSONObject
();
jsonObjects
.
add
(
jsonObject1
);
jsonObjects
.
add
(
jsonObject1
);
jsonObject1
.
put
(
"orderId"
,
order
.
getId
());
jsonObject1
.
put
(
"orderId"
,
order
.
getId
());
jsonObject1
.
put
(
"orderNumber"
,
order
.
getOrderNum
());
jsonObject1
.
put
(
"orderNumber"
,
order
.
getOrderNum
());
jsonObject1
.
put
(
"orderNo"
,
order
.
getOrderNo
());
jsonObject1
.
put
(
"orderNo"
,
order
.
getOrderNo
());
}
}
}
}
return
objects
;
return
objects
;
...
@@ -532,20 +537,20 @@ public class OrderServiceImpl implements IOrderService
...
@@ -532,20 +537,20 @@ public class OrderServiceImpl implements IOrderService
public
String
refundOrder
(
String
orderId
)
{
public
String
refundOrder
(
String
orderId
)
{
Order
order
=
orderMapper
.
selectOrderById
(
orderId
);
Order
order
=
orderMapper
.
selectOrderById
(
orderId
);
List
<
String
>
status
=
Arrays
.
asList
(
"2"
,
"3"
);
List
<
String
>
status
=
Arrays
.
asList
(
"2"
,
"3"
);
if
(
status
.
contains
(
order
.
getState
()))
{
if
(
status
.
contains
(
order
.
getState
()))
{
//todo 创建退款单,进行退款
//todo 创建退款单,进行退款
}
else
{
}
else
{
//todo 创建退款单
//todo 创建退款单
}
}
return
null
;
return
null
;
}
}
public
Map
<
String
,
String
>
getMyFristOrder
(
String
openId
,
String
shopId
)
{
public
Map
<
String
,
String
>
getMyFristOrder
(
String
openId
,
String
shopId
)
{
List
<
String
>
status
=
Arrays
.
asList
(
"2"
,
"3"
,
"4"
);
List
<
String
>
status
=
Arrays
.
asList
(
"2"
,
"3"
,
"4"
);
Order
order
=
orderMapper
.
selectHomeByUserId
(
openId
,
status
,
shopId
);
Order
order
=
orderMapper
.
selectHomeByUserId
(
openId
,
status
,
shopId
);
if
(
order
==
null
)
{
if
(
order
==
null
)
{
return
null
;
return
null
;
}
}
OrderDetail
orderDetail
=
new
OrderDetail
();
OrderDetail
orderDetail
=
new
OrderDetail
();
...
@@ -553,18 +558,18 @@ public class OrderServiceImpl implements IOrderService
...
@@ -553,18 +558,18 @@ public class OrderServiceImpl implements IOrderService
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
order
.
setOrderDetails
(
orderDetails
);
order
.
setOrderDetails
(
orderDetails
);
String
waitTime
=
getWaitTimeByOrderId
(
order
.
getId
());
String
waitTime
=
getWaitTimeByOrderId
(
order
.
getId
());
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"waitTime"
,
waitTime
);
map
.
put
(
"waitTime"
,
waitTime
);
map
.
put
(
"pickCode"
,
order
.
getPickCode
());
map
.
put
(
"pickCode"
,
order
.
getPickCode
());
map
.
put
(
"orderNum"
,
order
.
getOrderNum
());
map
.
put
(
"orderNum"
,
order
.
getOrderNum
());
map
.
put
(
"state"
,
order
.
getState
());
map
.
put
(
"state"
,
order
.
getState
());
return
map
;
return
map
;
}
}
public
String
getWaitTime
(
Order
order
)
{
public
String
getWaitTime
(
Order
order
)
{
String
shopId
=
order
.
getShopId
();
String
shopId
=
order
.
getShopId
();
List
<
String
>
status
=
Arrays
.
asList
(
OrderStatusConstant
.
Paid
,
OrderStatusConstant
.
production
);
List
<
String
>
status
=
Arrays
.
asList
(
OrderStatusConstant
.
Paid
,
OrderStatusConstant
.
production
);
List
<
Order
>
orders
=
orderMapper
.
selectOrderByShopId
(
status
,
shopId
);
List
<
Order
>
orders
=
orderMapper
.
selectOrderByShopId
(
status
,
shopId
);
List
<
OrderDetail
>
list
=
new
ArrayList
<>();
List
<
OrderDetail
>
list
=
new
ArrayList
<>();
list
.
addAll
(
order
.
getOrderDetails
());
list
.
addAll
(
order
.
getOrderDetails
());
...
@@ -572,57 +577,57 @@ public class OrderServiceImpl implements IOrderService
...
@@ -572,57 +577,57 @@ public class OrderServiceImpl implements IOrderService
OrderDetail
orderDetail
=
new
OrderDetail
();
OrderDetail
orderDetail
=
new
OrderDetail
();
orderDetail
.
setOrderId
(
order1
.
getId
());
orderDetail
.
setOrderId
(
order1
.
getId
());
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
if
(
CollectionUtils
.
isEmpty
(
orderDetails
))
{
if
(
CollectionUtils
.
isEmpty
(
orderDetails
))
{
}
else
{
}
else
{
list
.
addAll
(
orderDetails
);
list
.
addAll
(
orderDetails
);
}
}
}
}
Long
takeTimeCount
=
0L
;
Long
takeTimeCount
=
0L
;
for
(
OrderDetail
orderDetail
:
list
)
{
for
(
OrderDetail
orderDetail
:
list
)
{
Goods
goods
=
goodsMapper
.
selectGoodsById
(
orderDetail
.
getGoodsId
());
Goods
goods
=
goodsMapper
.
selectGoodsById
(
orderDetail
.
getGoodsId
());
if
(
goods
==
null
)
{
if
(
goods
==
null
)
{
continue
;
continue
;
}
}
Long
takeTime
=
goods
.
getTakeTime
();
Long
takeTime
=
goods
.
getTakeTime
();
takeTime
=
Integer
.
parseInt
(
orderDetail
.
getNum
())
*
takeTime
;
takeTime
=
Integer
.
parseInt
(
orderDetail
.
getNum
())
*
takeTime
;
takeTimeCount
+=
takeTime
;
takeTimeCount
+=
takeTime
;
}
}
return
String
.
valueOf
((
int
)(
takeTimeCount
/
60
));
return
String
.
valueOf
((
int
)
(
takeTimeCount
/
60
));
}
}
public
String
getWaitTimeByOrderId
(
Long
orderId
)
{
public
String
getWaitTimeByOrderId
(
Long
orderId
)
{
List
<
String
>
status
=
Arrays
.
asList
(
OrderStatusConstant
.
Paid
,
OrderStatusConstant
.
production
);
List
<
String
>
status
=
Arrays
.
asList
(
OrderStatusConstant
.
Paid
,
OrderStatusConstant
.
production
);
List
<
Order
>
orders
=
orderMapper
.
selectBeforeOrder
(
status
,
orderId
);
List
<
Order
>
orders
=
orderMapper
.
selectBeforeOrder
(
status
,
orderId
);
List
<
OrderDetail
>
list
=
new
ArrayList
<>();
List
<
OrderDetail
>
list
=
new
ArrayList
<>();
for
(
Order
order1
:
orders
)
{
for
(
Order
order1
:
orders
)
{
OrderDetail
orderDetail
=
new
OrderDetail
();
OrderDetail
orderDetail
=
new
OrderDetail
();
orderDetail
.
setOrderId
(
order1
.
getId
());
orderDetail
.
setOrderId
(
order1
.
getId
());
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
if
(
CollectionUtils
.
isEmpty
(
orderDetails
))
{
if
(
CollectionUtils
.
isEmpty
(
orderDetails
))
{
}
else
{
}
else
{
list
.
addAll
(
orderDetails
);
list
.
addAll
(
orderDetails
);
}
}
}
}
Long
takeTimeCount
=
0L
;
Long
takeTimeCount
=
0L
;
for
(
OrderDetail
orderDetail
:
list
)
{
for
(
OrderDetail
orderDetail
:
list
)
{
Goods
goods
=
goodsMapper
.
selectGoodsById
(
orderDetail
.
getGoodsId
());
Goods
goods
=
goodsMapper
.
selectGoodsById
(
orderDetail
.
getGoodsId
());
if
(
goods
!=
null
)
{
if
(
goods
!=
null
)
{
Long
takeTime
=
goods
.
getTakeTime
();
Long
takeTime
=
goods
.
getTakeTime
();
takeTime
=
Integer
.
parseInt
(
orderDetail
.
getNum
())
*
takeTime
;
takeTime
=
Integer
.
parseInt
(
orderDetail
.
getNum
())
*
takeTime
;
takeTimeCount
+=
takeTime
;
takeTimeCount
+=
takeTime
;
}
}
}
}
return
String
.
valueOf
((
int
)(
takeTimeCount
/
60
));
return
String
.
valueOf
((
int
)
(
takeTimeCount
/
60
));
}
}
public
List
<
GoodsVo
>
getNextOrder
(
String
orderId
,
String
shopId
)
{
public
List
<
GoodsVo
>
getNextOrder
(
String
orderId
,
String
shopId
)
{
OrderDetail
orderDetail
=
new
OrderDetail
();
OrderDetail
orderDetail
=
new
OrderDetail
();
orderDetail
.
setOrderId
(
Long
.
parseLong
(
orderId
));
orderDetail
.
setOrderId
(
Long
.
parseLong
(
orderId
));
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
...
@@ -630,36 +635,35 @@ public class OrderServiceImpl implements IOrderService
...
@@ -630,36 +635,35 @@ public class OrderServiceImpl implements IOrderService
OrderTakingVo
infoByShop
=
orderTakingService
.
getInfoByShop
(
shopId
);
OrderTakingVo
infoByShop
=
orderTakingService
.
getInfoByShop
(
shopId
);
List
<
CategoryVo
>
categorys
=
infoByShop
.
getCategorys
();
List
<
CategoryVo
>
categorys
=
infoByShop
.
getCategorys
();
List
<
GoodsVo
>
ccs
=
new
ArrayList
<>();
List
<
GoodsVo
>
ccs
=
new
ArrayList
<>();
if
(
categorys
!=
null
&&
!
categorys
.
isEmpty
())
{
if
(
categorys
!=
null
&&
!
categorys
.
isEmpty
())
{
for
(
CategoryVo
category
:
categorys
)
{
for
(
CategoryVo
category
:
categorys
)
{
if
(
category
.
getId
()==
0
)
{
if
(
category
.
getId
()
==
0
)
{
continue
;
continue
;
}
}
List
<
GoodsVo
>
goods
=
category
.
getGoods
();
List
<
GoodsVo
>
goods
=
category
.
getGoods
();
if
(
goods
==
null
||
goods
.
isEmpty
())
{
if
(
goods
==
null
||
goods
.
isEmpty
())
{
continue
;
continue
;
}
}
for
(
GoodsVo
good
:
goods
)
{
for
(
GoodsVo
good
:
goods
)
{
List
<
SkuVo
>
skuVoList
=
new
ArrayList
<>();
List
<
SkuVo
>
skuVoList
=
new
ArrayList
<>();
if
(
good
.
getSkus
()==
null
||
good
.
getSkus
().
isEmpty
())
{
if
(
good
.
getSkus
()
==
null
||
good
.
getSkus
().
isEmpty
())
{
continue
;
continue
;
}
}
for
(
SkuVo
skus
:
good
.
getSkus
())
{
for
(
SkuVo
skus
:
good
.
getSkus
())
{
if
(
skuIds
.
contains
(
skus
.
getSkuId
()))
{
if
(
skuIds
.
contains
(
skus
.
getSkuId
()))
{
skuVoList
.
add
(
skus
);
skuVoList
.
add
(
skus
);
}
}
}
}
if
(!
skuVoList
.
isEmpty
())
{
if
(!
skuVoList
.
isEmpty
())
{
ccs
.
add
(
good
);
ccs
.
add
(
good
);
good
.
setSkus
(
skuVoList
);
good
.
setSkus
(
skuVoList
);
}
}
}
}
}
}
}
}
return
ccs
;
return
ccs
;
}
}
}
}
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