Commit aa09a02c by 严久程

动态支付功能

parent 76709a76
......@@ -19,9 +19,9 @@ import java.util.List;
*/
public final class DemoGlobalConfig implements IConfigModule {
String APP_DOMAIN = "https://api.github.com/";
// String appEnv = YDLConstants.ENV_AUTO_TEST;
public static String appEnv = YDLConstants.ENV_PROD;
// String appEnv = YDLConstants.ENV_TEST;
// public static String appEnv = YDLConstants.ENV_AUTO_TEST;
// public static String appEnv = YDLConstants.ENV_PROD;
public static String appEnv = YDLConstants.ENV_TEST;
@Override
public void injectAppLifecycle(@NotNull Context context, @NotNull List<IAppLifecycles> lifecycles) {
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......
......@@ -101,8 +101,6 @@ public class ThankActivity extends BaseActivity implements PtrHandler, LoadMoreH
lv_content.setAdapter(adapter);
getData(false);
}
......@@ -146,7 +144,7 @@ public class ThankActivity extends BaseActivity implements PtrHandler, LoadMoreH
}
void getData(final boolean loadMore) {
public void getData(final boolean loadMore) {
if (loadMore && !hasMore) {
load_more_list_view_container.loadMoreFinish(false, false);
return;
......
package com.yidianling.dynamic.thank.view
import android.app.Activity
import android.text.TextUtils
import android.view.View
import android.widget.LinearLayout
import butterknife.ButterKnife
import butterknife.OnClick
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydl_image.transform.GlideCircleTransform
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.view.RoundCornerButton
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
import com.yidianling.dynamic.R
import com.yidianling.dynamic.R2
import com.yidianling.dynamic.common.net.DynamicApiUtils
import com.yidianling.dynamic.event.ThankReplyUpdateEvent
import com.yidianling.dynamic.model.Command
import com.yidianling.dynamic.router.DynamicIn
import com.yidianling.dynamic.thank.ShowIntroduceDialogFragment
import com.yidianling.dynamic.thank.ThankActivity
import com.yidianling.dynamic.thank.WorryDetailAnswer
import com.yidianling.dynamic.thank.data.ThxData
import com.yidianling.ydl_pay.CommonPayDialog
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......@@ -62,7 +65,6 @@ class ThankHeadView(activity: Activity) : LinearLayout(activity) {
init {
View.inflate(activity, R.layout.ui_thank_head, this)
ButterKnife.bind(this)
this.activity = activity as BaseActivity
}
......@@ -70,31 +72,36 @@ class ThankHeadView(activity: Activity) : LinearLayout(activity) {
this.thxData = thxData
tsv_select!!.setData(thxData.star_money)
LogUtil.d("thank userInfo head: " + thxData.userInfo.head)
GlideApp.with(context)
GlideApp.with(activity)
.load(thxData.userInfo.head)
.transform(GlideCircleTransform(context))
.transform(GlideCircleTransform(activity))
.placeholder(R.drawable.head_place_hold_pic)
.error(R.drawable.head_place_hold_pic)
.into(sdv_head!!)
}
@OnClick(R2.id.rcb_submit, R2.id.rcb_msg_submit)
internal fun click(view: View) {
if (answerId == 0)
return
if (thxData == null || thxData!!.userInfo == null || thxData!!.userInfo.uid == null)
return
if (thxData!!.userInfo.uid == DynamicIn.getUserInfo()!!.uid) {
ToastUtil.toastShort("不能给自己点赞")
return
}
if (view.id == R.id.rcb_submit) {
rcb_submit.setOnClickListener {
if (answerId == 0)
return@setOnClickListener
if (thxData == null || thxData!!.userInfo == null || thxData!!.userInfo.uid == null)
return@setOnClickListener
if (thxData!!.userInfo.uid == DynamicIn.getUserInfo()!!.uid) {
ToastUtil.toastShort("不能给自己点赞")
return@setOnClickListener
}
submitWithMoney()
} else if (view.id == R.id.rcb_msg_submit) {
submitWithoutMoney()
}
}
// @OnClick(R2.id.rcb_submit, R2.id.rcb_msg_submit)
// internal fun click(view: View) {
//
// if (view.id == R.id.rcb_submit) {
// submitWithMoney()
// } else if (view.id == R.id.rcb_msg_submit) {
// submitWithoutMoney()
// }
// }
internal fun submitWithMoney() {
var starNum = 0
if (selectId == -1) {
......@@ -108,7 +115,7 @@ class ThankHeadView(activity: Activity) : LinearLayout(activity) {
Integer.parseInt(thxData!!.userInfo.uid),
starNum, content, answerId, 1
)
val disposable = DynamicApiUtils.submitZan(cmd)
val disposable = DynamicApiUtils.submitZan(cmd)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
......@@ -121,7 +128,7 @@ class ThankHeadView(activity: Activity) : LinearLayout(activity) {
// payParams.setNeedPay(sendThxWithMoney.money)
// YdlCommonOut.startPayActivity(context as Activity, payParams, 0)
toPay(sendThxWithMoney.payId,sendThxWithMoney.money)
toPay(sendThxWithMoney.payId, sendThxWithMoney.money)
} else {
ToastUtil.toastShort(resp.msg)
}
......@@ -177,31 +184,31 @@ class ThankHeadView(activity: Activity) : LinearLayout(activity) {
fun toPay(payId: String, money: Float) {
// TODO: 2019-12-13 支付逻辑待补充 by:HaoRui
//
// val userInfo = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
// if (userInfo == null || TextUtils.isEmpty(userInfo.userId)) {
// YDLRouterManager.router(IYDLRouterConstant.ROUTER_MINE_LOGIN)
// return
// }
//
// val build = CommonPayDialog.Build(activity)
// .setCourseId(course_id.toString())
// .setToken(userInfo.token)
// .setUid(userInfo.userId)
// .setFfrom(PlatformDataManager.getRam().getChannelName())
// .setListener(object : CommonPayDialog.OnPayResultListener {
// override fun onSuccesed() {
// //刷新界面
// initData()
// }
//
// override fun onFailed() {
val userInfo = DynamicIn.getUserInfo()
if (userInfo == null || TextUtils.isEmpty(userInfo.uid)) {
YDLRouterManager.router(IYDLRouterConstant.ROUTER_MINE_LOGIN)
return
}
//
// }
// })
// .setIsTestEnvironment(BuildConfig.DEBUG)
// build.build().show()
val build = CommonPayDialog.Build(activity)
.setPayId(payId)
.setPayMoney(money)
.setToken(userInfo.accessToken!!)
.setUid(userInfo.uid)
.setFfrom(PlatformDataManager.getRam().getChannelName())
.setListener(object : CommonPayDialog.OnPayResultListener {
override fun onSuccesed() {
//刷新界面
(activity as ThankActivity).getData(false)
}
override fun onFailed() {
}
})
.setIsTestEnvironment(false)
build.build().show()
}
}
......@@ -14,14 +14,15 @@ 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.yidianling.ydl_pay.http.HttpUtils
import com.yidianling.ydl_pay.toast.ToastHelper
import com.yidianling.ydl_pay.widget.PayCouponView
import com.yidianling.ydl_pay.widget.PayInfoDetailView
import com.yidianling.common.tools.RxImageTool
import com.yidianling.ydl_pay.bean.*
import com.yidianling.ydl_pay.bean.params.*
import com.yidianling.ydl_pay.http.HttpUtils
import com.yidianling.ydl_pay.http.utils.NetUtils
import com.yidianling.ydl_pay.http.utils.RxDeviceTool
import com.yidianling.ydl_pay.toast.ToastHelper
import com.yidianling.ydl_pay.widget.PayCouponView
import com.yidianling.ydl_pay.widget.PayInfoDetailView
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......@@ -45,6 +46,8 @@ class CommonPayDialog : Dialog {
private var payCouponView: PayCouponView? = null
private var detailView: PayInfoDetailView? = null
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
......@@ -59,6 +62,7 @@ class CommonPayDialog : Dialog {
* [TYPE_CONFIDE] 倾诉支付
* [TYPE_TEST] 测评支付
* [TYPE_CONSULTANT] 咨询支付
* [TYPE_TRENDS_THANKS] 动态打赏
*/
private var payBusinessType = 0
......@@ -79,6 +83,10 @@ class CommonPayDialog : Dialog {
* 咨询
*/
const val TYPE_CONSULTANT = 4
/**
* 动态打赏
*/
const val TYPE_TRENDS_THANKS = 5
/**
* 支付方式
......@@ -95,6 +103,8 @@ class CommonPayDialog : Dialog {
this.activity = build.mActivity
this.listener = build.listener
this.payBusinessType = build.payType
this.payMoney = build.payMoney
this.thankPayId = build.payId
}
override fun onCreate(savedInstanceState: Bundle?) {
......@@ -108,10 +118,71 @@ class CommonPayDialog : Dialog {
EventBus.getDefault().register(this)
getOrderInfo()
if (payBusinessType == TYPE_TRENDS_THANKS) {
var parmas = view_pager.layoutParams
parmas.width = ViewGroup.LayoutParams.MATCH_PARENT
parmas.height = RxImageTool.dp2px(371f)
view_pager.layoutParams = parmas
getMyBalance()
} else {
getOrderInfo()
}
}
private fun initThanksPayInfoDetailView(bean: OrderInfoBean) {
view_pager.setScanScroll(false)
detailView =
PayInfoDetailView(activity, object : PayInfoDetailView.OnCouponDetailClickListener {
override fun selectCoupon(couponId: String) {
}
override fun ensurePay(
payWay: Int,
payMoney: Float,
useMoneyType: Int,
code: String,
couponType: String
) {
//感谢的时候比较暴力:payid是外部传过来的、余额一定会被扣掉
if (payBusinessType == TYPE_TRENDS_THANKS) {
showProgressDialog()
if (payMoney > 0) {
when (payWay) {
PAY_WECHAT -> {
getWeiXinPayOrderId(
thankPayId!!,
if (useMoneyType == 2) 1 else 0
)
}
else -> {
getAliPayOrderId(thankPayId!!, if (useMoneyType == 2) 1 else 0)
}
}
} else {
//余额支付
payByCharge()
}
}
}
})
if (bean.maxCoupon != null) {
//最优的优惠券id为0时,把最优优惠券对象置为null,因为正常的可用的优惠券id一定不为0,这里接口为了前端页面展示,返回的maxCoupon对象不为null,
//但maxCoupon的属性均为null或初始值
if (TextUtils.equals(bean.maxCoupon.id, "0")) {
bean.maxCoupon = null
}
}
detailView!!.setData(bean, payBusinessType)
viewList.add(detailView!!)
view_pager.adapter = ViewPagerAdapter()
view_pager.currentItem = 0
}
override fun show() {
super.show()
showProgressDialog()
......@@ -133,46 +204,83 @@ class CommonPayDialog : Dialog {
bean.goodsId = goodsId
bean.orderType = payBusinessType.toString()
HttpUtils.getOrderInfo(bean)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
dismissProgressDialog()
if (it.code == 200) {
if (it.data != null) {
progress_layout.visibility = View.GONE
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
dismissProgressDialog()
if (it.code == 200) {
if (it.data != null) {
progress_layout.visibility = View.GONE
view_pager.visibility = View.VISIBLE
updateDataOnView(it.data)
} else {
ToastHelper.show(activity, it.msg)
// progress.visibility = View.GONE
}
view_pager.visibility = View.VISIBLE
updateDataOnView(it.data)
} else {
ToastHelper.show(activity, it.msg)
// progress.visibility = View.GONE
}
} else {
ToastHelper.show(activity, it.msg)
// progress.visibility = View.GONE
}
}, { e ->
dismissProgressDialog()
// progress.visibility = View.GONE
ToastHelper.show(activity, e.message!!)
})
}
@SuppressLint("CheckResult")
private fun getMyBalance() {
HttpUtils.getMyBalance(BalanceParam())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
dismissProgressDialog()
if (it.status == 200) {
if (it.data != null) {
progress_layout.visibility = View.GONE
view_pager.visibility = View.VISIBLE
val bean = OrderInfoBean()
bean.availableMoney = it.data.balance
bean.applyFee = payMoney!!
bean.isShowCoupon = false
initThanksPayInfoDetailView(bean)
} else {
ToastHelper.show(activity, it.msg)
}
}, { e ->
dismissProgressDialog()
// progress.visibility = View.GONE
ToastHelper.show(activity, e.message!!)
})
} else {
ToastHelper.show(activity, it.msg)
}
}, {
dismissProgressDialog()
ToastHelper.show(activity, it.message!!)
})
}
private fun updateDataOnView(bean: OrderInfoBean) {
view_pager.setScanScroll(false)
detailView = PayInfoDetailView(activity, object : PayInfoDetailView.OnCouponDetailClickListener {
override fun selectCoupon(couponId: String) {
if (couponListBean != null) {
view_pager.currentItem = 1
} else {
getAllCoupon()
detailView =
PayInfoDetailView(activity, object : PayInfoDetailView.OnCouponDetailClickListener {
override fun selectCoupon(couponId: String) {
if (couponListBean != null) {
view_pager.currentItem = 1
} else {
getAllCoupon()
}
}
}
override fun ensurePay(payWay: Int, payMoney: Float, useMoneyType: Int, code: String, couponType: String) {
createOrder(payWay, payMoney, useMoneyType, code, couponType)
}
})
override fun ensurePay(
payWay: Int,
payMoney: Float,
useMoneyType: Int,
code: String,
couponType: String
) {
createOrder(payWay, payMoney, useMoneyType, code, couponType)
}
})
if (bean.maxCoupon != null) {
//最优的优惠券id为0时,把最优优惠券对象置为null,因为正常的可用的优惠券id一定不为0,这里接口为了前端页面展示,返回的maxCoupon对象不为null,
//但maxCoupon的属性均为null或初始值
......@@ -229,24 +337,24 @@ class CommonPayDialog : Dialog {
showProgressDialog()
HttpUtils.selectCoupon(bean)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
dismissProgressDialog()
if (it.code == 200) {
if (it.data != null) {
couponListBean = it.data
updateSelectCouponView()
} else {
ToastHelper.show(activity, it.msg)
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
dismissProgressDialog()
if (it.code == 200) {
if (it.data != null) {
couponListBean = it.data
updateSelectCouponView()
} else {
ToastHelper.show(activity, it.msg)
}
}, { e ->
dismissProgressDialog()
ToastHelper.show(activity, e.message!!)
})
} else {
ToastHelper.show(activity, it.msg)
}
}, { e ->
dismissProgressDialog()
ToastHelper.show(activity, e.message!!)
})
}
......@@ -255,7 +363,12 @@ class CommonPayDialog : Dialog {
*/
private fun updateSelectCouponView() {
detailView!!.setAvailableCount(couponListBean!!.availableCount)
payCouponView!!.setData(couponListBean!!, payBusinessType == TYPE_COURSE, selectedCouponBean, goodsId!!)
payCouponView!!.setData(
couponListBean!!,
payBusinessType == TYPE_COURSE,
selectedCouponBean,
goodsId!!
)
view_pager.currentItem = 1
}
......@@ -268,7 +381,13 @@ class CommonPayDialog : Dialog {
*
*/
@SuppressLint("CheckResult")
private fun createOrder(payWay: Int, payMoney: Float, useMoneyType: Int, code: String, couponType: String) {
private fun createOrder(
payWay: Int,
payMoney: Float,
useMoneyType: Int,
code: String,
couponType: String
) {
if (!NetUtils.isConnected(activity)) {
ToastHelper.show(activity, activity.getString(R.string.net_error))
return
......@@ -292,40 +411,43 @@ class CommonPayDialog : Dialog {
showProgressDialog()
HttpUtils.createOrder(bean)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == 200) {
if (it.data != null) {
if (it.data.payStatus) {
dismissProgressDialog()
ToastHelper.show(activity, "支付成功")
if (listener != null) {
listener!!.onSuccesed()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == 200) {
if (it.data != null) {
if (it.data.payStatus) {
dismissProgressDialog()
ToastHelper.show(activity, "支付成功")
if (listener != null) {
listener!!.onSuccesed()
}
dismiss()
} else {
when (payWay) {
PAY_WECHAT -> {
getWeiXinPayOrderId(
it.data.payId,
if (useMoneyType == 2) 1 else 0
)
}
dismiss()
} else {
when (payWay) {
PAY_WECHAT -> {
getWeiXinPayOrderId(it.data.payId, if (useMoneyType == 2) 1 else 0)
}
else -> {
getAliPayOrderId(it.data.payId, if (useMoneyType == 2) 1 else 0)
}
else -> {
getAliPayOrderId(it.data.payId, if (useMoneyType == 2) 1 else 0)
}
}
} else {
dismissProgressDialog()
ToastHelper.show(activity, it.msg)
}
} else {
dismissProgressDialog()
ToastHelper.show(activity, it.msg)
}
}, { e ->
} else {
dismissProgressDialog()
ToastHelper.show(activity, e.message!!)
})
ToastHelper.show(activity, it.msg)
}
}, { e ->
dismissProgressDialog()
ToastHelper.show(activity, e.message!!)
})
}
/**
......@@ -343,22 +465,22 @@ class CommonPayDialog : Dialog {
var bean = AliPayParam(payId, isThreePay)
HttpUtils.getAliPayOrderId(bean)
.subscribeOn(Schedulers.io())
.subscribe({
if (it.data != null) {
aliPay(it.data.aliSign)
} else {
activity.runOnUiThread {
ToastHelper.show(activity, it.msg)
}
dismissProgressDialog()
}
}, {
.subscribeOn(Schedulers.io())
.subscribe({
if (it.data != null) {
aliPay(it.data.aliSign)
} else {
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
ToastHelper.show(activity, it.msg)
}
dismissProgressDialog()
})
}
}, {
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
}
dismissProgressDialog()
})
}
private fun aliPay(aliSign: String) {
......@@ -394,22 +516,22 @@ class CommonPayDialog : Dialog {
var bean = WxPayParam(payId, isThreePay)
HttpUtils.wxPay(bean)
.subscribeOn(Schedulers.io())
.subscribe({
if (it.data != null) {
weixinPay(it.data.option)
} else {
activity.runOnUiThread {
ToastHelper.show(activity, it.msg)
}
dismissProgressDialog()
}
}, {
.subscribeOn(Schedulers.io())
.subscribe({
if (it.data != null) {
weixinPay(it.data.option)
} else {
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
ToastHelper.show(activity, it.msg)
}
dismissProgressDialog()
})
}
}, {
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
}
dismissProgressDialog()
})
}
private fun weixinPay(option: CommonWXPayBean.WXOption) {
......@@ -429,6 +551,33 @@ class CommonPayDialog : Dialog {
api.sendReq(request)
}
@SuppressLint("CheckResult")
private fun payByCharge() {
var bean = ChargePayParam()
bean.payId = thankPayId
HttpUtils.payByCharge(bean)
.subscribeOn(Schedulers.io())
.subscribe({
dismissProgressDialog()
if (it.data != null && it.code == 0) {
activity.runOnUiThread {
listener!!.onSuccesed()
dismiss()
}
} else {
activity.runOnUiThread {
ToastHelper.show(activity, it.msg)
}
}
}, {
activity.runOnUiThread {
ToastHelper.show(activity, it.localizedMessage)
}
dismissProgressDialog()
})
}
fun onEvent(event: WeiXinPayStatusEvent) {
dismissProgressDialog()
if (event.success) {
......@@ -453,10 +602,11 @@ class CommonPayDialog : Dialog {
}
if (dialog == null) {
dialog = AlertDialog.Builder(activity)
.create()
.create()
}
if (dialogContentView == null) {
dialogContentView = LayoutInflater.from(activity).inflate(R.layout.pay_loading_dialog, null)
dialogContentView =
LayoutInflater.from(activity).inflate(R.layout.pay_loading_dialog, null)
}
dialog?.show()
dialog?.window?.setContentView(dialogContentView)
......@@ -510,6 +660,8 @@ class CommonPayDialog : Dialog {
*/
class Build(internal var mActivity: Activity) {
internal var goodsId: String? = null
internal var payId: String? = null
internal var payMoney: Float? = null
private lateinit var uid: String
private lateinit var token: String
private lateinit var ffrom: String
......@@ -529,6 +681,18 @@ class CommonPayDialog : Dialog {
return this@Build
}
fun setPayId(payId: String): Build {
this.payId = payId
payType = TYPE_TRENDS_THANKS
return this@Build
}
fun setPayMoney(money: Float): Build {
this.payMoney = money
return this@Build
}
/**
* 商品id(调用此方法请务必再调用[setBusinessType]方法)
*/
......
package com.yidianling.ydl_pay.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/12/16
*/
class BalanceBean(val balance: Float)
\ No newline at end of file
package com.yidianling.ydl_pay.bean.params;
import com.ydl.ydlcommon.data.http.BaseCommand;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/12/16
*/
public class BalanceParam extends BaseCommand {
public int balance = 1;
}
package com.yidianling.ydl_pay.bean.params;
import com.ydl.ydlcommon.data.http.BaseCommand;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/12/16
*/
public class ChargePayParam extends BaseCommand {
public String payId;
}
package com.yidianling.ydl_pay.http
import com.google.gson.Gson
import com.yidianling.ydl_pay.actionpoint.ActionDataBean
import com.ydl.ydlcommon.data.http.BaseCommand
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.utils.NetworkParamsUtils
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.ydl_pay.actionpoint.ActionDataBean
import com.yidianling.ydl_pay.bean.*
import com.yidianling.ydl_pay.bean.params.CheckRequestCouponBean
import com.yidianling.ydl_pay.bean.params.CreateOrderRequestBean
......@@ -29,7 +29,10 @@ class HttpUtils {
*/
fun getOrderInfo(bean: OrderRequestBean): Observable<BaseResponse<OrderInfoBean>> {
var str = Gson().toJson(bean)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str) as RequestBody
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
str
) as RequestBody
return YDLHttpUtils.obtainApi(PayServices::class.java).getOrderInfo(body)
}
......@@ -38,7 +41,10 @@ class HttpUtils {
*/
fun checkCourseCoupon(bean: CheckRequestCouponBean): Observable<BaseResponse<CouponCodeInfoBean>> {
var str = Gson().toJson(bean)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str) as RequestBody
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
str
) as RequestBody
return YDLHttpUtils.obtainApi(PayServices::class.java).checkCourseCoupon(body)
}
......@@ -48,7 +54,10 @@ class HttpUtils {
*/
fun selectCoupon(bean: GetAllCouponRequestBean): Observable<BaseResponse<AllCouponListBean>> {
var str = Gson().toJson(bean)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str) as RequestBody
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
str
) as RequestBody
return YDLHttpUtils.obtainApi(PayServices::class.java).selectCoupon(body)
}
......@@ -58,7 +67,10 @@ class HttpUtils {
*/
fun createOrder(bean: CreateOrderRequestBean): Observable<BaseResponse<PayOrderBean>> {
var str = Gson().toJson(bean)
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), str) as RequestBody
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
str
) as RequestBody
return YDLHttpUtils.obtainApi(PayServices::class.java).createOrder(body)
}
......@@ -67,26 +79,48 @@ class HttpUtils {
* 支付宝在线支付
*/
fun getAliPayOrderId(bean: BaseCommand): Observable<BaseResponse<CommonPayRecharge>> {
var params = NetworkParamsUtils.getPostList(bean)
var params = NetworkParamsUtils.getPostList(bean)
var map = NetworkParamsUtils.getMaps(params)
return YDLHttpUtils.obtainApi(PayServices::class.java).getAliPayOrderId(map)
return YDLHttpUtils.obtainApi(PayServices::class.java).getAliPayOrderId(map)
}
/**
* 微信在线支付
*/
fun wxPay(bean: BaseCommand): Observable<BaseResponse<CommonWXPayBean>> {
var params = NetworkParamsUtils.getPostList(bean)
var params = NetworkParamsUtils.getPostList(bean)
var map = NetworkParamsUtils.getMaps(params)
return YDLHttpUtils.obtainApi(PayServices::class.java).wxPay(map)
}
/**
* 余额的接口
*/
fun getMyBalance(bean: BaseCommand): Observable<BaseResponse<BalanceBean>> {
var params = NetworkParamsUtils.getPostList(bean)
var map = NetworkParamsUtils.getMaps(params)
return YDLHttpUtils.obtainApi(PayServices::class.java).getMyBalance(map)
}
/**
* 余额支付
*/
fun payByCharge(bean: BaseCommand): Observable<BaseResponse<Any>> {
var params = NetworkParamsUtils.getPostList(bean)
var map = NetworkParamsUtils.getMaps(params)
return YDLHttpUtils.obtainApi(PayServices::class.java).pay(map)
}
/**
* 行为数据埋点统计接口
*/
internal fun actionDataCount(actionDataParams: ActionDataBean): Observable<BaseResponse<String>> {
val body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), Gson().toJson(actionDataParams))
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
Gson().toJson(actionDataParams)
)
return YDLHttpUtils.obtainApi(PayServices::class.java).actionDataCount(body)
}
}
......
......@@ -65,4 +65,14 @@ interface PayServices {
//行为动作埋点统计接口
@POST("maidian/writeMaiDianData")
fun actionDataCount(@Body body: RequestBody): Observable<BaseResponse<String>>
//余额的接口
@FormUrlEncoded
@POST("uc/mybalance")
fun getMyBalance(@FieldMap params: Map<String, String>): Observable<BaseResponse<BalanceBean>>
//余额支付
@FormUrlEncoded
@POST("pay/vcount-pay")
fun pay(@FieldMap params: Map<String, String>): Observable<BaseResponse<Any>>
}
\ No newline at end of file
......@@ -20,7 +20,8 @@ import java.math.BigDecimal
* @date 2019/4/4
*/
@SuppressLint("ViewConstructor")
class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListener) : LinearLayout(context) {
class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListener) :
LinearLayout(context) {
private var orderInfoBean: OrderInfoBean? = null
/**
* 是否使用余额
......@@ -76,7 +77,10 @@ class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListe
private fun initView() {
orientation = VERTICAL
val params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
val params = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
layoutParams = params
View.inflate(context, R.layout.view_pay_info_detail, this)
......@@ -123,7 +127,13 @@ class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListe
MONEY_TYPE_CHANGE
}
if (orderInfoBean!!.maxCoupon != null) {
listener.ensurePay(payWay, sdkPayMoney, useMoneyType, orderInfoBean!!.maxCoupon.code, orderInfoBean!!.maxCoupon.couponType)
listener.ensurePay(
payWay,
sdkPayMoney,
useMoneyType,
orderInfoBean!!.maxCoupon.code,
orderInfoBean!!.maxCoupon.couponType
)
} else {
listener.ensurePay(payWay, sdkPayMoney, useMoneyType, "", "")
}
......@@ -154,6 +164,16 @@ class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListe
tv_pay_title.text = "咨询服务"
}
if (payBusinessType == 5) {
tv_pay_title.text = "送感谢"
tv_change_money.isEnabled = false
if (orderInfoBean.availableMoney >= orderInfoBean.applyFee) {
rl_third_pay.visibility = View.INVISIBLE
rl_third_pay.isEnabled = false
}
}
//价格
tv_price.text = orderInfoBean.applyFee.toString()
......@@ -217,6 +237,7 @@ class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListe
ll_third_pay.isEnabled = true
}
if (isUseChange) {//使用余额
if (orderInfoBean!!.availableMoney >= needPay) {
tv_change_money.text = needPay.toString()
......@@ -275,9 +296,19 @@ class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListe
*/
private fun setChooseChangeMoney(isUse: Boolean) {
if (isUse) {
tv_change_money.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.pay_img_select, 0)
tv_change_money.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.pay_img_select,
0
)
} else {
tv_change_money.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.pay_img_no_select, 0)
tv_change_money.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.pay_img_no_select,
0
)
}
}
......@@ -297,6 +328,12 @@ class PayInfoDetailView(context: Context, var listener: OnCouponDetailClickListe
* @param couponType 券类型 1兑换券 2新优惠券
*
*/
fun ensurePay(payWay: Int, payMoney: Float, useMoneyType: Int, code: String, couponType: String)
fun ensurePay(
payWay: Int,
payMoney: Float,
useMoneyType: Int,
code: String,
couponType: String
)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/pay_color_FFFFFF">
android:background="@color/pay_color_FFFFFF"
android:orientation="vertical"
tools:parentTag="android.widget.LinearLayout">
<RelativeLayout
......@@ -197,105 +199,112 @@
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_third_pay"
<RelativeLayout
android:id="@+id/rl_third_pay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/pay_color_F7F7F7"
android:gravity="bottom"
android:paddingLeft="15dp"
android:paddingBottom="4dp"
android:text="选择支付方式"
android:textSize="12dp" />
<RelativeLayout
android:id="@+id/rl_weixin_pay"
<LinearLayout
android:id="@+id/ll_third_pay"
android:layout_width="match_parent"
android:layout_height="54dp"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:id="@+id/img_weixin"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:src="@drawable/pay_wechat_for_pay" />
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/img_weixin"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/pay_color_F7F7F7"
android:gravity="bottom"
android:paddingLeft="15dp"
android:paddingBottom="4dp"
android:text="选择支付方式"
android:textSize="12dp" />
<RelativeLayout
android:id="@+id/rl_weixin_pay"
android:layout_width="match_parent"
android:layout_height="54dp"
android:gravity="center_vertical"
android:text="微信支付"
android:textColor="@color/pay_color_242424"
android:textSize="15dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/img_weixin_way"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/pay_img_select" />
</RelativeLayout>
<View style="@style/pay_divide_color_style" />
<RelativeLayout
android:id="@+id/rl_ali_pay"
android:layout_width="match_parent"
android:layout_height="54dp"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:id="@+id/img_ali"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:src="@drawable/pay_zhifubao_for_pay" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/img_ali"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:id="@+id/img_weixin"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:src="@drawable/pay_wechat_for_pay" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/img_weixin"
android:gravity="center_vertical"
android:text="微信支付"
android:textColor="@color/pay_color_242424"
android:textSize="15dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/img_weixin_way"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/pay_img_select" />
</RelativeLayout>
<View style="@style/pay_divide_color_style" />
<RelativeLayout
android:id="@+id/rl_ali_pay"
android:layout_width="match_parent"
android:layout_height="54dp"
android:gravity="center_vertical"
android:text="支付宝支付"
android:textColor="@color/pay_color_242424"
android:textSize="15dp"
android:textStyle="bold" />
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:id="@+id/img_ali"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:src="@drawable/pay_zhifubao_for_pay" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/img_ali"
android:gravity="center_vertical"
android:text="支付宝支付"
android:textColor="@color/pay_color_242424"
android:textSize="15dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/img_ali_way"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/pay_img_no_select" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:id="@+id/img_ali_way"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/pay_img_no_select" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="@+id/view_empty"
......
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