Commit 444f32a4 by 宁斌

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	main/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
#	public-base/src/main/java/com/gingersoft/gsa/cloud/base/common/bean/OrderDetail.java
#	public-base/src/main/res/values/attrs.xml
parents ce264d78 2da52ed5
...@@ -219,7 +219,7 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow ...@@ -219,7 +219,7 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
private void stopDownDisposable() { private void stopDownDisposable() {
for (int i = 0; i < mDownDisposable.size(); i++) { for (int i = 0; i < mDownDisposable.size(); i++) {
if (mDownDisposable.get(i) != null && mDownDisposable.get(i).isDisposed() == false) if (mDownDisposable.get(i) != null && !mDownDisposable.get(i).isDisposed())
mDownDisposable.get(i).dispose(); mDownDisposable.get(i).dispose();
} }
mDownDisposable.clear(); mDownDisposable.clear();
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
android:id="@+id/RelativeLayout01" android:id="@+id/RelativeLayout01"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/theme_white_color"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:paddingLeft="15dp" android:paddingLeft="15dp"
......
...@@ -407,7 +407,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N ...@@ -407,7 +407,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.layout_login_out) { if (v.getId() == R.id.layout_login_out) {
//登出 //登出
CommonTipDialog.showWarnDialog(this,"確認登出?",null,null,"loginOut",null,null); mPresenter.loginOut();
} else if (v.getId() == R.id.iv_personal_center) { } else if (v.getId() == R.id.iv_personal_center) {
slideMenu.toggle(); slideMenu.toggle();
} else if (v.getId() == R.id.tv_restaurant_name) { } else if (v.getId() == R.id.tv_restaurant_name) {
......
...@@ -206,6 +206,7 @@ ...@@ -206,6 +206,7 @@
android:id="@+id/rv_staff_management" android:id="@+id/rv_staff_management"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft" android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" /> android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout> </LinearLayout>
...@@ -250,7 +251,7 @@ ...@@ -250,7 +251,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft" android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" /> android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout> </LinearLayout>
</com.lihang.ShadowLayout> </com.lihang.ShadowLayout>
......
...@@ -2,14 +2,15 @@ ...@@ -2,14 +2,15 @@
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20"
android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/iv_main_home_item_function_icon" android:id="@+id/iv_main_home_item_function_icon"
android:layout_width="@dimen/dp_32" android:layout_width="@dimen/dp_26"
android:layout_height="wrap_content" android:layout_height="@dimen/dp_26"
android:scaleType="fitCenter"
android:src="@drawable/ic_dining_table" /> android:src="@drawable/ic_dining_table" />
<TextView <TextView
......
apply from: rootProject.file('cc-settings.gradle') apply from: rootProject.file('cc-settings.gradle')
//apply plugin: 'com.android.application' apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig { defaultConfig {
if (project.ext.runAsApp) { if (project.ext.runAsApp) {
applicationId "com.gingersoft.gsa.other_order_mode" applicationId "com.gingersoft.gsa.other_order_mode"
...@@ -18,28 +22,32 @@ android { ...@@ -18,28 +22,32 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
javaCompileOptions { // javaCompileOptions {
annotationProcessorOptions { // annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()] // arguments = [AROUTER_MODULE_NAME: project.getName()]
includeCompileClasspath true // includeCompileClasspath true
} // }
} // }
} }
resourcePrefix "otherOrder" resourcePrefix "otherOrder"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding { dataBinding {
enabled = true enabled = true
} }
buildTypes {
compileOptions { debug {
sourceCompatibility JavaVersion.VERSION_1_8 buildConfigField "boolean", "LOG_DEBUG", "true"
targetCompatibility JavaVersion.VERSION_1_8 buildConfigField "boolean", "USE_CANARY", "true"
minifyEnabled false
proguardFiles 'proguard.cfg'
}
release {
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "USE_CANARY", "false"
minifyEnabled false
zipAlignEnabled false
proguardFiles 'proguard.cfg'
}
} }
} }
...@@ -57,7 +65,7 @@ dependencies { ...@@ -57,7 +65,7 @@ dependencies {
//协程 //协程
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' // implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' // implementation 'org.jetbrains.kotlinx:kotlinx-cor outines-android:1.1.1'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
//gson和scalars轉換器 //gson和scalars轉換器
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
...@@ -66,4 +74,8 @@ dependencies { ...@@ -66,4 +74,8 @@ dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
if (project.ext.runAsApp) {
addComponent 'print-module'
}
} }
...@@ -3,27 +3,12 @@ ...@@ -3,27 +3,12 @@
package="com.gingersoft.gsa.other_order_mode"> package="com.gingersoft.gsa.other_order_mode">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application <application>
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity <activity
android:name=".OtherOrderActivity" android:name=".ui.activity.OtherOrderActivity"
android:label="@string/app_name"> android:label="@string/app_name" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".service.GetInfoUpdateService" /> <service android:name=".service.GetInfoUpdateService" />
<activity android:name=".ui.activity.HistoryOrderActivity" />
<meta-data <meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" /> android:value="ConfigModule" />
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity <activity
android:name=".OtherOrderActivity" android:name=".ui.activity.OtherOrderActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<meta-data <meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" /> android:value="ConfigModule" />
<activity android:name=".ui.activity.HistoryOrderActivity" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import com.billy.cc.core.component.CC; ...@@ -4,6 +4,7 @@ import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent; import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity;
public class OtherOrderComponent implements IComponent { public class OtherOrderComponent implements IComponent {
......
package com.gingersoft.gsa.other_order_mode.data
import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
class HistoryOrderRepository private constructor(private val network: CoolWeatherNetwork) {
suspend fun getHistoryOrderList(restaurantId: String, status: String, pageIndex: String, pageSize: String, orderNo: String = "", phone: String = "") = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId)
.add("status", status)
.add("pageIndex", pageIndex)
.add("pageSize", pageSize)
.add("orderNo", orderNo)
.add("phone", phone)
.build()
val heWeather = network.getHistoryOrderList(requestBody)
heWeather
}
suspend fun getOrderInfo(orderId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.build()
val data = network.getOrderInfo(requestBody)
data
}
companion object {
private lateinit var instance: HistoryOrderRepository
fun getInstance(network: CoolWeatherNetwork): HistoryOrderRepository {
if (!::instance.isInitialized) {
synchronized(HistoryOrderRepository::class.java) {
if (!::instance.isInitialized) {
instance = HistoryOrderRepository(network)
}
}
}
return instance
}
}
}
\ No newline at end of file
...@@ -8,9 +8,9 @@ import okhttp3.FormBody ...@@ -8,9 +8,9 @@ import okhttp3.FormBody
class WeatherRepository private constructor(private val network: CoolWeatherNetwork) { class WeatherRepository private constructor(private val network: CoolWeatherNetwork) {
suspend fun requestOrderList(status: String, type: String, page: String, orderNo: String, phone: String) = withContext(Dispatchers.IO) { suspend fun requestOrderList(restaurantId: String, status: String, type: String, page: String, orderNo: String, phone: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("restaurantId", "26") .add("restaurantId", restaurantId)
.add("page", page) .add("page", page)
.add("status", status) .add("status", status)
.add("orderNo", orderNo) .add("orderNo", orderNo)
...@@ -21,9 +21,9 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -21,9 +21,9 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
heWeather heWeather
} }
suspend fun updateRestOpenStatus(state: Boolean) = withContext(Dispatchers.IO) { suspend fun updateRestOpenStatus(state: Boolean,restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("restId", "26") .add("restId", restaurantId)
.add("openStatus", if (state) "1" else "2") .add("openStatus", if (state) "1" else "2")
.build() .build()
val data = network.updateRestOpenStatus(requestBody) val data = network.updateRestOpenStatus(requestBody)
...@@ -39,7 +39,39 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -39,7 +39,39 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
data data
} }
suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.add("selfOrderId", selfOrderId)
.add("status", status.toString())
.add("mobile", mobile)
.add("sender", sender)
.add("isPush", isPush.toString())//1送貨 2確認訂單 結賬傳0
.add("orderType", orderType.toString())
.build()
val data = network.updateOrderStatus(requestBody)
data
}
suspend fun updateSelfOrderStatus(ids: String, status: String, restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("ids", ids)
.add("status", status)
.add("restaurantId", restaurantId)
.build()
val data = network.updateSelfOrderStatus(requestBody)
data
}
suspend fun getDeliveryInfo(restId: String, userId: String) = withContext(Dispatchers.IO){
val requestBody = FormBody.Builder()
.add("restId", restId)
.add("userId", userId)
.build()
val data = network.getDeliveryInfo(requestBody)
data
}
companion object { companion object {
private lateinit var instance: WeatherRepository private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class DeliveryBean(val data: List<Data>,
val success: Boolean,
val sysTime: Long) {
data class Data(
val id: Int,
val mobile: String,
val userName: String
)
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
/**
* 統一轉換類
*/
class FoodDetailsTranBean(var odsId: String?, var PRICE: String?,
var num: String?, var pid: String?,
var PRODUCT_NAME: String?) {
object FoodDetails{
fun getByPRODUCTNAMEBean(bean: OrderDetails.DataBean.PRODUCTNAMEBean): FoodDetailsTranBean {
return FoodDetailsTranBean(bean.odsId, bean.PRICE, bean.num, bean.pid, bean.PRODUCT_NAME)
}
fun getByChildBeanX(bean: OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX): FoodDetailsTranBean {
return FoodDetailsTranBean(bean.odsId, bean.PRICE, bean.num, bean.pid, bean.PRODUCT_NAME)
}
fun getByChildBean(bean: OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean): FoodDetailsTranBean {
return FoodDetailsTranBean(bean.odsId, bean.PRICE, bean.num, bean.pid, bean.PRODUCT_NAME)
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
class HistoryOrderBean {
/**
* success : true
* sysTime : 1587026350363
* data : [{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)15:30~16:00","PHONE":"18995813316","orderPayType":1,"ORDER_NO":"26201551325454427","STATUS":4,"PAY_AMOUNT":60,"Id":4350992,"CREATE_TIME":"Mar 27, 2020 3:23:45 PM","takeFoodCode":"0036","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)立即","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200681304157037","STATUS":4,"PAY_AMOUNT":60,"Id":4348789,"CREATE_TIME":"Mar 27, 2020 12:27:21 PM","takeFoodCode":"0035","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)立即","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200221368356841","STATUS":4,"PAY_AMOUNT":46,"Id":4348785,"CREATE_TIME":"Mar 27, 2020 12:27:07 PM","takeFoodCode":"0034","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:30~13:00","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26201371328853396","STATUS":4,"PAY_AMOUNT":44.9,"Id":4348780,"CREATE_TIME":"Mar 27, 2020 12:26:44 PM","takeFoodCode":"0033","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26203051303752129","STATUS":4,"PAY_AMOUNT":44.9,"Id":4348467,"CREATE_TIME":"Mar 27, 2020 11:47:59 AM","takeFoodCode":"0032","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"嘟嘟嘟1","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"15073379600","orderPayType":1,"ORDER_NO":"26201611370358516","STATUS":4,"PAY_AMOUNT":9999,"Id":4348434,"CREATE_TIME":"Mar 27, 2020 11:42:35 AM","takeFoodCode":"0031","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26201341375950995","STATUS":4,"PAY_AMOUNT":44.9,"Id":4348392,"CREATE_TIME":"Mar 27, 2020 11:35:35 AM","takeFoodCode":"0030","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"嘟嘟嘟1","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"15073379600","orderPayType":1,"ORDER_NO":"26200871312851078","STATUS":4,"PAY_AMOUNT":9999,"Id":4348287,"CREATE_TIME":"Mar 27, 2020 11:18:44 AM","takeFoodCode":"0029","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"嘟嘟嘟1","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"15073379600","orderPayType":1,"ORDER_NO":"26202231360959188","STATUS":4,"PAY_AMOUNT":9999,"Id":4348114,"CREATE_TIME":"Mar 27, 2020 10:43:53 AM","takeFoodCode":"0028","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200591367856595","STATUS":4,"PAY_AMOUNT":46,"Id":4347838,"CREATE_TIME":"Mar 27, 2020 9:51:13 AM","takeFoodCode":"0027","order_type":7,"RECEIVER":""},{"sumnum":1827}]
*/
private var success: Boolean = false
private var sysTime: Long = 0
private var data: ArrayList<DataBean>? = null
fun isSuccess(): Boolean {
return success
}
fun setSuccess(success: Boolean) {
this.success = success
}
fun getSysTime(): Long {
return sysTime
}
fun setSysTime(sysTime: Long) {
this.sysTime = sysTime
}
fun getData(): ArrayList<DataBean>? {
return data
}
fun setData(data: ArrayList<DataBean>) {
this.data = data
}
class DataBean {
/**
* MEMBER_NAME : Li
* ADDRESS_DETAIL :
* takeTime : 03-27 (週五)15:30~16:00
* PHONE : 18995813316
* orderPayType : 1
* ORDER_NO : 26201551325454427
* STATUS : 4
* PAY_AMOUNT : 60.0
* Id : 4350992
* CREATE_TIME : Mar 27, 2020 3:23:45 PM
* takeFoodCode : 0036
* order_type : 7
* RECEIVER :
* sumnum : 1827
*/
var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null
var takeTime: String? = null
var PHONE: String? = null
var orderPayType: Int = 0
var ORDER_NO: String? = null
var STATUS: Int = 0
var PAY_AMOUNT: Double = 0.toDouble()
var Id: Int = 0
var CREATE_TIME: String? = null
var takeFoodCode: String? = null
var order_type: Int = 0
var RECEIVER: String? = null
var sumnum: Int = 0
}
}
\ No newline at end of file
...@@ -59,7 +59,7 @@ class OrderList { ...@@ -59,7 +59,7 @@ class OrderList {
* Open_Status : 1 * Open_Status : 1
*/ */
var STATUS: Int = 0 var STATUS: Int = 0//0,1為待確認,2為製作中,3待取餐或送貨中
var MEMBER_NAME: String? = null var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null var ADDRESS_DETAIL: String? = null
var PAY_AMOUNT: Double = 0.toDouble() var PAY_AMOUNT: Double = 0.toDouble()
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
class UpdateOrderBean {
/**
* success : true
* sysTime : 1587095130753
* data : {"msgs":"確認成功!","code":"1","selfUrl":"https://hktest.ricepon.com:64377/member-web/api/h5/orderNotify?type=6&restaurantId=4413643","jsonObject":{"code":200,"data":{"code":200,"msg":"success","data":{"username":{},"password":{},"token":{},"type":6,"data":"修改訂單狀態消息,參數:restaurantId=4413643"}}}}
*/
var success: Boolean = false
var sysTime: Long = 0
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.network package com.gingersoft.gsa.other_order_mode.data.network
import android.util.Log
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
...@@ -21,18 +22,28 @@ class CoolWeatherNetwork { ...@@ -21,18 +22,28 @@ class CoolWeatherNetwork {
suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await() suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await()
suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await()
suspend fun updateSelfOrderStatus(requestBody: RequestBody) = orderService.updateSelfOrderStatus(requestBody).await()
suspend fun getDeliveryInfo(requestBody: RequestBody) = orderService.getDeliveryInfo(requestBody).await()
suspend fun getHistoryOrderList(requestBody: RequestBody) = orderService.getHistoryOrderList(requestBody).await()
private suspend fun <T> Call<T>.await(): T { private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation -> return suspendCoroutine { continuation ->
enqueue(object : Callback<T> { enqueue(object : Callback<T> {
override fun onFailure(call: Call<T>, t: Throwable) { override fun onFailure(call: Call<T>, t: Throwable) {
t.printStackTrace()
continuation.resumeWithException(t) continuation.resumeWithException(t)
} }
override fun onResponse(call: Call<T>, response: Response<T>) { override fun onResponse(call: Call<T>, response: Response<T>) {
val body = response.body() val body = response.body()
if (body != null) continuation.resume(body) Log.e("eee", "請求地址:" + response.raw().request().url())
else continuation.resumeWithException(RuntimeException("response body is null")) if (body != null) {
continuation.resume(body)
} else continuation.resumeWithException(RuntimeException("response body is null") as Throwable)
} }
}) })
} }
......
package com.gingersoft.gsa.other_order_mode.data.network.api package com.gingersoft.gsa.other_order_mode.data.network.api
import com.gingersoft.gsa.other_order_mode.data.model.bean.MessageBean import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderDetails import com.gingersoft.gsa.other_order_mode.data.model.bean.*
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
import retrofit2.http.Body import retrofit2.http.Body
...@@ -16,8 +15,18 @@ interface WeatherService { ...@@ -16,8 +15,18 @@ interface WeatherService {
@POST("wx/updateRestOpenStatus") @POST("wx/updateRestOpenStatus")
fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean> fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean>
@POST("wechat/findOrderDetails") @POST("wechat/findOrderDetails")
fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails> fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails>
@POST("wechat/updateOrderStatus")
fun updateOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
@POST("wechat/updateSelfOrderStatus")
fun updateSelfOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
@POST("wechat/findRestDelivery")
fun getDeliveryInfo(@Body requestBody: RequestBody): Call<DeliveryBean>
@POST("wechat/findHistoryOrderList")
fun getHistoryOrderList(@Body requestBody: RequestBody): Call<HistoryOrderBean>
} }
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.factory
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository
import com.gingersoft.gsa.other_order_mode.model.viewModel.HistoryOrderViewModel
class HistoryOrderModelFactory(private val repository: HistoryOrderRepository) : ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return HistoryOrderViewModel(repository) as T
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model package com.gingersoft.gsa.other_order_mode.model.factory
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
class WeatherModelFactory(private val repository: WeatherRepository) : ViewModelProvider.NewInstanceFactory() { class WeatherModelFactory(private val repository: WeatherRepository) : ViewModelProvider.NewInstanceFactory() {
...@@ -11,4 +11,5 @@ class WeatherModelFactory(private val repository: WeatherRepository) : ViewModel ...@@ -11,4 +11,5 @@ class WeatherModelFactory(private val repository: WeatherRepository) : ViewModel
override fun <T : ViewModel?> create(modelClass: Class<T>): T { override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return PageViewModel(repository) as T return PageViewModel(repository) as T
} }
} }
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.viewModel
import android.content.Context
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.HistoryOrderBean
import kotlinx.coroutines.launch
class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepository) : ViewModel() {
var data = MutableLiveData<HistoryOrderBean>()
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getHistoryOrderList(context: Context, pageIndex: String, orderNum: String = "", listener: (HistoryOrderBean) -> Unit) {
launch({
var phone = ""
var orderNumber = ""
if (orderNum.length <= 11) {
phone = orderNum
} else {
orderNumber = orderNum
}
historyOrderRepository.getHistoryOrderList(GsaCloudApplication.getRestaurantId(context).toString(), "4", pageIndex, "10", orderNumber, phone).apply {
this.getData()?.let {
if (it.size > 0) {
it.removeAt(it.size - 1)
}
if (pageIndex != "1") {
data.value!!.getData()!!.addAll(it)
data.value!!.setSuccess(true)
}
}
if (pageIndex == "1") {
data.value = this
}
listener.invoke(data.value!!)
}
}, {
//出錯
it.printStackTrace()
})
}
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getOrderInfo(orderId: String, listener: (OrderDetails) -> Unit) {
launch({
historyOrderRepository.getOrderInfo(orderId).apply {
listener.invoke(this)
}
}, {
//出錯
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
} catch (e: Throwable) {
error(e)
}
}
}
\ No newline at end of file
...@@ -6,21 +6,24 @@ import android.os.Binder ...@@ -6,21 +6,24 @@ import android.os.Binder
import android.os.Handler import android.os.Handler
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.google.gson.Gson
import okhttp3.* import okhttp3.*
import okio.ByteString import okio.ByteString
import org.json.JSONObject import org.json.JSONObject
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
class GetInfoUpdateService : Service() { class GetInfoUpdateService : Service() {
private val TAG = "eee"
/** /**
* 心跳检测时间 * 心跳检测时间
*/ */
private val HEART_BEAT_RATE = (15 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测 private val HEART_BEAT_RATE = (15 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测
private val WEBSOCKET_HOST_AND_PORT = "https://hktest.ricepon.com:64377/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号 private val WEBSOCKET_HOST_AND_PORT = "https://hktest.ricepon.com:64377/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号
private var mWebSocket: WebSocket? = null private var mWebSocket: WebSocket? = null
private val sendMsg = "{\"type\":1,\"token\":\"weixin_26_7xjmv0geea1111111111\"}"
var postCallBack: PostCallBack? = null var postCallBack: PostCallBack? = null
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?): IBinder? {
...@@ -28,18 +31,16 @@ class GetInfoUpdateService : Service() { ...@@ -28,18 +31,16 @@ class GetInfoUpdateService : Service() {
return MyBind() return MyBind()
} }
interface PostCallBack { interface PostCallBack {
fun callBack(type: Int) fun callBack(type: Int)
} }
inner class MyBind : Binder() { inner class MyBind : Binder() {
fun getService(): GetInfoUpdateService { fun getService(): GetInfoUpdateService {
return this@GetInfoUpdateService return this@GetInfoUpdateService
} }
fun setOnPostCallBack(postCallBack: PostCallBack?){ fun setOnPostCallBack(postCallBack: PostCallBack?) {
this@GetInfoUpdateService.postCallBack = postCallBack this@GetInfoUpdateService.postCallBack = postCallBack
} }
...@@ -68,9 +69,12 @@ class GetInfoUpdateService : Service() { ...@@ -68,9 +69,12 @@ class GetInfoUpdateService : Service() {
client.newWebSocket(request, object : WebSocketListener() { client.newWebSocket(request, object : WebSocketListener() {
override fun onOpen(webSocket: WebSocket?, response: Response?) {//开启长连接成功的回调 override fun onOpen(webSocket: WebSocket?, response: Response?) {//开启长连接成功的回调
super.onOpen(webSocket, response) super.onOpen(webSocket, response)
if (!this@GetInfoUpdateService.isDestroy) {
mWebSocket = webSocket mWebSocket = webSocket
webSocket!!.send(sendMsg) val token = "weixin_" + GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService) + "_" + getRandomString(24)
Log.e("aaa", "onOpen$sendMsg") Log.e(TAG, "token:$token")
webSocket!!.send(Gson().toJson(MsgBean(1, token)))
}
} }
override fun onMessage(webSocket: WebSocket?, text: String?) {//接收消息的回调 override fun onMessage(webSocket: WebSocket?, text: String?) {//接收消息的回调
...@@ -80,7 +84,7 @@ class GetInfoUpdateService : Service() { ...@@ -80,7 +84,7 @@ class GetInfoUpdateService : Service() {
postCallBack!!.callBack(json.optInt("type")) postCallBack!!.callBack(json.optInt("type"))
} }
//收到服务器端传过来的消息text //收到服务器端传过来的消息text
Log.e("aaa", "onMessage:" + text!!) Log.e(TAG, "onMessage:" + text!!)
} }
override fun onMessage(webSocket: WebSocket?, bytes: ByteString?) { override fun onMessage(webSocket: WebSocket?, bytes: ByteString?) {
...@@ -89,28 +93,48 @@ class GetInfoUpdateService : Service() { ...@@ -89,28 +93,48 @@ class GetInfoUpdateService : Service() {
if (postCallBack != null) { if (postCallBack != null) {
postCallBack!!.callBack(json.optInt("type")) postCallBack!!.callBack(json.optInt("type"))
} }
Log.e("aaa", "onMessage222:" + bytes!!) Log.e(TAG, "onMessage222:" + bytes!!)
} }
override fun onClosing(webSocket: WebSocket?, code: Int, reason: String?) { override fun onClosing(webSocket: WebSocket?, code: Int, reason: String?) {
super.onClosing(webSocket, code, reason) super.onClosing(webSocket, code, reason)
//連接斷開, //連接斷開,
Log.e("aaa", "onClosing") Log.e(TAG, "onClosing")
InitSocketThread().start()//创建一个新的连接 // InitSocketThread().start()//创建一个新的连接
} }
override fun onClosed(webSocket: WebSocket?, code: Int, reason: String?) { override fun onClosed(webSocket: WebSocket?, code: Int, reason: String?) {
super.onClosed(webSocket, code, reason) super.onClosed(webSocket, code, reason)
Log.e("aaa", "onClosed") Log.e(TAG, "onClosed")
webSocket?.cancel()
} }
override fun onFailure(webSocket: WebSocket?, t: Throwable?, response: Response?) {//长连接连接失败的回调 override fun onFailure(webSocket: WebSocket?, t: Throwable?, response: Response?) {//长连接连接失败的回调
super.onFailure(webSocket, t, response) super.onFailure(webSocket, t, response)
Log.e("aaa", "onFailure" + t!!.message) Log.e(TAG, "onFailure" + t!!.message)
if (!this@GetInfoUpdateService.isDestroy) {
Log.e(TAG, "沒銷毀")
initSocket()//创建一个新的连接
} else {
webSocket?.cancel()
client.dispatcher().cancelAll()
}
} }
}) })
client.dispatcher().executorService().shutdown() client.dispatcher().executorService().shutdown()
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测 // mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测
}
/*获取一条随机字符串*/
fun getRandomString(length: Int): String { //length表示生成字符串的长度
val base = "abcdefghijklmnopqrstuvwxyz0123456789" + System.currentTimeMillis()
val random = Random()
val sb = StringBuffer()
for (i in 0 until length) {
val number = random.nextInt(base.length)
sb.append(base[number])
}
return sb.toString()
} }
...@@ -122,8 +146,8 @@ class GetInfoUpdateService : Service() { ...@@ -122,8 +146,8 @@ class GetInfoUpdateService : Service() {
if (!isDestroy) { if (!isDestroy) {
if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) { if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态 val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态
Log.e("aaa", "連接狀態:$isSuccess") Log.e(TAG, "連接狀態:$isSuccess")
if (!isSuccess!!) {//长连接已断开 if (isSuccess != null && !isSuccess) {//长连接已断开
mHandler.removeCallbacks(this) mHandler.removeCallbacks(this)
mWebSocket?.cancel()//取消掉以前的长连接 mWebSocket?.cancel()//取消掉以前的长连接
InitSocketThread().start()//创建一个新的连接 InitSocketThread().start()//创建一个新的连接
...@@ -141,7 +165,7 @@ class GetInfoUpdateService : Service() { ...@@ -141,7 +165,7 @@ class GetInfoUpdateService : Service() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
Log.e("aaa", "onDestroy") Log.e(TAG, "onDestroy")
isDestroy = true isDestroy = true
if (mWebSocket != null) { if (mWebSocket != null) {
mWebSocket!!.send("-1") mWebSocket!!.send("-1")
...@@ -150,4 +174,5 @@ class GetInfoUpdateService : Service() { ...@@ -150,4 +174,5 @@ class GetInfoUpdateService : Service() {
} }
} }
class MsgBean(var type: Int, var token: String)
} }
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.activity
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.model.viewModel.HistoryOrderViewModel
import com.gingersoft.gsa.other_order_mode.ui.adapter.HistoryOrderAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import kotlinx.android.synthetic.main.activity_history_order.*
class HistoryOrderActivity : BaseActivity() {
private lateinit var mViewModel: HistoryOrderViewModel
private var mHistoryOrderAdapter: HistoryOrderAdapter? = null
private var pageIndex = 1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_history_order)
initAppTop()
rv_history_order.layoutManager = LinearLayoutManager(this)
initViewModel()
getHistoryInfo()
initSearch()
initRefresh()
}
private fun getHistoryInfo(page: Int = pageIndex, orderNum: String = "") {
showLoading()
mViewModel.getHistoryOrderList(this, page.toString(), orderNum) {
cancelDialogForLoading()
refresh_layout.setEnableLoadMore(it.getData() != null)
refresh_layout.finishRefresh()
refresh_layout.finishLoadMore()
if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.getData()?.let { it1 -> HistoryOrderAdapter(this@HistoryOrderActivity, it1) }
rv_history_order.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter {
showLoading()
mViewModel.getOrderInfo(it.Id.toString()) { it2 ->
cancelDialogForLoading()
if (it2.data != null && it2.data!!.isNotEmpty()) {
//顯示彈窗
OtherOrderUtils.showOrderDetailsDialog(this@HistoryOrderActivity, it2, it.STATUS, it.order_type, false) { _, _ ->
//確認訂單、指派送貨點擊事件
}
} else {
ToastUtils.show(this, "未查詢到訂單信息")
}
}
}
} else {
mHistoryOrderAdapter!!.data = it.getData()
mHistoryOrderAdapter!!.notifyDataSetChanged()
}
}
}
private fun initViewModel() {
mViewModel = ViewModelProvider(this, InjectorUtil.getHistoryModelFactory())[HistoryOrderViewModel::class.java]
}
private fun initSearch() {
iv_search_order.setOnClickListener {
//搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
getHistoryInfo(1, ed_order_num_search.text.toString())
} else {
ToastUtils.show(this@HistoryOrderActivity, "請輸入手機號或訂單號")
}
}
}
private fun initRefresh() {
//设置 Header 顏色
refresh_layout.setPrimaryColorsId(R.color.color_f0, R.color.color_66)
//下拉刷新,加載更多
refresh_layout.setOnRefreshListener {
pageIndex = 1
getHistoryInfo()
}
refresh_layout.setOnLoadMoreListener {
pageIndex++
getHistoryInfo()
}
}
private fun initAppTop() {
qm_other_order_bar.setTitle(R.string.history_order)
qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment