| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace hd\controllers;
- use biz\ghs\classes\GhsClass;
- use bizGhs\clear\classes\ClearClass;
- use bizGhs\clear\services\ClearService;
- use bizGhs\custom\classes\CustomClass;
- use common\components\dict;
- use common\components\util;
- use Yii;
- class ClearController extends BaseController
- {
- public $guestAccess = ['get-full-info', 'detail'];
- //取消结账单 ssh 20220509
- public function actionCancel()
- {
- $id = Yii::$app->request->get('id');
- $clear = ClearClass::getLockById($id);
- if (empty($clear)) {
- util::fail('没有结账信息');
- }
- $customId = $clear->customId ?? 0;
- $custom = CustomClass::getById($customId, true);
- $customShopId = $custom->shopId ?? 0;
- if ($customShopId != $this->shopId) {
- util::fail('没有权限');
- }
- if ($clear->clearStyle != dict::getDict('clearStyle', 'hd2Gys')) {
- util::fail('不是你建的账单');
- }
- if ($clear->status == ClearClass::STATUS_HAS_PAY) {
- util::fail('账单已完成');
- }
- if ($clear->status == ClearClass::STATUS_EXPIRE) {
- util::fail('账单已取消');
- }
- $clear->status = ClearClass::STATUS_EXPIRE;
- $clear->save();
- util::complete();
- }
- //结款单 ssh 20210625
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = [];
- if (isset($get['status']) && is_numeric($get['status'])) {
- $where['status'] = $get['status'];
- }
- $ghsId = $get['ghsId'] ?? 0;
- if (!empty($ghsId)) {
- $ghs = GhsClass::getById($ghsId, true);
- GhsClass::valid($ghs, $this->shopId);
- $where['ghsId'] = $ghsId;
- }
- $where['customShopId'] = $this->shopId ?? 0;
- $list = ClearService::getClearList($where);
- util::success($list);
- }
- //获取基本信息 ssh 20210625
- public function actionGetFullInfo()
- {
- $id = Yii::$app->request->get('id');
- $info = ClearClass::getById($id);
- $respond = ClearClass::getCgInfo($info);
- util::success($respond);
- }
- //获取结账单详情 ssh 20220509
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $clear = ClearClass::getById($id);
- if (empty($clear)) {
- util::fail('没有结账信息');
- }
- $deadline = isset($clear['deadline']) && !empty($clear['deadline']) ? strtotime($clear['deadline']) : 0;
- $now = time();
- $remainSecond = bcsub($deadline, $now);
- $remainSecond = bcsub($remainSecond, 100);
- $remainSecond = $remainSecond > 0 ? $remainSecond : 0;
- $clear['remainSecond'] = $remainSecond;
- util::success($clear);
- }
- }
|