|
@@ -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()
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|