ClearController.php 3.9 KB

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