|
|
@@ -8,14 +8,108 @@ use biz\product\classes\ProductClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\ghs\classes\GhsClass;
|
|
|
+use bizGhs\order\classes\PurchaseOrderClass;
|
|
|
+use bizGhs\order\classes\PurchaseOrderItemClass;
|
|
|
use bizGhs\order\classes\StockInOrderClass;
|
|
|
use bizGhs\order\classes\StockOutOrderClass;
|
|
|
use bizGhs\order\classes\StockOutOrderItemClass;
|
|
|
+use bizGhs\stock\classes\OnStockRecordClass;
|
|
|
+use bizHd\purchase\classes\PurchaseClass;
|
|
|
+use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
use yii\console\Controller;
|
|
|
|
|
|
class InitController extends Controller
|
|
|
{
|
|
|
|
|
|
+ //在路上库存 ssh 20231218
|
|
|
+ public function actionOnStock()
|
|
|
+ {
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+ ProductClass::updateByCondition(['id>' => 0], ['onStock' => 0]);
|
|
|
+ $cgList = PurchaseOrderClass::getAllByCondition(['status' => 3], null, '*', null, true);
|
|
|
+ if (!empty($cgList)) {
|
|
|
+ foreach ($cgList as $key => $cg) {
|
|
|
+ $orderSn = $cg->orderSn ?? '';
|
|
|
+ $sjId = $cg->sjId ?? 0;
|
|
|
+ $shopId = $cg->shopId ?? 0;
|
|
|
+ $mainId = $cg->mainId ?? 0;
|
|
|
+ $ghsName = $cg->ghsName ?? '';
|
|
|
+ $itemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($itemList)) {
|
|
|
+ foreach ($itemList as $info) {
|
|
|
+ $productId = $info->productId ?? 0;
|
|
|
+ $itemId = $info->itemId ?? 0;
|
|
|
+ $num = $info->itemNum ?? 0;
|
|
|
+ $product = ProductClass::getLockById($productId);
|
|
|
+ //增加路上库存
|
|
|
+ $onRecord = [];
|
|
|
+ $onRecord['sjId'] = $sjId;
|
|
|
+ $onRecord['shopId'] = $shopId;
|
|
|
+ $onRecord['mainId'] = $mainId;
|
|
|
+ $onRecord['orderSn'] = $orderSn;
|
|
|
+ $onRecord['productId'] = $productId;
|
|
|
+ $onRecord['itemId'] = $itemId;
|
|
|
+ $onRecord['relateName'] = $ghsName;
|
|
|
+ $onRecord['itemNum'] = $num;
|
|
|
+ $oldOnStock = $product->onStock ?? 0;
|
|
|
+ $onRecord['oldStock'] = $oldOnStock;
|
|
|
+ $newOnStock = bcadd($oldOnStock, $num);
|
|
|
+ $onRecord['newStock'] = $newOnStock;
|
|
|
+ $onRecord['ptStyle'] = 2;
|
|
|
+ OnStockRecordClass::addPurchaseOrderRecord($onRecord);
|
|
|
+ \bizGhs\product\classes\ProductClass::addOnStockByItemNum($productId, $num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionLsOnStock()
|
|
|
+ {
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+ $cgList = PurchaseClass::getAllByCondition(['status' => 3], null, '*', null, true);
|
|
|
+ if (!empty($cgList)) {
|
|
|
+ foreach ($cgList as $key => $cg) {
|
|
|
+ $orderSn = $cg->orderSn ?? '';
|
|
|
+ $sjId = $cg->sjId ?? 0;
|
|
|
+ $shopId = $cg->shopId ?? 0;
|
|
|
+ $mainId = $cg->mainId ?? 0;
|
|
|
+ $ghsName = $cg->ghsName ?? '';
|
|
|
+ $itemList = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($itemList)) {
|
|
|
+ foreach ($itemList as $val) {
|
|
|
+ $productId = $val->productId ?? 0;
|
|
|
+ $itemId = $val->itemId ?? 0;
|
|
|
+ $num = $val->xhNum ?? 0;
|
|
|
+ $product = ProductClass::getLockById($productId);
|
|
|
+ if (empty($product)) {
|
|
|
+ util::fail('没有找到花材呢');
|
|
|
+ }
|
|
|
+ //增加路上库存
|
|
|
+ $onRecord = [];
|
|
|
+ $onRecord['sjId'] = $sjId;
|
|
|
+ $onRecord['shopId'] = $shopId;
|
|
|
+ $onRecord['mainId'] = $mainId;
|
|
|
+ $onRecord['orderSn'] = $orderSn;
|
|
|
+ $onRecord['productId'] = $productId;
|
|
|
+ $onRecord['itemId'] = $itemId;
|
|
|
+ $onRecord['relateName'] = $ghsName;
|
|
|
+ $onRecord['itemNum'] = $num;
|
|
|
+ $oldOnStock = $product->onStock ?? 0;
|
|
|
+ $onRecord['oldStock'] = $oldOnStock;
|
|
|
+ $newOnStock = bcadd($oldOnStock, $num);
|
|
|
+ $onRecord['newStock'] = $newOnStock;
|
|
|
+ $onRecord['ptStyle'] = 1;
|
|
|
+ OnStockRecordClass::addPurchaseOrderRecord($onRecord);
|
|
|
+ \bizGhs\product\classes\ProductClass::addOnStockByItemNum($productId, $num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function actionCustom()
|
|
|
{
|
|
|
$list = CustomClass::getAllByCondition(['isHd' => 0], null, '*', null, true);
|