| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <?php
- namespace bizGhs\book\classes;
- use bizGhs\base\classes\BaseClass;
- use common\components\dict;
- use common\components\util;
- use Yii;
- class BookCustomClass extends BaseClass
- {
- public static $baseFile = '\bizGhs\book\models\BookCustom';
- public static function addOnNum($bookCustomRes, $addOnNum, $bill, $shop, $product, $params)
- {
- $bookCustomRes->onNum = bcadd($bookCustomRes->onNum, $addOnNum);
- $bookCustomRes->save();
- $bookCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? null;
- $relatedId = $ioRes->id ?? 0;
- //变动记录
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $shop->mainId ?? 0;
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $currentCapitalType = dict::getDict('capitalType', 'ghsCheckIn');
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $orderSn = $bill->orderSn ?? '';
- $currentChangeType = $params['currentChangeType'] ?? 'putIn';
- if ($currentChangeType == 'stockOn') {
- $currentCapitalType = 0;
- $event = "{$staffName} 手动上架 {$name} " . $addOnNum . $bigUnit;
- } elseif ($currentChangeType == 'putIn') {
- $event = "采购单 {$orderSn} 入库,{$name} 上架 " . $addOnNum . $bigUnit;
- } else {
- $event = '';
- util::fail('无效动作');
- }
- $changeData = [
- 'mainId' => $mainId,
- 'bookSn' => $bookSn,
- 'name' => $name,
- 'py' => $py,
- 'itemId' => $itemId,
- 'ptItemId' => $ptItemId,
- 'customId' => $customId,
- 'customName' => $customName,
- 'customNamePy' => $customNamePy,
- 'relateId' => $relatedId,
- 'relateSecondId' => $bookCustomResId,
- 'ptStyle' => 2,
- 'capitalType' => $currentCapitalType,
- 'io' => 1,
- 'changeNum' => $addOnNum,
- 'num' => $bookCustomRes->onNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomOnChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- public static function delOnNum($bookCustomRes, $delOnNum, $num, $bill, $shop, $product, $params)
- {
- $bookCustomRes->onNum = bcsub($bookCustomRes->onNum, $delOnNum);
- $bookCustomRes->save();
- $bookCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? null;
- $relatedId = $ioRes->id ?? 0;
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $shop->mainId ?? 0;
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $currentChangeType = $params['currentChangeType'] ?? 'delBook';
- if ($currentChangeType == 'ghsCgRefund') {
- //供货商采购单售后
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $orderSn = $bill->orderSn ?? '';
- $event = $staffName . ' 售后采购单' . $orderSn . ',下架' . $name . $delOnNum . $bigUnit;
- $currentCapitalType = dict::getDict('capitalType', 'ghsCgRefund');
- } elseif ($currentChangeType == 'stockOff') {
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $currentCapitalType = 0;
- $event = $staffName . '手动下架' . $name . $delOnNum . $bigUnit;
- } elseif ($currentChangeType == 'delBook') {
- $customId = $bill->customId ?? 0;
- $customName = $bill->customName ?? '';
- $customNamePy = $bill->customNamePy ?? '';
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
- } else {
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $customId = 0;
- $customName = '';
- $customNamePy = '';
- $event = '';
- util::fail('不存在的运作哈。。。');
- }
- $changeData = [
- 'mainId' => $mainId,
- 'bookSn' => $bookSn,
- 'name' => $name,
- 'py' => $py,
- 'itemId' => $itemId,
- 'ptItemId' => $ptItemId,
- 'customId' => $customId,
- 'customName' => $customName,
- 'customNamePy' => $customNamePy,
- 'relateId' => $relatedId,
- 'relateSecondId' => $bookCustomResId,
- 'ptStyle' => 2,
- 'capitalType' => $currentCapitalType,
- 'io' => 0,
- 'changeNum' => $delOnNum,
- 'num' => $bookCustomRes->onNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomOnChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- public static function addRoadNum($bookCustomRes, $addRoadNum, $bill, $shop, $product, $params)
- {
- $bookCustomRes->roadNum = bcadd($bookCustomRes->roadNum, $addRoadNum);
- $bookCustomRes->save();
- $bookItemCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? null;
- $relatedId = $ioRes->id ?? 0;
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $shop->mainId ?? 0;
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $orderSn = $bill->orderSn ?? '';
- $event = "{$staffName} 新增待入库 {$orderSn},路上增加 {$name}" . $addRoadNum . $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' => 1,
- 'changeNum' => $addRoadNum,
- 'num' => $bookCustomRes->roadNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomRoadChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- public static function delRoadNum($bookCustomRes, $delRoadNum, $num, $bill, $shop, $product, $params)
- {
- $bookCustomRes->roadNum = bcsub($bookCustomRes->roadNum, $delRoadNum);
- $bookCustomRes->save();
- $bookItemCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? null;
- $relatedId = $ioRes->id ?? 0;
- //路上减少变动记录
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $shop->mainId ?? 0;
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $currentChangeType = $params['currentChangeType'] ?? 'delBook';
- if ($currentChangeType == 'putIn') {
- //入库
- $currentCapitalType = dict::getDict('capitalType', 'ghsCheckIn');
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $orderSn = $bill->orderSn ?? '';
- $event = "采购单 {$orderSn} 入库上架,{$name} 路上减少" . $delRoadNum . $bigUnit;
- } elseif ($currentChangeType == 'delBook') {
- //减少预订
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $customId = $bill->customId ?? 0;
- $customName = $bill->customName ?? '';
- $customNamePy = $bill->customNamePy ?? '';
- $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中路上减少' . $delRoadNum . $bigUnit;
- } elseif ($currentChangeType == 'cgCancel') {
- $currentCapitalType = dict::getDict('capitalType', 'ghsCgCancel');
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->customName ?? '';
- $customNamePy = $bookCustomRes->customNamePy ?? '';
- $orderSn = $bill->orderSn ?? '';
- $event = "采购单 {$orderSn} 取消,{$name} 路上减少" . $delRoadNum . $bigUnit;
- } else {
- $event = '';
- $customId = 0;
- $customName = '';
- $customNamePy = '';
- util::fail('此变动方式没有找到');
- }
- $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' => $delRoadNum,
- 'num' => $bookCustomRes->roadNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomRoadChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- public static function delNeedCgNum($bookCustomRes, $delNeedCgNum, $totalBookNum, $bill, $shop, $product, $params)
- {
- $bookCustomRes->needCgNum = bcsub($bookCustomRes->needCgNum, $delNeedCgNum);
- $bookCustomRes->save();
- $bookItemCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? null;
- $relatedId = $ioRes->id ?? 0;
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $shop->mainId ?? 0;
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $currentChangeType = $params['currentChangeType'] ?? 'delBook';
- if ($currentChangeType == 'addCg') {
- $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $orderSn = $bill->orderSn ?? '';
- $event = $staffName . "增加待入库单 {$orderSn} 减少待采 {$name} " . $delNeedCgNum . $bigUnit;
- } elseif ($currentChangeType == 'pdAddStock') {
- $customId = 0;
- $customName = '';
- $customNamePy = '';
- $currentCapitalType = dict::getDict('capitalType', 'pd');
- $event = $staffName . '盘点增加库存' . $delNeedCgNum . $bigUnit . ',减少待采' . $delNeedCgNum . $bigUnit;
- } elseif ($currentChangeType == 'loanStock') {
- $currentCapitalType = dict::getDict('capitalType', 'loanStock');
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $outName = $params['outName'] ?? '';
- $event = $staffName . '向' . $outName . '借库存' . $delNeedCgNum . $bigUnit . ',减少待采' . $delNeedCgNum . $bigUnit;
- } elseif ($currentChangeType == 'delBook') {
- $currentCapitalType = dict::getDict('capitalType', 'delBook');
- $customId = $bill->customId ?? 0;
- $customName = $bill->customName ?? '';
- $customNamePy = $bill->customNamePy ?? '';
- $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
- } else {
- $customId = 0;
- $customName = '';
- $customNamePy = '';
- $event = '';
- util::fail('没有找到的操作');
- }
- $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' => $delNeedCgNum,
- 'num' => $bookCustomRes->needCgNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomCgChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- public static function addBookNum($bookCustomRes, $num, $order, $shop, $product, $params)
- {
- $currentNum = bcadd($bookCustomRes->bookNum, $num);
- $bookCustomRes->bookNum = $currentNum;
- $bookCustomRes->box = 0;
- $bookCustomRes->save();
- $bookItemCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? 0;
- $relatedId = $ioRes->id ?? 0;
- //预订增加变动记录
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $order->mainId ?? 0;
- $customId = $order->customId ?? 0;
- $customName = $order->customName ?? '';
- $customNamePy = $order->customNamePy ?? '';
- $currentCapitalType = dict::getDict('capitalType', 'addBook');
- $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' => 1,
- 'changeNum' => $num,
- 'num' => $bookCustomRes->bookNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- public static function addNeedCgNum($bookCustomRes, $addNeedCgNum, $num, $bill, $shop, $product, $params)
- {
- $bookCustomRes->needCgNum = bcadd($bookCustomRes->needCgNum, $addNeedCgNum);
- $bookCustomRes->save();
- $bookCustomResId = $bookCustomRes->id ?? 0;
- $ioRes = $params['ioRes'] ?? 0;
- $relatedId = $ioRes->id ?? 0;
- //待采增加变动记录
- $itemId = $product->id ?? 0;
- $ptItemId = $product->itemId ?? 0;
- $name = $product->name ?? '';
- $py = $product->py ?? '';
- $bigUnit = $product->bigUnit ?? '扎';
- $bookSn = $shop->bookSn ?? '';
- $mainId = $shop->mainId ?? 0;
- $staffName = $params['staffName'] ?? '';
- $staffId = $params['staffId'] ?? 0;
- $currentChangeType = $params['currentChangeType'] ?? 'addBook';
- if ($currentChangeType == 'cgCancel') {
- $currentCapitalType = dict::getDict('capitalType', 'ghsCgCancel');
- $customId = $bookCustomRes->customId ?? 0;
- $customName = $bookCustomRes->name ?? '';
- $customNamePy = $bookCustomRes->py ?? '';
- $orderSn = $bill->orderSn ?? '';
- $event = "采购单 {$orderSn} 取消,{$name} 增加待采" . $addNeedCgNum . $bigUnit;
- } elseif ($currentChangeType == 'addBook') {
- $currentCapitalType = dict::getDict('capitalType', 'addBook');
- $customId = $bill->customId ?? 0;
- $customName = $bill->customName ?? '';
- $customNamePy = $bill->customNamePy ?? '';
- $event = $customName . '预订 ' . $name . $num . $bigUnit . ',增加待采' . $addNeedCgNum . $bigUnit;
- } else {
- $currentCapitalType = dict::getDict('capitalType', 'addBook');
- $customId = 0;
- $customName = '';
- $customNamePy = '';
- $event = '';
- util::fail('无效动作哈...');
- }
- $changeData = [
- 'mainId' => $mainId,
- 'bookSn' => $bookSn,
- 'name' => $name,
- 'py' => $py,
- 'itemId' => $itemId,
- 'ptItemId' => $ptItemId,
- 'customId' => $customId,
- 'customName' => $customName,
- 'customNamePy' => $customNamePy,
- 'relateId' => $relatedId,
- 'relateSecondId' => $bookCustomResId,
- 'ptStyle' => 2,
- 'capitalType' => $currentCapitalType,
- 'io' => 1,
- 'changeNum' => $addNeedCgNum,
- 'num' => $bookCustomRes->needCgNum,
- 'event' => $event,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- 'remark' => '',
- ];
- BookCustomCgChangeClass::add($changeData, true);
- return $bookCustomRes;
- }
- }
|