var p = require('public.js') var businessT = require('../../../../tool/business-tool.js') var app = getApp() function handleData (data) { var r = [] for (var i in data) { var d = data[i] var tel = businessT.getPhone() if (!d.shebao_note || d.shebao_note == '') { d.shebao_note = '请确保补缴月与当前正常参保月连续,并于当前参保月截止时间前支付补缴订单。' } if (!d.fund_note || d.fund_note == '') { d.fund_note = '请确保补缴月与当前正常参保月连续,并于当前参保月截止时间前支付补缴订单。' } d.month = String(d.month).slice(0, 4) + '年' + String(d.month).slice(4, 6) + '月' if (d.shebaos && Object.prototype.toString.call(d.shebaos) == '[object Array]') { var shebaos = d.shebaos for (var index in shebaos) { for (var i = 1; i < shebaos[index].data.length; i ++) { //改两位小数&去年缴 if (i == 1) { shebaos[index].data[0].p = shebaos[index].data[0].p.toFixed(2) if (shebaos[index].data[0].n.slice(-4) == '(年缴)') { shebaos[index].data[0].s = true shebaos[index].data[0].n = shebaos[index].data[0].n.slice(0, -4) } } shebaos[index].data[i].p = shebaos[index].data[i].p.toFixed(2) if (shebaos[index].data[i].n.slice(-4) == '(年缴)') { shebaos[index].data[i].s = true shebaos[index].data[i].n = shebaos[index].data[i].n.slice(0, -4) } // 重新排序 var j = i - 1 var value = shebaos[index].data[i] while (j > 0 && shebaos[index].data[j]['i'] > value['i']) { shebaos[index].data[j + 1] = shebaos[index].data[j] j -- } shebaos[index].data[j + 1] = value } } } else { d.shebaos = [[], [], [], []] } if (d.funds && Object.prototype.toString.call(d.funds) == '[object Array]') { for (var index in d.funds) { var min = d.funds[index].min var _min = min | 0 if (min != _min) { _min += 1 } var max = d.funds[index].max | 0 var e = d.funds[index].e var _p = d.funds[index].p d.funds[index] = [_min, max, e, _p] } } else { d.funds = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] } r.push(d) } var order = p.getOrder() // if (order.isSupplementaryPay) { // app.purchase.supplementaryPurchaseDataArray = r // } else { // app.purchase.normalPurchaseDataArray = r // } app.purchase.purchaseDataArray = r app.purchase.purchaseData = r[0] } function getPurchaseDeadline (dead) { var day = new Date().getDate() var month = new Date().getMonth() + 1 businessT.debugLog(month) if (day > dead) { month += 1 } if (month > 12) { month = 1 } return month } function changeShebaoDataToCustomerData () { var order = p.getOrder() var data = app.purchase.purchaseData order.id = data.id order.city = data.city_code if (order.isSupplementaryPay) { p.setOrderPack(false) //beginTime var year = Number(data.month.slice(0, 4)) var month = Number(data.month.slice(5, 7)) if (month == 1) { year -= 1 month = 12 } else { month -= 1 } if (month < 10) { order.beginTime = year + '年0' + month + '月' } else { order.beginTime = year + '年' + month + '月' } order.timeInterval = 1 order.endTime = order.beginTime } else { order.beginTime = data.month if (order.timeInterval < data.nums) { order.timeInterval = data.nums } //endTime if (order.timeInterval == 1) { order.endTime = data.month } else { var year = Number(data.month.slice(0, 4)) var month = Number(data.month.slice(5, 7)) + order.timeInterval - 1 if (month > 12) { year += 1 month -= 12 } if (month < 10) { order.endTime = year + '年0' + month + '月' } else { order.endTime = year + '年' + month + '月' } } if (order.pack && !data.pack) { p.setOrderPack(false) } } } function getWageBase () { var order = p.getOrder() var purchase = app.purchase.purchaseData var wageBase = Number(order.accumulationFund) / (purchase.funds[order.accountType - 1][2] / 100 + purchase.funds[order.accountType - 1][3] / 100) var _wageBase = wageBase | 0 if (_wageBase != wageBase) { _wageBase += 1 } return _wageBase } module.exports = { handleData: handleData, getPurchaseDeadline: getPurchaseDeadline, changeShebaoDataToCustomerData: changeShebaoDataToCustomerData, getWageBase: getWageBase }