Factory_order.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace store\Admin;
  3. use Dever;
  4. class Factory_order extends Core
  5. {
  6. # 订单列表
  7. public function getList()
  8. {
  9. $data = Dever::load('mshop/lib/buy')->set(2, 1)->getList($this->id, '4,5,6');
  10. $html = '';
  11. $out_status = Dever::db('shop/buy_order')->config['out_status'];
  12. $excel = Dever::input('excel', 1);
  13. if ($data && $data['order']) {
  14. if ($excel == 2) {
  15. Dever::load('store/admin/factory_excel')->out($this->id, $this->user, $data['order']);
  16. die;
  17. return;
  18. }
  19. foreach ($data['order'] as $k => $v) {
  20. if ($v['ps_info']) {
  21. $ps_date = $v['ps_info']['cdate'];
  22. $ydate = $v['ps_info']['ydate'] ? $v['ps_info']['ydate'] : '-';
  23. } else {
  24. $ps_date = $ydate = '-';
  25. }
  26. $view = Dever::url('order_view?type=3&order_id=' . $v['id'] . '&cash=2', 'store');
  27. $send = Dever::url('order_send?id=' . $v['id'], 'store');
  28. $button = '<a href="'.$view.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看详情</button></a>';
  29. $print = Dever::url('admin/order.print?id=' . $v['id'] . '&type=2', 'store');
  30. $button .= '&nbsp;&nbsp;<a href="'.$print.'" target="_blank"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">打印订单</button></a>';
  31. if ($v['status'] == 4) {
  32. $url = Dever::url('admin/factory_order.action_commit&order_id='.$v['id'], 'store');
  33. $button .= '&nbsp;&nbsp;<a href="javascript:;" onclick="load(\''.$url.'\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">确认收货</button></a>';
  34. }
  35. if ($v['refund_status'] == 2 && $v['status'] != 8) {
  36. $v['status_name'] .= '[缺货报损中]';
  37. }
  38. $url = Dever::url('lib/buy.excel_one?type='.$v['type'].'&type_id='.$v['type_id'].'&id='.$v['id'], 'mshop');
  39. if ($v['status'] == 5 || $v['status'] == 6 || $v['status'] == 8) {
  40. //$button .= '&nbsp;&nbsp;<a href="'.$url.'"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">导出</button></a>';
  41. }
  42. $v['out_status_name'] = $out_status[$v['out_status']];
  43. $dao_date = '-';
  44. if ($v['out_date']) {
  45. $dao_date = date('Y-m-d H:i', $v['out_date']);
  46. }
  47. $html .= '<tr><td>'.$v['order_num'].'</td><td>'.$ps_date.'</td><td>'.$v['source_info']['name'].'</td><td>'.$ydate.'</td><td>'.$v['num'].'</td><td>'.$v['status_name'].'</td><td>'.$v['out_status_name'].'</td><td>'.$dao_date.'</td><td>'.$button.'</td></tr>';
  48. }
  49. }
  50. return $html;
  51. }
  52. # 获取列表页搜索信息
  53. public function getSearch()
  54. {
  55. $config = array
  56. (
  57. array('value' => '0', 'name' => '全部'),
  58. array('value' => 4, 'name' => '待收货确认'),
  59. array('value' => '5,6', 'name' => '已完成'),
  60. array('value' => 'refund', 'name' => '缺货与报损'),
  61. );
  62. $status = Dever::input('status');
  63. $html = '';
  64. foreach ($config as $k => $v) {
  65. $selected = '';
  66. if ((!$status && $k == 0) || $status == $v['value']) {
  67. $selected = 'selected=""';
  68. }
  69. $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
  70. }
  71. return $html;
  72. }
  73. # 获取列表页搜索信息
  74. public function getSearchOutStatus()
  75. {
  76. $config = array
  77. (
  78. array('value' => '0', 'name' => '全部'),
  79. array('value' => 1, 'name' => '未导出'),
  80. array('value' => 2, 'name' => '已导出'),
  81. );
  82. $status = Dever::input('source_out_status');
  83. $html = '';
  84. foreach ($config as $k => $v) {
  85. $selected = '';
  86. if ((!$status && $k == 0) || $status == $v['value']) {
  87. $selected = 'selected=""';
  88. }
  89. $html .= '<option value="'.$v['value'].'" '.$selected.'>'.$v['name'].'</option>';
  90. }
  91. return $html;
  92. }
  93. # 获取列表页搜索信息
  94. public function getService()
  95. {
  96. $service = Dever::db('shop/service')->select();
  97. $html = '';
  98. foreach ($service as $k => $v) {
  99. $selected = '';
  100. if ($k == 0) {
  101. $selected = 'selected=""';
  102. }
  103. $html .= '<option value="'.$v['id'].'" '.$selected.'>'.$v['name'].'</option>';
  104. }
  105. return $html;
  106. }
  107. # 获取基本信息
  108. public function getConfig()
  109. {
  110. $data['search'] = Dever::url('factory_order', 'store');
  111. # 确认收货
  112. $data['action'] = Dever::url('admin/factory_order.action_commit', 'store');
  113. return $data;
  114. }
  115. # 确认收货
  116. public function action_commit_api()
  117. {
  118. $order_id = Dever::input('order_id');
  119. Dever::load('mshop/lib/buy')->set(2,1)->finish($this->id, $order_id);
  120. return 'reload';
  121. }
  122. }