本文整理匯總了PHP中CommonModel::updateIoRecord方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonModel::updateIoRecord方法的具體用法?PHP CommonModel::updateIoRecord怎麽用?PHP CommonModel::updateIoRecord使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonModel
的用法示例。
在下文中一共展示了CommonModel::updateIoRecord方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: act_checkSkuNum
function act_checkSkuNum()
{
$bool = false;
//標誌是否有摒棄訂單
$assignNUmber = $_POST['order_group'];
$sku = trim($_POST['sku']);
$sku = get_goodsSn($sku);
$skuinfo = whShelfModel::selectSku(" where sku = '{$sku}'");
//獲取sku信息
//print_r($skuinfo);exit;
//var_dump($skuinfo);exit;
//$sku = getGoodsSn2($sku);
$sku_num = $_POST['sku_num'];
$assignId = $_POST['now_group_id'];
$now_pname = $_POST['now_pname'];
$sku_info = WhGoodsAssignModel::getDetail($assignId, " and a.sku='{$sku}' and a.checkUid=0");
//調撥單明細中的sku信息
//$sku_onhand = GroupDistributionModel::getSkuPositionStock("and c.sku='$sku' and b.pName='$now_pname'");
//$order_sku_info = $this->get_valid_order($sku_info[0]['shipOrderGroup'],$sku_info[0]['sku'],$sku_info[0]['pName']);
$now_num = $sku_num + $sku_info['assignNum'];
//已配貨數加上本次配貨數
if (!is_numeric($sku_num) || $now_num < 0) {
self::$errCode = "007";
self::$errMsg = "出庫數量必須為正整數,請確認!";
return false;
}
if ($sku_info['num'] < $now_num) {
self::$errCode = "008";
self::$errMsg = "配貨數量不能大於原始需求數量!";
return false;
}
//print_r($sku_info);exit;
$erp_onhand = CommonModel::getErpSkuInfo($sku);
//獲取老ERP料號庫存信息
if ($erp_onhand['errocode'] != 200) {
self::$errCode = "014";
self::$errMsg = "拉取老ERP庫存信息失敗,請稍後再試!";
return false;
}
//根據轉出倉庫獲取庫存
$goods_count = $sku_info['storeId'] == 1 ? $erp_onhand['data']['goods_count'] : $erp_onhand['data']['second_count'];
if ($sku_num > $goods_count) {
self::$errCode = "009";
self::$errMsg = "配貨數量不能大於舊ERP係統庫存[{$goods_count}],請確認!";
return false;
}
$uid = $_SESSION['userId'];
$scanTime = time();
$where = array('goodsAssignId' => $assignId, 'sku' => $sku);
//拚接where條件
$update = array('scanUid' => $uid, 'scanTime' => $scanTime, 'assignNum' => "assignNum+{$sku_num}");
//拚接更新字段
TransactionBaseModel::begin();
$info = WhGoodsAssignModel::updateAssignDetail($where, $update);
if ($info) {
$where = array('sku' => $sku, 'storeId' => $sku_info['storeId']);
$update = array('actualStock' => "actualStock - {$sku_num}", 'assignStock' => "assignStock + {$sku_num}");
$info = WhGoodsAssignModel::updateSkuLocation($where, $update);
//更新wh_sku_location的調撥庫存和總庫存
if (!$info) {
TransactionBaseModel::rollback();
self::$errCode = "010";
self::$errMsg = "更新總庫存失敗!";
return false;
}
$where = array('pId' => $skuinfo['id'], 'positionId' => $sku_info['positionId']);
$update = array('nums' => "nums - {$sku_num}");
$info = WhGoodsAssignModel::updateProdcutPosition($where, $update);
//更新wh_product_position_relation的倉位庫存
if (!$info) {
TransactionBaseModel::rollback();
self::$errCode = "011";
self::$errMsg = "更新倉位庫存失敗!";
return false;
}
/**** 插入出庫記錄 *****/
$paraArr = array('sku' => $sku, 'amount' => $sku_num, 'positionId' => $sku_info['positionId'], 'purchaseId' => $skuinfo['purchaseId'], 'ioType' => 1, 'ioTypeId' => 34, 'userId' => $_SESSION['userId'], 'reason' => '調撥出庫');
$record = CommonModel::addIoRecores($paraArr);
//出庫記錄
/** 暫時取消同步老ERP庫存**/
$info = CommonModel::updateIoRecord($sku, $sku_num, 2, '倉庫調撥', $_SESSION['userCnName'], $sku_info['pName']);
//var_dump($info);exit;
if ($info['errCode'] != 200) {
TransactionBaseModel::rollback();
self::$errCode = "012";
self::$errMsg = "同步舊ERP庫存失敗!";
return false;
}
TransactionBaseModel::commit();
self::$errCode = "0";
self::$errMsg = "配貨成功,請掃描下一個料號!";
$arr['sku'] = $sku;
$arr['num'] = $sku_info['num'];
$arr['assignNum'] = $sku_info['assignNum'] + $sku_num;
return $arr;
} else {
self::$errCode = "013";
self::$errMsg = "更新料號狀態失敗!";
return false;
}
//.........這裏部分代碼省略.........
示例2: act_whShelf
//.........這裏部分代碼省略.........
}
write_log($log_file, date('Y-m-d H:i:s') . '更新倉位庫存成功!' . "{$sku}\r\n");
} else {
if ($positionId) {
//沒有料號倉位關係則插入一條數據
$relationId = whShelfModel::insertRelation($skuinfo['id'], $positionId, $nums, 2);
//插入關係表
//$update_position = whShelfModel::updateProductPositionRelation($nums,"where id='$relationId'");
if (!$relationId) {
self::$errCode = 410;
self::$errMsg = "插入倉位關係失敗!";
$log_info = sprintf("料號:%s, 時間:%s,錯誤信息:%s,返回值:%s, 參數:%s, %s \r\n", $sku, $date, self::$errMsg, $update_position, $num, $select_now_store);
write_log($log_file, $log_info);
TransactionBaseModel::rollback();
return false;
}
write_log($log_file, date('Y-m-d H:i:s') . '插入倉位關係成功!' . "{$sku}\r\n");
}
}
/**** 更新總庫存 *****/
$actualStock = whShelfModel::selectSkuNums($sku, 2);
if (!empty($actualStock)) {
$where = "where sku='{$sku}' and storeId=2";
$info = whShelfModel::updateStoreNum($nums, $where);
if (!$info) {
self::$errCode = 412;
self::$errMsg = "更新總庫存失敗!";
$log_info = sprintf("料號:%s, 時間:%s,錯誤信息:%s,返回值:%s, 參數:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $nums, $where);
write_log($log_file, $log_info);
TransactionBaseModel::rollback();
return false;
}
write_log($log_file, date('Y-m-d H:i:s') . '更新總庫存成功!' . "{$sku}\r\n");
} else {
$info = whShelfModel::insertStore($sku, $nums, 2);
if (!$info) {
self::$errCode = 413;
self::$errMsg = "更新總庫存失敗!";
$log_info = sprintf("料號:%s, 時間:%s,錯誤信息:%s,返回值:%s, 參數:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $sku, $nums);
write_log($log_file, $log_info);
TransactionBaseModel::rollback();
return false;
}
write_log($log_file, date('Y-m-d H:i:s') . '更新總庫存成功!' . "{$sku}\r\n");
}
/**** 插入出入庫記錄 *****/
$paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => $ioTypeId, 'userId' => $userId, 'reason' => '調撥入庫上架');
$record = CommonModel::addIoRecores($paraArr);
//出庫記錄
if (!$record) {
self::$errCode = 414;
self::$errMsg = "插入出入庫記錄失敗!";
$log_info = sprintf("料號:%s, 時間:%s,錯誤信息:%s,返回值:%s, 參數:%s \r\n", $sku, $date, self::$errMsg, $record, json_encode($paraArr));
write_log($log_file, $log_info);
TransactionBaseModel::rollback();
return false;
}
write_log($log_file, date('Y-m-d H:i:s') . '插入入庫記錄成功!' . "{$sku}\r\n");
//更新調撥單料號上架數量
$where = array('goodsassignId' => $goodsAssignId, 'sku' => $sku);
$update = array('whselfNum' => $whselfNums);
$info = WhGoodsAssignModel::updateAssignDetail($where, $update);
if ($info === FALSE) {
self::$errCode = 415;
self::$errMsg = "更新上架數量失敗";
$log_info = sprintf("料號:%s, 時間:%s,錯誤信息:%s ,參數:s%\r\n", $sku, $date, self::$errMsg, $nums);
write_log($log_file, $log_info);
TransactionBaseModel::rollback();
return false;
}
//更新料號調撥庫存
$where = array('sku' => $sku, 'storeId' => $assignList[0]['outStoreId']);
$update = array('assignStock' => "assignStock - {$nums}");
$info = WhGoodsAssignModel::updateSkuLocation($where, $update);
if ($info == FALSE) {
self::$errCode = 416;
self::$errMsg = "更新調撥庫存失敗";
$log_info = sprintf("料號:%s, 時間:%s,錯誤信息:%s ,參數:s%\r\n", $sku, $date, self::$errMsg, $nums);
write_log($log_file, $log_info);
TransactionBaseModel::rollback();
return false;
}
/** 同步老ERP庫存**/
$pName = whShelfModel::selectPositionInfo('pName', array('id' => $positionId));
//獲取倉位名稱
$pName = $pName['pName'];
$info = CommonModel::updateIoRecord($sku, $nums, 1, '倉庫調撥入庫上架', $_SESSION['userCnName'], $pName);
//var_dump($info);exit;
if ($info['errCode'] != 200) {
TransactionBaseModel::rollback();
self::$errCode = "004";
self::$errMsg = "同步舊ERP庫存失敗!";
$log_info = sprintf("料號:%s, 時間:%s,信息:%s ,參數:%s\r\n", $sku, $date, self::$errMsg, is_array($info) ? json_encode($info) : $info);
write_log($log_file, $log_info);
return false;
}
TransactionBaseModel::commit();
self::$errMsg = "料號[{$sku}]上架成功!";
return true;
}