users/pages/order/offlinepay/utils/moneySubFn.js

18 lines
639 B
JavaScript

module.exports = {
modifyMoneySub: function(that) {//处理随机立减
// 获得随机立减
if (that.list.credit >= 0.1) {
let min = 0.01;
let max = that.list.credit * that.merch.sub_money_maxpercent;
let money_sub_credit = Math.random() * (max - min) + min
money_sub_credit = money_sub_credit * that.merch.credit_pay_rate
that.list.money_sub = getApp().globalData.util.numberFloor(money_sub_credit)
} else {
that.list.money_sub = 0;
}
that.list.credit = that.list.credit - (that.list.money_sub / that.merch.credit_give_rate)
that.list.credit = getApp().globalData.util.numberFloor(that.list.credit)
}
}