ClearController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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->clearStyle != dict::getDict('clearStyle', 'hd2Gys')) {
  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 20210625
  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. $respond = ClearClass::getCgInfo($info);
  64. util::success($respond);
  65. }
  66. //获取结账单详情 ssh 20220509
  67. public function actionDetail()
  68. {
  69. $id = Yii::$app->request->get('id');
  70. $clear = ClearClass::getById($id);
  71. if (empty($clear)) {
  72. util::fail('没有结账信息');
  73. }
  74. $deadline = isset($clear['deadline']) && !empty($clear['deadline']) ? strtotime($clear['deadline']) : 0;
  75. $now = time();
  76. $remainSecond = bcsub($deadline, $now);
  77. $remainSecond = bcsub($remainSecond, 100);
  78. $remainSecond = $remainSecond > 0 ? $remainSecond : 0;
  79. $clear['remainSecond'] = $remainSecond;
  80. util::success($clear);
  81. }
  82. }