| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace bizGhs\book\classes;
- use bizGhs\base\classes\BaseClass;
- use common\components\dict;
- use common\components\util;
- use Yii;
- class BookCustomChangeClass extends BaseClass
- {
- public static $baseFile = '\bizGhs\book\models\BookCustomChange';
- public static function getChangeList($where)
- {
- $data = self::getList('*', $where, 'addTime DESC,id DESC');
- return $data;
- }
- public static function delBookNum($bookCustomRes, $num, $order, $shop, $product, $params)
- {
- $mainId = $order->mainId ?? 0;
- $customId = $order->customId ?? 0;
- $customName = $order->customName ?? '';
- $customNamePy = $order->customNamePy ?? '';
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $nowNum = bcsub($bookCustomRes->bookNum, $num);
- if ($nowNum < 0) {
- $cacheKey = $params['cacheKey'] ?? '';
- if (!empty($cacheKey)) {
- util::unlock($cacheKey);
- }
- util::fail($customName . '预订的' . $name . '不够减哈 bookCustom');
- }
- $bookCustomRes->bookNum = $nowNum;
- $bookCustomRes->save();
- $bookItemCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? null;
- $relatedId = $ioRes->id ?? 0;
- //变动记录
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $event = $customName . '减少' . $name . $num . $bigUnit;
- $changeData = [
- 'mainId' => $mainId,
- 'bookSn' => $bookSn,
- 'name' => $name,
- 'py' => $py,
- 'itemId' => $itemId,
- 'ptItemId' => $ptItemId,
- 'customId' => $customId,
- 'customName' => $customName,
- 'customNamePy' => $customNamePy,
- 'relateId' => $relatedId,
- 'relateSecondId' => $bookItemCustomResId,
- 'ptStyle' => 2,
- 'capitalType' => $currentCapitalType,
- 'io' => 0,
- 'changeNum' => $num,
- 'num' => $bookCustomRes->bookNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- }
|