purchase-details.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. var p = require('public.js')
  2. var businessT = require('../../../../tool/business-tool.js')
  3. var app = getApp()
  4. function handleData (data) {
  5. var r = []
  6. for (var i in data) {
  7. var d = data[i]
  8. var tel = businessT.getPhone()
  9. if (!d.shebao_note || d.shebao_note == '') {
  10. d.shebao_note = '请确保补缴月与当前正常参保月连续,并于当前参保月截止时间前支付补缴订单。'
  11. }
  12. if (!d.fund_note || d.fund_note == '') {
  13. d.fund_note = '请确保补缴月与当前正常参保月连续,并于当前参保月截止时间前支付补缴订单。'
  14. }
  15. d.month = String(d.month).slice(0, 4) + '年' + String(d.month).slice(4, 6) + '月'
  16. if (d.shebaos && Object.prototype.toString.call(d.shebaos) == '[object Array]') {
  17. var shebaos = d.shebaos
  18. for (var index in shebaos) {
  19. for (var i = 1; i < shebaos[index].data.length; i ++) {
  20. //改两位小数&去年缴
  21. if (i == 1) {
  22. shebaos[index].data[0].p = shebaos[index].data[0].p.toFixed(2)
  23. if (shebaos[index].data[0].n.slice(-4) == '(年缴)') {
  24. shebaos[index].data[0].s = true
  25. shebaos[index].data[0].n = shebaos[index].data[0].n.slice(0, -4)
  26. }
  27. }
  28. shebaos[index].data[i].p = shebaos[index].data[i].p.toFixed(2)
  29. if (shebaos[index].data[i].n.slice(-4) == '(年缴)') {
  30. shebaos[index].data[i].s = true
  31. shebaos[index].data[i].n = shebaos[index].data[i].n.slice(0, -4)
  32. }
  33. // 重新排序
  34. var j = i - 1
  35. var value = shebaos[index].data[i]
  36. while (j > 0 && shebaos[index].data[j]['i'] > value['i']) {
  37. shebaos[index].data[j + 1] = shebaos[index].data[j]
  38. j --
  39. }
  40. shebaos[index].data[j + 1] = value
  41. }
  42. }
  43. } else {
  44. d.shebaos = [[], [], [], []]
  45. }
  46. if (d.funds && Object.prototype.toString.call(d.funds) == '[object Array]') {
  47. for (var index in d.funds) {
  48. var min = d.funds[index].min
  49. var _min = min | 0
  50. if (min != _min) {
  51. _min += 1
  52. }
  53. var max = d.funds[index].max | 0
  54. var e = d.funds[index].e
  55. var _p = d.funds[index].p
  56. d.funds[index] = [_min, max, e, _p]
  57. }
  58. } else {
  59. d.funds = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
  60. }
  61. r.push(d)
  62. }
  63. var order = p.getOrder()
  64. // if (order.isSupplementaryPay) {
  65. // app.purchase.supplementaryPurchaseDataArray = r
  66. // } else {
  67. // app.purchase.normalPurchaseDataArray = r
  68. // }
  69. app.purchase.purchaseDataArray = r
  70. app.purchase.purchaseData = r[0]
  71. }
  72. function getPurchaseDeadline (dead) {
  73. var day = new Date().getDate()
  74. var month = new Date().getMonth() + 1
  75. businessT.debugLog(month)
  76. if (day > dead) {
  77. month += 1
  78. }
  79. if (month > 12) {
  80. month = 1
  81. }
  82. return month
  83. }
  84. function changeShebaoDataToCustomerData () {
  85. var order = p.getOrder()
  86. var data = app.purchase.purchaseData
  87. order.id = data.id
  88. order.city = data.city_code
  89. if (order.isSupplementaryPay) {
  90. p.setOrderPack(false)
  91. //beginTime
  92. var year = Number(data.month.slice(0, 4))
  93. var month = Number(data.month.slice(5, 7))
  94. if (month == 1) {
  95. year -= 1
  96. month = 12
  97. } else {
  98. month -= 1
  99. }
  100. if (month < 10) {
  101. order.beginTime = year + '年0' + month + '月'
  102. } else {
  103. order.beginTime = year + '年' + month + '月'
  104. }
  105. order.timeInterval = 1
  106. order.endTime = order.beginTime
  107. } else {
  108. order.beginTime = data.month
  109. if (order.timeInterval < data.nums) {
  110. order.timeInterval = data.nums
  111. }
  112. //endTime
  113. if (order.timeInterval == 1) {
  114. order.endTime = data.month
  115. } else {
  116. var year = Number(data.month.slice(0, 4))
  117. var month = Number(data.month.slice(5, 7)) + order.timeInterval - 1
  118. if (month > 12) {
  119. year += 1
  120. month -= 12
  121. }
  122. if (month < 10) {
  123. order.endTime = year + '年0' + month + '月'
  124. } else {
  125. order.endTime = year + '年' + month + '月'
  126. }
  127. }
  128. if (order.pack && !data.pack) {
  129. p.setOrderPack(false)
  130. }
  131. }
  132. }
  133. function getWageBase () {
  134. var order = p.getOrder()
  135. var purchase = app.purchase.purchaseData
  136. var wageBase = Number(order.accumulationFund) / (purchase.funds[order.accountType - 1][2] / 100 + purchase.funds[order.accountType - 1][3] / 100)
  137. var _wageBase = wageBase | 0
  138. if (_wageBase != wageBase) {
  139. _wageBase += 1
  140. }
  141. return _wageBase
  142. }
  143. module.exports = {
  144. handleData: handleData,
  145. getPurchaseDeadline: getPurchaseDeadline,
  146. changeShebaoDataToCustomerData: changeShebaoDataToCustomerData,
  147. getWageBase: getWageBase
  148. }