Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
464a76a2
Commit
464a76a2
authored
Oct 19, 2023
by
wuwenlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
computer order price service dev;
parent
50b2df96
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
389 additions
and
240 deletions
+389
-240
CouponStatusEnum.java
...on/src/main/java/share/common/enums/CouponStatusEnum.java
+28
-0
CouponTypeEnum.java
...mmon/src/main/java/share/common/enums/CouponTypeEnum.java
+48
-0
DateUtils.java
share-common/src/main/java/share/common/utils/DateUtils.java
+15
-0
SOrderController.java
...in/java/share/web/controller/system/SOrderController.java
+37
-52
SConsumerCoupon.java
...em/src/main/java/share/system/domain/SConsumerCoupon.java
+0
-30
SRoom.java
share-system/src/main/java/share/system/domain/SRoom.java
+5
-152
SRoomVo.java
...-system/src/main/java/share/system/domain/vo/SRoomVo.java
+3
-1
CreateOrderRequest.java
...rc/main/java/share/system/request/CreateOrderRequest.java
+46
-0
OrderComputedPriceRequest.java
.../java/share/system/request/OrderComputedPriceRequest.java
+45
-0
ComputedOrderPriceResponse.java
...ava/share/system/response/ComputedOrderPriceResponse.java
+36
-0
ISOrderService.java
...em/src/main/java/share/system/service/ISOrderService.java
+18
-0
RoomStatusServiceImpl.java
...java/share/system/service/impl/RoomStatusServiceImpl.java
+3
-4
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+105
-1
No files found.
share-common/src/main/java/share/common/enums/CouponStatusEnum.java
0 → 100644
View file @
464a76a2
package
share
.
common
.
enums
;
/**
* @Author wwl
* @Date 2023/10/19 16:13
*/
public
enum
CouponStatusEnum
{
NORMAL
(
0
,
"正常"
),
USED
(
1
,
"已使用"
),
EXPIRED
(
2
,
"已过期"
);
private
Integer
value
;
private
String
name
;
CouponStatusEnum
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
}
share-common/src/main/java/share/common/enums/CouponTypeEnum.java
0 → 100644
View file @
464a76a2
package
share
.
common
.
enums
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @Author wwl
* @Date 2023/10/19 17:06
*/
public
enum
CouponTypeEnum
{
DISCOUNT
(
1
,
"1"
,
"折扣券"
),
CASH
(
2
,
"2"
,
"满减券(现金券)"
),
DURATION
(
3
,
"3"
,
"时长券"
);
private
Integer
code
;
private
String
value
;
private
String
name
;
CouponTypeEnum
(
Integer
code
,
String
value
,
String
name
)
{
this
.
code
=
code
;
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getCode
(){
return
code
;
}
public
String
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
public
static
CouponTypeEnum
getType
(
String
value
){
for
(
CouponTypeEnum
type
:
CouponTypeEnum
.
values
())
{
if
(
type
.
getValue
().
equals
(
value
))
{
return
type
;
}
}
return
null
;
}
}
share-common/src/main/java/share/common/utils/DateUtils.java
View file @
464a76a2
package
share
.
common
.
utils
;
import
java.lang.management.ManagementFactory
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
...
...
@@ -148,6 +150,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
}
/**
* 计算相差小时(保留一位小数)
*/
public
static
BigDecimal
differentHour
(
Date
beforeDate
,
Date
afterDate
)
{
return
BigDecimal
.
valueOf
((
afterDate
.
getTime
()
-
beforeDate
.
getTime
())).
divide
(
BigDecimal
.
valueOf
(
1000
*
3600
),
1
,
BigDecimal
.
ROUND_HALF_UP
);
}
/**
* 计算时间差
*
* @param endDate 最后时间
...
...
@@ -191,4 +201,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
ZonedDateTime
zdt
=
localDateTime
.
atZone
(
ZoneId
.
systemDefault
());
return
Date
.
from
(
zdt
.
toInstant
());
}
public
static
void
main
(
String
[]
args
)
{
Date
now
=
new
Date
();
System
.
out
.
println
(
differentHour
(
DateUtils
.
parseDate
(
"2023-10-19 16:40"
),
now
));
}
}
share-front/src/main/java/share/web/controller/system/SOrderController.java
View file @
464a76a2
package
share
.
web
.
controller
.
system
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
share.common.annotation.Log
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
share.common.core.controller.BaseController
;
import
share.common.core.domain.AjaxResult
;
import
share.common.enums.BusinessType
;
import
share.common.core.domain.R
;
import
share.common.core.redis.RedisUtil
;
import
share.common.utils.JsonConvertUtil
;
import
share.system.domain.SOrder
;
import
share.system.domain.vo.MyRecord
;
import
share.system.request.CreateOrderRequest
;
import
share.system.request.OrderComputedPriceRequest
;
import
share.system.response.ComputedOrderPriceResponse
;
import
share.system.service.ISOrderService
;
import
share.common.utils.poi.ExcelUtil
;
import
share.common.core.page.TableDataInfo
;
/**
...
...
@@ -27,17 +26,20 @@ import share.common.core.page.TableDataInfo;
* @author ruoyi
* @date 2023-10-09
*/
@Slf4j
@RestController
@RequestMapping
(
"/
system
/order"
)
@RequestMapping
(
"/
front
/order"
)
public
class
SOrderController
extends
BaseController
{
@Autowired
private
ISOrderService
sOrderService
;
@Autowired
private
RedisUtil
redisUtil
;
/**
* 查询订单列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:list')"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
SOrder
sOrder
)
{
...
...
@@ -46,23 +48,10 @@ public class SOrderController extends BaseController
return
getDataTable
(
list
);
}
/**
* 导出订单列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:export')"
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
EXPORT
)
@PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
SOrder
sOrder
)
{
List
<
SOrder
>
list
=
sOrderService
.
selectSOrderList
(
sOrder
);
ExcelUtil
<
SOrder
>
util
=
new
ExcelUtil
<
SOrder
>(
SOrder
.
class
);
util
.
exportExcel
(
response
,
list
,
"订单数据"
);
}
/**
* 获取订单详细信息
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:query')"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
Long
id
)
{
...
...
@@ -70,35 +59,31 @@ public class SOrderController extends BaseController
}
/**
*
新增订
单
*
下
单
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:add')"
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
public
AjaxResult
add
(
@RequestBody
SOrder
sOrder
)
{
return
toAjax
(
sOrderService
.
insertSOrder
(
sOrder
));
@ApiOperation
(
value
=
"下单"
)
@RequestMapping
(
value
=
"/creat"
,
method
=
RequestMethod
.
POST
)
public
R
<
MyRecord
>
createOrder
(
@RequestBody
@Validated
CreateOrderRequest
request
)
{
if
(
"1"
.
equals
(
redisUtil
.
frontInOutLogSwitch
()))
{
log
.
info
(
"SOrderController method preOrder 入参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
request
));
}
MyRecord
record
=
sOrderService
.
createOrder
(
request
);
if
(
"1"
.
equals
(
redisUtil
.
frontInOutLogSwitch
()))
{
log
.
info
(
"SOrderController method preOrder 出参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
record
));
}
return
R
.
ok
(
record
);
}
/**
* 修改订单
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:edit')"
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
public
AjaxResult
edit
(
@RequestBody
SOrder
sOrder
)
{
return
toAjax
(
sOrderService
.
updateSOrder
(
sOrder
));
}
/**
*
删除订单
*
根据参数计算订单价格
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:remove')"
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
DELETE
)
@DeleteMapping
(
"/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
ids
)
{
return
toAjax
(
sOrderService
.
deleteSOrderByIds
(
ids
));
@ApiOperation
(
value
=
"计算订单价格"
)
@RequestMapping
(
value
=
"/computed/price"
,
method
=
RequestMethod
.
POST
)
public
R
<
ComputedOrderPriceResponse
>
computedPrice
(
@Validated
@RequestBody
OrderComputedPriceRequest
request
)
{
log
.
info
(
"StoreOrderController method computedPrice 入参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
request
));
ComputedOrderPriceResponse
response
=
sOrderService
.
computedOrderPrice
(
request
);
log
.
info
(
"StoreOrderController method computedPrice 出参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
response
));
return
R
.
ok
(
response
);
}
}
share-system/src/main/java/share/system/domain/SConsumerCoupon.java
View file @
464a76a2
...
...
@@ -102,34 +102,4 @@ public class SConsumerCoupon extends BaseEntity
@Excel
(
name
=
"更新时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
deleteTime
;
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"consumerId"
,
getConsumerId
())
.
append
(
"couponId"
,
getCouponId
())
.
append
(
"couponCode"
,
getCouponCode
())
.
append
(
"name"
,
getName
())
.
append
(
"couponType"
,
getCouponType
())
.
append
(
"maxDuration"
,
getMaxDuration
())
.
append
(
"duration"
,
getDuration
())
.
append
(
"minPrice"
,
getMinPrice
())
.
append
(
"subPrice"
,
getSubPrice
())
.
append
(
"sourceType"
,
getSourceType
())
.
append
(
"platformType"
,
getPlatformType
())
.
append
(
"startDate"
,
getStartDate
())
.
append
(
"endDate"
,
getEndDate
())
.
append
(
"useDate"
,
getUseDate
())
.
append
(
"useStatus"
,
getUseStatus
())
.
append
(
"isDelete"
,
getIsDelete
())
.
append
(
"createBy"
,
getCreateBy
())
.
append
(
"createTime"
,
getCreateTime
())
.
append
(
"updateBy"
,
getUpdateBy
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"deleteBy"
,
getDeleteBy
())
.
append
(
"deleteTime"
,
getDeleteTime
())
.
append
(
"remark"
,
getRemark
())
.
toString
();
}
}
share-system/src/main/java/share/system/domain/SRoom.java
View file @
464a76a2
package
share
.
system
.
domain
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
import
java.math.BigDecimal
;
/**
* 房间对象 s_room
*
* @author ruoyi
* @date 2023-10-12
*/
@Data
public
class
SRoom
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -48,7 +52,7 @@ public class SRoom extends BaseEntity
/** 房间单价(默认单位:元/小时) */
@Excel
(
name
=
"房间单价(默认单位:元/小时)"
)
private
Integer
price
;
private
BigDecimal
price
;
/** 门锁编码(接入第三方使用) */
@Excel
(
name
=
"门锁编码(接入第三方使用)"
)
...
...
@@ -70,155 +74,4 @@ public class SRoom extends BaseEntity
@Excel
(
name
=
"其他可能硬件接入参数(备用2)"
)
private
String
params2
;
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setStoreId
(
Long
storeId
)
{
this
.
storeId
=
storeId
;
}
public
Long
getStoreId
()
{
return
storeId
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
public
void
setRoomType
(
String
roomType
)
{
this
.
roomType
=
roomType
;
}
public
String
getRoomType
()
{
return
roomType
;
}
public
void
setImages
(
String
images
)
{
this
.
images
=
images
;
}
public
String
getImages
()
{
return
images
;
}
public
void
setFacilities
(
String
facilities
)
{
this
.
facilities
=
facilities
;
}
public
String
getFacilities
()
{
return
facilities
;
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
public
String
getInfo
()
{
return
info
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setPrice
(
Integer
price
)
{
this
.
price
=
price
;
}
public
Integer
getPrice
()
{
return
price
;
}
public
void
setDoorLockCode
(
String
doorLockCode
)
{
this
.
doorLockCode
=
doorLockCode
;
}
public
String
getDoorLockCode
()
{
return
doorLockCode
;
}
public
void
setElectricControlCode
(
String
electricControlCode
)
{
this
.
electricControlCode
=
electricControlCode
;
}
public
String
getElectricControlCode
()
{
return
electricControlCode
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setParams1
(
String
params1
)
{
this
.
params1
=
params1
;
}
public
String
getParams1
()
{
return
params1
;
}
public
void
setParams2
(
String
params2
)
{
this
.
params2
=
params2
;
}
public
String
getParams2
()
{
return
params2
;
}
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"storeId"
,
getStoreId
())
.
append
(
"name"
,
getName
())
.
append
(
"roomType"
,
getRoomType
())
.
append
(
"images"
,
getImages
())
.
append
(
"facilities"
,
getFacilities
())
.
append
(
"info"
,
getInfo
())
.
append
(
"status"
,
getStatus
())
.
append
(
"price"
,
getPrice
())
.
append
(
"doorLockCode"
,
getDoorLockCode
())
.
append
(
"electricControlCode"
,
getElectricControlCode
())
.
append
(
"password"
,
getPassword
())
.
append
(
"params1"
,
getParams1
())
.
append
(
"params2"
,
getParams2
())
.
append
(
"createBy"
,
getCreateBy
())
.
append
(
"createTime"
,
getCreateTime
())
.
append
(
"updateBy"
,
getUpdateBy
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"remark"
,
getRemark
())
.
toString
();
}
}
share-system/src/main/java/share/system/domain/vo/SRoomVo.java
View file @
464a76a2
...
...
@@ -7,6 +7,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
share.common.core.domain.BaseEntity
;
import
java.math.BigDecimal
;
/**
* 房间对象 s_room
*
...
...
@@ -56,7 +58,7 @@ public class SRoomVo extends BaseEntity
/** 房间单价(默认单位:元/小时) */
@ApiModelProperty
(
value
=
"房间单价(默认单位:元/小时)"
)
private
Integer
price
;
private
BigDecimal
price
;
/** 门锁编码(接入第三方使用) */
@ApiModelProperty
(
value
=
"门锁编码(接入第三方使用)"
)
...
...
share-system/src/main/java/share/system/request/CreateOrderRequest.java
0 → 100644
View file @
464a76a2
package
share
.
system
.
request
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
java.util.Date
;
/**
* @Author wwl
* @Date 2023/10/19 14:56
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"CreateOrderRequest对象"
,
description
=
"下单请求对象"
)
public
class
CreateOrderRequest
{
@ApiModelProperty
(
value
=
"门店ID"
,
required
=
true
)
@NotBlank
(
message
=
"门店ID不能为空"
)
private
Long
storeId
;
@ApiModelProperty
(
value
=
"房间ID"
,
required
=
true
)
@NotBlank
(
message
=
"房间ID不能为空"
)
private
Long
roomId
;
@ApiModelProperty
(
value
=
"优惠券id"
)
private
Integer
couponId
;
@ApiModelProperty
(
value
=
"订单类型(0:订房订单,1:续房订单,2:充值订单)"
,
required
=
true
)
@NotBlank
(
message
=
"订单类型不能为空"
)
private
Integer
orderType
;
/** 预约开始时间 */
@ApiModelProperty
(
value
=
"预约开始时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@NotBlank
(
message
=
"预约开始时间不能为空"
)
private
Date
preStartDate
;
/** 预约结束时间 */
@ApiModelProperty
(
value
=
"预约结束时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@NotBlank
(
message
=
"预约结束时间不能为空"
)
private
Date
preEndDate
;
}
share-system/src/main/java/share/system/request/OrderComputedPriceRequest.java
0 → 100644
View file @
464a76a2
package
share
.
system
.
request
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
java.util.Date
;
/**
* @Author wwl
* @Date 2023/10/19 15:34
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"OrderComputedPriceRequest对象"
,
description
=
"计算订单价格请求对象"
)
public
class
OrderComputedPriceRequest
{
@ApiModelProperty
(
value
=
"门店ID"
,
required
=
true
)
@NotBlank
(
message
=
"门店ID不能为空"
)
private
Long
storeId
;
@ApiModelProperty
(
value
=
"房间ID"
,
required
=
true
)
@NotBlank
(
message
=
"房间ID不能为空"
)
private
Long
roomId
;
@ApiModelProperty
(
value
=
"优惠券id"
)
private
Integer
couponId
;
@ApiModelProperty
(
value
=
"订单类型(0:订房订单,1:续房订单,2:充值订单)"
,
required
=
true
)
@NotBlank
(
message
=
"订单类型不能为空"
)
private
Integer
orderType
;
/** 预约开始时间 */
@ApiModelProperty
(
value
=
"预约开始时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@NotBlank
(
message
=
"预约开始时间不能为空"
)
private
Date
preStartDate
;
/** 预约结束时间 */
@ApiModelProperty
(
value
=
"预约结束时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@NotBlank
(
message
=
"预约结束时间不能为空"
)
private
Date
preEndDate
;
}
share-system/src/main/java/share/system/response/ComputedOrderPriceResponse.java
0 → 100644
View file @
464a76a2
package
share
.
system
.
response
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @Author wwl
* @Date 2023/10/19 15:35
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"ComputedOrderPriceResponse对象"
,
description
=
"计算订单价格响应对象"
)
public
class
ComputedOrderPriceResponse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
7282892323898493847L
;
@ApiModelProperty
(
value
=
"优惠券优惠金额"
)
private
BigDecimal
couponFee
;
@ApiModelProperty
(
value
=
"实际支付金额"
)
private
BigDecimal
payFee
;
@ApiModelProperty
(
value
=
"商品总金额"
)
private
BigDecimal
totalFee
;
}
share-system/src/main/java/share/system/service/ISOrderService.java
View file @
464a76a2
...
...
@@ -5,6 +5,10 @@ import java.util.List;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
share.system.domain.SOrder
;
import
share.system.domain.vo.MyRecord
;
import
share.system.request.CreateOrderRequest
;
import
share.system.request.OrderComputedPriceRequest
;
import
share.system.response.ComputedOrderPriceResponse
;
/**
* 订单Service接口
...
...
@@ -70,4 +74,18 @@ public interface ISOrderService extends IService<SOrder>
* @return
*/
List
<
SOrder
>
listByRoomInfo
(
Long
storeId
,
Long
roomId
,
Date
day
);
/**
* 订单预下单
* @param request 预下单请求参数
* @return PreOrderResponse
*/
MyRecord
createOrder
(
CreateOrderRequest
request
);
/**
* 计算订单价格
* @param request 计算订单价格请求对象
* @return ComputedOrderPriceResponse
*/
ComputedOrderPriceResponse
computedOrderPrice
(
OrderComputedPriceRequest
request
);
}
share-system/src/main/java/share/system/service/impl/RoomStatusServiceImpl.java
View file @
464a76a2
...
...
@@ -60,10 +60,10 @@ public class RoomStatusServiceImpl implements RoomStatusService {
RoomStatusVo
vo
=
new
RoomStatusVo
();
Integer
lockInt
=
Integer
.
parseInt
(
lock
);
String
timeHour
=
""
;
if
(
Integer
.
compare
(
lockInt
,
new
Integer
(
10
))
==
0
){
timeHour
=
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD
,
day
)
+
"
0"
+
lock
;
if
(
Integer
.
compare
(
lockInt
,
new
Integer
(
10
))
==
-
1
){
timeHour
=
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD
,
day
)
+
"
0"
+
lock
;
}
else
{
timeHour
=
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD
,
day
)
+
lock
;
timeHour
=
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD
,
day
)
+
" "
+
lock
;
}
vo
.
setStoreId
(
store
.
getId
());
vo
.
setRoomId
(
roomId
);
...
...
@@ -149,5 +149,4 @@ public class RoomStatusServiceImpl implements RoomStatusService {
}
}
}
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
464a76a2
package
share
.
system
.
service
.
impl
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
share.common.enums.CouponStatusEnum
;
import
share.common.enums.CouponTypeEnum
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.DateUtil
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SRoom
;
import
share.system.domain.vo.MyRecord
;
import
share.system.mapper.SOrderMapper
;
import
share.system.domain.SOrder
;
import
share.system.request.CreateOrderRequest
;
import
share.system.request.OrderComputedPriceRequest
;
import
share.system.response.ComputedOrderPriceResponse
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISOrderService
;
import
share.system.service.ISRoomService
;
import
share.system.service.SConsumerService
;
/**
* 订单Service业务层处理
...
...
@@ -25,6 +45,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Autowired
private
SOrderMapper
sOrderMapper
;
@Autowired
private
SConsumerService
sConsumerService
;
@Autowired
private
ISConsumerCouponService
consumerCouponService
;
@Autowired
private
ISRoomService
roomService
;
/**
* 查询订单
*
...
...
@@ -111,4 +140,79 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
queryWrapper
.
last
(
"ORDER BY IFNULL(start_date,pre_start_date) "
);
return
list
(
queryWrapper
);
}
@Override
public
MyRecord
createOrder
(
CreateOrderRequest
request
)
{
return
null
;
}
/**
* 计算订单价格
* @param request 计算订单价格请求对象
* @return ComputedOrderPriceResponse
*/
@Override
public
ComputedOrderPriceResponse
computedOrderPrice
(
OrderComputedPriceRequest
request
)
{
SConsumer
user
=
sConsumerService
.
getSConsumer
();
return
computedPrice
(
request
,
user
);
}
private
BigDecimal
computeTotalPrice
(
BigDecimal
unitPrice
,
Date
startTime
,
Date
endTime
){
return
DateUtils
.
differentHour
(
startTime
,
endTime
).
multiply
(
unitPrice
);
}
private
ComputedOrderPriceResponse
computedPrice
(
OrderComputedPriceRequest
request
,
SConsumer
user
)
{
// 计算各种价格
ComputedOrderPriceResponse
priceResponse
=
new
ComputedOrderPriceResponse
();
SRoom
room
=
roomService
.
getById
(
request
.
getRoomId
());
BigDecimal
totalPrice
=
computeTotalPrice
(
room
.
getPrice
(),
request
.
getPreStartDate
(),
request
.
getPreEndDate
());
priceResponse
.
setTotalFee
(
totalPrice
);
// 计算优惠券金额
if
(
ObjectUtil
.
isNull
(
request
.
getCouponId
())
||
request
.
getCouponId
()
<=
0
)
{
priceResponse
.
setCouponFee
(
BigDecimal
.
ZERO
);
}
else
{
// 判断优惠券是否可以使用
SConsumerCoupon
consumerCoupon
=
consumerCouponService
.
getById
(
request
.
getCouponId
());
computedCouponPrice
(
priceResponse
,
user
,
consumerCoupon
);
}
return
priceResponse
;
}
/**
* 计算使用优惠券后的订单金额
*/
private
void
computedCouponPrice
(
ComputedOrderPriceResponse
priceResponse
,
SConsumer
user
,
SConsumerCoupon
consumerCoupon
){
if
(
ObjectUtil
.
isNull
(
consumerCoupon
)
||
!
consumerCoupon
.
getCouponId
().
equals
(
user
.
getId
()))
{
throw
new
BaseException
(
"优惠券领取记录不存在!"
);
}
if
(
CouponStatusEnum
.
USED
.
getValue
().
compareTo
(
Integer
.
parseInt
(
consumerCoupon
.
getUseStatus
()))
==
0
)
{
throw
new
BaseException
(
"此优惠券已使用!"
);
}
if
(
CouponStatusEnum
.
EXPIRED
.
getValue
().
compareTo
(
Integer
.
parseInt
(
consumerCoupon
.
getUseStatus
()))
==
0
)
{
throw
new
BaseException
(
"此优惠券已失效!"
);
}
//判断是否在使用时间内
Date
date
=
DateUtil
.
nowDateTime
();
if
(
date
.
compareTo
(
consumerCoupon
.
getEndDate
())
>
0
)
{
throw
new
BaseException
(
"此优惠券已经失效了"
);
}
CouponTypeEnum
couponType
=
CouponTypeEnum
.
getType
(
consumerCoupon
.
getCouponType
());
switch
(
couponType
){
case
DISCOUNT:
//TODO 折扣券
break
;
case
CASH:
//现金券
//判断优惠券最小使用金额
if
(
consumerCoupon
.
getMinPrice
().
compareTo
(
priceResponse
.
getTotalFee
())
>
0
)
{
throw
new
BaseException
(
"总金额小于优惠券最小使用金额"
);
}
priceResponse
.
setCouponFee
(
consumerCoupon
.
getSubPrice
());
priceResponse
.
setPayFee
(
priceResponse
.
getTotalFee
().
subtract
(
consumerCoupon
.
getSubPrice
()));
break
;
case
DURATION:
//TODO 时长券
break
;
default
:
break
;
}
}
}
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