ClearController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use bizGhs\clear\classes\ClearClass;
  5. use bizGhs\clear\services\ClearService;
  6. use bizGhs\custom\classes\CustomClass;
  7. use common\components\dict;
  8. use common\components\util;
  9. use Yii;
  10. class ClearController extends BaseController
  11. {
  12. //获取客户待结订单明细 ssh 20220926
  13. public function actionGetUnClear()
  14. {
  15. $get = Yii::$app->request->get();
  16. $customId = $get['customId'] ?? 0;
  17. $custom = CustomClass::getById($customId, true);
  18. CustomClass::valid($custom, $this->shopId);
  19. $info = ClearClass::getByCondition(['customId' => $customId, 'status' => 1], true);
  20. if (isset($info->deadline) && $info->deadline < date("Y-m-d H:i:s")) {
  21. if ($info->status == 1) {
  22. $info->status = 3;
  23. $info->save();
  24. }
  25. util::success(['info' => []]);
  26. }
  27. util::success(['info' => $info]);
  28. }
  29. public function actionCancel()
  30. {
  31. $id = Yii::$app->request->get('id');
  32. $clear = ClearClass::getLockById($id);
  33. if (empty($clear)) {
  34. util::fail('没有结账信息');
  35. }
  36. $ghsId = $clear->ghsId ?? 0;
  37. $ghs = GhsClass::getById($ghsId, true);
  38. if (empty($ghs)) {
  39. util::fail('没有找到供货商关系');
  40. }
  41. if ($ghs->shopId != $this->shopId) {
  42. util::fail('没有权限');
  43. }
  44. if ($clear->clearStyle != dict::getDict('clearStyle', 'gys2Hd')) {
  45. util::fail('不是你建的账单');
  46. }
  47. if ($clear->status == ClearClass::STATUS_HAS_PAY) {
  48. util::fail('账单已完成');
  49. }
  50. if ($clear->status == ClearClass::STATUS_EXPIRE) {
  51. util::fail('账单已取消');
  52. }
  53. $clear->status = ClearClass::STATUS_EXPIRE;
  54. $clear->save();
  55. util::complete();
  56. }
  57. //城市供货商向基地批发商的结账单 ssh 20220523
  58. public function actionList()
  59. {
  60. $get = Yii::$app->request->get();
  61. $where = [];
  62. if (isset($get['status']) && is_numeric($get['status'])) {
  63. $where['status'] = $get['status'];
  64. }
  65. $ghsId = $get['ghsId'] ?? 0;
  66. if (!empty($ghsId)) {
  67. $ghs = GhsClass::getById($ghsId, true);
  68. GhsClass::valid($ghs, $this->shopId);
  69. $where['ghsId'] = $ghsId;
  70. }
  71. $where['customShopId'] = $this->shopId ?? 0;
  72. $list = ClearService::getClearList($where);
  73. util::success($list);
  74. }
  75. //获取基本信息 ssh 20210625
  76. public function actionGetFullInfo()
  77. {
  78. $id = Yii::$app->request->get('id', '');
  79. $info = clearClass::getById($id);
  80. if (isset($info['customShopId']) == false || $info['customShopId'] != $this->shopId) {
  81. util::fail('没有权限');
  82. }
  83. $respond = ClearClass::getGhsCgInfo($info);
  84. util::success($respond);
  85. }
  86. //客户的结帐单 ssh 20210625
  87. public function actionCustomList()
  88. {
  89. $get = Yii::$app->request->get();
  90. $where = [];
  91. if (isset($get['status']) && is_numeric($get['status'])) {
  92. $where['status'] = $get['status'];
  93. }
  94. $customId = $get['customId'] ?? 0;
  95. if (!empty($customId)) {
  96. $custom = CustomClass::getById($customId, true);
  97. CustomClass::valid($custom, $this->shopId);
  98. $where['customId'] = $customId;
  99. }
  100. $where['ghsShopId'] = $this->shopId ?? 0;
  101. $list = ClearService::getClearList($where);
  102. util::success($list);
  103. }
  104. //获取基本信息 ssh 20210625
  105. public function actionGetCustomFullInfo()
  106. {
  107. $id = Yii::$app->request->get('id', '');
  108. $info = ClearClass::getById($id);
  109. if (isset($info['ghsShopId']) == false || $info['ghsShopId'] != $this->shopId) {
  110. util::fail('没有权限');
  111. }
  112. $respond = ClearClass::getSaleInfo($info);
  113. util::success($respond);
  114. }
  115. }