Out.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace Scm_servicer\Lib;
  3. use Dever;
  4. class Out
  5. {
  6. # 获取订单信息
  7. public function info($id)
  8. {
  9. Dever::load('manage/auth.init');
  10. $info = Dever::db('scm_servicer/out_order')->find($id);
  11. $string = '';
  12. $string = $info['order_num'];
  13. $servicer = Dever::db('scm_servicer/info')->one($info['servicer_id']);
  14. $string .= '<br />' . $servicer['name'];
  15. $store = Dever::db('scm_servicer/store')->one($info['servicer_store_id']);
  16. $string .= '.' . $store['name'];
  17. $string .= '<br />' . $info['info'];
  18. return $string;
  19. }
  20. # 查看详情
  21. public function show_api()
  22. {
  23. $id = Dever::input('order_id');
  24. $config = Dever::db('scm_servicer/out_order')->config['set'];
  25. $info = Dever::db('scm_servicer/out_order')->one($id);
  26. $status = Dever::status($config['status'], $info['status']);
  27. $member = Dever::db('scm_servicer/info')->one($info['servicer_id']);
  28. $store = Dever::db('scm_servicer/store')->one($info['servicer_store_id']);
  29. $type = Dever::db('scm_servicer/out_order_type')->one($info['type']);
  30. $cdate = date('Y-m-d H:i', $info['cdate']);
  31. $result = array();
  32. $result[$info['order_num']] = array
  33. (
  34. 'type' => 'info',
  35. 'content' => array
  36. (
  37. array
  38. (
  39. array('配送商', $member['name']),
  40. array('仓库', $store['name']),
  41. ),
  42. array
  43. (
  44. array('出库类型', $type['name']),
  45. array('订单状态', $status),
  46. array('订单备注', $info['info']),
  47. ),
  48. ),
  49. );
  50. if (!$info['address']) {
  51. $info['address'] = $store['address'];
  52. }
  53. if ($info['address']) {
  54. $temp = explode('、', $store['address']);
  55. $result['收货信息'] = array
  56. (
  57. 'type' => 'info',
  58. 'content' => array
  59. (
  60. array
  61. (
  62. array('联系人', $temp[1]),
  63. array('联系电话', $temp[2]),
  64. ),
  65. array
  66. (
  67. array('收货地址', $temp[0]),
  68. ),
  69. ),
  70. );
  71. }
  72. $body = array();
  73. $body_total = array();
  74. $body_total['price'] = 0;
  75. $body_total['num'] = 0;
  76. $data = Dever::db('scm_servicer/out_order_goods')->select(array('order_id' => $id));
  77. if ($data) {
  78. $status = Dever::db('scm_servicer/out_order_goods')->config['status'];
  79. foreach ($data as $k => $v) {
  80. $goods_info = Dever::load('scm_product/lib/info')->getBaseInfo($v['goods_id'], $v['sku_id'], $v['unit_id']);
  81. $status_name = Dever::status($status, $v['status']);
  82. if ($v['unit_id'] != $goods_info['base_unit_id']) {
  83. $unit = Dever::load('scm/lib/price')->getByUnit($v['goods_id'], $v['sku_id'], $v['unit_id'], $v['num'], $v['cash']);
  84. if ($unit) {
  85. $base_unit = Dever::db('scm/unit')->find($goods_info['base_unit_id']);
  86. $goods_info['unit'] .= '(审核成功将转换成:'.$unit['base_num'].''.$base_unit['name'].')';
  87. }
  88. }
  89. $detail = array
  90. (
  91. 'pic' => $goods_info['cover'],
  92. 'name' => $goods_info['name'] . ' [批次:'.$v['batch'].']',
  93. 'sku' => $goods_info['spec_name'],
  94. 'price' => $v['cash'],
  95. 'num' => $v['num'] . $goods_info['unit'],
  96. 'status' => $status_name,
  97. );
  98. if ($goods_info['goods']) {
  99. $detail['goods'] = $goods_info['goods'];
  100. }
  101. $body[] = $detail;
  102. $body_total['price'] += $v['cash'] * $v['num'];
  103. $body_total['num'] += $v['num'];
  104. }
  105. }
  106. $result['商品清单'] = array
  107. (
  108. 'type' => 'list',
  109. 'content' => $body,
  110. 'total' => $body_total,
  111. );
  112. $head = array
  113. (
  114. 'name' => '基本信息',
  115. 'btn' => '',
  116. );
  117. $html = Dever::show($head, $result);
  118. return $html;
  119. }
  120. }