ClearController.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace hd\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 $guestAccess = ['get-full-info', 'detail'];
  13. //取消结账单 ssh 20220509
  14. public function actionCancel()
  15. {
  16. $id = Yii::$app->request->get('id');
  17. $clear = ClearClass::getLockById($id);
  18. if (empty($clear)) {
  19. util::fail('没有结账信息');
  20. }
  21. $customId = $clear->customId ?? 0;
  22. $custom = CustomClass::getById($customId, true);
  23. $customShopId = $custom->shopId ?? 0;
  24. if ($customShopId != $this->shopId) {
  25. util::fail('没有权限');
  26. }
  27. if ($clear->status == ClearClass::STATUS_HAS_PAY) {
  28. util::fail('账单已完成');
  29. }
  30. if ($clear->status == ClearClass::STATUS_EXPIRE) {
  31. util::fail('账单已取消');
  32. }
  33. $clear->status = ClearClass::STATUS_EXPIRE;
  34. $clear->save();
  35. util::complete();
  36. }
  37. //结款单 ssh 20210625
  38. public function actionList()
  39. {
  40. $get = Yii::$app->request->get();
  41. $where = [];
  42. if (isset($get['status']) && is_numeric($get['status'])) {
  43. $where['status'] = $get['status'];
  44. }
  45. $ghsId = $get['ghsId'] ?? 0;
  46. if (!empty($ghsId)) {
  47. $ghs = GhsClass::getById($ghsId, true);
  48. GhsClass::valid($ghs, $this->shopId);
  49. $where['ghsId'] = $ghsId;
  50. }
  51. $where['customShopId'] = $this->shopId ?? 0;
  52. $list = ClearService::getClearList($where);
  53. util::success($list);
  54. }
  55. //获取基本信息 ssh 20210625
  56. public function actionGetFullInfo()
  57. {
  58. $id = Yii::$app->request->get('id');
  59. $info = ClearClass::getById($id);
  60. $respond = ClearClass::getCgInfo($info);
  61. util::success($respond);
  62. }
  63. //获取结账单详情 ssh 20220509
  64. public function actionDetail()
  65. {
  66. $id = Yii::$app->request->get('id');
  67. $clear = ClearClass::getById($id);
  68. if (empty($clear)) {
  69. util::fail('没有结账信息');
  70. }
  71. $deadline = isset($clear['deadline']) && !empty($clear['deadline']) ? strtotime($clear['deadline']) : 0;
  72. $now = time();
  73. $remainSecond = bcsub($deadline, $now);
  74. $remainSecond = bcsub($remainSecond, 100);
  75. $remainSecond = $remainSecond > 0 ? $remainSecond : 0;
  76. $clear['remainSecond'] = $remainSecond;
  77. util::success($clear);
  78. }
  79. }