Commit 923450d3 by 万齐军

ConfideWebServiceImpl重构

parent f65fca61
...@@ -11,13 +11,14 @@ import com.ydl.audioim.IntentConstants ...@@ -11,13 +11,14 @@ import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager import com.ydl.audioim.YDLavManager
import com.ydl.audioim.bean.ExpertInfoBean import com.ydl.audioim.bean.ExpertInfoBean
import com.ydl.audioim.widget.AxbConfirmDialog import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConnectParamJava import com.ydl.confide.home.bean.ConnectParamJava
import com.ydl.confide.home.constants.FinalString import com.ydl.confide.home.constants.FinalString
import com.ydl.confide.home.http.ConfideHomeDataManager import com.ydl.confide.home.http.ConfideHomeDataManager
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.webview.TellData import com.ydl.webview.TellData
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.ui.Loading import com.ydl.ydlcommon.ui.Loading
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.dialog.CommonDialog import com.ydl.ydlcommon.view.dialog.CommonDialog
...@@ -37,7 +38,7 @@ import io.reactivex.schedulers.Schedulers ...@@ -37,7 +38,7 @@ import io.reactivex.schedulers.Schedulers
class ConfideWebServiceImpl { class ConfideWebServiceImpl {
//倾诉支付弹窗 //倾诉支付弹窗
fun confidePayDialog( private fun confidePayDialog(
id: Int?, id: Int?,
type: Int?, type: Int?,
activity: Activity, activity: Activity,
...@@ -64,78 +65,70 @@ class ConfideWebServiceImpl { ...@@ -64,78 +65,70 @@ class ConfideWebServiceImpl {
.show(confidePay) .show(confidePay)
} }
//java版axb和声网接口 private fun needPay(
@SuppressLint("CheckResult")
fun connectionJava(
id: Int, id: Int,
type: Int, type: Int,
activity: Activity, activity: Activity,
tellData: TellData?, callType: String?,
callType: String? data: ConfideConnectResponse?
) { ) {
ConfideHomeDataManager.getHttp()
.connectionJava(ConnectParamJava("" + id, "" + type, callType))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if ("200" == it.code) {
if (it.data?.dialDetail?.dialStatus != null) {
if (100007 == it.data?.dialDetail?.dialStatus) {
//支付弹窗 //支付弹窗
//参数转换 //参数转换
var confidePay = ConfidePayParams( val confidePay = ConfidePayParams(
it.data?.payTitle ?: "倾诉服务", data?.payTitle ?: "倾诉服务",
it.data?.listenOrderPrice, data?.listenOrderPrice,
it.data?.coupon?.couponMoney ?: 0.00, data?.coupon?.couponMoney ?: 0.00,
it.data?.userBaseInfoRespDto?.availableMoney ?: 0.00, data?.userBaseInfoRespDto?.availableMoney ?: 0.00,
it.data?.payId ?: "", data?.payId ?: "",
"", "",
"" ""
) )
confidePayDialog(id, type, activity, confidePay, callType) confidePayDialog(id, type, activity, confidePay, callType)
} else if (100008 == it.data?.dialDetail?.dialStatus) { }
private fun needBindPhone(activity: Activity) {
CommonDialog(activity) CommonDialog(activity)
.setCancelAble(false) .setCancelAble(false)
.setMessage(FinalString.TEL_BINDPHONE) .setMessage(FinalString.TEL_BINDPHONE)
.setLeftOnclick("忍痛放弃", null) .setLeftOnclick("忍痛放弃", null)
.setRightClick("果断绑定") { view -> .setRightClick("果断绑定") {
try { findRouteService(IUserService::class.java).wxBindToInputhonePage(activity)
ModularServiceManager.provide(IUserService::class.java)
.wxBindToInputhonePage(activity)
} catch (e: Exception) {
}
} }
.show() .show()
} else if (0 == it.data?.dialDetail?.dialStatus) { }
//连接成功
if (it.data?.dialDetail?.callConnectType ?: -1 == 3) { private fun agora(
//声网 id: Int,
it.data?.dialDetail?.agoraExpertInfo ?: return@subscribe type: Int,
activity: Context,
callType: String?,
tellData: TellData?,
data: ConfideConnectResponse?){
val expertInfo = data?.dialDetail?.agoraExpertInfo ?: return
if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线 if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线
ToastUtil.toastShort("网络通话错误代码001") ToastUtil.toastShort("网络通话错误代码001")
return@subscribe return
} }
callAgora( callAgora(
activity, activity,
id, id,
it.data!!.dialDetail!!.agoraExpertInfo!!, expertInfo,
it.data.callId ?: "0", data.callId ?: "0",
it.data.listenOrderId ?: 0L, data.listenOrderId ?: 0L,
tellData, tellData,
it.data.isShowAxb, data.isShowAxb,
it.data?.dialDetail?.dialStatus.toString() data.dialDetail?.dialStatus.toString()
) )
} else { }
//axb
private fun axb(activity: Activity,phone:String?){
if(phone.isNullOrEmpty())return
val dialog = AxbConfirmDialog( val dialog = AxbConfirmDialog(
activity, activity,
1, 1,
object : AxbConfirmDialog.OnClickEnsureListener { object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() { override fun onClickEnsure() {
var phoneIntent = Intent( val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:${phone}"))
Intent.ACTION_DIAL,
Uri.parse("tel:${it.data?.dialDetail?.phoneNu ?: 0}")
)
activity.startActivity(phoneIntent) activity.startActivity(phoneIntent)
} }
...@@ -145,12 +138,40 @@ class ConfideWebServiceImpl { ...@@ -145,12 +138,40 @@ class ConfideWebServiceImpl {
}) })
dialog.show() dialog.show()
} }
//java版axb和声网接口
@SuppressLint("CheckResult")
fun connectionJava(
id: Int,
type: Int,
activity: Activity,
tellData: TellData?,
callType: String?
) {
ConfideHomeDataManager.getHttp()
.connectionJava(ConnectParamJava("" + id, "" + type, callType))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if ("200" == it.code) {
when (it.data?.dialDetail?.dialStatus) {
0 -> {//连接成功
if (it.data?.dialDetail?.callConnectType == 3) {
agora(id, type, activity, callType, tellData, it.data)
} else { } else {
ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败") axb(activity, it.data?.dialDetail?.phoneNu)
} }
} else { }
100007 -> {
needPay(id, type, activity, callType, it.data)
}
100008 -> {
needBindPhone(activity)
}
else -> {
ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败") ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败")
} }
}
} else { } else {
ToastHelper.show(it.msg) ToastHelper.show(it.msg)
} }
...@@ -173,46 +194,24 @@ class ConfideWebServiceImpl { ...@@ -173,46 +194,24 @@ class ConfideWebServiceImpl {
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
Loading.close() Loading.close()
if ("200" == it.code) { if ("200" == it.code) {
if (it.data?.dialDetail?.dialStatus != null) { when (it.data?.dialDetail?.dialStatus) {
if (100007 == it.data?.dialDetail?.dialStatus) { 0 -> {//连接成功
//支付弹窗 if (it.data?.dialDetail?.callConnectType == 3) {
agora(id, type, activity, callType, null, it.data)
}
}
100007 -> {
otherwise?.invoke() otherwise?.invoke()
} else if (100008 == it.data?.dialDetail?.dialStatus) {
CommonDialog(activity)
.setCancelAble(false)
.setMessage(FinalString.TEL_BINDPHONE)
.setLeftOnclick("忍痛放弃", null)
.setRightClick("果断绑定") { view ->
try {
ModularServiceManager.provide(IUserService::class.java)
.wxBindToInputhonePage(activity as Activity)
} catch (e: Exception) {
} }
100008 -> {
if (activity is Activity) {
needBindPhone(activity)
} }
.show()
} else if (0 == it.data?.dialDetail?.dialStatus && it.data?.dialDetail?.callConnectType == 3) {
it.data?.dialDetail?.agoraExpertInfo ?: return@subscribe
if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线
ToastUtil.toastShort("网络通话错误代码001")
return@subscribe
} }
callAgora( else -> {
activity,
id,
it.data!!.dialDetail!!.agoraExpertInfo!!,
it.data.callId ?: "0",
it.data.listenOrderId ?: 0L,
null,
it.data.isShowAxb,
it.data?.dialDetail?.dialStatus.toString()
)
} else {
ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败") ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败")
} }
} else {
ToastHelper.show(it.data?.dialDetail?.dialReason ?: "连接失败")
} }
} else { } else {
ToastHelper.show(it.msg) ToastHelper.show(it.msg)
......
...@@ -3,7 +3,8 @@ apply plugin: 'maven' ...@@ -3,7 +3,8 @@ apply plugin: 'maven'
def mavenRepositoryUrl = "http://nexus.yidianling.com/repository/AndroidReleases/" def mavenRepositoryUrl = "http://nexus.yidianling.com/repository/AndroidReleases/"
def getVersionName() { def getVersionName() {
return rootProject.ext.ydl2PublishVersion def publishVersion = rootProject.ext.ydl2PublishVersion
return isLocal() ? publishVersion + "-LOCAL" : publishVersion
} }
def isLocal(){ def isLocal(){
Properties properties = new Properties() Properties properties = new Properties()
...@@ -47,7 +48,7 @@ afterEvaluate { project -> ...@@ -47,7 +48,7 @@ afterEvaluate { project ->
, project.getName() , project.getName()
, getVersionName() , getVersionName()
, "aar" , "aar"
, "release" , isLocal() ? "Local" : "release"
) )
} }
// rootProject.getTasksByName("aa",false).forEach{println(it)} // rootProject.getTasksByName("aa",false).forEach{println(it)}
......
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