Commit 1cb53fb1 authored by mengcuiguang's avatar mengcuiguang

添加umeng电商

parent 7f7073f4
package com.mints.xunmi.manager
import com.mints.xunmi.MintsApplication
import com.umeng.analytics.MobclickAgent
import java.lang.Exception
import java.util.HashMap
/**
* 电商场景
*/
object UmengManager {
/**
* 指注册设备数,在App内用户注册成功的设备数,
* 请在注册成功后执行此事件,系统会追踪点击后续15日(含当日)的激活并注册行为,
* 一个用户在App内多次注册,注册设备数只算1次
*/
fun register(userid: String) {
try {
val vo = HashMap<String, String>()
vo["userid"] = userid
MobclickAgent.onEvent(MintsApplication.getContext(), "__register", vo)
} catch (e: Exception) {
e.printStackTrace()
}
}
/**
* 在App内通过用账号“登录”成功的设备数,
* 在登录成功后执行此事件,系统将记录此事件。追踪点击后续15日(含当日)的激活并登录的行为,
* 一个用户在App内多次登录,登录设备数只算1次。
*/
fun login(userid: String) {
try {
val vo = HashMap<String, String>()
vo["userid"] = userid
MobclickAgent.onEvent(MintsApplication.getContext(), "__login", vo)
} catch (e: Exception) {
e.printStackTrace()
}
}
/**
* 在有付费场景中,在支付成功后后执行此事件,
* 系统将记录此事件。追踪点击后续15日(含当日)的激活并成功支付的行为,
* 一个用户在App内多次付费,“付费设备数”只算1次;
* “付费金额”每次支持的金额累加; “付费次数“每次支持累加
*/
fun pay(userid: String, orderid: String, amount: String) {
try {
val vo = HashMap<String, String>()
vo["userid"] = userid
vo["orderid"] = orderid
vo["item"] = "buyVip"
vo["amount"] = amount
MobclickAgent.onEvent(MintsApplication.getContext(), "__finish_payment", vo)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import com.mints.xunmi.common.Constant
import com.mints.xunmi.common.DeviceInfo
import com.mints.xunmi.manager.AppHttpManager
import com.mints.xunmi.manager.JpushManager
import com.mints.xunmi.manager.UmengManager
import com.mints.xunmi.manager.UserManager
import com.mints.xunmi.mvp.model.BaseResponse
import com.mints.xunmi.mvp.model.LocationBean
......@@ -231,6 +232,8 @@ class MainFragmentPresenter : BasePresenter<MainFragmentView>() {
UserManager.getInstance().saveUserInfo(data)
val consumer = data.getConsumer()
if (consumer != null) {
UmengManager.register(data.consumer.pk_id.toString())
UmengManager.login(data.consumer.pk_id.toString())
saveTerminalInfo(context)
}
checkProductType()
......
......@@ -10,6 +10,7 @@ import com.mints.library.utils.json.JsonUtil
import com.mints.xunmi.common.AppConfig
import com.mints.xunmi.common.DeviceInfo
import com.mints.xunmi.manager.AppHttpManager
import com.mints.xunmi.manager.UmengManager
import com.mints.xunmi.manager.UserManager
import com.mints.xunmi.mvp.model.BaseResponse
import com.mints.xunmi.mvp.model.LocationBean
......@@ -102,6 +103,8 @@ class MyPresenter : BasePresenter<MyView>() {
UserManager.getInstance().saveUserInfo(data)
val consumer = data.getConsumer()
if (consumer != null) {
UmengManager.register(data.consumer.pk_id.toString())
UmengManager.login(data.consumer.pk_id.toString())
saveTerminalInfo(context, consumer)
}
}
......
......@@ -9,6 +9,7 @@ import com.mints.library.utils.json.JsonUtil
import com.mints.xunmi.common.AppConfig
import com.mints.xunmi.common.DeviceInfo
import com.mints.xunmi.manager.AppHttpManager
import com.mints.xunmi.manager.UmengManager
import com.mints.xunmi.manager.UserManager
import com.mints.xunmi.mvp.model.BaseResponse
import com.mints.xunmi.mvp.model.LocationBean
......@@ -43,6 +44,8 @@ class PositionPresenter : BasePresenter<PositionView>() {
UserManager.getInstance().saveUserInfo(data)
val consumer = data.getConsumer()
if (consumer != null) {
UmengManager.register(data.consumer.pk_id.toString())
UmengManager.login(data.consumer.pk_id.toString())
saveTerminalInfo(context, consumer)
}
}
......
......@@ -11,6 +11,7 @@ import com.mints.xunmi.BuildConfig
import com.mints.xunmi.R
import com.mints.xunmi.common.Constant
import com.mints.xunmi.manager.JpushLoginManager
import com.mints.xunmi.manager.UmengManager
import com.mints.xunmi.manager.UserManager
import com.mints.xunmi.mvp.model.VipBean
import com.mints.xunmi.mvp.model.WxPayParamBean
......@@ -206,6 +207,9 @@ class Vip2Activity : BaseActivity()
RxPay(this).requestWXpay(str)
.subscribe({ isPay ->
if (isPay) {
if (vipList != null && vipList!!.size > 0) {
UmengManager.pay(UserManager.getInstance().userID, wxParanBean.tid.toString(), vipList!![0].price.toString())
}
//支付成功
UserManager.getInstance().vipFlag = true
}
......@@ -220,6 +224,9 @@ class Vip2Activity : BaseActivity()
RxPay(this).requestAlipay(wxParanBean.params.params)
.subscribe({ isPay ->
if (isPay) {
if (vipList != null && vipList!!.size > 0) {
UmengManager.pay(UserManager.getInstance().userID, wxParanBean.tid.toString(), vipList!![0].price.toString())
}
//支付成功
UserManager.getInstance().vipFlag = true
}
......
......@@ -12,6 +12,7 @@ import com.mints.xunmi.BuildConfig
import com.mints.xunmi.R
import com.mints.xunmi.common.Constant
import com.mints.xunmi.manager.JpushLoginManager
import com.mints.xunmi.manager.UmengManager
import com.mints.xunmi.manager.UserManager
import com.mints.xunmi.manager.VipPayManager
import com.mints.xunmi.mvp.model.VipBean
......@@ -203,6 +204,9 @@ class Vip3Activity : BaseActivity()
RxPay(this).requestWXpay(str)
.subscribe({ isPay ->
if (isPay) {
if (vipList != null && vipList!!.size > 0) {
UmengManager.pay(UserManager.getInstance().userID, wxParanBean.tid.toString(), vipList!![vipAdapter?.getPosition()].price.toString())
}
//支付成功
UserManager.getInstance().vipFlag = true
}
......@@ -217,6 +221,9 @@ class Vip3Activity : BaseActivity()
RxPay(this).requestAlipay(wxParanBean.params.params)
.subscribe({ isPay ->
if (isPay) {
if (vipList != null && vipList!!.size > 0) {
UmengManager.pay(UserManager.getInstance().userID, wxParanBean.tid.toString(), vipList!![vipAdapter?.getPosition()].price.toString())
}
//支付成功
UserManager.getInstance().vipFlag = true
}
......
......@@ -12,6 +12,7 @@ import com.mints.xunmi.BuildConfig
import com.mints.xunmi.R
import com.mints.xunmi.common.Constant
import com.mints.xunmi.manager.JpushLoginManager
import com.mints.xunmi.manager.UmengManager
import com.mints.xunmi.manager.UserManager
import com.mints.xunmi.mvp.model.VipBean
import com.mints.xunmi.mvp.model.WxPayParamBean
......@@ -181,6 +182,9 @@ class VipActivity : BaseActivity()
RxPay(this).requestWXpay(str)
.subscribe({ isPay ->
if (isPay) {
if (vipList != null && vipList!!.size > 0) {
UmengManager.pay(UserManager.getInstance().userID, wxParanBean.tid.toString(), vipList!![vipAdapter?.getPosition()].price.toString())
}
//支付成功
UserManager.getInstance().vipFlag = true
}
......@@ -195,6 +199,9 @@ class VipActivity : BaseActivity()
RxPay(this).requestAlipay(wxParanBean.params.params)
.subscribe({ isPay ->
if (isPay) {
if (vipList != null && vipList!!.size > 0) {
UmengManager.pay(UserManager.getInstance().userID, wxParanBean.tid.toString(), vipList!![vipAdapter?.getPosition()].price.toString())
}
//支付成功
UserManager.getInstance().vipFlag = true
}
......
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