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
aaf0ecfe
Commit
aaf0ecfe
authored
Mar 22, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单换房增加历史订单
parent
350b7477
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
33 deletions
+56
-33
SOrder.java
share-system/src/main/java/share/system/domain/SOrder.java
+5
-4
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+43
-29
SOrderMapper.xml
...-system/src/main/resources/mapper/system/SOrderMapper.xml
+8
-0
No files found.
share-system/src/main/java/share/system/domain/SOrder.java
View file @
aaf0ecfe
package
share
.
system
.
domain
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
...
...
@@ -14,7 +11,8 @@ import org.springframework.validation.annotation.Validated;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
import
javax.validation.constraints.NotBlank
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* 订单对象 s_order
...
...
@@ -36,6 +34,9 @@ public class SOrder extends BaseEntity
@Excel
(
name
=
"订单编号"
)
private
String
orderNo
;
@Excel
(
name
=
"历史订单号"
)
private
String
historicalOrderNo
;
@Excel
(
name
=
"商户订单号"
)
private
String
outTradeNo
;
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
aaf0ecfe
...
...
@@ -116,8 +116,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
private
OrderRefundArtificialService
orderRefundArtificialService
;
@Autowired
private
RedisUtil
redisUtils
;
@Autowired
private
ISCouponService
sCouponService
;
...
...
@@ -459,7 +457,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map
.
put
(
"orderNo"
,
one
.
getOrderNo
());
map
.
put
(
"expirationTime"
,
one
.
getEndDate
().
toString
());
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
s
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
one
.
getOrderNo
(),
jsonObject
.
toString
());
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
one
.
getOrderNo
(),
jsonObject
.
toString
());
}
else
{
// 使用中订单断电, 延时3分钟断电
deviceOpService
.
openOrCloseDevice
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
...
...
@@ -470,7 +468,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map
.
put
(
"orderNo"
,
one
.
getOrderNo
());
map
.
put
(
"expirationTime"
,
one
.
getEndDate
().
toString
());
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
s
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
one
.
getOrderNo
(),
jsonObject
.
toString
());
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
one
.
getOrderNo
(),
jsonObject
.
toString
());
}
}
// 如果订单使用中,房间修改状态
...
...
@@ -576,28 +574,28 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
public
Boolean
changeRoom
(
SOrderDto
dto
)
{
SOrder
s
Order
=
getById
(
dto
.
getId
());
SOrder
oldS
Order
=
getById
(
dto
.
getId
());
//订单状态不等于待使用或者使用中都报错
if
(!
sOrder
.
getStatus
().
equals
(
OrderStatusEnum
.
UNUSED
.
getCode
())
&&
!
s
Order
.
getStatus
().
equals
(
OrderStatusEnum
.
INUSE
.
getCode
()))
{
if
(!
oldSOrder
.
getStatus
().
equals
(
OrderStatusEnum
.
UNUSED
.
getCode
())
&&
!
oldS
Order
.
getStatus
().
equals
(
OrderStatusEnum
.
INUSE
.
getCode
()))
{
throw
new
BaseException
(
"订单异常,不能换房"
);
}
SOrder
oldS
Order
=
new
SOrder
();
SOrder
new
Order
=
new
SOrder
();
LambdaQueryWrapper
<
SRoom
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
SRoom:
:
getStoreId
,
s
Order
.
getStoreId
());
queryWrapper
.
eq
(
SRoom:
:
getStoreId
,
oldS
Order
.
getStoreId
());
List
<
SRoom
>
list
=
roomService
.
list
(
queryWrapper
);
BeanUtils
.
copyProperties
(
sOrder
,
oldS
Order
);
BeanUtils
.
copyProperties
(
oldSOrder
,
new
Order
);
LambdaQueryWrapper
<
SOrder
>
sOrderLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sOrderLambdaQueryWrapper
.
notIn
(
SOrder:
:
getRefundStatus
,
RefundStatusEnum
.
getRefundedStatus
());
sOrderLambdaQueryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
getUnfinishOrderStatus
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getStoreId
,
s
Order
.
getStoreId
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getStoreId
,
oldS
Order
.
getStoreId
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getRoomId
,
dto
.
getRoomId
());
sOrderLambdaQueryWrapper
.
apply
(
"(IFNULL(start_date,pre_start_date) BETWEEN '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
s
Order
.
getPreStartDate
())
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
s
Order
.
getPreEndDate
(),
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' "
+
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
oldS
Order
.
getPreStartDate
())
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
oldS
Order
.
getPreEndDate
(),
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' "
+
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
s
Order
.
getPreStartDate
(),
-
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
s
Order
.
getPreEndDate
())
+
"' )"
);
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
oldS
Order
.
getPreStartDate
(),
-
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
oldS
Order
.
getPreEndDate
())
+
"' )"
);
List
<
SOrder
>
orderList
=
list
(
sOrderLambdaQueryWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
orderList
))
{
return
false
;
...
...
@@ -605,37 +603,53 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 判断原房间是否生成保洁
if
(
dto
.
getIsClean
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
//判断订单是否已经添加保洁记录
SCleanRecords
cleanRecords
=
isCleanRecordsService
.
lastCleanByRoomId
(
s
Order
.
getRoomId
());
if
(
ObjectUtil
.
isEmpty
(
getOne
(
new
LambdaQueryWrapper
<
SOrder
>().
eq
(
SOrder:
:
getRoomId
,
s
Order
.
getRoomId
()).
eq
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
INUSE
.
getCode
())))
&&
SCleanRecords
cleanRecords
=
isCleanRecordsService
.
lastCleanByRoomId
(
oldS
Order
.
getRoomId
());
if
(
ObjectUtil
.
isEmpty
(
getOne
(
new
LambdaQueryWrapper
<
SOrder
>().
eq
(
SOrder:
:
getRoomId
,
oldS
Order
.
getRoomId
()).
eq
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
INUSE
.
getCode
())))
&&
(
ObjectUtil
.
isEmpty
(
cleanRecords
)
||
cleanRecords
.
getStatus
().
equals
(
CleaningStatusEnum
.
CLEANED
.
getCode
())))
{
//房间添加保洁记录
isCleanRecordsService
.
addSCleanRecords
(
sOrder
.
getStoreId
(),
s
Order
.
getRoomId
());
isCleanRecordsService
.
addSCleanRecords
(
oldSOrder
.
getStoreId
(),
oldS
Order
.
getRoomId
());
}
}
//判断极端条件,在订单换房时原订单在自动开始的订单中变为订单开始状态
boolean
inuse
=
redisUtils
.
exists
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
sOrder
.
getOrderNo
());
boolean
inuse
=
redisUtil
.
exists
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
oldSOrder
.
getOrderNo
());
String
cj
=
BaseUtil
.
getOrderNo
(
"CJ"
);
//原订单是否使用中
if
(
s
Order
.
getStatus
().
equals
(
OrderStatusEnum
.
INUSE
.
getCode
())
|
inuse
)
{
if
(
oldS
Order
.
getStatus
().
equals
(
OrderStatusEnum
.
INUSE
.
getCode
())
|
inuse
)
{
// 使用中订单断电, 延时3分钟断电
deviceOpService
.
openOrCloseDevice
(
sOrder
.
getRoomId
(),
s
Order
.
getConsumerPhone
(),
deviceOpService
.
openOrCloseDevice
(
oldSOrder
.
getRoomId
(),
oldS
Order
.
getConsumerPhone
(),
OpTypeEnum
.
CUT_ELECTRIC
.
getCode
(),
false
,
0
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
//修改原房间状态
SRoom
sRoom
=
new
SRoom
();
sRoom
.
setId
(
s
Order
.
getRoomId
());
sRoom
.
setId
(
oldS
Order
.
getRoomId
());
sRoom
.
setStatus
(
RoomStatusEnum
.
FREE
.
getValue
());
roomService
.
updateById
(
sRoom
);
//修改新房间状态
sRoom
.
setId
(
dto
.
getRoomId
());
sRoom
.
setStatus
(
RoomStatusEnum
.
HOLD
.
getValue
());
//删除原来的redis
roomService
.
updateById
(
sRoom
);
}
sOrder
.
setIsDelete
(
YesNoEnum
.
yes
.
getIndex
());
sOrder
.
setRemark
(
"订单:"
+
sOrder
.
getOrderNo
()
+
"由原来的"
+
list
.
stream
().
filter
(
item
->
item
.
getId
().
equals
(
sOrder
.
getRoomId
())).
findFirst
().
orElse
(
null
).
getName
()
+
"换到"
+
list
.
stream
().
filter
(
item
->
item
.
getId
().
equals
(
dto
.
getRoomId
())).
findFirst
().
orElse
(
null
).
getName
()
+
"房间"
);
sOrder
.
setCreateTime
(
new
Date
());
save
(
sOrder
);
oldSOrder
.
setRoomId
(
dto
.
getRoomId
());
return
updateById
(
oldSOrder
);
//生成新的redis
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderNo"
,
cj
);
map
.
put
(
"expirationTime"
,
oldSOrder
.
getEndDate
().
toString
());
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
cj
,
jsonObject
.
toString
());
redisUtil
.
delete
(
oldSOrder
.
getOrderNo
());
}
else
if
(
oldSOrder
.
getStatus
().
equals
(
OrderStatusEnum
.
UNUSED
.
getCode
()))
{
//未使用订单
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderNo"
,
cj
);
map
.
put
(
"expirationTime"
,
oldSOrder
.
getPreStartDate
().
toString
());
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_NO
.
getValue
()
+
cj
,
jsonObject
.
toString
());
redisUtil
.
delete
(
oldSOrder
.
getOrderNo
());
}
oldSOrder
.
setIsDelete
(
YesNoEnum
.
yes
.
getIndex
());
newOrder
.
setHistoricalOrderNo
(
oldSOrder
.
getOrderNo
());
newOrder
.
setOrderNo
(
cj
);
newOrder
.
setRoomId
(
dto
.
getRoomId
());
save
(
newOrder
);
return
removeById
(
oldSOrder
);
}
@Override
...
...
share-system/src/main/resources/mapper/system/SOrderMapper.xml
View file @
aaf0ecfe
...
...
@@ -8,6 +8,7 @@
<result
property=
"id"
column=
"id"
/>
<result
property=
"orderNo"
column=
"order_no"
/>
<result
property=
"outTradeNo"
column=
"out_trade_no"
/>
<result
property=
"historicalOrderNo"
column=
"historical_order_no"
/>
<result
property=
"orderType"
column=
"order_type"
/>
<result
property=
"payType"
column=
"pay_type"
/>
<result
property=
"payStatus"
column=
"pay_status"
/>
...
...
@@ -46,6 +47,7 @@
select id,
order_no,
out_trade_no,
historical_order_no,
order_type,
pay_type,
pay_status,
...
...
@@ -86,6 +88,9 @@
where pay_status = 1
and is_delete = 0
<if
test=
"orderNo != null and orderNo != ''"
>
and order_no = #{orderNo}
</if>
<if
test=
"historicalOrderNo != null and historicalOrderNo != ''"
>
and historical_order_no =
#{historicalOrderNo}
</if>
<if
test=
"outTradeNo != null and outTradeNo != ''"
>
and out_trade_no = #{outTradeNo}
</if>
<if
test=
"orderType != null and orderType != ''"
>
and order_type = #{orderType}
</if>
<if
test=
"payType != null and payType != ''"
>
and pay_type = #{payType}
</if>
...
...
@@ -155,6 +160,7 @@
insert into s_order
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"orderNo != null and orderNo != ''"
>
order_no,
</if>
<if
test=
"historicalOrderNo != null and historicalOrderNo != ''"
>
historical_order_no,
</if>
<if
test=
"outTradeNo != null and outTradeNo != ''"
>
out_trade_no,
</if>
<if
test=
"orderType != null and orderType != ''"
>
order_type,
</if>
<if
test=
"payType != null and payType != ''"
>
pay_type,
</if>
...
...
@@ -188,6 +194,7 @@
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"orderNo != null"
>
#{orderNo},
</if>
<if
test=
"historicalOrderNo != null"
>
#{historicalOrderNo},
</if>
<if
test=
"outTradeNo != null "
>
#{outTradeNo},
</if>
<if
test=
"orderType != null"
>
#{orderType},
</if>
<if
test=
"payType != null"
>
#{payType},
</if>
...
...
@@ -225,6 +232,7 @@
update s_order
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"orderNo != null"
>
order_no = #{orderNo},
</if>
<if
test=
"historicalOrderNo != null"
>
historical_order_no = #{historicalOrderNo},
</if>
<if
test=
"outTradeNo != null"
>
out_trade_no = #{outTradeNo},
</if>
<if
test=
"orderType != null"
>
order_type = #{orderType},
</if>
<if
test=
"payType != null"
>
pay_type = #{payType},
</if>
...
...
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