| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- namespace hd\controllers;
- use biz\item\classes\PtItemClass;
- use bizGhs\item\classes\ItemClass;
- use bizGhs\item\services\ItemService;
- use bizHd\product\classes\ProductClass;
- use common\components\dict;
- use common\components\util;
- use Yii;
- class ItemController extends BaseController
- {
- //增加和减少半扎 ssh 20250417
- public function actionChangeHalf()
- {
- util::fail('此功能已停用');
- $post = Yii::$app->request->post();
- $productId = $post['productId'] ?? '';
- $add = $post['add'] ?? 0;
- $remark = $post['remark'] ?? '';
- $product = ProductClass::getLockById($productId);
- if (empty($product)) {
- util::fail('没有找到花材');
- }
- if ($product->mainId != $this->mainId) {
- util::fail('不是你的花材');
- }
- if ($product->ratioType == 1) {
- util::fail('若干扎的花材不能减半份');
- }
- //避免重复提交
- util::checkRepeatCommit($this->adminId, 4);
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $shop = $this->shop;
- $staff = $this->shopAdmin;
- $staffName = $staff->name ?? '';
- $staffId = $staff->id;
- $adminId = $this->adminId;
- $params = [
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'adminId' => $adminId,
- 'remark' => $remark,
- ];
- ItemClass::modifyHalf($shop, $product, $params, $add);
- $product = ProductClass::getLockById($productId);
- $stock = $product->stock;
- $stock = floatval($stock);
- $transaction->commit();
- util::success(['stock' => $stock]);
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::info("加减半份失败原因:" . $e->getMessage());
- util::fail('加减半份失败');
- }
- }
- //检测是否要刷新
- public function actionCheckRefresh()
- {
- $mainId = $this->mainId;
- $staffId = $this->shopAdminId;
- $respond = Yii::$app->redis->executeCommand('GET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
- if ($respond == 'yes') {
- util::success(['remind' => 1]);
- }
- util::complete();
- }
- //列出所有花材,包括特价花材列表 ssh 20220315
- public function actionShowList()
- {
- $headers = Yii::$app->getRequest()->getHeaders();
- $requestVersion = $headers->get('appVersion');
- $currentVersion = dict::getDict('appVersion');
- if ($requestVersion < $currentVersion) {
- util::fail('请先升级系统');
- }
- $get = Yii::$app->request->get();
- $isCashier = $get['isCashier'] ?? 0;
- $mainId = $this->mainId;
- if ($isCashier == 1) {
- //去掉收银台提示价格更新
- $staffId = $this->shopAdminId;
- Yii::$app->redis->executeCommand('DEL', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
- }
- $where['mainId'] = $mainId;
- $where['delStatus'] = 0;
- $where['status'] = 1;
- $list = \bizHd\item\classes\ItemClass::getShowList($where);
- util::success(['list' => $list]);
- }
- public function actionAdd()
- {
- util::fail('开发中');
- }
- public function actionBatchAdd()
- {
- util::fail('开发中');
- }
- public function actionDelete()
- {
- util::fail('不能删除哦!');
- }
- //获取平台里的花材信息
- public function actionPlatformItem()
- {
- $py = Yii::$app->request->get('py', '');
- $where = [];
- if ($py) {
- $where = ['py' => $py];
- }
- $list = PtItemClass::getItemList($where);
- util::success($list);
- }
- }
|