Manage.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace Scm_servicer\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function __construct()
  7. {
  8. Dever::load('manage/auth.init');
  9. }
  10. public function getStore($id)
  11. {
  12. $table = array();
  13. $table['head'] = array('仓库名称', '仓库编码', '操作');
  14. $table['body'] = array();
  15. $data = Dever::db('scm_servicer/store')->select(array('servicer_id' => $id));
  16. if ($data) {
  17. $status = Dever::db('scm_servicer/store')->config['status'];
  18. foreach ($data as $k => $v) {
  19. $status_name = '';
  20. if ($v['status'] == 2) {
  21. $status_name = '(已禁用)';
  22. }
  23. $oper = '<a class="layui-btn" href="'.Dever::url('lib/set.home?role=servicer/store&id=' . $v['id'], 'scm_product').'">仓库明细</a>';
  24. $table['body'][$k][] = $v['name'] . $status_name;
  25. $table['body'][$k][] = $v['code'];
  26. $table['body'][$k][] = $oper;
  27. }
  28. }
  29. $body[''] = array
  30. (
  31. 'type' => 'table',
  32. 'content' => $table,
  33. );
  34. if ($table['body']) {
  35. return Dever::show('', $body);
  36. } else {
  37. return '暂无';
  38. }
  39. }
  40. public function getGoods($id)
  41. {
  42. $table = array();
  43. $table['head'] = array('名称', '单价', '数量', '状态');
  44. $table['body'] = array();
  45. $data = Dever::db('scm_servicer/in_order_goods')->select(array('order_id' => $id));
  46. if ($data) {
  47. $status = Dever::db('scm_servicer/in_order_goods')->config['status'];
  48. foreach ($data as $k => $v) {
  49. $status_name = Dever::status($status, $v['status']);
  50. $table['body'][$k][] = $v['goods'];
  51. $table['body'][$k][] = $v['cash'];
  52. $table['body'][$k][] = $v['num'];
  53. $table['body'][$k][] = $status_name;
  54. }
  55. }
  56. $body[''] = array
  57. (
  58. 'type' => 'table',
  59. 'content' => $table,
  60. );
  61. if ($table['body']) {
  62. return Dever::show('', $body);
  63. } else {
  64. return '暂无';
  65. }
  66. }
  67. public function updateGoods($id, $name, $data)
  68. {
  69. $table = Dever::input('table');
  70. $goods = Dever::param('goods', $data);
  71. if ($goods) {
  72. $info = Dever::db('scm_servicer/' . $table . '_goods')->find($id);
  73. if ($info) {
  74. $order = Dever::db('scm_servicer/' . $table)->find($info['order_id']);
  75. $update['where_id'] = $info['order_id'];
  76. $update['order_num'] = $this->getOrderId($table);
  77. Dever::db('scm_servicer/' . $table)->update($update);
  78. $temp = explode('-', $goods);
  79. $update = array();
  80. $update['where_id'] = $id;
  81. $update['goods_id'] = $temp[0];
  82. $update['sku_id'] = $temp[1];
  83. $update['cash'] = $temp[2];
  84. Dever::db('scm_servicer/' . $table . '_goods')->update($update);
  85. Dever::config('base')->hook = false;
  86. }
  87. }
  88. }
  89. # 生成订单号
  90. public function getOrderId($table)
  91. {
  92. $first = ucfirst(substr($table, 0, 1));
  93. $where['order_num'] = Dever::order('C' . $first);
  94. $state = Dever::db('scm_servicer/' . $table)->one($where);
  95. if (!$state) {
  96. return $where['order_num'];
  97. } else {
  98. return $this->getOrderId($table);
  99. }
  100. }
  101. }