| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace ghs\controllers;
- use bizGhs\book\classes\BookClass;
- use common\components\book;
- use common\components\bookJd;
- use common\components\orderSn;
- use common\components\util;
- use Yii;
- class BookController extends BaseController
- {
- public $guestAccess = ['list', 'detail', 'jd-list'];
- //教程列表 ssh 20211206
- public function actionList()
- {
- $list = book::$list;
- util::success(['list' => $list]);
- }
- //基地教学视频 ssh 20231203
- public function actionJdList()
- {
- $list = bookJd::$list;
- util::success(['list' => $list]);
- }
- //手册详情页 ssh 20211206
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $data = book::$data;
- $bookTitleList = book::$list;
- //取出title
- $titleData = [];
- foreach ($bookTitleList as $bookList) {
- foreach ($bookList['list'] as $item) {
- $currentId = $item['id'] ?? '';
- $title = $item['title'] ?? '';
- $titleData[$currentId] = $title;
- }
- }
- $currentTitle = $titleData[$id] ?? '';
- $info = $data[$id] ?? [];
- array_unshift($info, ['style' => 'title', 'value' => $currentTitle]);
- //组合出视频完整链接
- $apiHost = Yii::$app->params['ghsHost'];
- foreach ($info as $key => $val) {
- if (isset($val['style']) && $val['style'] == 'video') {
- $info[$key]['value'] = $apiHost . '/' . $val['value'];
- }
- }
- util::success(['list' => $info]);
- }
- //关闭手册 ssh 20211211
- public function actionCloseBook()
- {
- $cacheKey = 'close_book_' . $this->shopAdminId;
- Yii::$app->redis->executeCommand('SET', [$cacheKey, 'has']);
- util::complete();
- }
- //变更预订活动 ssh 20240623
- public function actionChangeBook()
- {
- $get = Yii::$app->request->get();
- $status = $get['status'] ?? 0;
- $shop = $this->shop;
- $staff = $this->shopAdmin;
- if ($staff->founder != 2 && $staff->mobile != 15280215347) {
- //util::fail('这个需要超管才能操作');
- }
- $pfLevel = $shop->pfLevel ?? 0;
- if ($pfLevel == 0) {
- util::fail('昆明批发才能使用');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- if ($status == 0) {
- if ($shop->bookSn == 0) {
- util::fail('已经关闭了');
- }
- $shop->bookSn = 0;
- $shop->save();
- $transaction->commit();
- $bookSn = $shop->bookSn ?? 0;
- //删除采购单货位需要更新标记
- $cacheKey1 = 'ghs_cg_order_staff_refresh_seat_' . $bookSn;
- Yii::$app->redis->executeCommand('DEL', [$cacheKey1]);
- $cacheKey2 = 'ghs_cg_order_guest_refresh_seat_' . $bookSn;
- Yii::$app->redis->executeCommand('DEL', [$cacheKey2]);
- util::success(['bookSn' => 0], '已关闭');
- } else {
- $orderSn = orderSn::getBookSn();
- $data = [
- 'orderSn' => $orderSn,
- 'shopId' => $this->shopId,
- 'mainId' => $this->mainId,
- ];
- BookClass::add($data, true);
- $shop = $this->shop;
- $shop->bookSn = $orderSn;
- $shop->save();
- $transaction->commit();
- util::success(['bookSn' => $orderSn], '开启成功');
- }
- } catch (\Exception $e) {
- Yii::info("操作失败原因:" . $e->getMessage());
- $transaction->rollBack();
- util::fail('操作失败');
- }
- }
- }
|