Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
672b2865
Commit
672b2865
authored
Aug 03, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update TowerPro通用配置数据获取迁移到BGeneralBusiness组件
parent
60eb2874
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
152 additions
and
572 deletions
+152
-572
AppConfig.kt
...on/src/main/java/com/yidian/bcommon/constant/AppConfig.kt
+4
-0
CommonDataSource.kt
...src/main/java/com/yidian/bcommon/http/CommonDataSource.kt
+0
-82
CommonService.kt
...on/src/main/java/com/yidian/bcommon/http/CommonService.kt
+3
-23
BCommonManager.kt
...on/src/main/java/com/yidian/bcommon/sdk/BCommonManager.kt
+5
-3
ZapServiceActionConstants.kt
.../com/yidian/bcommon/services/ZapServiceActionConstants.kt
+3
-0
KS3Core.kt
...BCommon/src/main/java/com/yidian/bcommon/utils/KS3Core.kt
+0
-374
ShareUtils.kt
...mmon/src/main/java/com/yidian/bcommon/utils/ShareUtils.kt
+0
-10
ViewHolderUtil.kt
.../src/main/java/com/yidian/bcommon/utils/ViewHolderUtil.kt
+0
-15
GeneralBusinessApiService.kt
...uoquan/bgeneralbusiness/http/GeneralBusinessApiService.kt
+9
-1
GeneralBusinessRemoteDataService.kt
...bgeneralbusiness/http/GeneralBusinessRemoteDataService.kt
+34
-0
GeneralAbilityService.kt
...huoquan/bgeneralbusiness/service/GeneralAbilityService.kt
+33
-4
Constant.kt
...m/yidian/shenghuoquan/bmanagercenter/constant/Constant.kt
+2
-0
MerchantCenterActivity.kt
...uoquan/bmanagercenter/ui/center/MerchantCenterActivity.kt
+59
-60
No files found.
CommonLib/BCommon/src/main/java/com/yidian/bcommon/constant/AppConfig.kt
View file @
672b2865
...
...
@@ -32,6 +32,10 @@ class AppConfig {
const
val
TowerProXBridUpgradePlatformId
=
32
// XBrid版本升级
const
val
TowerProPlatform
=
"Android"
// Tower Api域名定义
const
val
TowerApiDomainTest
=
"http://open-tower-api.test.int.yidian-inc.com:8222"
const
val
TowerApiDomainPro
=
"https://open-tower-api.go2yd.com"
// TowerPro 通用配置模块
const
val
TowerApiEnvTest
=
0
// 测试环境
const
val
TowerApiEnvPro
=
2
// 外网-正式环境
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/CommonDataSource.kt
View file @
672b2865
package
com.yidian.bcommon.http
import
com.google.gson.reflect.TypeToken
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.http.bean.CommitFeedbackBean
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.bean.GetKSYunObjectIdBean
import
com.yidian.bcommon.http.bean.GetKSYunTokenBean
import
com.yidian.bcommon.http.callback.ICommitFeedbackCallback
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.bcommon.http.callback.IGetKSYunObjectIdCallback
import
com.yidian.http.ServiceFactory
import
com.yidian.utils.ToastUtil
/**
* author: yinjiacheng
...
...
@@ -21,82 +11,10 @@ import com.yidian.utils.ToastUtil
*/
object
CommonDataSource
{
// Tower-Api 域名
private
val
domainTowerApi
by
lazy
{
if
(
RunConfig
.
TOWER_API_ENV
==
AppConfig
.
TowerApiEnvTest
)
{
CommonService
.
SCHEME_HTTP
+
CommonService
.
DOMAIN_TOWER_API_TEST
}
else
{
CommonService
.
SCHEME_HTTPS
+
CommonService
.
DOMAIN_TOWER_API_PRO
}
}
private
val
towerApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
,
domainTowerApi
)
}
private
val
ydJiraApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
,
CommonService
.
SCHEME_HTTPS
+
CommonService
.
DOMAIN_YD_JIRA
)
}
// 301 获取金山云token接口
fun
getKSYunToken
(
requestParams
:
HashMap
<
String
,
String
?
>):
HttpResult
<
GetKSYunTokenBean
.
Response
>?
{
val
timeStamp
=
System
.
currentTimeMillis
()
val
publicParamsMap
=
HttpParamsUtils
.
getPublicParamsMap
(
timeStamp
)
val
privateParamsMap
=
HttpParamsUtils
.
getPrivateParamsMap
(
requestParams
,
timeStamp
)
val
res
:
HttpResult
<
Any
?>?
=
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
getKSYunToken
(
publicParamsMap
,
privateParamsMap
)
.
execute
().
body
()
if
(
res
?.
code
==
0
)
{
return
HttpParamsUtils
.
rsaDecryptResult
(
res
,
object
:
TypeToken
<
GetKSYunTokenBean
.
Response
>()
{}.
type
)
}
else
{
val
decodeResult
=
HttpResult
<
GetKSYunTokenBean
.
Response
>()
decodeResult
.
code
=
res
?.
code
!!
decodeResult
.
reason
=
res
.
reason
decodeResult
.
status
=
res
.
status
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
res
.
reason
)
}
return
null
}
// 302 获取金山云ObjectId和Bucket接口
fun
getKSYunObjectId
(
apiCallback
:
IGetKSYunObjectIdCallback
,
requestParams
:
HashMap
<
String
,
String
?
>)
{
val
timeStamp
=
System
.
currentTimeMillis
()
val
publicParamsMap
=
HttpParamsUtils
.
getPublicParamsMap
(
timeStamp
)
val
privateParamsMap
=
HttpParamsUtils
.
getPrivateParamsMap
(
requestParams
,
timeStamp
)
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
getKSYunObjectId
(
publicParamsMap
,
privateParamsMap
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultSubscriber
<
GetKSYunObjectIdBean
.
Response
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetKSYunObjectIdBean
.
Response
>?)
{
apiCallback
.
getKSYunObjectIdSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetKSYunObjectIdBean
.
Response
>?)
{
apiCallback
.
getKSYunObjectIdFailure
(
result
?.
reason
)
}
})
}
// TowerPro 获取配置数据
fun
getCommonConfig
(
apiCallback
:
IGetCommonConfigCallback
,
requestParams
:
HashMap
<
String
,
String
>)
{
towerApi
.
getCommonConfig
(
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultObserver
<
GetCommonConfigBean
.
GetCommonConfigResponse
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
override
fun
onNetworkFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
})
}
// 用户反馈提交
fun
commitFeedback
(
apiCallback
:
ICommitFeedbackCallback
,
requestParams
:
CommitFeedbackBean
.
CommitFeedbackRequest
)
{
ydJiraApi
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/CommonService.kt
View file @
672b2865
package
com.yidian.bcommon.http
import
com.yidian.bcommon.http.bean.CommitFeedbackBean
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
io.reactivex.rxjava3.core.Observable
import
retrofit2.Call
import
retrofit2.http.*
import
retrofit2.http.Body
import
retrofit2.http.Headers
import
retrofit2.http.POST
/**
* author: yinjiacheng
...
...
@@ -17,33 +17,13 @@ interface CommonService {
const
val
SCHEME_HTTP
=
"http://"
const
val
SCHEME_HTTPS
=
"https://"
// Tower Api域名定义
const
val
DOMAIN_TOWER_API_TEST
=
"open-tower-api.test.int.yidian-inc.com:8222"
const
val
DOMAIN_TOWER_API_PRO
=
"open-tower-api.go2yd.com"
// 一点jira域名定义
const
val
DOMAIN_YD_JIRA
=
"hub.go2yd.com"
// tower-api 获取配置数据
private
const
val
getCommonConfig
=
"/api/resource"
// 用户反馈提交
private
const
val
commitFeedback
=
"/feedback/save"
}
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
getKSYunToken
)
fun
getKSYunToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
Map
<
String
,
String
?
>):
Call
<
HttpResult
<
Any
?
>>
@GET
(
URLs
.
getKSYunObjectId
)
fun
getKSYunObjectId
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
requestParams
:
Map
<
String
,
String
?
>
):
Observable
<
HttpResult
<
Any
?
>>
@GET
(
getCommonConfig
)
fun
getCommonConfig
(
@QueryMap
requestParams
:
Map
<
String
,
String
>):
Observable
<
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>>
@Headers
(
"Content-Type: application/json"
)
@POST
(
commitFeedback
)
fun
commitFeedback
(
@Body
requestParams
:
CommitFeedbackBean
.
CommitFeedbackRequest
):
Observable
<
HttpResult
<
CommitFeedbackBean
.
CommitFeedbackResponse
>>
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/sdk/BCommonManager.kt
View file @
672b2865
...
...
@@ -47,9 +47,11 @@ object BCommonManager {
*/
fun
getUid
():
String
?
{
var
userId
:
String
?
=
null
ZapTicket
(
ZapServiceNameConstants
.
ClientInfoService
).
withAction
(
ZapServiceActionConstants
.
ActionGetUserInfo
).
onResult
{
userId
=
(
it
.
result
as
JSONObject
).
optString
(
"userId"
)
}.
ship
()
if
(
JudgeClientUtils
.
judgeClient
(
YdBaseApplication
.
context
.
packageName
)
==
ClientType
.
MERCHANT_C
)
{
ZapTicket
(
ZapServiceNameConstants
.
ClientInfoService
).
withAction
(
ZapServiceActionConstants
.
ActionGetUserInfo
).
onResult
{
userId
=
(
it
.
result
as
JSONObject
).
optString
(
"userId"
)
}.
ship
()
}
return
userId
}
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/services/ZapServiceActionConstants.kt
View file @
672b2865
...
...
@@ -45,5 +45,8 @@ class ZapServiceActionConstants {
// 延迟初始化
const
val
ActionLazyInit
=
"lazyInit"
// 获取TowerPro通用配置数据
const
val
ActionGetTowerProCommonConfig
=
"getTowerProCommonConfig"
}
}
CommonLib/BCommon/src/main/java/com/yidian/bcommon/utils/KS3Core.kt
deleted
100644 → 0
View file @
60eb2874
This diff is collapsed.
Click to expand it.
CommonLib/BCommon/src/main/java/com/yidian/bcommon/utils/ShareUtils.kt
deleted
100644 → 0
View file @
60eb2874
package
com.yidian.bcommon.utils
import
android.content.Context
/**
* 分享工具类
*/
object
ShareUtils
{
}
CommonLib/BCommon/src/main/java/com/yidian/bcommon/utils/ViewHolderUtil.kt
deleted
100644 → 0
View file @
60eb2874
package
com.yidian.bcommon.utils
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.annotation.LayoutRes
import
androidx.recyclerview.widget.RecyclerView
class
ViewHolderUtil
{
companion
object
{
fun
RecyclerView
.
Adapter
<
out
RecyclerView
.
ViewHolder
>.
createItemView
(
parent
:
ViewGroup
,
@LayoutRes
layoutId
:
Int
):
View
{
return
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
layoutId
,
parent
,
false
)
}
}
}
Components/BGeneralBusiness/src/main/java/com/yidian/shenghuoquan/bgeneralbusiness/http/GeneralBusinessApiService.kt
View file @
672b2865
package
com.yidian.shenghuoquan.bgeneralbusiness.http
import
com.yidian.bcommon.http.*
import
com.yidian.bcommon.http.HttpResult
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
io.reactivex.rxjava3.core.Observable
import
retrofit2.http.GET
import
retrofit2.http.QueryMap
...
...
@@ -9,6 +10,7 @@ interface GeneralBusinessApiService {
private
companion
object
{
const
val
sendMsgCode
=
"/sms/sms/send_code"
const
val
getCommonConfig
=
"/api/resource"
}
/**
...
...
@@ -16,4 +18,10 @@ interface GeneralBusinessApiService {
*/
@GET
(
sendMsgCode
)
fun
sendMsgCode
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
params
:
Map
<
String
,
String
?
>):
Observable
<
HttpResult
<
Any
?
>>
/**
* TowerPro获取通用配置数据
*/
@GET
(
getCommonConfig
)
fun
getCommonConfig
(
@QueryMap
requestParams
:
Map
<
String
,
String
>):
Observable
<
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>>
}
Components/BGeneralBusiness/src/main/java/com/yidian/shenghuoquan/bgeneralbusiness/http/GeneralBusinessRemoteDataService.kt
View file @
672b2865
package
com.yidian.shenghuoquan.bgeneralbusiness.http
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.http.*
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.http.ServiceFactory
object
GeneralBusinessRemoteDataService
{
private
var
api
=
ServiceFactory
.
getInstance
().
createService
(
GeneralBusinessApiService
::
class
.
java
)
private
val
towerApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
GeneralBusinessApiService
::
class
.
java
,
if
(
RunConfig
.
TOWER_API_ENV
==
AppConfig
.
TowerApiEnvTest
)
{
AppConfig
.
TowerApiDomainTest
}
else
{
AppConfig
.
TowerApiDomainPro
}
)
}
// 获取短信验证码
fun
sendMsgCode
(
requestParams
:
HashMap
<
String
,
String
?
>,
callback
:
((
Boolean
)
->
Unit
)?
=
null
)
{
val
timeStamp
=
System
.
currentTimeMillis
()
...
...
@@ -23,4 +37,24 @@ object GeneralBusinessRemoteDataService {
}
})
}
// TowerPro 获取配置数据
fun
getCommonConfig
(
apiCallback
:
IGetCommonConfigCallback
,
requestParams
:
HashMap
<
String
,
String
>)
{
towerApi
.
getCommonConfig
(
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultObserver
<
GetCommonConfigBean
.
GetCommonConfigResponse
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
override
fun
onNetworkFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
})
}
}
Components/BGeneralBusiness/src/main/java/com/yidian/shenghuoquan/bgeneralbusiness/service/GeneralAbilityService.kt
View file @
672b2865
package
com.yidian.shenghuoquan.bgeneralbusiness.service
import
com.google.gson.Gson
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.bcommon.sdk.BCommonManager
import
com.yidian.bcommon.services.ZapServiceActionConstants
import
com.yidian.shenghuoquan.bgeneralbusiness.config.LazyInitConfig
import
com.yidian.shenghuoquan.bgeneralbusiness.http.GeneralBusinessRemoteDataService
...
...
@@ -13,14 +19,14 @@ import org.json.JSONObject
*/
class
GeneralAbilityService
:
ZapService
()
{
private
lateinit
var
resolver
:
ResultResolver
private
val
gson
by
lazy
{
Gson
()
}
override
fun
onAction
(
path
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
this
.
resolver
=
resolver
params
as
JSONObject
when
(
action
)
{
ZapServiceActionConstants
.
ActionRequestSmsCode
->
requestSmsCode
(
params
)
ZapServiceActionConstants
.
ActionRequestSmsCode
->
requestSmsCode
(
params
,
resolver
)
ZapServiceActionConstants
.
ActionLazyInit
->
lazyInit
()
ZapServiceActionConstants
.
ActionGetTowerProCommonConfig
->
getTowerProCommonConfig
(
resolver
)
}
}
...
...
@@ -33,7 +39,7 @@ class GeneralAbilityService : ZapService() {
/**
* 请求短信验证码
*/
private
fun
requestSmsCode
(
params
:
JSONObject
)
{
private
fun
requestSmsCode
(
params
:
JSONObject
,
resolver
:
ResultResolver
)
{
val
mobile
=
params
.
optString
(
"mobile"
)
val
scene
=
params
.
optString
(
"scene"
)
val
paramsMap
=
HashMap
<
String
,
String
?>()
...
...
@@ -53,4 +59,27 @@ class GeneralAbilityService : ZapService() {
// 初始化慧眼
LazyInitConfig
.
initXInsight
()
}
/**
* 获取TowerPro通用配置数据
*/
private
fun
getTowerProCommonConfig
(
resolver
:
ResultResolver
)
{
GeneralBusinessRemoteDataService
.
getCommonConfig
(
object
:
IGetCommonConfigCallback
{
override
fun
getCommonConfigSuccess
(
result
:
GetCommonConfigBean
.
GetCommonConfigResponse
?)
{
resolver
.
success
(
JSONObject
(
gson
.
toJson
(
result
)))
}
override
fun
getCommonConfigFailure
(
message
:
String
?)
{
resolver
.
fail
(-
1
,
message
,
"获取配置失败,请稍后重试"
)
}
},
hashMapOf
(
"appid"
to
BCommonManager
.
getAppId
(),
"env"
to
RunConfig
.
TOWER_API_ENV
.
toString
(),
"version"
to
AppConfig
.
TowerApiVersion
,
"os"
to
AppConfig
.
TowerApiOS
,
"keytag"
to
BCommonManager
.
getTowerProKeyTag
()
)
)
}
}
Components/BManagerCenter/src/main/java/com/yidian/shenghuoquan/bmanagercenter/constant/Constant.kt
View file @
672b2865
...
...
@@ -7,6 +7,8 @@ package com.yidian.shenghuoquan.bmanagercenter.constant
*/
object
Constant
{
const
val
LOG_TAG
=
"BManagerCenter"
const
val
LIFE_ACCOUNT_AUTH_TAG
=
"LifeAccountAuth"
// 认证类型
...
...
Components/BManagerCenter/src/main/java/com/yidian/shenghuoquan/bmanagercenter/ui/center/MerchantCenterActivity.kt
View file @
672b2865
...
...
@@ -6,16 +6,14 @@ import android.view.View
import
androidx.core.content.ContextCompat
import
androidx.core.view.isVisible
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.google.gson.Gson
import
com.scwang.smart.refresh.layout.api.RefreshLayout
import
com.scwang.smart.refresh.layout.listener.OnRefreshListener
import
com.yidian.bcommon.base.BaseActivity
import
com.yidian.bcommon.bean.HintOptionBean
import
com.yidian.bcommon.bean.LifeAccountItemBean
import
com.yidian.bcommon.constant.*
import
com.yidian.bcommon.http.CommonDataSource
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.bcommon.sdk.BCommonManager
import
com.yidian.bcommon.sdk.ClientType
import
com.yidian.bcommon.sdk.JudgeClientUtils
import
com.yidian.bcommon.services.ZapServiceActionConstants
...
...
@@ -44,6 +42,8 @@ import com.yidian.xpage.XPageManager
import
com.yidian.yac.core.zap.ZapTicket
import
org.greenrobot.eventbus.Subscribe
import
org.greenrobot.eventbus.ThreadMode
import
org.json.JSONObject
import
timber.log.Timber
/**
* author: yinjiacheng
...
...
@@ -53,7 +53,7 @@ import org.greenrobot.eventbus.ThreadMode
class
MerchantCenterActivity
:
BaseActivity
<
ActivityMerchantCenterBinding
>(),
MerchantSwitchDialog
.
OnMerchantSwitchCallback
,
LifeAccountLabelView
.
OnLifeAccountLabelCallback
,
MerchantCenterBottomHintDialog
.
OnMerchantCenterBottomHintCallback
,
IAuthMerchantCheckCallback
,
MerchantServiceFunctionAdapter
.
OnItemClickListener
,
CommonTopBarView
.
OnCommonTopBarActionCallback
,
OnRefreshListener
,
DialogInterface
.
OnShowListener
,
DialogInterface
.
OnDismissListener
,
IGetCommonConfigCallback
{
OnRefreshListener
,
DialogInterface
.
OnShowListener
,
DialogInterface
.
OnDismissListener
{
companion
object
{
const
val
PARAMS_LIFE_ACCOUNT_ID
=
"life_account_id"
...
...
@@ -79,6 +79,8 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), Me
*/
private
lateinit
var
functionPermissionList
:
ArrayList
<
Int
>
private
val
gson
by
lazy
{
Gson
()
}
override
fun
createViewBinding
():
ActivityMerchantCenterBinding
{
return
ActivityMerchantCenterBinding
.
inflate
(
layoutInflater
)
}
...
...
@@ -418,16 +420,59 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), Me
override
fun
onRefresh
(
refreshLayout
:
RefreshLayout
)
{
// 刷新数据
// 请求TowerPro通用配置
CommonDataSource
.
getCommonConfig
(
this
,
hashMapOf
(
"appid"
to
BCommonManager
.
getAppId
(),
"env"
to
RunConfig
.
TOWER_API_ENV
.
toString
(),
"version"
to
AppConfig
.
TowerApiVersion
,
"os"
to
AppConfig
.
TowerApiOS
,
"keytag"
to
BCommonManager
.
getTowerProKeyTag
()
)
)
ZapTicket
(
ZapServiceNameConstants
.
GeneralAbilityService
).
withAction
(
ZapServiceActionConstants
.
ActionGetTowerProCommonConfig
)
.
onResult
{
xResult
->
val
configResult
=
if
(
xResult
.
code
==
0
)
{
Timber
.
tag
(
Constant
.
LOG_TAG
).
i
(
"get common config success, result: ${xResult.result}"
)
gson
.
fromJson
((
xResult
.
result
as
JSONObject
).
toString
(),
GetCommonConfigBean
.
GetCommonConfigResponse
::
class
.
java
)
}
else
{
Timber
.
tag
(
Constant
.
LOG_TAG
).
e
(
"get common config fail, message: ${xResult.mesg}"
)
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
return
@onResult
}
// 请求生活号列表
ApiService
.
getLifeAccountList
(
object
:
IGetLifeAccountListCallback
{
override
fun
getLifeAccountListSuccess
(
@Suppress
(
"PARAMETER_NAME_CHANGED_ON_OVERRIDE"
)
lifeAccountResult
:
ArrayList
<
LifeAccountItemBean
.
Response
>?)
{
viewBind
.
rlRefresh
.
finishRefresh
(
true
)
if
(
lifeAccountResult
?.
size
==
0
)
{
// 如果当前无生活号则退出登录
ToastUtil
.
showToast
(
this
@MerchantCenterActivity
,
resources
.
getString
(
R
.
string
.
no_life_account
))
requestLogout
()
return
}
lifeAccountResult
?.
let
{
// 切换主体入口是否展示判断
viewBind
.
bvTopBar
.
setActionVisibility
(
it
.
size
>
1
)
}
val
lifeAccountIdList
=
lifeAccountResult
?.
map
{
it
.
life_account_id
}
val
curLifeAccountId
=
StorageUtil
.
getLifeAccountId
()
if
(
lifeAccountIdList
?.
contains
(
curLifeAccountId
)
==
false
)
{
// 当前选择的生活号已不存在则切换第一个生活号 目前为企业员工被解除关系会触发
// C端开店赚钱生成未认证生活号进入管理中心会触发 curLifeAccountId为null且生活号列表只有一条数据
curLifeAccount
=
lifeAccountResult
[
0
]
// 更新本地存储的生活号id
StorageUtil
.
putLifeAccountId
(
lifeAccountResult
[
0
].
life_account_id
)
// 刷新数据
configResult
?.
data
?.
let
{
refreshMerchantCenterData
(
lifeAccountResult
[
0
],
it
)
}
return
}
lifeAccountResult
?.
forEach
{
if
(
curLifeAccountId
==
it
.
life_account_id
)
{
curLifeAccount
=
it
// 刷新数据
configResult
?.
let
{
configData
->
refreshMerchantCenterData
(
it
,
configData
.
data
)
}
}
}
}
override
fun
getLifeAccountListFailure
(
message
:
String
?)
{
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
}
})
}.
onLost
{
Timber
.
tag
(
Constant
.
LOG_TAG
).
e
(
"get common config fail, message: ${it.mesg}"
)
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
}.
ship
()
}
override
fun
onShow
(
dialog
:
DialogInterface
?)
{
...
...
@@ -442,52 +487,6 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), Me
viewBind
.
bvTopBar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
transparent
))
}
override
fun
getCommonConfigSuccess
(
@Suppress
(
"PARAMETER_NAME_CHANGED_ON_OVERRIDE"
)
configResult
:
GetCommonConfigBean
.
GetCommonConfigResponse
?)
{
// 请求生活号列表
ApiService
.
getLifeAccountList
(
object
:
IGetLifeAccountListCallback
{
override
fun
getLifeAccountListSuccess
(
@Suppress
(
"PARAMETER_NAME_CHANGED_ON_OVERRIDE"
)
lifeAccountResult
:
ArrayList
<
LifeAccountItemBean
.
Response
>?)
{
viewBind
.
rlRefresh
.
finishRefresh
(
true
)
if
(
lifeAccountResult
?.
size
==
0
)
{
// 如果当前无生活号则退出登录
ToastUtil
.
showToast
(
this
@MerchantCenterActivity
,
resources
.
getString
(
R
.
string
.
no_life_account
))
requestLogout
()
return
}
lifeAccountResult
?.
let
{
// 切换主体入口是否展示判断
viewBind
.
bvTopBar
.
setActionVisibility
(
it
.
size
>
1
)
}
val
lifeAccountIdList
=
lifeAccountResult
?.
map
{
it
.
life_account_id
}
val
curLifeAccountId
=
StorageUtil
.
getLifeAccountId
()
if
(
lifeAccountIdList
?.
contains
(
curLifeAccountId
)
==
false
)
{
// 当前选择的生活号已不存在则切换第一个生活号 目前为企业员工被解除关系会触发
// C端开店赚钱生成未认证生活号进入管理中心会触发 curLifeAccountId为null且生活号列表只有一条数据
curLifeAccount
=
lifeAccountResult
[
0
]
// 更新本地存储的生活号id
StorageUtil
.
putLifeAccountId
(
lifeAccountResult
[
0
].
life_account_id
)
// 刷新数据
configResult
?.
data
?.
let
{
refreshMerchantCenterData
(
lifeAccountResult
[
0
],
it
)
}
return
}
lifeAccountResult
?.
forEach
{
if
(
curLifeAccountId
==
it
.
life_account_id
)
{
curLifeAccount
=
it
// 刷新数据
configResult
?.
let
{
configData
->
refreshMerchantCenterData
(
it
,
configData
.
data
)
}
}
}
}
override
fun
getLifeAccountListFailure
(
message
:
String
?)
{
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
}
})
}
override
fun
getCommonConfigFailure
(
message
:
String
?)
{
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
}
private
fun
requestLogout
()
{
ZapTicket
(
ZapServiceNameConstants
.
SettingService
).
withAction
(
ZapServiceActionConstants
.
ActionLogout
)
.
onResult
{
result
->
...
...
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