Selaa lähdekoodia

feat: add merchant transfer confirmation for withdraw

danyshen 2 päivää sitten
vanhempi
commit
a097132bad

+ 4 - 2
packageUser/pages/user/cash/cash.js

@@ -1,5 +1,6 @@
 var _request = require('../../../../utils/request.js')
 var util = require('../../../../utils/util.js')
+var MAX_MERCHANT_TRANSFER_CASH = 20000
 Page({
   data: {
     page: 1,
@@ -96,10 +97,11 @@ Page({
   		var url = 'v1/user/takecash/limit'
     var params = {}
     var success = function (res) {
-		var withdrawnum = that.data.balance > res.data.max_limit_cash ? res.data.max_limit_cash:that.data.balance;
+		var maxCash = Math.min(res.data.max_limit_cash || MAX_MERCHANT_TRANSFER_CASH, MAX_MERCHANT_TRANSFER_CASH)
+		var withdrawnum = that.data.balance > maxCash ? maxCash : that.data.balance;
       that.setData({
         min_cash: res.data.min_limit_cash,
-        max_cash: res.data.max_limit_cash,
+        max_cash: maxCash,
 		fee:res.data.fee_bl ? res.data.fee_bl : 0,
 		withdraw_num: withdrawnum,
 		view_withdraw:parseFloat(withdrawnum/100).toFixed(2),

+ 40 - 0
packageUser/pages/user/cashDetail/cashDetail.js

@@ -21,6 +21,46 @@ Page({
     }
     _request.$get(url, params, success)
   },
+  confirmMerchantTransfer () {
+    var that = this
+    var detail = that.data.detail || {}
+    if (!detail.can_confirm_transfer || !detail.package_info) {
+      wx.showToast({
+        title: '当前提现无需确认收款',
+        icon: 'none',
+        duration: 2000
+      })
+      return
+    }
+    if (!wx.canIUse || !wx.canIUse('requestMerchantTransfer')) {
+      wx.showToast({
+        title: '当前微信版本不支持确认收款,请升级微信',
+        icon: 'none',
+        duration: 2000
+      })
+      return
+    }
+    wx.requestMerchantTransfer({
+      mchId: String(detail.mch_id || ''),
+      appId: String(detail.app_id || ''),
+      package: detail.package_info,
+      success: function () {
+        wx.showToast({
+          title: '确认收款已提交',
+          icon: 'none',
+          duration: 2000
+        })
+        that.getRadish()
+      },
+      fail: function (res) {
+        wx.showToast({
+          title: (res && res.errMsg) ? res.errMsg : '确认收款失败',
+          icon: 'none',
+          duration: 3000
+        })
+      }
+    })
+  },
   onShareAppMessage: function (val) {
     return _request.share({
       sc: 'xcx_user_radishdetail'

+ 6 - 0
packageUser/pages/user/cashDetail/cashDetail.wxml

@@ -30,5 +30,11 @@
       <view class="radishDetail-line__value">{{detail.remark}}</view>
       <view class="clean"></view>
     </view>
+    <view class="radishDetail-line" wx:if="{{detail.transfer_state}}">
+      <view class="radishDetail-line__title">转账状态</view>
+      <view class="radishDetail-line__value">{{detail.transfer_state}}</view>
+      <view class="clean"></view>
+    </view>
+    <view class="merchant-transfer-btn" wx:if="{{detail.can_confirm_transfer}}" bindtap="confirmMerchantTransfer">确认收款</view>
   </view>
 </view>

+ 12 - 1
packageUser/pages/user/cashDetail/cashDetail.wxss

@@ -34,4 +34,15 @@
   float: right;
   width: 540rpx;
   text-align: right;
-}
+}
+.merchant-transfer-btn {
+  width: 560rpx;
+  height: 88rpx;
+  line-height: 88rpx;
+  margin: 56rpx auto 0;
+  border-radius: 44rpx;
+  background-image: linear-gradient(90deg, #eab86a 0%, #e23232 100%);
+  color: #ffffff;
+  font-size: 30rpx;
+  text-align: center;
+}

+ 47 - 1
packageUser/pages/user/withdraw/withdraw.js

@@ -76,9 +76,55 @@ Page({
     }
     _request.$get(url, params, success)
   },
+  confirmMerchantTransfer (e) {
+    var that = this
+    var index = e.currentTarget.dataset.index
+    var item = that.data.cashList[index] || {}
+    if (!item.can_confirm_transfer || !item.package_info) {
+      wx.showToast({
+        title: '当前提现无需确认收款',
+        icon: 'none',
+        duration: 2000
+      })
+      return
+    }
+    if (!wx.canIUse || !wx.canIUse('requestMerchantTransfer')) {
+      wx.showToast({
+        title: '当前微信版本不支持确认收款,请升级微信',
+        icon: 'none',
+        duration: 2000
+      })
+      return
+    }
+    wx.requestMerchantTransfer({
+      mchId: String(item.mch_id || ''),
+      appId: String(item.app_id || ''),
+      package: item.package_info,
+      success: function () {
+        wx.showToast({
+          title: '确认收款已提交',
+          icon: 'none',
+          duration: 2000
+        })
+        that.setData({
+          page: 1,
+          cashList_more: true,
+          cashList_change: true
+        })
+        that.getCashList()
+      },
+      fail: function (res) {
+        wx.showToast({
+          title: (res && res.errMsg) ? res.errMsg : '确认收款失败',
+          icon: 'none',
+          duration: 3000
+        })
+      }
+    })
+  },
   onShareAppMessage: function (val) {
     return _request.share({
       sc: 'xcx_user_withdraw'
     })
   }
-})
+})

+ 2 - 1
packageUser/pages/user/withdraw/withdraw.wxml

@@ -33,9 +33,10 @@
       <view class="price1" wx:if="{{!item.pay_state && (!item.audit_state || item.audit_state === 1)}}">{{item.state_cn}}</view>
       <view class="price2" wx:if="{{(!item.pay_state && item.audit_state === 2) || (item.pay_state === 2 && item.audit_state === 1)}}">{{item.state_cn}}</view>
       <view class="price3" wx:if="{{item.pay_state ===1 && item.audit_state === 1}}">{{item.state_cn}}</view>
+      <view class="confirm-transfer" wx:if="{{item.can_confirm_transfer}}" data-index="{{index}}" catchtap="confirmMerchantTransfer">确认收款</view>
       <view class="time"><format-time type="formatTime1" value="{{item.created_at}}" ></format-time></view>
       <view class="clean"></view>
     </view>
   </view>
 
-</view>
+</view>

+ 14 - 1
packageUser/pages/user/withdraw/withdraw.wxss

@@ -88,6 +88,19 @@
   font-size: 28rpx;
   color: #bbb;
 }
+.confirm-transfer {
+  float: left;
+  min-width: 150rpx;
+  height: 52rpx;
+  line-height: 52rpx;
+  padding: 0 22rpx;
+  margin-left: 24rpx;
+  border-radius: 26rpx;
+  background-image: linear-gradient(90deg, #eab86a 0%, #e23232 100%);
+  color: #ffffff;
+  font-size: 24rpx;
+  text-align: center;
+}
 .granary-no {
   padding-top: 200rpx;
 }
@@ -102,4 +115,4 @@
   font-size: 28rpx;
   margin-top: 25rpx;
   color: #cccccc;
-}
+}