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) {
rcb_submit.setOnClickListener {
if (answerId == 0)
return
return@setOnClickListener
if (thxData == null || thxData!!.userInfo == null || thxData!!.userInfo.uid == null)
return
return@setOnClickListener
if (thxData!!.userInfo.uid == DynamicIn.getUserInfo()!!.uid) {
ToastUtil.toastShort("不能给自己点赞")
return
return@setOnClickListener
}
if (view.id == R.id.rcb_submit) {
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) {
......@@ -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()
}
}
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)
}
......@@ -83,10 +95,32 @@ class HttpUtils {
/**
* 余额的接口
*/
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,6 +199,11 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_third_pay"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_third_pay"
......@@ -297,6 +304,8 @@
</LinearLayout>
</RelativeLayout>
<View
android:id="@+id/view_empty"
android:layout_width="match_parent"
......
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