Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
3f8eda10
Commit
3f8eda10
authored
Feb 26, 2020
by
王宇航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
營業報表數據、打印回調
parent
7b954ba2
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
172 additions
and
36 deletions
+172
-36
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/contract/BusinessReportContract.java
+12
-2
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/BusinessReportModel.java
+15
-3
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/bean/HomeTurnoverBean.java
+12
-3
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/presenter/BusinessReportPresenter.java
+88
-0
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/fragment/BusinessReportFragment.java
+26
-11
print-module/src/main/java/com/joe/print/PrintComponent.java
+16
-5
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
+3
-0
table-mode/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderContentPresenter.java
+0
-12
No files found.
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/contract/BusinessReportContract.java
View file @
3f8eda10
package
com
.
gingersoft
.
gsa
.
cloud
.
main
.
mvp
.
contract
;
import
com.jess.arms.mvp.IView
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.BusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean
;
import
com.jess.arms.mvp.IModel
;
import
com.jess.arms.mvp.IView
;
import
java.util.List
;
import
java.util.Map
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
/**
...
...
@@ -19,11 +27,13 @@ import com.jess.arms.mvp.IModel;
public
interface
BusinessReportContract
{
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface
View
extends
IView
{
void
loadChart
(
Map
<
String
,
HomeTurnoverBean
.
DataBean
>
data
);
void
loadAdapter
(
List
<
BusinessBean
>
businessBeans
);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface
Model
extends
IModel
{
Observable
<
HomeTurnoverBean
>
getRestaurantBusinessInfo
(
RequestBody
requestBody
);
}
}
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/BusinessReportModel.java
View file @
3f8eda10
...
...
@@ -2,15 +2,19 @@ package com.gingersoft.gsa.cloud.main.mvp.model;
import
android.app.Application
;
import
com.gingersoft.gsa.cloud.main.mvp.contract.BusinessReportContract
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.service.HomeService
;
import
com.google.gson.Gson
;
import
com.jess.arms.di.scope.FragmentScope
;
import
com.jess.arms.integration.IRepositoryManager
;
import
com.jess.arms.mvp.BaseModel
;
import
com.jess.arms.di.scope.FragmentScope
;
import
javax.inject.Inject
;
import
com.gingersoft.gsa.cloud.main.mvp.contract.BusinessReportContract
;
import
io.reactivex.Observable
;
import
me.jessyan.retrofiturlmanager.RetrofitUrlManager
;
import
okhttp3.RequestBody
;
/**
...
...
@@ -43,4 +47,11 @@ public class BusinessReportModel extends BaseModel implements BusinessReportCont
this
.
mGson
=
null
;
this
.
mApplication
=
null
;
}
@Override
public
Observable
<
HomeTurnoverBean
>
getRestaurantBusinessInfo
(
RequestBody
requestBody
)
{
RetrofitUrlManager
.
getInstance
().
putDomain
(
"common"
,
"http://a.ricepon.com:61177/member-web/api/"
);
return
mRepositoryManager
.
obtainRetrofitService
(
HomeService
.
class
)
.
getRestaurantReport
(
requestBody
);
}
}
\ No newline at end of file
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/bean/HomeTurnoverBean.java
View file @
3f8eda10
...
...
@@ -56,10 +56,10 @@ public class HomeTurnoverBean {
* billNum_skyOder : 1.00
* billPrice_table : 2623.00
* billPrice_skyOder : 111.00
* billNum_table : 30.00
* billNum_Takeout
* billNum_table : 30.00
堂食賬單數
* billNum_Takeout
外賣賬單數
* CreditCardNum
* billPrice_Takeout
* billPrice_Takeout
外賣賬單金額
* TipsNum
* servicecharge : 72.00 服務費
*/
...
...
@@ -76,6 +76,7 @@ public class HomeTurnoverBean {
private
String
billPrice_skyOder
;
private
String
billNum_table
;
private
String
servicecharge
;
private
String
billNum_Takeout
;
public
String
getBusiness_amount
()
{
return
Business_amount
;
...
...
@@ -180,5 +181,13 @@ public class HomeTurnoverBean {
public
void
setServicecharge
(
String
servicecharge
)
{
this
.
servicecharge
=
servicecharge
;
}
public
String
getBillNum_Takeout
()
{
return
billNum_Takeout
;
}
public
void
setBillNum_Takeout
(
String
billNum_Takeout
)
{
this
.
billNum_Takeout
=
billNum_Takeout
;
}
}
}
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/presenter/BusinessReportPresenter.java
View file @
3f8eda10
...
...
@@ -2,15 +2,31 @@ package com.gingersoft.gsa.cloud.main.mvp.presenter;
import
android.app.Application
;
import
com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.main.mvp.contract.BusinessReportContract
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.BusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean
;
import
com.jess.arms.di.scope.FragmentScope
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.mvp.BasePresenter
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
javax.inject.Inject
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.schedulers.Schedulers
;
import
me.jessyan.retrofiturlmanager.RetrofitUrlManager
;
import
me.jessyan.rxerrorhandler.core.RxErrorHandler
;
import
me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
;
import
okhttp3.FormBody
;
import
okhttp3.RequestBody
;
/**
...
...
@@ -49,4 +65,76 @@ public class BusinessReportPresenter extends BasePresenter<BusinessReportContrac
this
.
mImageLoader
=
null
;
this
.
mApplication
=
null
;
}
public
void
getRestaurantBusinessInfo
(
String
restaurantId
,
String
startTime
,
String
endTime
)
{
RequestBody
requestBody
=
new
FormBody
.
Builder
()
.
add
(
"restaurantId"
,
restaurantId
)
.
add
(
"startTime"
,
startTime
)
//TimeUtils.getYesterdayTime(TimeUtils.DATE_FORMAT_DATE)
.
add
(
"endTime"
,
endTime
)
//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
.
build
();
mModel
.
getRestaurantBusinessInfo
(
requestBody
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
""
))
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
.
subscribe
(
new
ErrorHandleSubscriber
<
HomeTurnoverBean
>(
mErrorHandler
)
{
@Override
public
void
onNext
(
@NonNull
HomeTurnoverBean
info
)
{
if
(
info
!=
null
&&
info
.
isSuccess
())
{
if
(
info
.
getData
()
!=
null
)
{
mRootView
.
loadChart
(
info
.
getData
());
loadAdapterInfo
(
info
.
getData
());
}
}
else
{
mRootView
.
showMessage
(
"營業信息獲取失敗"
);
}
}
@Override
public
void
onComplete
()
{
super
.
onComplete
();
RetrofitUrlManager
.
getInstance
().
putDomain
(
"common"
,
HttpsConstans
.
ROOT_SERVER_ADDRESS_FORMAL
);
}
@Override
public
void
onError
(
Throwable
t
)
{
super
.
onError
(
t
);
RetrofitUrlManager
.
getInstance
().
putDomain
(
"common"
,
HttpsConstans
.
ROOT_SERVER_ADDRESS_FORMAL
);
}
});
}
private
String
[]
itemNames
=
new
String
[]{
"項目銷售總金額"
,
"折扣"
,
"服務費"
,
"賬單數"
,
"簽單"
,
"營業金額淨值"
,
"貼士"
,
"堂食總數"
,
"外賣總數"
,
"單數"
,
"平均每單"
,
"人數"
,
"平均每人"
};
private
void
loadAdapterInfo
(
Map
<
String
,
HomeTurnoverBean
.
DataBean
>
data
)
{
HomeTurnoverBean
.
DataBean
dataBean
=
data
.
get
(
TimeUtils
.
getOldDate
(
0
));
//底部信息默認顯示今天的數據
List
<
BusinessBean
>
businessBeans
=
new
ArrayList
<>();
if
(
dataBean
!=
null
)
{
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
0
],
dataBean
.
getBusiness_amount
()));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
1
],
dataBean
.
getDiscount
()));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
2
],
dataBean
.
getServicecharge
()));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
3
],
dataBean
.
getNumber_bill
()));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
4
],
"簽單"
));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
5
],
"營業金額淨值"
));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
6
],
"貼士"
));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
7
],
dataBean
.
getBillNum_table
()));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
8
],
dataBean
.
getBillNum_Takeout
()));
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
9
],
"單數"
));
float
averageBill
=
Float
.
parseFloat
(
dataBean
.
getBusiness_amount
())
/
Float
.
parseFloat
(
dataBean
.
getNumber_bill
());
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
10
],
averageBill
+
""
));
//"平均每單"
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
11
],
dataBean
.
getPeople
()));
//人數
float
averageConsumption
=
Float
.
parseFloat
(
dataBean
.
getBusiness_amount
())
/
Float
.
parseFloat
(
dataBean
.
getPeople
());
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
12
],
averageConsumption
+
""
));
//平均每人
}
else
{
//為空,全部顯示0
for
(
int
i
=
0
;
i
<
itemNames
.
length
;
i
++)
{
businessBeans
.
add
(
new
BusinessBean
(
itemNames
[
i
],
"0"
));
}
}
mRootView
.
loadAdapter
(
businessBeans
);
}
}
main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/fragment/BusinessReportFragment.java
View file @
3f8eda10
...
...
@@ -19,12 +19,14 @@ import com.daivd.chart.data.style.FontStyle;
import
com.daivd.chart.data.style.LineStyle
;
import
com.daivd.chart.data.style.PointStyle
;
import
com.daivd.chart.provider.component.point.Point
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.main.R
;
import
com.gingersoft.gsa.cloud.main.R2
;
import
com.gingersoft.gsa.cloud.main.di.component.DaggerBusinessReportComponent
;
import
com.gingersoft.gsa.cloud.main.mvp.contract.BusinessReportContract
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.BusinessBean
;
import
com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean
;
import
com.gingersoft.gsa.cloud.main.mvp.presenter.BusinessReportPresenter
;
import
com.gingersoft.gsa.cloud.main.mvp.ui.adapter.BusinessInfoAdapter
;
import
com.gingersoft.gsa.cloud.main.mvp.ui.view.CustomMarkView
;
...
...
@@ -34,6 +36,7 @@ import com.jess.arms.utils.ArmsUtils;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
...
...
@@ -88,17 +91,8 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
@Override
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
loadReport
();
List
<
BusinessBean
>
businessBeans
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
businessBeans
.
add
(
new
BusinessBean
(
"項目總金額"
,
"10000.0"
));
}
mBusinessDetails
.
setLayoutManager
(
new
GridLayoutManager
(
mContext
,
3
)
{
@Override
public
boolean
canScrollVertically
()
{
return
false
;
}
});
mBusinessDetails
.
setAdapter
(
new
BusinessInfoAdapter
(
businessBeans
));
//獲取一段時間內的營業信息,默認獲取七天的數據
mPresenter
.
getRestaurantBusinessInfo
(
"26"
,
TimeUtils
.
getOldDate
(-
7
),
TimeUtils
.
getCurrentTimeInString
(
TimeUtils
.
DATE_FORMAT_DATE
));
}
private
void
loadReport
()
{
...
...
@@ -287,4 +281,25 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
public
void
killMyself
()
{
}
/**
* 加載營業信息圖表
*/
@Override
public
void
loadChart
(
Map
<
String
,
HomeTurnoverBean
.
DataBean
>
data
)
{
}
@Override
public
void
loadAdapter
(
List
<
BusinessBean
>
businessBeans
)
{
mBusinessDetails
.
setLayoutManager
(
new
GridLayoutManager
(
mContext
,
3
)
{
@Override
public
boolean
canScrollVertically
()
{
return
false
;
}
});
mBusinessDetails
.
setAdapter
(
new
BusinessInfoAdapter
(
businessBeans
));
}
}
print-module/src/main/java/com/joe/print/PrintComponent.java
View file @
3f8eda10
...
...
@@ -3,7 +3,6 @@ package com.joe.print;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
import
com.billy.cc.core.component.CC
;
import
com.billy.cc.core.component.CCResult
;
...
...
@@ -28,6 +27,7 @@ public class PrintComponent implements IComponent {
* 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity
*
* @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
...
...
@@ -52,8 +52,7 @@ public class PrintComponent implements IComponent {
case
"print_order"
:
return
printOrderInfo
(
cc
);
case
"printActivity"
:
CCUtil
.
navigateTo
(
cc
,
PrintActivity
.
class
);
break
;
return
print
(
cc
);
default
:
// cc.callAsync(new IComponentCallback() {
// @Override
...
...
@@ -94,7 +93,7 @@ public class PrintComponent implements IComponent {
CC
.
sendCCResult
(
cc
.
getCallId
(),
CCResult
.
success
());
}
private
boolean
printOrderInfo
(
CC
cc
){
private
boolean
printOrderInfo
(
CC
cc
)
{
Context
context
=
cc
.
getContext
();
Intent
intent
=
new
Intent
(
context
,
OldPrintActivity
.
class
);
if
(!(
context
instanceof
Activity
))
{
...
...
@@ -106,8 +105,20 @@ public class PrintComponent implements IComponent {
context
.
startActivity
(
intent
);
//返回true,不立即调用CC.sendCCResult
return
true
;
}
private
boolean
print
(
CC
cc
)
{
Context
context
=
cc
.
getContext
();
Intent
intent
=
new
Intent
(
context
,
PrintActivity
.
class
);
if
(!(
context
instanceof
Activity
))
{
//调用方没有设置context或app间组件跳转,context为application
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
}
//将cc的callId传给Activity,登录完成后通过这个callId来回传结果
intent
.
putExtra
(
"callId"
,
cc
.
getCallId
());
context
.
startActivity
(
intent
);
//返回true,不立即调用CC.sendCCResult
return
true
;
}
}
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
View file @
3f8eda10
...
...
@@ -104,6 +104,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
Log
.
e
(
"bbb"
,
"打印類型:"
+
type
);
List
<
Bitmap
>
bitmaps
=
PrintUtils
.
getPrintBitmap
(
mContext
,
type
,
500
);
if
(
bitmaps
.
size
()
<=
0
)
{
printFile
();
finish
();
return
;
}
...
...
@@ -193,12 +194,14 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
*/
private
void
printFile
()
{
CC
.
sendCCResult
(
getIntent
().
getStringExtra
(
"callId"
),
CCResult
.
error
(
"print error"
));
finish
();
}
/**
* 打印成功
*/
private
void
printSuccess
()
{
CC
.
sendCCResult
(
getIntent
().
getStringExtra
(
"callId"
),
CCResult
.
success
());
finish
();
}
//初始化打印內容
public
Bitmap
initPrintBitmap
(
int
width
)
{
...
...
table-mode/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/OrderContentPresenter.java
View file @
3f8eda10
...
...
@@ -109,17 +109,6 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
break
;
case
1
:
printOrder
(
OpenTableManage
.
getDefault
().
getTableBean
().
getId
());
// printOrder(OpenTableContract.getDefault().getTableBean().getId());
CC
.
obtainBuilder
(
"Component.Print"
)
.
setActionName
(
"printActivity"
)
.
addParam
(
"type"
,
1
)
//印單
.
build
()
.
callAsync
((
cc
,
result
)
->
{
if
(
result
.
isSuccess
())
{
//打印成功
mRootView
.
printSuccess
();
}
});
//打印
break
;
case
2
:
...
...
@@ -223,7 +212,6 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
// });
}
public
void
printOrder
(
int
tableId
)
{
RequestBody
requestBody
=
new
FormBody
.
Builder
()
.
add
(
"tableId"
,
tableId
+
""
)
.
build
();
...
...
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