Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
c4e87076
Commit
c4e87076
authored
Jan 13, 2022
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加支付和退款功能
parent
14a115b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
7 deletions
+146
-7
PayRepository.kt
...ain/java/com/miya/fastcashier/repository/PayRepository.kt
+146
-0
PayRepository.kt
...c/main/java/com/miya/fastcashier/service/PayRepository.kt
+0
-7
No files found.
app/src/main/java/com/miya/fastcashier/repository/PayRepository.kt
0 → 100644
View file @
c4e87076
package
com.miya.fastcashier.repository
import
androidx.annotation.WorkerThread
import
com.sdy.miya.moblie.component.pay.core.constance.AppTagConstance
import
com.sdy.miya.moblie.component.pay.core.result.MiYaMobilePayResult
import
com.sdy.miya.moblie.component.pay.core.result.ResultBuilder
import
com.sdy.miya.moblie.component.pay.platform.MiYaPlatformPayService
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import
java.lang.Exception
import
java.util.HashMap
/**
* 提供支付、退款的功能
*/
class
PayRepository
{
/**
* 支付功能
*/
@WorkerThread
fun
pay
(
params
:
Map
<
String
,
String
>):
PayServiceResponse
{
if
(
params
==
null
)
{
throw
RuntimeException
(
"MiyaPayServiceComponent startPay params is null"
)
}
val
baseUrl
=
params
[
"baseUrl"
]
val
payPrice
=
params
[
"payPrice"
]
val
payType
=
params
[
"payType"
]
val
token
=
params
[
"token"
]
val
goodsDetail
=
params
[
"goodsDetail"
]
val
signKey
=
params
[
"signKey"
]
val
saasid
=
params
[
"saasid"
]
val
marketid
=
params
[
"marketid"
]
val
posId
=
params
[
"posId"
]
val
cashierCode
=
params
[
"cashierCode"
]
val
version
=
params
[
"version"
]
val
orderNo
=
params
[
"orderNo"
]
val
memberPhone
=
params
[
"memberPhone"
]
var
terminalParams
=
params
[
"terminalParams"
]
val
paymentInfoShowMessage
=
params
[
"paymentInfoShowMessage"
]
checkNotNull
(
baseUrl
)
{
"MiyaPayServiceComponent startPay baseUrl is null"
}
checkNotNull
(
payPrice
)
{
"MiyaPayServiceComponent startPay payPrice is null"
}
checkNotNull
(
payType
)
{
"MiyaPayServiceComponent startPay payType is null"
}
checkNotNull
(
goodsDetail
)
{
"MiyaPayServiceComponent startPay goodsDetail is null"
}
checkNotNull
(
signKey
)
{
"MiyaPayServiceComponent startPay signKey is null"
}
checkNotNull
(
saasid
)
{
"MiyaPayServiceComponent startPay saasid is null"
}
checkNotNull
(
marketid
)
{
"MiyaPayServiceComponent startPay marketid is null"
}
checkNotNull
(
posId
)
{
"MiyaPayServiceComponent startPay posId is null"
}
checkNotNull
(
cashierCode
)
{
"MiyaPayServiceComponent startPay cashierCode is null"
}
checkNotNull
(
version
)
{
"MiyaPayServiceComponent startPay version is null"
}
checkNotNull
(
orderNo
)
{
"MiyaPayServiceComponent startPay oderNo is null"
}
val
paramsMap
:
MutableMap
<
String
,
Any
?>
=
HashMap
(
14
,
1.0f
)
paramsMap
[
"baseUrl"
]
=
baseUrl
paramsMap
[
"signKey"
]
=
signKey
paramsMap
[
"saasId"
]
=
saasid
paramsMap
[
"marketId"
]
=
marketid
paramsMap
[
"posId"
]
=
posId
paramsMap
[
"cashierCode"
]
=
cashierCode
paramsMap
[
"version"
]
=
version
paramsMap
[
"token"
]
=
token
paramsMap
[
"goodsDetail"
]
=
goodsDetail
paramsMap
[
"payPrice"
]
=
payPrice
paramsMap
[
"payType"
]
=
payType
paramsMap
[
"orderNo"
]
=
orderNo
paramsMap
[
"appTag"
]
=
AppTagConstance
.
QINGTING_TYPE
paramsMap
[
"needRetryWhenNetworkError"
]
=
true
try
{
//发起付款
val
miYaMobilePayResult
=
MiYaPlatformPayService
.
getService
().
syncStartMiYaPay
(
paramsMap
)
if
(
miYaMobilePayResult
!=
null
&&
miYaMobilePayResult
.
resultCode
==
ResultBuilder
.
SUCCESS
)
{
return
miYaMobilePayResult
.
payServiceResponse
}
else
{
throw
RuntimeException
(
miYaMobilePayResult
!!
.
errorMsg
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
throw
RuntimeException
(
e
.
message
)
}
}
/**
* 退款功能
*/
fun
refundByOrderNo
(
params
:
Map
<
String
,
String
>):
PayServiceResponse
{
if
(
params
==
null
)
{
throw
RuntimeException
(
"MiyaPayServiceComponent refundByOrderNo params is null"
)
}
val
baseUrl
=
params
[
"baseUrl"
]
val
signKey
=
params
[
"signKey"
]
val
saasid
=
params
[
"saasid"
]
val
marketid
=
params
[
"marketid"
]
val
posId
=
params
[
"posId"
]
val
cashierCode
=
params
[
"cashierCode"
]
val
version
=
params
[
"version"
]
val
oriOrderNo
=
params
[
"oriOrderNo"
]
val
refundOrderNo
=
params
[
"refundOrderNo"
]
val
refundPrice
=
params
[
"refundPrice"
]
checkNotNull
(
baseUrl
)
{
"MiyaPayServiceComponent refundByOrderNo baseUrl is null"
}
checkNotNull
(
signKey
)
{
"MiyaPayServiceComponent refundByOrderNo signKey is null"
}
checkNotNull
(
saasid
)
{
"MiyaPayServiceComponent refundByOrderNo saasid is null"
}
checkNotNull
(
marketid
)
{
"MiyaPayServiceComponent refundByOrderNo marketid is null"
}
checkNotNull
(
posId
)
{
"MiyaPayServiceComponent refundByOrderNo posId is null"
}
checkNotNull
(
cashierCode
)
{
"MiyaPayServiceComponent refundByOrderNo cashierCode is null"
}
checkNotNull
(
version
)
{
"MiyaPayServiceComponent refundByOrderNo version is null"
}
checkNotNull
(
oriOrderNo
)
{
"MiyaPayServiceComponent refundByOrderNo oriOrderNo is null"
}
checkNotNull
(
refundOrderNo
)
{
"MiyaPayServiceComponent refundByOrderNo refundOrderNo is null"
}
checkNotNull
(
refundPrice
)
{
"MiyaPayServiceComponent refundByOrderNo refundPrice is null"
}
val
paramsMap
:
MutableMap
<
String
,
Any
>
=
HashMap
(
14
,
1.0f
)
paramsMap
[
"baseUrl"
]
=
baseUrl
paramsMap
[
"signKey"
]
=
signKey
paramsMap
[
"saasId"
]
=
saasid
paramsMap
[
"marketId"
]
=
marketid
paramsMap
[
"posId"
]
=
posId
paramsMap
[
"cashierCode"
]
=
cashierCode
paramsMap
[
"version"
]
=
version
paramsMap
[
"oriOrderNo"
]
=
oriOrderNo
paramsMap
[
"refundOrderNo"
]
=
refundOrderNo
paramsMap
[
"refundPrice"
]
=
refundPrice
try
{
//发起付款
val
miYaMobilePayResult
=
MiYaPlatformPayService
.
getService
()
.
syncRequestRefundOrderByOrderId
(
paramsMap
)
if
(
miYaMobilePayResult
!=
null
&&
miYaMobilePayResult
.
resultCode
==
ResultBuilder
.
SUCCESS
)
{
return
miYaMobilePayResult
.
payServiceResponse
}
else
{
throw
RuntimeException
(
miYaMobilePayResult
!!
.
errorMsg
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
throw
RuntimeException
(
e
.
message
)
}
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/service/PayRepository.kt
deleted
100644 → 0
View file @
14a115b3
package
com.miya.fastcashier.service
class
PayRepository
{
}
\ No newline at end of file
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