Kaynağa Gözat

增加支付接口入参

sunshibo 3 hafta önce
ebeveyn
işleme
5f8f1e6762
2 değiştirilmiş dosya ile 19 ekleme ve 5 silme
  1. 10 1
      api/dining.js
  2. 9 4
      pages/checkout/index.vue

+ 10 - 1
api/dining.js

@@ -186,7 +186,7 @@ export const GetMyOrders = (params) =>
 export const GetOrderInfo = (orderId) =>
   api.get({ url: `/store/order/info/${encodeURIComponent(orderId)}` });
 
-// 订单支付(GET /payment/prePay,入参 orderNo、payType、payer、price、subject、storeId、couponId 优惠券ID、payerId 用户ID;返回微信支付调起参数)
+// 订单支付(GET /payment/prePay,入参 orderNo、payType、payer、price、subject、storeId、couponId、payerId、tablewareFee 餐具费、discountAmount 优惠金额、payAmount 支付金额;返回微信支付调起参数)
 export const PostOrderPay = (params) => {
   const query = {
     orderNo: params.orderNo,
@@ -202,6 +202,15 @@ export const PostOrderPay = (params) => {
   if (params.payerId != null && params.payerId !== '') {
     query.payerId = params.payerId;
   }
+  if (params.tablewareFee != null && params.tablewareFee !== '') {
+    query.tablewareFee = params.tablewareFee;
+  }
+  if (params.discountAmount != null && params.discountAmount !== '') {
+    query.discountAmount = params.discountAmount;
+  }
+  if (params.payAmount != null && params.payAmount !== '') {
+    query.payAmount = params.payAmount;
+  }
   return api.get({
     url: '/payment/prePay',
     params: query

+ 9 - 4
pages/checkout/index.vue

@@ -363,8 +363,8 @@ const handleConfirmPay = async () => {
     uni.showToast({ title: '请先登录', icon: 'none' });
     return;
   }
-  const priceAmount = Number(orderInfo.value.payAmount ?? 0) || 0;
-  if (priceAmount <= 0) {
+  const payAmountVal = Math.round((Number(orderInfo.value.payAmount ?? 0) || 0) * 100) / 100;
+  if (payAmountVal <= 0) {
     uni.showToast({ title: '订单金额异常', icon: 'none' });
     return;
   }
@@ -373,7 +373,7 @@ const handleConfirmPay = async () => {
     uni.showToast({ title: '缺少订单号', icon: 'none' });
     return;
   }
-  const price = Math.round(priceAmount * 100);
+  const price = Math.round(payAmountVal * 100);
   uni.showLoading({ title: '拉起支付...' });
   try {
     const storeId = orderInfo.value.storeId || uni.getStorageSync('currentStoreId') || '';
@@ -385,6 +385,8 @@ const handleConfirmPay = async () => {
         : selectedCouponId.value != null && selectedCouponId.value !== ''
           ? String(selectedCouponId.value)
           : '';
+    const tablewareFeeVal = Number(orderInfo.value.utensilFee) || 0;
+    const discountAmountVal = Number(orderInfo.value.discountAmount) || 0;
     const res = await diningApi.PostOrderPay({
       orderNo,
       payer: openid,
@@ -392,7 +394,10 @@ const handleConfirmPay = async () => {
       subject: '订单支付',
       storeId: storeId || undefined,
       couponId: couponIdVal || undefined,
-      payerId: payerId ? String(payerId) : undefined
+      payerId: payerId ? String(payerId) : undefined,
+      tablewareFee: tablewareFeeVal,
+      discountAmount: discountAmountVal,
+      payAmount: payAmountVal
     });
     uni.hideLoading();
     uni.requestPayment({