PurchaseController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use bizGhs\order\classes\PurchaseOrderClass;
  5. use bizGhs\order\services\PurchaseOrderService;
  6. use common\components\dateUtil;
  7. use common\components\util;
  8. use Yii;
  9. class PurchaseController extends BaseController
  10. {
  11. //待结款明细 ssh 2021.1.26
  12. public function actionDebtList()
  13. {
  14. $get = Yii::$app->request->get();
  15. $id = $get['id'] ?? 0;
  16. $confirm = $get['confirm'] ?? -1;
  17. $shortOrderSn = $get['shortOrderSn'] ?? '';
  18. $info = GhsClass::getGhsInfo($id);
  19. GhsClass::valid($info, $this->shopId);
  20. $where = ['ghsId' => $id, 'debt' => PurchaseOrderClass::DEBT_YES];
  21. if ($confirm > -1) {
  22. $where['confirm'] = $confirm;
  23. }
  24. $searchTime = $get['searchTime'] ?? '';
  25. if (!empty($searchTime)) {
  26. $startTime = $get['startTime'] ?? '';
  27. $endTime = $get['endTime'] ?? '';
  28. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  29. $where['entryTime'] = ['between', [$period['startTime'], $period['endTime']]];
  30. }
  31. if (!empty($shortOrderSn)) {
  32. $where['orderSn'] = ['like', $shortOrderSn];
  33. }
  34. $respond = PurchaseOrderService::getDebtList($where);
  35. $respond['ghsInfo'] = $info;
  36. util::success($respond);
  37. }
  38. //批量确认 ssh 20240518
  39. public function actionBatchConfirm()
  40. {
  41. if (getenv('YII_ENV') == 'production') {
  42. //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
  43. if (in_array($this->mainId, [23390, 24516])) {
  44. if (!in_array($this->adminId, [24655])) {
  45. util::fail('不能操作哦');
  46. }
  47. }
  48. } else {
  49. if (in_array($this->shopId, [36523])) {
  50. // if (!in_array($this->adminId, [919])) {
  51. // util::fail('不能操作哈');
  52. // }
  53. }
  54. }
  55. $post = Yii::$app->request->post();
  56. $str = $post['id'] ?? 0;
  57. $ghsId = $post['ghsId'] ?? 0;
  58. if (empty($str)) {
  59. util::fail('没有选择订单');
  60. }
  61. $arr = json_decode($str, true);
  62. $ids = array_column($arr, 'id');
  63. if (empty($ids)) {
  64. util::fail('没有订单哦');
  65. }
  66. $list = PurchaseOrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
  67. if (empty($list)) {
  68. util::fail('没有订单');
  69. }
  70. foreach ($list as $order) {
  71. if ($order->ghsId != $ghsId) {
  72. util::fail('订单有问题');
  73. }
  74. $order->confirm = 1;
  75. $order->save();
  76. }
  77. util::complete('确认成功');
  78. }
  79. }