ClearController.php 3.3 KB

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