xll 1 день тому
батько
коміт
e6ab03145f

+ 63 - 59
nova-tourism/pages/my/merchant/merchant-home/gift-order/index.less

@@ -39,7 +39,7 @@
         border-bottom: 1rpx solid rgb(228, 228, 228);
         padding-bottom: 20rpx;
 
-      
+
     }
 
     .goodDetil {
@@ -139,7 +139,7 @@
                         margin-left: 10rpx;
                         width: 150rpx;
                         font-size: 26rpx;
-                        color:rgb(160, 160, 160);
+                        color: rgb(160, 160, 160);
                     }
                 }
             }
@@ -171,78 +171,82 @@
         }
     }
 }
-.refund_popup{
-    .title{
-      font-weight: bold;
-      padding: 20rpx;
-      font-size: 40rpx;
-      text-align: center;
-      border-bottom: rgb(228, 228, 228) 1rpx solid;
+
+.refund_popup {
+    .title {
+        font-weight: bold;
+        padding: 20rpx;
+        font-size: 40rpx;
+        text-align: center;
+        border-bottom: rgb(228, 228, 228) 1rpx solid;
     }
-    .refundPopup{
-      padding: 30rpx;
-      .address {
-        width: 100%;
-        display: flex;
-        align-items: center;
-        margin-top: 15rpx;
-        padding-left: 10rpx;
-        padding-right: 10rpx;
-
-        .a {
-            padding: 5rpx 8rpx;
-            border-radius: 5rpx;
-            margin-right: 20rpx;
-            font-size: 25rpx;
-            display: flex;
-            justify-content: center;
-            align-items: center;
-            background-color: #46a9a4;
-            color: #d8faf8;
-        }
 
-        .b {
-            padding: 5rpx 8rpx;
-            border-radius: 5rpx;
-            margin-right: 20rpx;
-            font-size: 25rpx;
-            display: flex;
-            justify-content: center;
-            align-items: center;
-            background-color: #d8faf8;
-            color: #46a9a4;
-        }
+    .refundPopup {
+        padding: 30rpx;
 
-        .address2 {
+        .address {
             width: 100%;
-            font-size: 30rpx;
+            display: flex;
+            align-items: center;
+            margin-top: 15rpx;
+            padding-left: 10rpx;
+            padding-right: 10rpx;
+
+            .a {
+                padding: 5rpx 8rpx;
+                border-radius: 5rpx;
+                margin-right: 20rpx;
+                font-size: 25rpx;
+                display: flex;
+                justify-content: center;
+                align-items: center;
+                background-color: #46a9a4;
+                color: #d8faf8;
+            }
 
-            .address-address {
-                color: rgb(78, 78, 78);
-                width: 100%;
+            .b {
+                padding: 5rpx 8rpx;
+                border-radius: 5rpx;
+                margin-right: 20rpx;
+                font-size: 25rpx;
                 display: flex;
+                justify-content: center;
                 align-items: center;
-                
+                background-color: #d8faf8;
+                color: #46a9a4;
             }
 
-            .name {
-                color: rgb(175, 174, 174);
-                margin-top: 10rpx;
+            .address2 {
+                width: 100%;
+                font-size: 30rpx;
+
+                .address-address {
+                    color: rgb(78, 78, 78);
+                    width: 100%;
+                    display: flex;
+                    align-items: center;
+
+                }
+
+                .name {
+                    color: rgb(175, 174, 174);
+                    margin-top: 10rpx;
+                }
             }
         }
-    }
 
-    
+
     }
-    button{
-      background:#46a9a4;
-      color: white;
-      width: 90vw;
+
+    button {
+        background: #46a9a4;
+        color: white;
+        width: 90vw;
     }
-  }
+}
+
 
 
-  
 
 
 
@@ -255,7 +259,7 @@
 
 
 
-  .expressPopup {
+.expressPopup {
     width: 100%;
     height: 70vh;
 

+ 52 - 21
nova-tourism/pages/my/merchant/merchant-home/index.js

@@ -19,6 +19,7 @@ Page({
     todayPrice: 0,
     uid: null,
     profit: 0, //分润
+    isShowPayouts: false
   },
 
   /**
@@ -50,9 +51,10 @@ Page({
   async refersh() {
     await this.getShopStore()
     if (!this.data.store?.objectId) return
-    this.getProfit()
     await this.getShopOrder(this.data.store?.objectId)
     await this.getTodayOrder(this.data.store?.objectId)
+    this.getProfit()
+
   },
   /**获取店铺 */
   async getShopStore() {
@@ -71,7 +73,19 @@ Page({
       wx.setStorageSync('merchant', undefined)
     }
   },
-
+  /**提现弹框-开 */
+  async openPayouts() {
+    await this.refersh()
+    this.setData({
+      isShowPayouts: true
+    })
+  },
+  /**提现弹框-关 */
+  closePayouts() {
+    this.setData({
+      isShowPayouts: false
+    })
+  },
   /**获取当前商户分润金额 */
   async getProfit() {
     let store_uid = wx.getStorageSync('merchant')?.objectId
@@ -110,24 +124,37 @@ Page({
     })
     this.getWithdraw()
   },
-  /**可提现金额=获取当前商户分润金额-申请提现金额 */
+  /**
+   * 分润可提现金额 = 获取当前商户分润金额-申请提现金额
+   * 营业额可提现金额 = 总营业额*0.7-申请提现金额
+   */
   async getWithdraw() {
     let sql = `select sum("count") as "withdraw" from "UserAgentWithdraw"
         where "company" = '${company}' and "user" = '${this.data.merchant.objectId}' 
         and "isDeleted" is not true
+        and "channel" = 'sharing'
+        group by "user"`
+    let sql02 = `select sum("count") as "withdraw" from "UserAgentWithdraw"
+        where "company" = '${company}' and "user" = '${this.data.merchant.objectId}' 
+        and "isDeleted" is not true
+        and "channel" = 'turnover'
         group by "user"`
     let data = await req.customSQL(sql)
-    if (data && data.length > 0) {
-      // console.log(((this.data.profit||0)*1000 - (data[0].withdraw||0)*1000)/1000)
-      this.setData({
-        earnings: (this.data.profit - data[0].withdraw).toFixed(5)
-      })
-    } else {
-      this.setData({
-        earnings: this.data.profit
-      })
-    }
-    console.log(this.data.earnings)
+    let data02 = await req.customSQL(sql02)
+
+    console.log(data, data02)
+    console.log(this.data.profit)
+    let overSharing= data[0]?.withdraw || 0
+    let overTurnover = data02[0]?.withdraw||0
+    this.setData({
+      sharing: (Math.floor(this.data.profit - overSharing * 100) / 100)?.toFixed(2),
+      overSharing,
+      turnover: (Math.floor((this.data.payoutPrice - overTurnover ) * 100) / 100)?.toFixed(2),
+      overTurnover,
+      // earnings: (Math.floor((this.data.profit - data[0].withdraw + payoutPrice) * 100) / 100)?.toFixed(2)
+    })
+ 
+    // console.log(this.data.earnings)
   },
 
   /**获取累计订单数据 */
@@ -151,8 +178,9 @@ Page({
     let totalCount = parseFloat(data[0]?.count || 0) + parseFloat(gift_data[0]?.count || 0)
     let totalPrice = ((parseFloat(data[0]?.totalPrice || 0) * 1000) + (parseFloat(gift_data[0]?.totalPrice || 0) * 1000)) / 1000
     this.setData({
-      totalCount:totalCount||0,
-      totalPrice:totalPrice||0,
+      totalCount: totalCount || 0,
+      totalPrice: totalPrice || 0,
+      payoutPrice: Math.floor(totalPrice * 0.7 * 100) / 100,
       room_count: parseFloat(data[0]?.count || 0),
       room_totalPrice: parseFloat(data[0]?.totalPrice || 0),
       gift_count: parseFloat(gift_data[0]?.count || 0),
@@ -161,7 +189,7 @@ Page({
   },
 
 
-/** 获取今日订单数据*/
+  /** 获取今日订单数据*/
   async getTodayOrder(id) {
     var TIME = util.formatTime(new Date()); //当前时间
     console.log(TIME);
@@ -187,8 +215,8 @@ Page({
     let todayCount = parseFloat(data[0]?.count || 0) + parseFloat(gift_data[0]?.count || 0)
     let todayPrice = ((parseFloat(data[0]?.totalPrice || 0) * 1000) + (parseFloat(gift_data[0]?.totalPrice || 0) * 1000)) / 1000
     this.setData({
-      todayCount:todayCount||0,
-      todayPrice:todayPrice||0,
+      todayCount: todayCount || 0,
+      todayPrice: todayPrice || 0,
       room_todayCount: parseFloat(data[0]?.count || 0),
       room_todayPrice: parseFloat(data[0]?.totalPrice || 0),
       gift_todayCount: parseFloat(gift_data[0]?.count || 0),
@@ -361,10 +389,11 @@ Page({
       }
     })
   },
-  toWithdraw() {
+  toWithdraw(e) {
+    let {price,channel} = e.currentTarget.dataset
     let id = this.data.store.storeName
     wx.navigateTo({
-      url: `../../merchant/merchant-home/store-withdraw/index?earnings=${this.data.profit||0}&&id=${id}`,
+      url: `../../merchant/merchant-home/store-withdraw/index?earnings=${price||0}&&channel=${channel}&&id=${id}`,
     })
   },
 
@@ -387,6 +416,8 @@ Page({
    */
   onShow: function () {
     // this.getShopStore()
+    this.refersh()
+
   },
 
   /**

+ 2 - 1
nova-tourism/pages/my/merchant/merchant-home/index.json

@@ -1,6 +1,7 @@
 {
   "usingComponents": {
       "van-rate": "@vant/weapp/rate/index",
-      "van-icon": "@vant/weapp/icon/index"
+      "van-icon": "@vant/weapp/icon/index",
+      "van-popup": "@vant/weapp/popup/index"
   }
 }

+ 54 - 12
nova-tourism/pages/my/merchant/merchant-home/index.less

@@ -38,11 +38,12 @@ page {
                     margin: 5rpx 0;
                     height: 99rpx;
 
-                    .item{
+                    .item {
                         font-size: 25rpx;
                     }
-                    .gray{
-                        color:rgb(185, 185, 185);
+
+                    .gray {
+                        color: rgb(185, 185, 185);
                     }
                 }
             }
@@ -58,11 +59,12 @@ page {
                     margin: 5rpx 0;
                     height: 99rpx;
 
-                    .item{
+                    .item {
                         font-size: 25rpx;
                     }
-                    .gray{
-                        color:rgb(185, 185, 185);
+
+                    .gray {
+                        color: rgb(185, 185, 185);
                     }
                 }
             }
@@ -84,11 +86,12 @@ page {
                     margin: 5rpx 0;
                     height: 99rpx;
 
-                    .item{
+                    .item {
                         font-size: 25rpx;
                     }
-                    .gray{
-                        color:rgb(185, 185, 185);
+
+                    .gray {
+                        color: rgb(185, 185, 185);
                     }
                 }
             }
@@ -103,11 +106,13 @@ page {
                     text-align: center;
                     margin: 5rpx 0;
                     height: 99rpx;
-                    .item{
+
+                    .item {
                         font-size: 25rpx;
                     }
-                    .gray{
-                        color:rgb(185, 185, 185);
+
+                    .gray {
+                        color: rgb(185, 185, 185);
                     }
                 }
             }
@@ -190,4 +195,41 @@ page {
     padding: 20rpx 50rpx;
     border-radius: 30rpx;
     text-align: center;
+}
+
+.refund_popup {
+
+
+    .title {
+        font-weight: bold;
+        padding: 20rpx;
+        font-size: 40rpx;
+        text-align: center;
+        border-bottom: rgb(228, 228, 228) 1rpx solid;
+    }
+
+    .refundPopup {
+        display: flex;
+
+        .payoutsBox {
+            width: 40vw;
+            background: #46a9a4;
+            margin: 20rpx;
+            padding: 20rpx;
+            border-radius:10rpx;
+            .box_title {
+                font-size: 23rpx;
+            }
+            .price{
+                margin: 5rpx 0;
+                font-size: 32rpx;
+                text{
+                    font-size:23rpx;
+                }
+            }
+            .overPrice{
+                font-size: 25rpx;
+            }
+        }
+    }
 }

+ 42 - 5
nova-tourism/pages/my/merchant/merchant-home/index.wxml

@@ -5,11 +5,12 @@
     <view class="store-box">
       <view class="store-name">{{store.storeName}}</view>
       <view class="draw_box" style="margin-top: 10rpx;">
-        <view class="withdraw" bindtap="toWithdraw">
+        <view class="withdraw" bindtap="openPayouts">
           提现
         </view>
         <view>
-          可提现 {{earnings}} 元
+          <!-- 可提现 {{earnings}} 元 -->
+          <!-- <view style="font-size: 20rpx;">订单+分润</view> -->
         </view>
       </view>
     </view>
@@ -157,7 +158,7 @@
       </view>
       <van-icon name="arrow" />
     </view>
-    
+
     <!-- <view class="box-title" data-url="/common-page/pages/sharing/index?path=yswx&uid={{uid}}" bindtap="gourl"> -->
     <view class="box-title" data-url="/nova-tourism/pages/my/sharing/index?path=yswx&uid={{uid}}" bindtap="gourl">
       <view class="box-details">
@@ -166,7 +167,7 @@
       </view>
       <van-icon name="arrow" />
     </view>
-   
+
     <block wx:if="{{store.type=='shop'}}">
       <!-- <view class="box-title">商品管理</view> -->
       <!-- <view class="box-title" bindtap="goods">
@@ -190,4 +191,40 @@
 <view class="bommon" bind:tap="logout" style="color: #382E2E;">退出登录</view>
 <!-- <block wx:if="{{store.type=='catering'}}">
     <view class="bommon" bind:tap="code">扫码核销</view>
-</block> -->
+</block> -->
+
+<van-popup class="refund_popup" custom-style="height: 500rpx" show="{{ isShowPayouts }}" position="bottom" round bind:close="closePayouts">
+  <view class="title">
+    可提现金额
+  </view>
+  <view class="refundPopup">
+    <view class="payoutsBox" data-channel="sharing" data-price="{{sharing}}" bind:tap="toWithdraw">
+      <view class="box_title">
+        <van-icon name="balance-pay" size='18'/>
+        分润:
+      </view>
+      <view class="price">
+        {{sharing}} <text>元</text>
+      </view>
+      <view class="overPrice">
+        累计申请 {{overSharing}} 元
+      </view>
+    </view>
+    <view class="payoutsBox" data-channel="turnover" data-price="{{turnover}}" bind:tap="toWithdraw">
+      <view class="box_title">
+        <van-icon name="shop-o" size='18'/>
+        营业额:
+      </view>
+      <view class="price">
+        {{turnover}} <text>元</text>
+      </view>
+      <view class="overPrice">
+        累计申请 {{overTurnover}} 元
+      </view>
+    </view>
+   
+    <!-- <view class="withdraw" bindtap="toWithdraw">
+      提现
+    </view> -->
+  </view>
+</van-popup>

+ 30 - 0
nova-tourism/pages/my/merchant/merchant-home/index.wxss

@@ -145,3 +145,33 @@ page {
   border-radius: 30rpx;
   text-align: center;
 }
+.refund_popup .title {
+  font-weight: bold;
+  padding: 20rpx;
+  font-size: 40rpx;
+  text-align: center;
+  border-bottom: #e4e4e4 1rpx solid;
+}
+.refund_popup .refundPopup {
+  display: flex;
+}
+.refund_popup .refundPopup .payoutsBox {
+  width: 40vw;
+  background: #46a9a4;
+  margin: 20rpx;
+  padding: 20rpx;
+  border-radius: 10rpx;
+}
+.refund_popup .refundPopup .payoutsBox .box_title {
+  font-size: 23rpx;
+}
+.refund_popup .refundPopup .payoutsBox .price {
+  margin: 5rpx 0;
+  font-size: 32rpx;
+}
+.refund_popup .refundPopup .payoutsBox .price text {
+  font-size: 23rpx;
+}
+.refund_popup .refundPopup .payoutsBox .overPrice {
+  font-size: 25rpx;
+}

+ 15 - 9
nova-tourism/pages/my/merchant/merchant-home/store-withdraw/index.js

@@ -22,6 +22,7 @@ Page({
         accountId: null,
         activeColor: getApp().globalData.activeColor,
         titleColor: getApp().globalData.titleColor,
+        channel:''
     },
     async getUserAgentWithdraw() {
         let merchant = wx.getStorageSync("merchant");
@@ -56,14 +57,14 @@ Page({
             });
             return
         }
-        // if (this.data.price < 1000) {
-        //     wx.showToast({
-        //         title: '最低提现金额为1000元',
-        //         icon: 'none',
+        if (this.data.price < 1000) {
+            wx.showToast({
+                title: '最低提现金额为1000元',
+                icon: 'none',
 
-        //     });
-        //     return
-        // }
+            });
+            return
+        }
 
         if (!this.data.name) {
             wx.showToast({
@@ -85,6 +86,7 @@ Page({
         let userAgentWithdraw = new UserAgentWithdraw()
         userAgentWithdraw.set("count", Number(this.data.price))
         userAgentWithdraw.set("type", "bank")
+        userAgentWithdraw.set("channel", this.data.channel)
         userAgentWithdraw.set("isVerified", false)
         userAgentWithdraw.set("company", {
             __type: 'Pointer',
@@ -103,9 +105,10 @@ Page({
             bankName: this.data.bankName,
             storeName: this.data.id,
         }]
-
         )
-
+        userAgentWithdraw.set('bank',{
+          "bank":this.data.bankName,"name":this.data.names,"bankcard":this.data.accountId
+        })
         userAgentWithdraw.save().then(res => {
             console.log(res)
             wx.showToast({
@@ -147,6 +150,7 @@ Page({
         let UserAgentWithdraw = new Parse.Query('UserAgentWithdraw')
         UserAgentWithdraw.equalTo('user', this.data.merchant)
         UserAgentWithdraw.equalTo('type', 'bank')
+        UserAgentWithdraw.notEqualTo('isDeleted',true)
         UserAgentWithdraw.greaterThan('createdAt', startTime)
         UserAgentWithdraw.lessThan('createdAt', endTime)
         let userAgentWithdraw = await UserAgentWithdraw.find()
@@ -166,12 +170,14 @@ Page({
     onLoad: function (options) {
         console.log(Parse.User.current().id);
         let earnings = options.earnings
+        let channel= options.channel
         let id = options.id
         let merchant = wx.getStorageSync('merchant'); //用户
         console.log(merchant);
         console.log(earnings);
         this.setData({
             earnings: earnings,
+            channel,
             merchant: merchant.objectId,
             id: id
         })

+ 13 - 1
project.private.config.json

@@ -4,6 +4,18 @@
     "compileHotReLoad": false,
     "urlCheck": true
   },
-  "condition": {},
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "nova-tourism/pages/my/merchant/merchant-home/index",
+          "pathName": "nova-tourism/pages/my/merchant/merchant-home/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  },
   "projectname": "nova-wapp"
 }