Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
parking_local_general
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
李东升
parking_local_general
Commits
1517e55f
Commit
1517e55f
authored
May 27, 2020
by
李东升
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化计费规则实现以及添加首时段计费
parent
769482ef
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
460 additions
and
158 deletions
+460
-158
RequestChargeCommand.java
...l/parking_local_general/command/RequestChargeCommand.java
+1
-3
ThsIntervalPayableMoney.java
...ocal_general/domain/local/bo/ThsIntervalPayableMoney.java
+0
-114
ThsRequestChargeDTO.java
...eneral/domain/local/dto/response/ThsRequestChargeDTO.java
+0
-4
BaseChargeDetailPOJO.java
...ain/local/pojo/chargeCalculator/BaseChargeDetailPOJO.java
+81
-0
IntervalChargeDetailPOJO.java
...local/pojo/chargeCalculator/IntervalChargeDetailPOJO.java
+67
-0
OneTimeChargeDetailPOJO.java
.../local/pojo/chargeCalculator/OneTimeChargeDetailPOJO.java
+30
-0
TimeFrameChargeDetailPOJO.java
...ocal/pojo/chargeCalculator/TimeFrameChargeDetailPOJO.java
+100
-0
LocalCarInAndOutServiceImpl.java
...al_general/service/local/LocalCarInAndOutServiceImpl.java
+3
-6
PaymentChargesServiceImpl.java
...ocal_general/service/local/PaymentChargesServiceImpl.java
+5
-6
ThsIntervalPayableMoney.java
.../local/base/chargeCalculator/ThsIntervalPayableMoney.java
+120
-0
ThsOneTimePayableMoney.java
...e/local/base/chargeCalculator/ThsOneTimePayableMoney.java
+40
-3
ThsRequestChargeAbstract.java
...local/base/chargeCalculator/ThsRequestChargeAbstract.java
+2
-2
ThsRequestChargeService.java
.../local/base/chargeCalculator/ThsRequestChargeService.java
+4
-10
ThsTimeFramePayableMoney.java
...local/base/chargeCalculator/ThsTimeFramePayableMoney.java
+0
-0
Calculator.java
...l/service/local/base/chargeCalculator/old/Calculator.java
+1
-1
Calculator24Hours.java
...ce/local/base/chargeCalculator/old/Calculator24Hours.java
+1
-2
CalculatorCarSpace.java
...e/local/base/chargeCalculator/old/CalculatorCarSpace.java
+1
-2
CalculatorFree.java
...rvice/local/base/chargeCalculator/old/CalculatorFree.java
+1
-1
CalculatorNormal.java
...ice/local/base/chargeCalculator/old/CalculatorNormal.java
+1
-2
ChargeCalculatorUtil.java
...local/base/chargeCalculator/old/ChargeCalculatorUtil.java
+1
-1
ChargeInfo.java
...l/service/local/base/chargeCalculator/old/ChargeInfo.java
+1
-1
No files found.
src/main/java/com/huaching/parking/local/parking_local_general/command/RequestChargeCommand.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
command
;
import
com.huaching.parking.local.parking_local_general.
domain.local.bo
.ThsRequestChargeAbstract
;
import
com.huaching.parking.local.parking_local_general.
service.local.base.chargeCalculator
.ThsRequestChargeAbstract
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/domain/local/bo/ThsIntervalPayableMoney.java
deleted
100644 → 0
View file @
769482ef
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
bo
;
import
com.alibaba.fastjson.JSON
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesPO
;
import
com.huaching.parking.local.parking_local_general.enums.local.RequestChargeTypeEnums
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
/**
* @program: parking_local_general
* @description: 按照时间间隔计算费用
* @author: lidongsheng
* @createData: 2020-04-26 10:31
* @updateAuthor: lidongsheng
* @updateData: 2020-04-26 10:31
* @updateContent: 按照时间间隔计算费用
* @Version: 1.0.0
* ************************************************
* Copyright @ 李东升 2020. All rights reserved
* ************************************************
*/
@Component
public
class
ThsIntervalPayableMoney
implements
ThsRequestChargeAbstract
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ThsIntervalPayableMoney
.
class
);
@Override
public
Integer
getPayableMoney
(
ThsChargingRulesPO
thsChargingRulesPO
,
Date
inTime
)
{
String
chargeDetails
=
thsChargingRulesPO
.
getChargeDetails
();
return
intervalPayableMoney
(
JSON
.
parseObject
(
chargeDetails
,
IntervalChargeDetail
.
class
),
inTime
,
thsChargingRulesPO
.
getFreeTime
()
,
thsChargingRulesPO
.
getMaxOneTimeMoney
());
}
@Override
public
Integer
getType
()
{
return
RequestChargeTypeEnums
.
INTERVAL
.
getCode
();
}
/**
* 按照间隔收费
*
* @param detail
* @param inTime 计费开始时间
* @param freeTime 免费时长(分钟)
* @param maxOneTimeMoney 一次停车的最高费用(单位分)
* @return
*/
public
Integer
intervalPayableMoney
(
IntervalChargeDetail
detail
,
Date
inTime
,
Integer
freeTime
,
Integer
maxOneTimeMoney
)
{
inTime
=
DateUtils
.
getNextMinute
(
inTime
,
freeTime
);
long
sumMoney
=
0
;
switch
(
detail
.
frameType
)
{
//按照分钟收费
case
0
:
long
minute
=
DateUtils
.
subDate
(
inTime
,
new
Date
(),
2
);
sumMoney
=
(
minute
/
detail
.
intervalTime
)
*
detail
.
money
;
break
;
//按照小时收费
case
1
:
long
hour
=
DateUtils
.
subDate
(
inTime
,
new
Date
(),
3
);
sumMoney
=
(
hour
/
detail
.
intervalTime
)
*
detail
.
money
;
break
;
//按照固定收费
default
:
sumMoney
=
(
DateUtils
.
subDate
(
inTime
,
new
Date
(),
2
)
/
detail
.
intervalTime
)
*
detail
.
money
;
break
;
}
sumMoney
=
sumMoney
>
maxOneTimeMoney
?
maxOneTimeMoney
:
sumMoney
;
return
(
int
)
sumMoney
;
}
/**
* 按照间隔收费
* "frameType": 0 按分钟收费
* "frameType": 1 按小时收费
*/
static
class
IntervalChargeDetail
{
private
Integer
money
;
private
Integer
frameType
;
//间隔时长
private
Integer
intervalTime
;
public
Integer
getMoney
()
{
return
money
;
}
public
void
setMoney
(
Integer
money
)
{
this
.
money
=
money
;
}
public
Integer
getFrameType
()
{
return
frameType
;
}
public
void
setFrameType
(
Integer
frameType
)
{
this
.
frameType
=
frameType
;
}
public
Integer
getIntervalTime
()
{
return
intervalTime
;
}
public
void
setIntervalTime
(
Integer
intervalTime
)
{
this
.
intervalTime
=
intervalTime
;
}
}
}
src/main/java/com/huaching/parking/local/parking_local_general/domain/local/dto/response/ThsRequestChargeDTO.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
dto
.
response
;
import
com.alibaba.fastjson.JSON
;
import
com.huaching.parking.local.parking_local_general.domain.local.bo.ThsRequestChargeBO
;
import
com.huaching.parking.local.parking_local_general.domain.local.dto.BaseDTO
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesPO
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsParkingRecordsPO
;
import
com.huaching.parking.local.parking_local_general.service.local.PaymentChargesServiceImpl
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Date
;
import
java.util.UUID
;
/**
* @program: parking_local_general
...
...
src/main/java/com/huaching/parking/local/parking_local_general/domain/local/pojo/chargeCalculator/BaseChargeDetailPOJO.java
0 → 100644
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
pojo
.
chargeCalculator
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
java.util.Date
;
/**
* @program: parking_local_general
* @description: 首时段收费
* @author: lidongsheng
* @createData: 2020-05-27 10:39
* @updateAuthor: lidongsheng
* @updateData: 2020-05-27 10:39
* @updateContent:
* @Version: 1.0.0
* ************************************************
* Copyright @ 李东升 2020. All rights reserved
* ************************************************
*/
public
class
BaseChargeDetailPOJO
<
T
>
{
//首时段的时间
private
Integer
fastTime
;
//首时段类型 0 按分钟 1按小时
private
Integer
fastFrameType
;
//首时段金额
private
Integer
fastMoney
;
private
T
data
;
public
T
getData
()
{
return
data
;
}
public
void
setData
(
T
data
)
{
this
.
data
=
data
;
}
public
Integer
getFastTime
()
{
return
fastTime
;
}
public
void
setFastTime
(
Integer
fastTime
)
{
this
.
fastTime
=
fastTime
;
}
public
Integer
getFastFrameType
()
{
return
fastFrameType
;
}
public
void
setFastFrameType
(
Integer
fastFrameType
)
{
this
.
fastFrameType
=
fastFrameType
;
}
public
Integer
getFastMoney
()
{
return
fastMoney
;
}
public
void
setFastMoney
(
Integer
fastMoney
)
{
this
.
fastMoney
=
fastMoney
;
}
/**
* 验证是否还在首时段内
*
* @param detail
* @param inTime
* @param endTime
* @return
*/
public
boolean
validateFirstTime
(
BaseChargeDetailPOJO
detail
,
Date
inTime
,
Date
endTime
)
{
Date
temp
=
inTime
;
if
(
detail
.
getFastFrameType
()==
null
)
{
detail
.
setFastFrameType
(
0
);
}
int
dateNum
=
Math
.
toIntExact
(
DateUtils
.
subDate
(
inTime
,
endTime
,
detail
.
getFastFrameType
()
+
2
));
return
dateNum
<=
detail
.
getFastTime
();
}
}
src/main/java/com/huaching/parking/local/parking_local_general/domain/local/pojo/chargeCalculator/IntervalChargeDetailPOJO.java
0 → 100644
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
pojo
.
chargeCalculator
;
/**
* @program: parking_local_general
* @description: 按照间隔收费
* @author: lidongsheng
* @createData: 2020-05-27 10:47
* @updateAuthor: lidongsheng
* @updateData: 2020-05-27 10:47
* @updateContent: 按照间隔收费
* @Version: 1.0.0
* @email: lidongshenglife@163.com
* @blog: www.b0c0.com
* ************************************************
* Copyright @ 李东升 2020. All rights reserved
* ************************************************
*/
/*
首时段:2小时10元
后续:每间隔10分钟收费10元
{
"fastTime": 2,
"frameType": 1,
"fastMoney": 100,
"data": {
//金额
"money": 100,
//时间类型
"frameType": 0,
//间隔时长
"intervalTime": 10
}
}
*/
public
class
IntervalChargeDetailPOJO
{
private
Integer
money
;
private
Integer
frameType
;
//间隔时长
private
Integer
intervalTime
;
public
Integer
getMoney
()
{
return
money
;
}
public
void
setMoney
(
Integer
money
)
{
this
.
money
=
money
;
}
public
Integer
getFrameType
()
{
return
frameType
;
}
public
void
setFrameType
(
Integer
frameType
)
{
this
.
frameType
=
frameType
;
}
public
Integer
getIntervalTime
()
{
return
intervalTime
;
}
public
void
setIntervalTime
(
Integer
intervalTime
)
{
this
.
intervalTime
=
intervalTime
;
}
}
src/main/java/com/huaching/parking/local/parking_local_general/domain/local/pojo/chargeCalculator/OneTimeChargeDetailPOJO.java
0 → 100644
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
pojo
.
chargeCalculator
;
/**
* @program: parking_local_general
* @description: 一次收费
* @author: lidongsheng
* @createData: 2020-05-27 11:03
* @updateAuthor: lidongsheng
* @updateData: 2020-05-27 11:03
* @updateContent: 一次收费
* @Version: 1.0.0
* @email: lidongshenglife@163.com
* @blog: www.b0c0.com
* ************************************************
* Copyright @ 李东升 2020. All rights reserved
* ************************************************
*/
public
class
OneTimeChargeDetailPOJO
{
private
Integer
money
;
public
Integer
getMoney
()
{
return
money
;
}
public
void
setMoney
(
Integer
money
)
{
this
.
money
=
money
;
}
}
src/main/java/com/huaching/parking/local/parking_local_general/domain/local/pojo/chargeCalculator/TimeFrameChargeDetailPOJO.java
0 → 100644
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
pojo
.
chargeCalculator
;
import
java.util.List
;
/**
* @program: parking_local_general
* @description: 按照时段收费
* @author: lidongsheng
* @createData: 2020-05-27 10:53
* @updateAuthor: lidongsheng
* @updateData: 2020-05-27 10:53
* @updateContent: 按照时段收费
* @Version: 1.0.0
* @email: lidongshenglife@163.com
* @blog: www.b0c0.com
* ************************************************
* Copyright @ 李东升 2020. All rights reserved
* ************************************************
*/
/*
TimeFrameChargeDetail:
首时段:30分钟 收费5元
后续:
00:00-07:00时间端内每分钟收费2元
07:00-20:30时间端内每小时钟收费4元
20:30-00:00时间端内一共收费3元
//json数组
{
"fastTime": 30,
"frameType": 0,
"fastMoney": 50,
"data": [
{
//"frameType": 0 按分钟收费
"frameType": 0,
"beginTime": "00:00",
"endTime": "07:00",
//表示在00:00-07:00时间端内每分钟收费2元
"money": 200
},
{
//"frameType": 1 按小时收费
"frameType": 1,
"beginTime": "07:00",
"endTime": "20:30",
//表示在07:00-20:30时间端内每小时钟收费4元
"money": 400
},
{
//"frameType": 2 按固定收费
"frameType": 2,
"beginTime": "20:30",
"endTime": "00:00",
//表示在20:30-00:00时间端内一共收费3元
"money": 300
}
]
}
*/
public
class
TimeFrameChargeDetailPOJO
{
private
String
beginTime
;
private
String
endTime
;
private
Integer
money
;
private
Integer
frameType
;
public
Integer
getFrameType
()
{
return
frameType
;
}
public
void
setFrameType
(
Integer
frameType
)
{
this
.
frameType
=
frameType
;
}
public
String
getBeginTime
()
{
return
beginTime
;
}
public
void
setBeginTime
(
String
beginTime
)
{
this
.
beginTime
=
beginTime
;
}
public
String
getEndTime
()
{
return
endTime
;
}
public
void
setEndTime
(
String
endTime
)
{
this
.
endTime
=
endTime
;
}
public
Integer
getMoney
()
{
return
money
;
}
public
void
setMoney
(
Integer
money
)
{
this
.
money
=
money
;
}
}
src/main/java/com/huaching/parking/local/parking_local_general/service/local/LocalCarInAndOutServiceImpl.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
;
import
com.alibaba.fastjson.JSON
;
import
com.huaching.parking.local.parking_local_general.domain.ResponseResult
;
import
com.huaching.parking.local.parking_local_general.
domain.local.bo.ThsRequestChargeBO
;
import
com.huaching.parking.local.parking_local_general.
service.local.base.chargeCalculator.ThsRequestChargeService
;
import
com.huaching.parking.local.parking_local_general.domain.local.dto.request.ManualCarOutDTO
;
import
com.huaching.parking.local.parking_local_general.domain.local.dto.request.ThsCarInDTO
;
import
com.huaching.parking.local.parking_local_general.domain.local.dto.request.ThsCarOutDTO
;
...
...
@@ -10,9 +9,7 @@ import com.huaching.parking.local.parking_local_general.domain.local.dto.request
import
com.huaching.parking.local.parking_local_general.domain.local.dto.response.ThsRequestChargeDTO
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.*
;
import
com.huaching.parking.local.parking_local_general.enums.local.ReasonCodeEnums
;
import
com.huaching.parking.local.parking_local_general.intercept.local.GeneralPrintLogAOP
;
import
com.huaching.parking.local.parking_local_general.service.local.base.*
;
import
com.huaching.parking.local.parking_local_general.service.zhaf.RemoteRequestService
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -59,7 +56,7 @@ public class LocalCarInAndOutServiceImpl implements LocalCarInAndOutService {
private
PaymentChargesService
paymentChargesService
;
@Autowired
private
ThsRequestCharge
BO
thsRequestChargeBO
;
private
ThsRequestCharge
Service
thsRequestChargeService
;
@Autowired
private
PayOrderRecordsService
payOrderRecordsService
;
...
...
@@ -273,7 +270,7 @@ public class LocalCarInAndOutServiceImpl implements LocalCarInAndOutService {
logger
.
error
(
"未查询到 parkCode -> {} 配置收费规则"
,
parkCode
);
return
null
;
}
return
thsRequestCharge
BO
.
getPayableMoney
(
thsChargingRulesPO
,
carNo
,
thsParkingRecordsPO
.
getInTime
());
return
thsRequestCharge
Service
.
getPayableMoney
(
thsChargingRulesPO
,
carNo
,
thsParkingRecordsPO
.
getInTime
());
}
catch
(
Exception
ex
)
{
logger
.
error
(
"出场请求费用出错, parkCode -> {} ,carNo -> {}"
,
parkCode
,
carNo
);
return
null
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/service/local/PaymentChargesServiceImpl.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
;
import
com.alibaba.fastjson.JSON
;
import
com.huaching.parking.local.parking_local_general.domain.ResponseResult
;
import
com.huaching.parking.local.parking_local_general.
domain.local.bo.ThsRequestChargeBO
;
import
com.huaching.parking.local.parking_local_general.
service.local.base.chargeCalculator.ThsRequestChargeService
;
import
com.huaching.parking.local.parking_local_general.domain.local.dto.request.ThsPaySyncDTO
;
import
com.huaching.parking.local.parking_local_general.domain.local.dto.response.ThsRequestChargeDTO
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.*
;
...
...
@@ -10,8 +9,7 @@ import com.huaching.parking.local.parking_local_general.enums.local.ReasonCodeEn
import
com.huaching.parking.local.parking_local_general.factory.ThreadPoolFactory
;
import
com.huaching.parking.local.parking_local_general.intercept.local.GeneralPrintLogAOP
;
import
com.huaching.parking.local.parking_local_general.service.local.base.*
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
com.huaching.parking.local.parking_local_general.util.local.chargeCalculator.ChargeCalculatorUtil
;
import
com.huaching.parking.local.parking_local_general.service.local.base.chargeCalculator.old.ChargeCalculatorUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -55,7 +53,7 @@ public class PaymentChargesServiceImpl implements PaymentChargesService {
private
LocalCarInAndOutService
localCarInAndOutService
;
@Autowired
private
ThsRequestCharge
BO
thsRequestChargeBO
;
private
ThsRequestCharge
Service
thsRequestChargeService
;
@Autowired
private
ChargeCalculatorUtil
chargeCalculatorUtil
;
...
...
@@ -84,7 +82,7 @@ public class PaymentChargesServiceImpl implements PaymentChargesService {
return
ThsRequestChargeDTO
.
errorMsg
(
"该车场未配置收费规则"
);
}
thsParkingRecordsId
=
thsParkingRecordsPO
.
getId
();
payableMoney
=
thsRequestCharge
BO
.
getPayableMoney
(
thsChargingRulesPO
,
carNo
,
thsParkingRecordsPO
.
getInTime
());
payableMoney
=
thsRequestCharge
Service
.
getPayableMoney
(
thsChargingRulesPO
,
carNo
,
thsParkingRecordsPO
.
getInTime
());
totalMoney
=
payableMoney
<
0
?
0
:
payableMoney
;
payableMoney
-=
thsParkingRecordsPO
.
getPayedMoney
();
payableMoney
=
payableMoney
<
0
?
0
:
payableMoney
;
...
...
@@ -106,6 +104,7 @@ public class PaymentChargesServiceImpl implements PaymentChargesService {
}
@Override
@GeneralPrintLogAOP
(
value
=
"场内付请求费用 old"
,
jsonSubs
=
{-
1
})
public
ThsRequestChargeDTO
requestChargeOld
(
String
parkCode
,
String
carNo
)
{
Integer
thsParkingRecordsId
;
String
orderNo
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/service/local/base/chargeCalculator/ThsIntervalPayableMoney.java
0 → 100644
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesPO
;
import
com.huaching.parking.local.parking_local_general.domain.local.pojo.chargeCalculator.BaseChargeDetailPOJO
;
import
com.huaching.parking.local.parking_local_general.domain.local.pojo.chargeCalculator.IntervalChargeDetailPOJO
;
import
com.huaching.parking.local.parking_local_general.enums.local.RequestChargeTypeEnums
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
* @program: parking_local_general
* @description: 按照时间间隔计算费用
* @author: lidongsheng
* @createData: 2020-04-26 10:31
* @updateAuthor: lidongsheng
* @updateData: 2020-04-26 10:31
* @updateContent: 按照时间间隔计算费用
* @Version: 1.0.0
* ************************************************
* Copyright @ 李东升 2020. All rights reserved
* ************************************************
*/
/*
//表示每2分钟收费10元
IntervalChargeDetail:
"data":{
//金额
"money": 100,
// 0 分钟 1 小时
"frameType": 0,
// 时间
"intervalTime": 2
}
*/
@Component
public
class
ThsIntervalPayableMoney
implements
ThsRequestChargeAbstract
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ThsIntervalPayableMoney
.
class
);
@Override
public
Integer
getPayableMoney
(
ThsChargingRulesPO
thsChargingRulesPO
,
Date
inTime
,
Date
endTime
)
{
String
chargeDetails
=
thsChargingRulesPO
.
getChargeDetails
();
BaseChargeDetailPOJO
<
IntervalChargeDetailPOJO
>
baseChargeDetailPOJO
=
JSON
.
parseObject
(
chargeDetails
,
new
TypeReference
<
BaseChargeDetailPOJO
<
IntervalChargeDetailPOJO
>>()
{
});
return
intervalPayableMoney
(
baseChargeDetailPOJO
,
inTime
,
endTime
,
thsChargingRulesPO
.
getFreeTime
()
,
thsChargingRulesPO
.
getMaxOneTimeMoney
());
}
@Override
public
Integer
getType
()
{
return
RequestChargeTypeEnums
.
INTERVAL
.
getCode
();
}
/**
* 按照间隔收费
*
* @param detail
* @param inTime 计费开始时间
* @param freeTime 免费时长(分钟)
* @param maxOneTimeMoney 一次停车的最高费用(单位分)
* @return
*/
public
Integer
intervalPayableMoney
(
BaseChargeDetailPOJO
<
IntervalChargeDetailPOJO
>
detail
,
Date
inTime
,
Date
endTime
,
Integer
freeTime
,
Integer
maxOneTimeMoney
)
{
inTime
=
DateUtils
.
getNextMinute
(
inTime
,
freeTime
);
//1. 判断是否在免费时长内
if
(
inTime
.
after
(
endTime
))
{
return
0
;
}
long
sumMoney
=
detail
.
getFastMoney
();
//2. 判断是否在首时段内
if
(
detail
.
validateFirstTime
(
detail
,
inTime
,
endTime
))
{
return
Math
.
toIntExact
(
sumMoney
);
}
//3. 加上首时段的时间
int
[]
dateType
=
{
Calendar
.
MINUTE
,
Calendar
.
HOUR_OF_DAY
};
inTime
=
DateUtils
.
calAddDate
(
inTime
,
detail
.
getFastTime
(),
dateType
[
detail
.
getFastFrameType
()]);
//4. 计算费用
int
dateNum
=
Math
.
toIntExact
(
DateUtils
.
subDate
(
inTime
,
endTime
,
detail
.
getData
().
getFrameType
()
+
2
));
sumMoney
+=
(
dateNum
/
detail
.
getData
().
getIntervalTime
())
*
detail
.
getData
().
getMoney
();
sumMoney
=
sumMoney
>
maxOneTimeMoney
?
maxOneTimeMoney
:
sumMoney
;
return
Math
.
toIntExact
(
sumMoney
);
}
public
static
void
main
(
String
[]
args
)
{
ThsChargingRulesPO
thsChargingRulesPO
=
new
ThsChargingRulesPO
();
thsChargingRulesPO
.
setFreeTime
(
10
);
thsChargingRulesPO
.
setChargeType
(
RequestChargeTypeEnums
.
INTERVAL
.
getCode
());
thsChargingRulesPO
.
setMaxOneTimeMoney
(
20000000
);
thsChargingRulesPO
.
setChargeDetails
(
"{\n"
+
" \"fastTime\": 0,\n"
+
" \"frameType\": 0,\n"
+
" \"fastMoney\": 0,\n"
+
" \"data\": {\n"
+
" \"money\": 100,\n"
+
" \"frameType\": 0,\n"
+
" \"intervalTime\": 2\n"
+
" }\n"
+
"}"
);
ThsIntervalPayableMoney
payableMoney
=
new
ThsIntervalPayableMoney
();
Integer
money
=
payableMoney
.
getPayableMoney
(
thsChargingRulesPO
,
DateUtils
.
stringConvertDate
(
"2020-05-27 06:25:20"
,
3
),
DateUtils
.
stringConvertDate
(
"2020-05-27 15:24:20"
,
3
));
System
.
out
.
println
(
money
);
}
}
src/main/java/com/huaching/parking/local/parking_local_general/
domain/local/bo
/ThsOneTimePayableMoney.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator
/ThsOneTimePayableMoney.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
bo
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesPO
;
import
com.huaching.parking.local.parking_local_general.domain.local.pojo.chargeCalculator.BaseChargeDetailPOJO
;
import
com.huaching.parking.local.parking_local_general.domain.local.pojo.chargeCalculator.OneTimeChargeDetailPOJO
;
import
com.huaching.parking.local.parking_local_general.enums.local.RequestChargeTypeEnums
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
...
...
@@ -29,13 +33,46 @@ public class ThsOneTimePayableMoney implements ThsRequestChargeAbstract {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ThsOneTimePayableMoney
.
class
);
@Override
public
Integer
getPayableMoney
(
ThsChargingRulesPO
thsChargingRulesPO
,
Date
inTime
)
{
public
Integer
getPayableMoney
(
ThsChargingRulesPO
thsChargingRulesPO
,
Date
inTime
,
Date
endTime
)
{
String
chargeDetails
=
thsChargingRulesPO
.
getChargeDetails
();
return
(
Integer
)
JSON
.
parseObject
(
chargeDetails
).
get
(
"oneTimeMoney"
);
BaseChargeDetailPOJO
<
OneTimeChargeDetailPOJO
>
detail
=
JSON
.
parseObject
(
chargeDetails
,
new
TypeReference
<
BaseChargeDetailPOJO
<
OneTimeChargeDetailPOJO
>>()
{
});
inTime
=
DateUtils
.
getNextMinute
(
inTime
,
thsChargingRulesPO
.
getFreeTime
());
//1. 判断是否在免费时长内
if
(
inTime
.
after
(
endTime
))
{
return
0
;
}
long
sumMoney
=
detail
.
getFastMoney
();
//2. 判断是否在首时段内
if
(
detail
.
validateFirstTime
(
detail
,
inTime
,
endTime
))
{
return
Math
.
toIntExact
(
sumMoney
);
}
return
detail
.
getData
().
getMoney
();
}
@Override
public
Integer
getType
()
{
return
RequestChargeTypeEnums
.
ONE_TIME
.
getCode
();
}
public
static
void
main
(
String
[]
args
)
{
ThsChargingRulesPO
thsChargingRulesPO
=
new
ThsChargingRulesPO
();
thsChargingRulesPO
.
setFreeTime
(
10
);
thsChargingRulesPO
.
setChargeType
(
RequestChargeTypeEnums
.
ONE_TIME
.
getCode
());
thsChargingRulesPO
.
setMaxOneTimeMoney
(
20000000
);
thsChargingRulesPO
.
setChargeDetails
(
"{\n"
+
" \"fastTime\": 0,\n"
+
" \"frameType\": 0,\n"
+
" \"fastMoney\": 0,\n"
+
" \"data\": {\n"
+
" \"money\": 100\n"
+
" }\n"
+
"}"
);
ThsOneTimePayableMoney
payableMoney
=
new
ThsOneTimePayableMoney
();
Integer
money
=
payableMoney
.
getPayableMoney
(
thsChargingRulesPO
,
DateUtils
.
stringConvertDate
(
"2020-05-27 06:25:20"
,
3
)
,
DateUtils
.
stringConvertDate
(
"2020-05-27 15:20:20"
,
3
));
System
.
out
.
println
(
money
);
}
}
src/main/java/com/huaching/parking/local/parking_local_general/
domain/local/bo
/ThsRequestChargeAbstract.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator
/ThsRequestChargeAbstract.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
bo
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesPO
;
...
...
@@ -21,7 +21,7 @@ import java.util.Date;
public
interface
ThsRequestChargeAbstract
{
Integer
getPayableMoney
(
ThsChargingRulesPO
thsChargingRulesPO
,
Date
inTime
);
Integer
getPayableMoney
(
ThsChargingRulesPO
thsChargingRulesPO
,
Date
inTime
,
Date
endTime
);
Integer
getType
();
}
src/main/java/com/huaching/parking/local/parking_local_general/
domain/local/bo/ThsRequestChargeBO
.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/ThsRequestChargeService
.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
domain
.
local
.
bo
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
;
import
com.alibaba.fastjson.JSON
;
import
com.huaching.parking.local.parking_local_general.command.RequestChargeCommand
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesPO
;
import
com.huaching.parking.local.parking_local_general.intercept.local.GeneralPrintLogAOP
;
import
com.huaching.parking.local.parking_local_general.service.local.MemberCarHelperService
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Component
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
/**
* @program: parking_local_general
...
...
@@ -31,9 +25,9 @@ import java.util.UUID;
* ************************************************
*/
@Component
public
class
ThsRequestCharge
BO
{
public
class
ThsRequestCharge
Service
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ThsRequestCharge
BO
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ThsRequestCharge
Service
.
class
);
@Autowired
private
MemberCarHelperService
memberCarHelperService
;
...
...
@@ -53,7 +47,7 @@ public class ThsRequestChargeBO {
if
(
memberCarHelperService
.
vaildMember
(
thsChargingRulesPO
.
getParkCode
(),
carNo
)
!=
null
)
{
return
0
;
}
return
requestChargeCommand
.
getProcessor
(
thsChargingRulesPO
.
getChargeType
()).
getPayableMoney
(
thsChargingRulesPO
,
inTime
);
return
requestChargeCommand
.
getProcessor
(
thsChargingRulesPO
.
getChargeType
()).
getPayableMoney
(
thsChargingRulesPO
,
inTime
,
new
Date
()
);
}
}
src/main/java/com/huaching/parking/local/parking_local_general/
domain/local/bo
/ThsTimeFramePayableMoney.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator
/ThsTimeFramePayableMoney.java
View file @
1517e55f
This diff is collapsed.
Click to expand it.
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/Calculator.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/Calculator.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
import
java.util.Date
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/Calculator24Hours.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/Calculator24Hours.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRules24OldPO
;
import
com.huaching.parking.local.parking_local_general.service.local.base.ChargingRulesOldService
;
import
com.huaching.parking.local.parking_local_general.service.local.base.impl.ChargingRulesOldServiceImpl
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/CalculatorCarSpace.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/CalculatorCarSpace.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesFeeOldPO
;
import
com.huaching.parking.local.parking_local_general.service.local.base.ChargingRulesOldService
;
import
com.huaching.parking.local.parking_local_general.service.local.base.impl.ChargingRulesOldServiceImpl
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/CalculatorFree.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/CalculatorFree.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
import
org.springframework.stereotype.Service
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/CalculatorNormal.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/CalculatorNormal.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesOldPO
;
import
com.huaching.parking.local.parking_local_general.service.local.base.ChargingRulesOldService
;
import
com.huaching.parking.local.parking_local_general.service.local.base.impl.ChargingRulesOldServiceImpl
;
import
com.huaching.parking.local.parking_local_general.util.local.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/ChargeCalculatorUtil.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/ChargeCalculatorUtil.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRules24OldPO
;
import
com.huaching.parking.local.parking_local_general.domain.local.po.ThsChargingRulesOldPO
;
...
...
src/main/java/com/huaching/parking/local/parking_local_general/
util/local/chargeCalculator
/ChargeInfo.java
→
src/main/java/com/huaching/parking/local/parking_local_general/
service/local/base/chargeCalculator/old
/ChargeInfo.java
View file @
1517e55f
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
util
.
local
.
chargeCalculator
;
package
com
.
huaching
.
parking
.
local
.
parking_local_general
.
service
.
local
.
base
.
chargeCalculator
.
old
;
/**
* Created by sunke on 2018/3/5.
...
...
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