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
242c34f2
Commit
242c34f2
authored
Jan 14, 2022
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
c4e87076
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
87 additions
and
117 deletions
+87
-117
build.gradle
app/build.gradle
+1
-1
miya-print-1.0.22.aar
app/libs/miya-print-1.0.22.aar
+0
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
BaseApplication.kt
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
+12
-0
CodeScanDialog.java
...main/java/com/miya/fastcashier/dialog/CodeScanDialog.java
+0
-72
PayRepository.kt
...ain/java/com/miya/fastcashier/repository/PayRepository.kt
+1
-1
AccountService.kt
.../main/java/com/miya/fastcashier/service/AccountService.kt
+18
-0
PrintService.kt
...rc/main/java/com/miya/fastcashier/service/PrintService.kt
+18
-0
MainActivity.kt
...rc/main/java/com/miya/fastcashier/ui/main/MainActivity.kt
+3
-10
MainViewModel.kt
...main/java/com/miya/fastcashier/viewmodel/MainViewModel.kt
+33
-12
dialog_code_scan.xml
app/src/main/res/layout/dialog_code_scan.xml
+0
-21
No files found.
app/build.gradle
View file @
242c34f2
...
...
@@ -37,7 +37,6 @@ android {
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
// implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
'androidx.core:core-ktx:1.3.1'
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'com.google.android.material:material:1.2.1'
...
...
@@ -59,4 +58,5 @@ dependencies {
implementation
'com.alibaba:fastjson:1.2.8'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
implementation
files
(
'libs/miya-print-1.0.22.aar'
)
}
\ No newline at end of file
app/libs/miya-print-1.0.22.aar
0 → 100644
View file @
242c34f2
File added
app/src/main/AndroidManifest.xml
View file @
242c34f2
...
...
@@ -12,6 +12,7 @@
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:name=
".BaseApplication"
android:theme=
"@style/Theme.MiYaFastCashier"
>
<activity
...
...
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
0 → 100644
View file @
242c34f2
package
com.miya.fastcashier
import
android.app.Application
import
com.miya.print.PrinterManager
class
BaseApplication
:
Application
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
PrinterManager
.
instance
.
init
(
this
)
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/dialog/CodeScanDialog.java
deleted
100644 → 0
View file @
c4e87076
package
com
.
miya
.
fastcashier
.
dialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.constraintlayout.widget.Group
;
import
com.miya.fastcashier.R
;
import
com.miya.fastcashier.utils.ScanGunKeyEventHelper
;
public
class
CodeScanDialog
extends
Dialog
implements
DialogInterface
.
OnDismissListener
{
private
final
ScanGunKeyEventHelper
scanGunKeyEventHelper
;
private
OnScanListener
listener
;
public
CodeScanDialog
(
Context
context
)
{
super
(
context
);
initWindow
();
setContentView
(
R
.
layout
.
dialog_code_scan
);
setCanceledOnTouchOutside
(
false
);
setOnDismissListener
(
this
);
scanGunKeyEventHelper
=
new
ScanGunKeyEventHelper
();
scanGunKeyEventHelper
.
setOnBarCodeCatchListener
(
barcode
->
{
if
(
listener
!=
null
)
{
listener
.
onScan
(
barcode
);
}
});
}
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
event
)
{
scanGunKeyEventHelper
.
analysisKeyEvent
(
event
);
return
true
;
}
private
void
initWindow
()
{
Window
win
=
this
.
getWindow
();
win
.
getDecorView
().
setPadding
(
0
,
0
,
0
,
0
);
WindowManager
.
LayoutParams
lp
=
win
.
getAttributes
();
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
;
lp
.
height
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
;
lp
.
gravity
=
Gravity
.
BOTTOM
;
lp
.
windowAnimations
=
R
.
style
.
BottomInAndOutStyle
;
win
.
setAttributes
(
lp
);
win
.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
);
}
public
void
setOnScanListener
(
OnScanListener
listener
)
{
this
.
listener
=
listener
;
}
@Override
public
void
onDismiss
(
DialogInterface
dialogInterface
)
{
if
(
scanGunKeyEventHelper
!=
null
)
{
scanGunKeyEventHelper
.
onDestroy
();
}
}
public
interface
OnScanListener
{
void
onScan
(
String
result
);
}
}
app/src/main/java/com/miya/fastcashier/repository/PayRepository.kt
View file @
242c34f2
...
...
@@ -12,7 +12,7 @@ import java.util.HashMap
/**
* 提供支付、退款的功能
*/
class
PayRepository
{
object
PayRepository
{
/**
* 支付功能
...
...
app/src/main/java/com/miya/fastcashier/service/AccountService.kt
0 → 100644
View file @
242c34f2
package
com.miya.fastcashier.service
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
object
AccountService
{
private
var
selfCashierAccountInfo
:
SelfCashierAccountInfo
?
=
null
;
fun
setAccountInfo
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
){
this
.
selfCashierAccountInfo
=
selfCashierAccountInfo
}
fun
getAccountInfo
():
SelfCashierAccountInfo
?
{
return
selfCashierAccountInfo
;
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/service/PrintService.kt
0 → 100644
View file @
242c34f2
package
com.miya.fastcashier.service
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import
com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
object
PrintService
{
/**
* 退款
*/
fun
refundPrint
(
selfCashierAccountInfo
:
SelfCashierAccountInfo
,
payServiceResponse
:
PayServiceResponse
){
if
(
true
){
throw
RuntimeException
(
"退款异常"
);
}
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/ui/main/MainActivity.kt
View file @
242c34f2
...
...
@@ -4,22 +4,15 @@ import androidx.appcompat.app.AppCompatActivity
import
android.os.Bundle
import
androidx.lifecycle.ViewModelProvider
import
com.miya.fastcashier.R
import
com.miya.fastcashier.dialog.CodeScanDialog
import
com.miya.fastcashier.viewmodel.PayViewModel
import
com.miya.fastcashier.viewmodel.MainViewModel
class
MainActivity
:
AppCompatActivity
()
{
private
lateinit
var
viewModel
:
PayViewModel
private
lateinit
var
scanDialog
:
CodeScanDialog
private
lateinit
var
viewModel
:
MainViewModel
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
viewModel
=
ViewModelProvider
(
this
).
get
(
PayViewModel
::
class
.
java
)
scanDialog
=
CodeScanDialog
(
this
);
scanDialog
.
setOnScanListener
{
viewModel
.
}
viewModel
=
ViewModelProvider
(
this
).
get
(
MainViewModel
::
class
.
java
)
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/viewmodel/MainViewModel.kt
View file @
242c34f2
package
com.miya.fastcashier.viewmodel
import
androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.viewModelScope
import
com.miya.fastcashier.beans.LoginRequest
import
com.miya.fastcashier.beans.SelfCashierAccountInfo
import
com.miya.fastcashier.repository.PayRepository
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.LoginService
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.async
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
com.miya.fastcashier.service.PrintService
import
com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import
kotlinx.coroutines.*
class
PayViewModel
:
ViewModel
()
{
fun
refund
(
userName
:
String
,
passWord
:
String
)
{
viewModelScope
.
launch
{
val
refundResult
=
async
(
Dispatchers
.
IO
)
{
booksRepository
.
getAllBooks
()
}
class
MainViewModel
:
ViewModel
()
{
refundResult
,
val
refundLiveData
:
MutableLiveData
<
Result
<
PayRepository
>>
=
MutableLiveData
()
/**
* oriOrderNo 原订单号
* refundOrderNo 退款订单号
* refundPrice 退款金额
*/
fun
refund
(
oriOrderNo
:
String
,
refundOrderNo
:
String
,
refundPrice
:
String
)
=
runBlocking
{
val
refundParams
=
HashMap
<
String
,
String
>()
refundParams
[
"oriOrderNo"
]
=
oriOrderNo
;
refundParams
[
"refundOrderNo"
]
=
refundOrderNo
;
refundParams
[
"refundPrice"
]
=
refundPrice
;
val
refundResult
=
async
(
Dispatchers
.
IO
)
{
PayRepository
.
refundByOrderNo
(
refundParams
)
}
}
val
printResult
=
async
(
Dispatchers
.
IO
)
{
AccountService
.
getAccountInfo
()
?.
let
{
PrintService
.
refundPrint
(
it
,
refundResult
.
await
())
}
}
printResult
.
await
()
refundLiveData
.
value
=
Result
.
success
()
}
}
\ No newline at end of file
app/src/main/res/layout/dialog_code_scan.xml
deleted
100644 → 0
View file @
c4e87076
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<TextView
android:id=
"@+id/tvRefund"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"请扫码退款"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.498"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.258"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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