waybillController.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package controller
  2. import (
  3. "bswas/utilities"
  4. "encoding/json"
  5. )
  6. func WaybillFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
  7. row := []interface{}{
  8. "运单类型", "货主", "上游单号", "wms订单号", "运单号", "运输收费",
  9. "其他收费", "其他收费备注", "始发地", "目的地", "承运商", "承运商单号",
  10. "仓库计抛", "承运商计抛", "仓库计重", "承运商计重", "车型", "车辆信息",
  11. "计件", "里程数", "运费(元)", "提货费(元)", "其他费用(元)", "发货时间",
  12. "调度备注", "创建时间",
  13. }
  14. column := map[string]int{
  15. "type" : 0,
  16. "owner_name" : 1,
  17. "source_bill" : 2,
  18. "wms_bill_number" : 3,
  19. "waybill_number" : 4,
  20. "charge" : 5,
  21. "other_charge" : 6,
  22. "other_charge_remark" : 7,
  23. "origination" : 8,
  24. "destination" : 9,
  25. "carrier_name" : 10,
  26. "carrier_bill" : 11,
  27. "warehouse_weight" : 12,
  28. "carrier_weight" : 13,
  29. "warehouse_weight_other" : 14,
  30. "carrier_weight_other" : 15,
  31. "car_type_name" : 16,
  32. "car_owner_info" : 17,
  33. "amount" : 18,
  34. "mileage" : 19,
  35. "fee" : 20,
  36. "pick_up_fee" : 21,
  37. "other_fee" : 22,
  38. "deliver_at" : 23,
  39. "dispatch_remark" : 24,
  40. "created_at" : 25,
  41. }
  42. list := make([][]interface{},len(data))
  43. for k,v := range data{
  44. line := make([]interface{},len(row))
  45. for key,value := range column {
  46. if key == "created_at" {
  47. line[value] = utilities.DateFormat(v[key])
  48. continue
  49. }
  50. line[value] = v[key]
  51. }
  52. list[k] = line
  53. }
  54. return row,list
  55. }
  56. func WaybillDeliveringFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
  57. row := []interface{}{
  58. "日期", "承运商", "宝时运单号", "提货仓", "货主", "预估重量",
  59. "预估体积", "状态", "专线运单号", "查件电话", "件数", "重量",
  60. "体积",
  61. }
  62. column := map[string]int{
  63. "created_at" : 0,
  64. "carrier_name" : 1,
  65. "waybill_number" : 2,
  66. "origination" : 3,
  67. "owner_name" : 4,
  68. "warehouse_weight_other" : 5,
  69. "warehouse_weight" : 6,
  70. "status" : 7,
  71. "carrier_bill" : 8,
  72. "inquire_tel" : 9,
  73. "amount" : 10,
  74. "carrier_weight_other" : 11,
  75. "carrier_weight" : 12,
  76. }
  77. list := make([][]interface{},len(data))
  78. for k,v := range data{
  79. line := make([]interface{},len(row))
  80. for key,value := range column {
  81. if key == "status" {
  82. if v[key] == "已完结" {
  83. line[value] = "已完成"
  84. }else{
  85. if v["carrier_bill"] != "" {
  86. line[value] = "已提交"
  87. }else{
  88. line[value] = "待提交"
  89. }
  90. }
  91. continue
  92. }
  93. if key == "created_at" {
  94. line[value] = utilities.DateFormat(v[key])
  95. continue
  96. }
  97. line[value] = v[key]
  98. }
  99. list[k] = line
  100. }
  101. return row,list
  102. }
  103. func WaybillFinancialFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
  104. row := []interface{}{
  105. "运单类型", "运单号", "货主", "WMS单号", "始发地", "目的地", "收件人", "收件人电话",
  106. "收费(元)", "下单备注", "承运商", "承运商单号", "始发市", "目的市", "仓库计数(抛)", "仓库计数二",
  107. "承运商计数(抛)", "承运商计数二", "车型", "车辆信息","运费(元)", "提货费(元)", "其他费用(元)", "到付金额(元)",
  108. "调度备注", "终审人员", "运单创建时间", "应收款(元)", "应付款(元)", "毛利(元)",
  109. "毛利率(元)", "报表生成时间",
  110. }
  111. column := map[string]int{
  112. "type" : 0,
  113. "waybill_number" : 1,
  114. "owner_name" : 2,
  115. "wms_bill_number" : 3,
  116. "origination" : 4,
  117. "destination" : 5,
  118. "recipient" : 6,
  119. "recipient_mobile" : 7,
  120. "charge" : 8,
  121. "ordering_remark" : 9,
  122. "carrier" : 10,
  123. "carrier_bill" : 11,
  124. "origination_city" : 12,
  125. "destination_city" : 13,
  126. "warehouse_weight" : 14,
  127. "warehouse_weight_other" : 15,
  128. "carrier_weight" : 16,
  129. "carrier_weight_other" : 17,
  130. "car_type_name" : 18,
  131. "car_owner_info" : 19,
  132. "fee" : 20,
  133. "pick_up_fee" : 21,
  134. "other_fee" : 22,
  135. "collect_fee" : 23,
  136. "dispatch_remark" : 24,
  137. "auditLog_user_name" : 25,
  138. "created_at" : 26,
  139. "total_receivable" : 27,
  140. "total_expense" : 28,
  141. "gross_margin" : 29,
  142. "gross_profit_rate" : 30,
  143. "snapshotCreated_at" : 31,
  144. }
  145. list := make([][]interface{},len(data))
  146. for k,v := range data{
  147. m := make(map[string]string)
  148. err := json.Unmarshal([]byte(v["json_content"]),&m)
  149. if err != nil {
  150. utilities.WriteLog("/api/controller/waybillController.go:145 运单财务记录内字段json解析失败!","ERROR")
  151. }
  152. line := make([]interface{},len(row))
  153. for key,value := range column {
  154. if key == "snapshotCreated_at" {
  155. line[value] = utilities.DateFormat(v["created_at"])
  156. continue
  157. }
  158. if key == "created_at"{
  159. line[value] = utilities.DateFormat(m[key])
  160. continue
  161. }
  162. line[value] = m[key]
  163. }
  164. list[k] = line
  165. }
  166. return row,list
  167. }