| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace ghs\controllers;
- use bizGhs\book\classes\BookItemClass;
- use bizGhs\book\classes\BookItemCustomClass;
- use bizGhs\product\classes\ProductClass;
- use common\components\util;
- use Yii;
- class BookItemCustomController extends BaseController
- {
- //预订客户列表 ssh 20240616
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = [];
- $where['mainId'] = $this->mainId;
- $bookSn = $get['bookSn'] ?? '';
- if (empty($bookSn)) {
- $shop = $this->shop;
- $bookSn = $shop->bookSn ?? 0;
- if (empty($bookSn)) {
- util::success(['list' => [], 'hint' => 'no bookSn']);
- }
- }
- $where['bookSn'] = $bookSn;
- $customId = $get['customId'] ?? 0;
- if (!empty($customId)) {
- $where['customId'] = $customId;
- }
- $itemId = $get['itemId'] ?? 0;
- $remainNum = 0;
- $remainName = '';
- if (!empty($itemId)) {
- $where['itemId'] = $itemId;
- //显示剩余数量
- $product = ProductClass::getById($itemId, true);
- $booItem = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true);
- if (!empty($booItem)) {
- $stock = $product->stock ?? 0;
- $onNum = $booItem->onNum ?? 0;
- $remainNum = bcsub($stock, $onNum);
- $remainName = $product->name ?? '';
- }
- }
- $list = BookItemCustomClass::getAllByCondition($where, '(bookNum-onNum) DESC', '*');
- util::success(['list' => $list, 'remainNum' => $remainNum, 'remainName' => $remainName]);
- }
- }
|