|
|
@@ -25,19 +25,24 @@ Page({
|
|
|
userEndDateString: '',
|
|
|
factAmt: 0,
|
|
|
routeObjName: 'company',
|
|
|
+ integral: 0,
|
|
|
+ viewHeight: 302,
|
|
|
+ couponList: [],
|
|
|
+ couponUse: {},
|
|
|
+ // 策略
|
|
|
+ integralTacticItem: {},
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
- console.log("app.globalData.company.funPackage",app.globalData.company.funPackage);
|
|
|
// 用户到期日期
|
|
|
if (app.globalData.company.userEndDate) {
|
|
|
this.setData({
|
|
|
userEndDate: app.globalData.company.userEndDate
|
|
|
})
|
|
|
- }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -50,11 +55,62 @@ Page({
|
|
|
regions: regions,
|
|
|
})
|
|
|
|
|
|
- //获取服务器的最新时间
|
|
|
- this.getCurrentDate()
|
|
|
+ // 优惠券 积分 一个函数查询
|
|
|
+ this.getCouponUse()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 关闭所有的tip
|
|
|
+ * @date : 2024/5/24 15:49
|
|
|
+ * @author : 王英杰
|
|
|
+ */
|
|
|
+ closeAllTips() {
|
|
|
+ this.closeTips(['tipIntegral','tipOrd'])
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * @desc : 优惠劵数量获取
|
|
|
+ * @author : 刘尧
|
|
|
+ * @date : 2024/7/29 15:54
|
|
|
+ */
|
|
|
+ getCouponUse() {
|
|
|
+ let params = {
|
|
|
+ couponStatus: Constants.couponStatus.unused,
|
|
|
+ flgValid: true,
|
|
|
+ cpId: app.globalData.company.cpId,
|
|
|
+ }
|
|
|
+ let service = app.globalData['couponUseService']
|
|
|
+ this.excute(service, service.listByCondUse, params).then(res => {
|
|
|
+ if (res.data && res.data.data) {
|
|
|
+ if (res.data.data.list && res.data.data.list.length > 0) {
|
|
|
+ this.setData({
|
|
|
+ couponList: res.data.data.list,
|
|
|
+ couponUse: res.data.data.list[0],
|
|
|
+ viewHeight: this.data.viewHeight + 40
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (res.data.data.integral) {
|
|
|
+ this.setData({
|
|
|
+ integral: res.data.data.integral,
|
|
|
+ viewHeight: this.data.viewHeight + 40
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 积分策略
|
|
|
+ if (res.data.data.listIntegralTactic && res.data.data.listIntegralTactic.length > 0) {
|
|
|
+ this.setData({
|
|
|
+ integralTacticItem: res.data.data.listIntegralTactic[0],
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //获取服务器的最新时间
|
|
|
+ this.getCurrentDate()
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* @desc : 服务器的日期
|
|
|
* @author : 姜永辉
|
|
|
* @date : 2024/4/1
|
|
|
@@ -67,24 +123,53 @@ Page({
|
|
|
//服务器的时间
|
|
|
let nowDate = res.data.data.currentDate
|
|
|
let endDate = new Date(nowDate).addMonths(12).addDays(-1).toDateStr()
|
|
|
+ // 积分转成现金
|
|
|
+ let integralRateVal = Number((_this.data.integral / _this.data.integralTacticItem.exchangeRate).toFixed(2))
|
|
|
+ // 折扣--数据库的值不能超过10
|
|
|
+ let discount = _this.data.couponUse.discount ? _this.data.couponUse.discount / 10 : 1
|
|
|
+ // couponUse.discount / 10
|
|
|
|
|
|
// 用户到期日期
|
|
|
if (_this.data.userEndDate == null || !_this.data.userEndDate) {
|
|
|
- this.setData({
|
|
|
+ // 积分兑换的大于订单详情的
|
|
|
+ if (_this.data.integral > Math.ceil(_this.data.integralTacticItem.exchangeRate * _this.data.item.wxPrice)) {
|
|
|
+ _this.setData({
|
|
|
+ factAmt: 0.00,
|
|
|
+ integral: Math.ceil(_this.data.integralTacticItem.exchangeRate * _this.data.item.wxPrice)
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
+ _this.setData({
|
|
|
+ factAmt: Number((_this.data.item.wxPrice - integralRateVal) * discount.toFixed(2)),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ _this.setData({
|
|
|
userEndDate: endDate,
|
|
|
userEndDateFlg: true,
|
|
|
userEndDateString: _this.data.item.wxPrice + '元/年(' + _this.data.item.activityItemDescribe + ')',
|
|
|
- factAmt: _this.data.item.wxPrice,
|
|
|
+ // factAmt: _this.data.item.wxPrice,
|
|
|
extendDays: 365,
|
|
|
nowDate,
|
|
|
})
|
|
|
} else {
|
|
|
// 和 服务器的时间一致
|
|
|
if (_this.data.userEndDate == endDate) {
|
|
|
- this.setData({
|
|
|
+ // 积分兑换的大于订单详情的
|
|
|
+ if (_this.data.integral > Math.ceil(_this.data.integralTacticItem.exchangeRate * _this.data.item.wxPrice)) {
|
|
|
+ _this.setData({
|
|
|
+ factAmt: 0.00,
|
|
|
+ integral: Math.ceil(_this.data.integralTacticItem.exchangeRate * _this.data.item.wxPrice)
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
+ _this.setData({
|
|
|
+ factAmt: Number((_this.data.item.wxPrice - integralRateVal) * discount.toFixed(2)),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ _this.setData({
|
|
|
userEndDateFlg: true,
|
|
|
userEndDateString: _this.data.item.wxPrice + '元/年(' + _this.data.item.activityItemDescribe + ')',
|
|
|
- factAmt: _this.data.item.wxPrice,
|
|
|
+ // factAmt: _this.data.item.wxPrice,
|
|
|
extendDays: 365,
|
|
|
nowDate,
|
|
|
})
|
|
|
@@ -92,12 +177,23 @@ Page({
|
|
|
let extendDays = Math.ceil(new Date(_this.data.userEndDate).dayDiff(new Date(nowDate)) + 1);
|
|
|
|
|
|
let price = (Math.round((_this.data.item.wxPrice / 365 + Number.EPSILON) * 100) / 100).toFixed(2)
|
|
|
- console.log(price);
|
|
|
let factAmt = (Number(price) * extendDays).toFixed(2)
|
|
|
- this.setData({
|
|
|
+ // 积分兑换的大于订单详情的
|
|
|
+ if (_this.data.integral > Math.ceil(_this.data.integralTacticItem.exchangeRate * factAmt)) {
|
|
|
+ _this.setData({
|
|
|
+ factAmt: 0.00,
|
|
|
+ integral: Math.ceil(_this.data.integralTacticItem.exchangeRate * factAmt)
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
+ _this.setData({
|
|
|
+ factAmt: Number((factAmt - integralRateVal) * discount.toFixed(2)),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ _this.setData({
|
|
|
userEndDateFlg: false,
|
|
|
userEndDateString: price + '元/天(' + _this.data.item.activityItemDescribe + ')* ' + extendDays + '天=' + factAmt + '元',
|
|
|
- factAmt: factAmt,
|
|
|
+ // factAmt: factAmt,
|
|
|
extendDays,
|
|
|
nowDate,
|
|
|
})
|
|
|
@@ -114,8 +210,8 @@ Page({
|
|
|
* @author : 周兴
|
|
|
* @date : 2024/4/1
|
|
|
*/
|
|
|
- setParams(params) {
|
|
|
- let funPackage = app.globalData.company.funPackage? [...app.globalData.company.funPackage] : []
|
|
|
+ setParams(params) {
|
|
|
+ let funPackage = app.globalData.company.funPackage ? [...app.globalData.company.funPackage] : []
|
|
|
params.endDate = app.globalData.company.endDate
|
|
|
params.userEndDate = this.data.userEndDate
|
|
|
params.gradeCode = app.globalData.company.gradeCode
|
|
|
@@ -129,7 +225,7 @@ Page({
|
|
|
params.wxMaxNum = app.globalData.company.wxMaxNum
|
|
|
params.webMaxNum = app.globalData.company.webMaxNum
|
|
|
params.activityId = this.data.item.activityId
|
|
|
- params.activityItemId = this.data.item.itemId
|
|
|
+ params.activityItemId = this.data.item.itemId
|
|
|
params.remarks = this.data.userEndDateString
|
|
|
params.reNew = app.globalData.company.reNew
|
|
|
params.activityIds = [this.data.item.activityId]
|
|
|
@@ -143,7 +239,12 @@ Page({
|
|
|
params.vip = true;
|
|
|
}
|
|
|
params.buyLong = this.data.extendDays + '天'
|
|
|
+ // 操作员
|
|
|
params.staffNameFrom = app.globalData.user.staffName
|
|
|
+ // 优惠券使用id 金额大于0
|
|
|
+ params.couponUseId = this.data.couponUse.userId && Number(this.data.factAmt) > 0
|
|
|
+ ? this.data.couponUse.userId : null
|
|
|
+ params.integral = this.data.integral
|
|
|
return params;
|
|
|
},
|
|
|
/**
|
|
|
@@ -153,7 +254,8 @@ Page({
|
|
|
*/
|
|
|
saveData(params) {
|
|
|
return this.excute(this.data.service, this.data.service.saveFunc, this.data.params).then(res => {
|
|
|
- if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
+ // 金额大于0 才调用支付
|
|
|
+ if (res.data.code == Constants.SUCESS_CODE && Number(this.data.factAmt) > 0) {
|
|
|
// 成功后跳转支付
|
|
|
this.toPay(res.data.data);
|
|
|
}
|