PurchaseController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 bizHd\purchase\classes\PurchaseClass;
  7. use common\components\dateUtil;
  8. use common\components\util;
  9. use Yii;
  10. class PurchaseController extends BaseController
  11. {
  12. public $guestAccess = ['get-cg-salt'];
  13. /**
  14. * 分享跳转花店采购详情时,按 xhCg 主键取 salt(无需登录)
  15. */
  16. public function actionGetCgSalt()
  17. {
  18. $get = Yii::$app->request->get();
  19. $id = intval($get['id'] ?? 0);
  20. if (empty($id)) {
  21. util::fail('采购单无效');
  22. }
  23. $cg = PurchaseClass::getById($id, true);
  24. if (empty($cg)) {
  25. util::fail('没有找到采购单');
  26. }
  27. $salt = $cg->salt ?? '';
  28. if (empty($salt)) {
  29. util::fail('采购单信息无效');
  30. }
  31. util::success(['salt' => $salt]);
  32. }
  33. //待结款明细 ssh 2021.1.26
  34. public function actionDebtList()
  35. {
  36. $get = Yii::$app->request->get();
  37. $id = $get['id'] ?? 0;
  38. $confirm = $get['confirm'] ?? -1;
  39. $shortOrderSn = $get['shortOrderSn'] ?? '';
  40. $info = GhsClass::getGhsInfo($id);
  41. GhsClass::valid($info, $this->shopId);
  42. $where = ['ghsId' => $id, 'debt' => PurchaseOrderClass::DEBT_YES];
  43. if ($confirm > -1) {
  44. $where['confirm'] = $confirm;
  45. }
  46. $searchTime = $get['searchTime'] ?? '';
  47. if (!empty($searchTime)) {
  48. $startTime = $get['startTime'] ?? '';
  49. $endTime = $get['endTime'] ?? '';
  50. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  51. $where['entryTime'] = ['between', [$period['startTime'], $period['endTime']]];
  52. }
  53. if (!empty($shortOrderSn)) {
  54. $where['orderSn'] = ['like', $shortOrderSn];
  55. }
  56. $respond = PurchaseOrderService::getDebtList($where);
  57. $respond['ghsInfo'] = $info;
  58. util::success($respond);
  59. }
  60. //批量确认 ssh 20240518
  61. public function actionBatchConfirm()
  62. {
  63. if (getenv('YII_ENV') == 'production') {
  64. //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
  65. if (in_array($this->mainId, [23390, 24516])) {
  66. if (!in_array($this->adminId, [24655,77951])) {
  67. util::fail('不能操作哦');
  68. }
  69. }
  70. } else {
  71. if (in_array($this->shopId, [36523])) {
  72. // if (!in_array($this->adminId, [919])) {
  73. // util::fail('不能操作哈');
  74. // }
  75. }
  76. }
  77. $post = Yii::$app->request->post();
  78. $str = $post['id'] ?? 0;
  79. $ghsId = $post['ghsId'] ?? 0;
  80. if (empty($str)) {
  81. util::fail('没有选择订单');
  82. }
  83. $arr = json_decode($str, true);
  84. $ids = array_column($arr, 'id');
  85. if (empty($ids)) {
  86. util::fail('没有订单哦');
  87. }
  88. $list = PurchaseOrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
  89. if (empty($list)) {
  90. util::fail('没有订单');
  91. }
  92. foreach ($list as $order) {
  93. if ($order->ghsId != $ghsId) {
  94. util::fail('订单有问题');
  95. }
  96. $order->confirm = 1;
  97. $order->save();
  98. }
  99. util::complete('确认成功');
  100. }
  101. }