StandingBook.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\Db;
  4. //台账
  5. class StandingBook extends Base
  6. {
  7. //台账列表
  8. public function getList()
  9. {
  10. $param = $this->request->only([
  11. 'start_date' => '',
  12. 'end_date' => '',
  13. 'standBookNo' => '',
  14. 'projectNo' => '',
  15. 'infoNo' => '',
  16. 'bargainNo' => '',
  17. 'bk_code' => '',
  18. 'orderCode' => '',
  19. 'cgdNo' => '',
  20. 'spuCode' => '',
  21. 'skuCode' => '',
  22. 'supplierNo' => '',
  23. 'companyNo' => '',
  24. 'customer_code' => '',
  25. 'page' => 1,
  26. 'size' => 15
  27. ], 'post', 'trim');
  28. $where = [];
  29. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  30. if ($param['standBookNo'] != '') $where[] = ['standBookNo', 'like', '%' . $param['standBookNo'] . '%'];
  31. if ($param['projectNo'] != '') $where[] = ['projectNo', 'like', '%' . $param['projectNo'] . '%'];
  32. if ($param['infoNo'] != '') $where[] = ['infoNo', 'like', '%' . $param['infoNo'] . '%'];
  33. if ($param['bargainNo'] != '') $where[] = ['bargainNo', 'like', '%' . $param['bargainNo'] . '%'];
  34. if ($param['bk_code'] != '') $where[] = ['bk_code', 'like', '%' . $param['bk_code'] . '%'];
  35. if ($param['orderCode'] != '') $where[] = ['orderCode', 'like', '%' . $param['orderCode'] . '%'];
  36. if ($param['cgdNo'] != '') $where[] = ['cgdNo', 'like', '%' . $param['cgdNo'] . '%'];
  37. if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%'];
  38. if ($param['skuCode'] != '') $where[] = ['skuCode', 'like', '%' . $param['skuCode'] . '%'];
  39. if ($param['supplierNo'] != '') $where[] = ['supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
  40. if ($param['companyNo'] != '') $where[] = ['companyNo', 'like', '%' . $param['companyNo'] . '%'];
  41. if ($param['customer_code'] != '') $where[] = ['customer_code', 'like', '%' . $param['customer_code'] . '%'];
  42. $count = Db::name('standing_book')
  43. ->where($where)
  44. ->count('id');
  45. $list = Db::name('standing_book')
  46. ->where($where)
  47. ->order('addtime', 'desc')
  48. ->page($param['page'], $param['size'])
  49. ->withAttr('outCode', function ($val) {
  50. //有可能第一个是,开头
  51. return trim($val, ',');
  52. })
  53. ->withAttr('returnCode', function ($val) {
  54. return trim($val, ',');
  55. })
  56. ->withAttr('thNo', function ($val) {
  57. return trim($val, ',');
  58. })
  59. ->withAttr('returnGoodCode', function ($val) {
  60. return trim($val, ',');
  61. })
  62. ->withAttr('wsm_in_code', function ($val) {
  63. return trim($val, ',');
  64. })
  65. ->withAttr('cgdReturnCode', function ($val) {
  66. return trim($val, ',');
  67. })
  68. ->select()
  69. ->toArray();
  70. return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  71. }
  72. //台账详情
  73. public function getDetail()
  74. {
  75. $id = $this->request->post('id/d', 0, 'trim');
  76. $res = Db::name('standing_book')
  77. ->where('id', $id)
  78. ->withAttr('outCode', function ($val) {
  79. //有可能第一个是,开头
  80. return trim($val, ',');
  81. })
  82. ->withAttr('returnCode', function ($val) {
  83. return trim($val, ',');
  84. })
  85. ->withAttr('thNo', function ($val) {
  86. return trim($val, ',');
  87. })
  88. ->withAttr('returnGoodCode', function ($val) {
  89. return trim($val, ',');
  90. })
  91. ->withAttr('wsm_in_code', function ($val) {
  92. return trim($val, ',');
  93. })
  94. ->withAttr('cgdReturnCode', function ($val) {
  95. return trim($val, ',');
  96. })
  97. ->find();
  98. return app_show(0, '请求成功', $res);
  99. }
  100. }