Commit 8b9a99be by 刘鹏

feat: 支付日志埋点完成

parent 3d6e551e
......@@ -38,8 +38,8 @@ ext {
//第二步 若干
"ydl-webview" : "0.0.38.36",
"ydl-media" : "0.0.21.6",
"ydl-pay" : "0.0.18.13",
"m-audioim" : "0.0.49.29.30",
"ydl-pay" : "0.0.18.15",
"m-audioim" : "0.0.49.29.32",
"ydl-flutter-base": "0.0.14.20",
//以下 几乎不会动
......@@ -120,8 +120,8 @@ ext {
//第二步 若干
"ydl-webview" : "0.0.38.36",
"ydl-media" : "0.0.21.6",
"ydl-pay" : "0.0.18.11",
"m-audioim" : "0.0.49.29.30",
"ydl-pay" : "0.0.18.15",
"m-audioim" : "0.0.49.29.32",
"ydl-flutter-base": "0.0.14.20",
//以下 几乎不会动
......
......@@ -14,6 +14,8 @@ import android.widget.LinearLayout
import com.alipay.sdk.app.PayTask
import com.tencent.mm.opensdk.modelpay.PayReq
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunLogHelper
import com.yidianling.common.tools.RxImageTool
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.common.bean.*
......@@ -42,6 +44,7 @@ class CommonPayDialog : Dialog {
private lateinit var activity: Activity
private var viewList = ArrayList<LinearLayout>()
private var couponListBean: AllCouponListBean? = null
//选中的优惠券
private var selectedCouponBean: CommonCouponBean? = null
private var payCouponView: PayCouponView? = null
......@@ -49,14 +52,17 @@ class CommonPayDialog : Dialog {
private var listener: OnPayResultListener? = null
private var payMoney: Float? = null
private var thankPayId: String? = null
//加载中弹窗
private var dialog: AlertDialog? = null
private var dialogContentView: View? = null
/**
* 支付方式
* 1024.微信支付 1025.支付宝支付
*/
private var payWay = 0
/**
* 支付的业务类型
* [TYPE_COURSE] 课程支付
......@@ -72,18 +78,22 @@ class CommonPayDialog : Dialog {
* 课程业务
*/
const val TYPE_COURSE = 1
/**
* 倾诉
*/
const val TYPE_CONFIDE = 2
/**
* 测评
*/
const val TYPE_TEST = 3
/**
* 咨询
*/
const val TYPE_CONSULTANT = 4
/**
* 动态打赏
*/
......@@ -157,11 +167,14 @@ class CommonPayDialog : Dialog {
PAY_WECHAT -> {
getWeiXinPayOrderId(
thankPayId!!,
if (useMoneyType == 2) 1 else 0,bean.merchantType
if (useMoneyType == 2) 1 else 0, bean.merchantType
)
}
else -> {
getAliPayOrderId(thankPayId!!, if (useMoneyType == 2) 1 else 0)
getAliPayOrderId(
thankPayId!!,
if (useMoneyType == 2) 1 else 0
)
}
}
} else {
......@@ -198,6 +211,7 @@ class CommonPayDialog : Dialog {
private fun getOrderInfo() {
if (!NetUtils.isConnected(activity)) {
ToastHelper.show(activity, activity.getString(R.string.net_error))
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "获取下单信息,无网络")
// progress.visibility = View.GONE
dismissProgressDialog()
return
......@@ -216,12 +230,18 @@ class CommonPayDialog : Dialog {
progress_layout.visibility = View.GONE
view_pager.visibility = View.VISIBLE
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "获取下单信息,成功")
updateDataOnView(it.data)
} else {
AliYunLogHelper.getInstance()
.sendLog(AliYunLogConfig.PAY, "获取下单信息data=null msg: ${it.msg}")
ToastHelper.show(activity, it.msg)
// progress.visibility = View.GONE
}
} else {
AliYunLogHelper.getInstance()
.sendLog(AliYunLogConfig.PAY, "获取下单信息code!=200 msg: ${it.msg}")
ToastHelper.show(activity, it.msg)
// progress.visibility = View.GONE
}
......@@ -229,6 +249,9 @@ class CommonPayDialog : Dialog {
dismissProgressDialog()
// progress.visibility = View.GONE
ToastHelper.show(activity, e.message!!)
AliYunLogHelper.getInstance()
.sendLog(AliYunLogConfig.PAY, "获取下单信息error e:${e.message}")
})
}
......@@ -413,6 +436,10 @@ class CommonPayDialog : Dialog {
}
bean.orderType = payBusinessType.toString()
bean.payType = useMoneyType.toString()
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"创建订单,支付方式payWay:$payWay---payMoney:$payMoney----useMoneyType:$useMoneyType"
)
showProgressDialog()
HttpUtils.createOrder(bean)
......@@ -422,6 +449,10 @@ class CommonPayDialog : Dialog {
if (it.code == 200) {
if (it.data != null) {
if (it.data.payStatus) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"创建订单,支付成功"
)
dismissProgressDialog()
ToastHelper.show(activity, "支付成功")
if (listener != null) {
......@@ -463,6 +494,10 @@ class CommonPayDialog : Dialog {
@SuppressLint("CheckResult")
private fun getAliPayOrderId(payId: String, isThreePay: Int) {
if (!NetUtils.isConnected(activity)) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"支付宝支付:无网络"
)
activity.runOnUiThread {
ToastHelper.show(activity, activity.getString(R.string.net_error))
}
......@@ -474,14 +509,26 @@ class CommonPayDialog : Dialog {
.subscribeOn(Schedulers.io())
.subscribe({
if (it.data != null) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"支付宝支付:无网络"
)
aliPay(it.data.aliSign)
} else {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"支付宝支付:data = null msg: ${it.msg} "
)
activity.runOnUiThread {
ToastHelper.show(activity, it.msg)
}
dismissProgressDialog()
}
}, {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"支付宝支付:error message: ${it.message} localizedMessage: ${it.localizedMessage}"
)
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
}
......@@ -494,6 +541,10 @@ class CommonPayDialog : Dialog {
val result = alipay.payV2(aliSign, true)
val payResult = PayResult(result)
if ("9000" == payResult.resultStatus) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"支付宝支付:支付成功"
)
activity.runOnUiThread {
ToastHelper.show(activity, "支付成功")
listener!!.onSuccesed()
......@@ -501,6 +552,10 @@ class CommonPayDialog : Dialog {
}
dismissProgressDialog()
} else {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"支付宝支付:resultStatus != 9000 memo${payResult.memo} "
)
dismissProgressDialog()
activity.runOnUiThread {
ToastHelper.show(activity, payResult.memo)
......@@ -512,27 +567,39 @@ class CommonPayDialog : Dialog {
* 微信支付
*/
@SuppressLint("CheckResult")
private fun getWeiXinPayOrderId(payId: String, isThreePay: Int,merchantType:String) {
private fun getWeiXinPayOrderId(payId: String, isThreePay: Int, merchantType: String) {
if (!NetUtils.isConnected(activity)) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"微信支付,无网络"
)
activity.runOnUiThread {
ToastHelper.show(activity, activity.getString(R.string.net_error))
}
return
}
var bean = WxPayParam(payId, isThreePay,merchantType)
var bean = WxPayParam(payId, isThreePay, merchantType)
HttpUtils.wxPay(bean)
.subscribeOn(Schedulers.io())
.subscribe({
if (it.data != null) {
weixinPay(it.data.option)
} else {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"微信支付data=null ${it.msg}"
)
activity.runOnUiThread {
ToastHelper.show(activity, it.msg)
}
dismissProgressDialog()
}
}, {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"微信支付,异常:message:${it.message}----localizedMessage:${it.localizedMessage}"
)
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
}
......@@ -566,16 +633,28 @@ class CommonPayDialog : Dialog {
.subscribe({
dismissProgressDialog()
if (it.data != null && it.code == 0) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"余额支付:成功"
)
activity.runOnUiThread {
listener!!.onSuccesed()
dismiss()
}
} else {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"余额支付:失败 msg:${it.msg}"
)
activity.runOnUiThread {
ToastHelper.show(activity, it.msg)
}
}
}, {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"余额支付:ERROR message:${it.message} localizedMessage: ${it.localizedMessage}"
)
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
}
......@@ -587,10 +666,18 @@ class CommonPayDialog : Dialog {
fun onEvent(event: WeiXinPayStatusEvent) {
dismissProgressDialog()
if (event.success) {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"微信支付成功"
)
ToastHelper.show(activity, "支付成功")
listener!!.onSuccesed()
dismiss()
} else {
AliYunLogHelper.getInstance().sendLog(
AliYunLogConfig.PAY,
"微信支付:失败 msg:${event.msg}"
)
if (!TextUtils.isEmpty(event.msg)) {
ToastHelper.show(activity, event.msg!!)
}
......@@ -673,6 +760,7 @@ class CommonPayDialog : Dialog {
private lateinit var ffrom: String
internal lateinit var listener: OnPayResultListener
private var isTestEnvironment = true
/**
* 支付的业务类型[CommonPayDialog.payBusinessType]
*/
......
......@@ -18,6 +18,8 @@ import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunLogHelper
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
......@@ -65,6 +67,7 @@ class PayActivity : BaseActivity() {
*/
private const val PARAMS = "params"
private const val PARAMS_RED = "params_redPacket"
/**
* 支付类型
* 1.微信支付 2.支付宝支付
......@@ -91,29 +94,41 @@ class PayActivity : BaseActivity() {
//订单信息数据
private var payParams: PayParams? = null
//红包列表数据+支付金额
private var redPacketPayBean: RedPacketPayBean? = null
//入口
private var inlet = PayParams.INLET_NORMAL
//红包列表弹窗
private var redPacketPopWindow: RedPacketPopWindow? = null
//加载中弹窗
private var dialog: AlertDialog? = null
private var dialogContentView: View? = null
//红包id 默认为0
private var redPacketId: String? = "0"
//使用红包金额
private var redPacketMoney: Float = 0f
//使用红包文案
private var redPacketMoneyContent: String = ""
//账户余额
private var balanceMoney: Float = 0f
//支付金额
private var payMoney: Float = 0F
//可使用余额
private var canBalanceMoney = 0F
//支付类型
private var payType = PAY_ALI
//测评下单数据bean
private var testAddOrderBean: TestAddOrderBean? = null
......@@ -538,6 +553,7 @@ class PayActivity : BaseActivity() {
* 点击支付
*/
private fun onClickPay() {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "点击支付")
when (inlet) {
INLET_NORMAL -> {
//正常入口
......@@ -603,6 +619,7 @@ class PayActivity : BaseActivity() {
if (null == payParams) {
return
}
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "进入充值, 0微信充值,其他支付宝充值:$select")
HttpUtils.recharge(RechargeParam(payParams!!.needPay.toInt().toString()))
.subscribeOn(Schedulers.io())
......@@ -622,6 +639,8 @@ class PayActivity : BaseActivity() {
.doOnSubscribe { showProgressDialog("") }
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付成功")
LogHelper.getInstance().writeLogSync("支付成功")
ToastUtil.toastShort("支付成功")
var intent = Intent()
......@@ -633,6 +652,8 @@ class PayActivity : BaseActivity() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
LogHelper.getInstance().writeLogSync("支付失败$msg")
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付失败$msg")
}
})
......@@ -644,13 +665,19 @@ class PayActivity : BaseActivity() {
when (inlet) {
INLET_NORMAL -> {
//正常入口
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "余额支付 正常入口")
balancePayById(payParams!!.payId)
}
INLET_TEST -> {
//测评入口
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "余额支付 测评入口")
balancePayById(testAddOrderBean!!.payId!!)
}
else -> {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "余额支付")
balancePayById(payParams!!.payId)
}
}
......@@ -673,6 +700,7 @@ class PayActivity : BaseActivity() {
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
LogHelper.getInstance().writeLogSync("支付成功")
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "余额支付:支付成功")
ToastUtil.toastShort("支付成功")
setResult(Activity.RESULT_OK)
finish()
......@@ -680,6 +708,8 @@ class PayActivity : BaseActivity() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
LogHelper.getInstance().writeLogSync("支付失败:$msg")
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "余额支付:支付失败:$msg")
}
})
}
......@@ -689,6 +719,7 @@ class PayActivity : BaseActivity() {
*/
@SuppressLint("CheckResult")
private fun appPay() {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "微信支付 0 其他支付宝支付 select:${select}")
Observable.just(select)
.subscribeOn(Schedulers.io())
......@@ -706,6 +737,7 @@ class PayActivity : BaseActivity() {
.doOnSubscribe { showProgressDialog("") }
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付成功")
LogHelper.getInstance().writeLogSync("支付成功")
setResult(Activity.RESULT_OK)
finish()
......@@ -713,6 +745,8 @@ class PayActivity : BaseActivity() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
LogHelper.getInstance().writeLogSync("支付失败:$msg")
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付失败:$msg")
}
})
}
......@@ -724,18 +758,21 @@ class PayActivity : BaseActivity() {
return when (inlet) {
INLET_NORMAL -> {
//正常入口
wxPayById(payParams!!.payId,payParams?.merchantType.toString())
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "微信支付:正常入口")
wxPayById(payParams!!.payId, payParams?.merchantType.toString())
}
INLET_TEST -> {
//测评入口
if (null != testAddOrderBean && !TextUtils.isEmpty(testAddOrderBean!!.payId!!)) {
wxPayById(testAddOrderBean!!.payId!!,payParams?.merchantType.toString())
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "微信支付:测评入口")
wxPayById(testAddOrderBean!!.payId!!, payParams?.merchantType.toString())
} else {
null
}
}
else -> {
wxPayById(payParams!!.payId,payParams?.merchantType.toString())
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "微信支付")
wxPayById(payParams!!.payId, payParams?.merchantType.toString())
}
}
}
......@@ -744,8 +781,8 @@ class PayActivity : BaseActivity() {
* 微信支付
* @param payId 支付id
*/
private fun wxPayById(payId: String,merchantType:String): Observable<PayStatus> {
val bean = WxPayParam(payId, 1,merchantType)
private fun wxPayById(payId: String, merchantType: String): Observable<PayStatus> {
val bean = WxPayParam(payId, 1, merchantType)
return HttpUtils.wxPay(bean)
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
......@@ -760,17 +797,23 @@ class PayActivity : BaseActivity() {
return when (inlet) {
INLET_NORMAL -> {
//正常入口
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付宝支付:正常入口")
aliPayById(payParams!!.payId)
}
INLET_TEST -> {
//测评入口
if (null != testAddOrderBean && !TextUtils.isEmpty(testAddOrderBean!!.payId!!)) {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付宝支付:测评入口")
aliPayById(testAddOrderBean!!.payId!!)
} else {
null
}
}
else -> {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付宝支付")
aliPayById(payParams!!.payId)
}
}
......@@ -811,7 +854,8 @@ class PayActivity : BaseActivity() {
.create()
}
if (dialogContentView == null) {
dialogContentView = LayoutInflater.from(this).inflate(R.layout.pay_fragment_loading_dialog, null)
dialogContentView =
LayoutInflater.from(this).inflate(R.layout.pay_fragment_loading_dialog, null)
dialogContentView?.tvMsg?.visibility = View.GONE
}
dialog?.show()
......
......@@ -3,14 +3,16 @@ package com.yidianling.ydl_pay.pay
import android.app.Activity
import android.content.Context
import com.alipay.sdk.app.PayTask
import com.yidianling.ydl_pay.pay.bean.PayStatus
import com.tencent.mm.opensdk.constants.Build
import com.tencent.mm.opensdk.modelpay.PayReq
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import com.yidianling.ydl_pay.pay.bean.WXPayEvent
import com.ydl.ydlcommon.data.http.CustomThrowable
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunLogHelper
import com.yidianling.ydl_pay.common.bean.CommonWXPayBean
import com.yidianling.ydl_pay.common.bean.PayResult
import com.yidianling.ydl_pay.pay.bean.PayStatus
import com.yidianling.ydl_pay.pay.bean.WXPayEvent
import de.greenrobot.event.EventBus
import io.reactivex.Emitter
import io.reactivex.Observable
......@@ -59,8 +61,18 @@ object RxPay {
val result = alipay.payV2(aliSign, true)
val payResult = PayResult(result)
when {
"9000" == payResult.resultStatus -> it.onNext(PayStatus(true))
else -> it.onError(CustomThrowable(payResult.memo))
"9000" == payResult.resultStatus -> {
it.onNext(PayStatus(true))
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY, "支付宝支付成功")
}
else -> {
it.onError(CustomThrowable(payResult.memo))
AliYunLogHelper.getInstance()
.sendLog(AliYunLogConfig.PAY, "支付宝支付失败 memo:${payResult.memo}")
}
}
it.onComplete()
}
......
......@@ -9,6 +9,8 @@ import android.support.v7.app.AlertDialog
import android.view.*
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.StringUtils
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunLogHelper
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.ydl_pay.R
......@@ -160,6 +162,7 @@ class PayDialog : Dialog {
if (data?.payId == null) {
ToastHelper.show("支付id有误,请返回重试")
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY,"支付id有误,请返回重试")
return
}
......@@ -187,9 +190,12 @@ class PayDialog : Dialog {
this.callBack?.onSuccess()
}
LogHelper.getInstance().writeLogSync("支付成功")
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY,"支付成功")
this.callBack?.onSuccess()
dismiss()
}, {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY,"支付失败:${it.message}")
ToastHelper.show(it.message ?: "支付失败")
LogHelper.getInstance().writeLogSync("支付失败:${it.message}")
})
......@@ -200,6 +206,7 @@ class PayDialog : Dialog {
* @param payId 支付id
*/
private fun wxPayById(payId: String,merchantType:String): Observable<PayStatus> {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY,"微信支付")
val bean = WxPayParam(payId, 1,merchantType)
return HttpUtils.wxPay(bean)
.compose(RxUtils.resultData())
......@@ -212,6 +219,8 @@ class PayDialog : Dialog {
* @param payId 支付Id
*/
private fun aliPayById(payId: String): Observable<PayStatus> {
AliYunLogHelper.getInstance().sendLog(AliYunLogConfig.PAY,"支付宝支付")
var bean = AliPayParam(payId, 1)
return HttpUtils.getAliPayOrderId(bean)
.compose(RxUtils.resultData())
......
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