PurchaseController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. $payDate = substr($cg->payTime ?? '', 0, 10);
  28. //2026年6月1号前的可以取这个数据,之后的不行
  29. if ($payDate >= '2026-06-01') {
  30. util::fail('该分享链接已失效');
  31. }
  32. $salt = $cg->salt ?? '';
  33. if (empty($salt)) {
  34. util::fail('采购单信息无效');
  35. }
  36. util::success(['salt' => $salt]);
  37. }
  38. //待结款明细 ssh 2021.1.26
  39. public function actionDebtList()
  40. {
  41. $get = Yii::$app->request->get();
  42. $id = $get['id'] ?? 0;
  43. $confirm = $get['confirm'] ?? -1;
  44. $shortOrderSn = $get['shortOrderSn'] ?? '';
  45. $info = GhsClass::getGhsInfo($id);
  46. GhsClass::valid($info, $this->shopId);
  47. $where = ['ghsId' => $id, 'debt' => PurchaseOrderClass::DEBT_YES];
  48. if ($confirm > -1) {
  49. $where['confirm'] = $confirm;
  50. }
  51. $searchTime = $get['searchTime'] ?? '';
  52. if (!empty($searchTime)) {
  53. $startTime = $get['startTime'] ?? '';
  54. $endTime = $get['endTime'] ?? '';
  55. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  56. $where['entryTime'] = ['between', [$period['startTime'], $period['endTime']]];
  57. }
  58. if (!empty($shortOrderSn)) {
  59. $where['orderSn'] = ['like', $shortOrderSn];
  60. }
  61. $respond = PurchaseOrderService::getDebtList($where);
  62. $respond['ghsInfo'] = $info;
  63. util::success($respond);
  64. }
  65. //批量确认 ssh 20240518
  66. public function actionBatchConfirm()
  67. {
  68. if (getenv('YII_ENV') == 'production') {
  69. //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
  70. if (in_array($this->mainId, [23390, 24516])) {
  71. if (!in_array($this->adminId, [24655,77951])) {
  72. util::fail('不能操作哦');
  73. }
  74. }
  75. } else {
  76. if (in_array($this->shopId, [36523])) {
  77. // if (!in_array($this->adminId, [919])) {
  78. // util::fail('不能操作哈');
  79. // }
  80. }
  81. }
  82. $post = Yii::$app->request->post();
  83. $str = $post['id'] ?? 0;
  84. $ghsId = $post['ghsId'] ?? 0;
  85. if (empty($str)) {
  86. util::fail('没有选择订单');
  87. }
  88. $arr = json_decode($str, true);
  89. $ids = array_column($arr, 'id');
  90. if (empty($ids)) {
  91. util::fail('没有订单哦');
  92. }
  93. $list = PurchaseOrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
  94. if (empty($list)) {
  95. util::fail('没有订单');
  96. }
  97. foreach ($list as $order) {
  98. if ($order->ghsId != $ghsId) {
  99. util::fail('订单有问题');
  100. }
  101. $order->confirm = 1;
  102. $order->save();
  103. }
  104. util::complete('确认成功');
  105. }
  106. }