order-model.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import PurchaseOrder from '../../../home/public/model/purchaseOrder.js'
  2. var app = getApp()
  3. var businessType = require('../../../../public/business-type.js')
  4. function handleWaitForPayData(data) {
  5. for (var i in data) {
  6. var item = data[i]
  7. handleData(item)
  8. }
  9. return data
  10. }
  11. function handleAllData(data) {
  12. var w = []
  13. var f = []
  14. var wi = 0
  15. var fi = 0
  16. for (var i in data) {
  17. var item = data[i]
  18. handleData(item)
  19. if (item.status == 1) {
  20. w.push(item)
  21. } else {
  22. f.push(item)
  23. }
  24. }
  25. return [data, w, f]
  26. }
  27. function handleData(item) {
  28. item.orderListType = businessType.OrderListType.orderListTypePurchase
  29. item.a = item.total_fee.toFixed(2)
  30. if (item.pay_for == 1 || item.pay_for == 3) {
  31. if (item.added) {
  32. item.i = 's_pay_s'
  33. item.title = '社保补缴'
  34. } else {
  35. item.i = 'purchase_s'
  36. if (item.pay_for == 1) {
  37. item.title = '社保缴纳'
  38. } else {
  39. item.title = '社保 (打包公积金)'
  40. }
  41. }
  42. } else {
  43. if (item.added) {
  44. item.i = 's_pay_a'
  45. item.title = '公积金补缴'
  46. } else {
  47. item.i = 'purchase_a'
  48. if (item.pay_for == 2) {
  49. item.title = '公积金缴存'
  50. } else {
  51. item.title = '公积金 (打包社保)'
  52. }
  53. }
  54. }
  55. if (item.status == 1) {
  56. item.s = {
  57. t: '等待付款',
  58. c: 'order-item-status-w'
  59. }
  60. item.bs = 3
  61. } else if (item.status == 11) {
  62. item.s = {
  63. t: '已退款',
  64. c: 'order-item-status-f'
  65. }
  66. item.bs = 1
  67. } else {
  68. item.s = {
  69. t: '交易完成',
  70. c: 'order-item-status-f'
  71. }
  72. item.bs = 1
  73. }
  74. var beginYear = (item.start_month / 100) | 0
  75. var beginMonth = item.start_month % 100
  76. if (item.nums > 1) {
  77. var endMonth = beginMonth + item.nums - 1
  78. beginMonth = ('00' + beginMonth).slice(-2)
  79. if (endMonth > 12) {
  80. var endYear = beginYear + 1
  81. endMonth = ('00' + (endMonth - 12)).slice(-2)
  82. var t = beginYear + '年' + beginMonth + '月-' + endYear + '年' + endMonth + '月'
  83. } else {
  84. var t = beginYear + '年' + beginMonth + '月-' + ('00' + endMonth).slice(-2) + '月'
  85. }
  86. } else {
  87. var t = beginYear + '年' + ('00' + beginMonth).slice(-2) + '月'
  88. }
  89. item.cancelContent = '是否要取消' + t + '的' + item.title + '订单'
  90. item.showTime = t
  91. item.ct = '参保姓名\n购买月份\n购买城市'
  92. item.c = item.u_name + '\n' + t + '\n' + item.city_name
  93. }
  94. // function createOrder(data) {
  95. // var order = new PurchaseOrder()
  96. // var time = getOrderTime(data.start_month, data.nums)
  97. // order.city = data.city_code
  98. // order.cityName = data.city_name
  99. // order.accountType = data.hukou_type
  100. // order.customerData = {
  101. // 'user_name': data.u_name,
  102. // 'id_card': data.id_card,
  103. // 'nation': '',
  104. // 'gender': '',
  105. // 'phone': '',
  106. // 'sbuId': data.sbuId
  107. // }
  108. // order.beginTime = time[0]
  109. // order.timeInterval = data.nums
  110. // order.endTime = time[1]
  111. // order.isNewCustomer = false
  112. // if (data.pay_for == 1) {
  113. // order.purchaseType = businessType.PurchaseType.socialInsurance
  114. // order.pack = false
  115. // } else if (data.pay_for == 2) {
  116. // order.purchaseType = businessType.PurchaseType.accumulationFund
  117. // order.pack = false
  118. // } else if (data.pay_for == 3) {
  119. // order.purchaseType = businessType.PurchaseType.socialInsurancePackage
  120. // order.pack = true
  121. // } else if (data.pay_for == 4) {
  122. // order.purchaseType = businessType.PurchaseType.accumulationFundPackage
  123. // order.pack = true
  124. // }
  125. // order.SSCard = data.new_card
  126. // order.socialInsurance = data.shebao
  127. // order.accumulationFund = (data.fund / data.nums).toFixed(2)
  128. // order.id = data.cid
  129. // order.payFor = data.pay_for
  130. // order.isSupplementaryPay = false
  131. // order.isFirstBuyShebao = data.first_sb == 0 ? false : true
  132. // order.isFirstBuyFund = data.first_fund == 0 ? false : true
  133. // app.purchase.order = order
  134. // }
  135. // function getOrderTime(b, l) {
  136. // var beginYear = (b / 100) | 0
  137. // var beginMonth = b % 100
  138. // if (l > 1) {
  139. // var endYear = beginYear
  140. // var endMonth = beginMonth + l - 1
  141. // beginMonth = ('00' + beginMonth).slice(-2)
  142. // if (endMonth > 12) {
  143. // var endYear = beginYear + 1
  144. // endMonth = ('00' + (endMonth - 12)).slice(-2)
  145. // } else {
  146. // endMonth = ('00' + endMonth).slice(-2)
  147. // }
  148. // return [beginYear + '年' + beginMonth + '月', endYear + '年' + endMonth + '月']
  149. // } else {
  150. // var t = beginYear + '年' + ('00' + beginMonth).slice(-2) + '月'
  151. // return [t, t]
  152. // }
  153. // }
  154. module.exports = {
  155. handleWaitForPayData: handleWaitForPayData,
  156. handleAllData: handleAllData
  157. }