Просмотр исходного кода

1.修改购买问诊后发送患者信息逻辑

王鹏鹏 2 лет назад
Родитель
Сommit
90945676ac

+ 24 - 0
baselib/src/main/java/com/yingyangfly/baselib/bean/PurchaseConsultationEvent.java

@@ -0,0 +1,24 @@
+package com.yingyangfly.baselib.bean;
+
+/**
+ * 购买问诊服务成功
+ * @author 王鹏鹏
+ */
+public class PurchaseConsultationEvent {
+
+    private String doctorId;
+    private String patientInfo;
+
+    public PurchaseConsultationEvent(String doctorId, String patientInfo) {
+        this.doctorId = doctorId;
+        this.patientInfo = patientInfo;
+    }
+
+    public String getDoctorId() {
+        return doctorId;
+    }
+
+    public String getPatientInfo() {
+        return patientInfo;
+    }
+}

+ 0 - 1
baselib/src/main/java/com/yingyangfly/baselib/utils/CommonParam.kt

@@ -15,5 +15,4 @@ object CommonParam {
     val MOBILE = "mobile"
     val IDCARD = "idCard"
     val DOCTORAVATAR = "doctor_avatar"
-    val PATIENTINFO = "patientInfo"
 }

+ 5 - 0
baselib/src/main/java/com/yingyangfly/baselib/utils/RxBusCodes.kt

@@ -133,4 +133,9 @@ object RxBusCodes {
      * 已预约直播
      */
     const val APPOINTMENTLIVE = "appointmentLive"
+
+    /**
+     * 购买问诊服务成功
+     */
+    const val purchaseConsultationEvent = 9009
 }

+ 0 - 15
baselib/src/main/java/com/yingyangfly/baselib/utils/User.kt

@@ -223,19 +223,4 @@ object User {
             Preferences.getString(CommonParam.SNCODE)!!
         }
     }
-
-    /**
-     * 保存患者问诊信息
-     */
-    fun savePatientInfo(patientInfo: String) {
-        Preferences.put(CommonParam.PATIENTINFO, patientInfo)
-    }
-
-    fun getPatientInfo(): String {
-        return if (TextUtils.isEmpty(Preferences.getString(CommonParam.PATIENTINFO))) {
-            ""
-        } else {
-            Preferences.getString(CommonParam.PATIENTINFO)!!
-        }
-    }
 }

+ 10 - 6
healthconsultation/src/main/java/com/yingyang/healthconsultation/payment/PaymentActivity.kt

@@ -3,6 +3,7 @@ package com.yingyang.healthconsultation.payment
 import android.annotation.SuppressLint
 import android.os.Bundle
 import android.text.TextUtils
+import android.util.Log
 import android.view.MotionEvent
 import android.view.View
 import com.alibaba.android.arouter.facade.annotation.Route
@@ -11,6 +12,7 @@ import com.yingyang.healthconsultation.databinding.ActivityPaymentBinding
 import com.yingyang.healthconsultation.dialog.PaymentQrCodeDialog
 import com.yingyang.healthconsultation.entity.PurchaseConsultationBean
 import com.yingyang.healthconsultation.utils.CommonUtils
+import com.yingyangfly.baselib.bean.PurchaseConsultationEvent
 import com.yingyangfly.baselib.db.DoctorBean
 import com.yingyangfly.baselib.ext.getEndAnimation
 import com.yingyangfly.baselib.ext.getScaleAnimation
@@ -20,7 +22,7 @@ import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
 import com.yingyangfly.baselib.router.RouterUrlCommon
 import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
-import com.yingyangfly.baselib.utils.User
+import gorden.rxbus2.RxBus
 
 /**
  * 订单支付
@@ -45,14 +47,10 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
         purchaseConsultationBean =
             intent.getSerializableExtra("purchaseConsultationBean") as PurchaseConsultationBean
         super.onCreate(savedInstanceState)
+        Log.e("wpp", "患者信息--------------->  $patientInfo")
     }
 
     override fun initViews() {
-        if (TextUtils.isEmpty(patientInfo)) {
-            User.savePatientInfo("")
-        } else {
-            User.savePatientInfo(patientInfo)
-        }
         if (doctorDao != null) {
             doctorBean = doctorDao?.getDoctor(id)
             if (doctorBean != null) {
@@ -191,4 +189,10 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
             }
         }
     }
+
+    override fun onDestroy() {
+        RxBus.get()
+            .send(RxBusCodes.purchaseConsultationEvent, PurchaseConsultationEvent(id, patientInfo))
+        super.onDestroy()
+    }
 }

+ 31 - 31
home/src/main/java/com/yingyangfly/home/activity/HomeActivity.kt

@@ -15,6 +15,7 @@ import com.tencent.qcloud.tuikit.tuichat.bean.message.PatientStartConsultationBe
 import com.yingyang.home.R
 import com.yingyang.home.databinding.ActivityHomeBinding
 import com.yingyangfly.baselib.bean.MessageBean
+import com.yingyangfly.baselib.bean.PurchaseConsultationEvent
 import com.yingyangfly.baselib.bean.Record
 import com.yingyangfly.baselib.db.VoicePlayerBean
 import com.yingyangfly.baselib.dialog.TipsDialog
@@ -36,6 +37,8 @@ import com.yingyangfly.home.component.ShowProfessionalEvaluationViewComponent
 import com.yingyangfly.home.dialog.DownLoadAppFragment
 import com.yingyangfly.home.utils.AnimUtil
 import gorden.rxbus2.RxBus
+import gorden.rxbus2.Subscribe
+import gorden.rxbus2.ThreadMode
 
 
 /**
@@ -708,7 +711,6 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(),
                                                     messageBean
                                                 )
                                             }, 800)
-                                            sendPatientMessage(messageBean)
                                         } else {
                                             addAMessageData(messageBean)
                                         }
@@ -870,39 +872,37 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(),
     /**
      * 发送患者问诊消息
      */
-    private fun sendPatientMessage(messageBean: MessageBean) {
-        runOnUiThread {
-            val description = if (TextUtils.isEmpty(User.getPatientInfo())) {
-                ""
-            } else {
-                User.getPatientInfo()
-            }
-            val patientStartConsultationBean = PatientStartConsultationBean()
-            patientStartConsultationBean.businessID = "patient"
-            val data = GsonUtil.GsonString(patientStartConsultationBean)
-            val v2TIMMessage = V2TIMManager.getMessageManager()
-                .createCustomMessage(
-                    data.toByteArray(),
-                    description,
-                    data.toByteArray()
-                )
-            Log.e("wpp", "患者信息自定义消息" + GsonUtil.GsonString(v2TIMMessage))
-            V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, messageBean.sender, "",
-                V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, null, object :
-                    V2TIMSendCallback<V2TIMMessage> {
-                    override fun onSuccess(p0: V2TIMMessage?) {
-                        Log.e("wpp", "患者信息发送成功")
-                    }
+    @Subscribe(code = RxBusCodes.purchaseConsultationEvent, threadMode = ThreadMode.MAIN)
+    fun sendPatientMessage(event: PurchaseConsultationEvent) {
+        if (event != null) {
+            runOnUiThread {
+                val patientStartConsultationBean = PatientStartConsultationBean()
+                patientStartConsultationBean.businessID = "patient"
+                val data = GsonUtil.GsonString(patientStartConsultationBean)
+                val v2TIMMessage = V2TIMManager.getMessageManager()
+                    .createCustomMessage(
+                        data.toByteArray(),
+                        event.patientInfo,
+                        data.toByteArray()
+                    )
+                Log.e("wpp", "患者信息自定义消息" + GsonUtil.GsonString(v2TIMMessage))
+                V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, event.doctorId, "",
+                    V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, null, object :
+                        V2TIMSendCallback<V2TIMMessage> {
+                        override fun onSuccess(p0: V2TIMMessage?) {
+                            Log.e("wpp", "患者信息发送成功")
+                        }
 
-                    override fun onError(p0: Int, p1: String?) {
-                        Log.e("wpp", "患者信息发送失败,错误码:$p0  错误信息:$p1")
-                    }
+                        override fun onError(p0: Int, p1: String?) {
+                            Log.e("wpp", "患者信息发送失败,错误码:$p0  错误信息:$p1")
+                        }
 
-                    override fun onProgress(p0: Int) {
-                        Log.e("wpp", "患者信息发送中$p0")
-                    }
+                        override fun onProgress(p0: Int) {
+                            Log.e("wpp", "患者信息发送中$p0")
+                        }
 
-                })
+                    })
+            }
         }
     }
 }