Exemplo n.º 1
0
 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;
     }
 }
 function act_checkSkuNum()
 {
     $bool = false;
     //标志是否有摒弃订单
     $assignNUmber = $_POST['order_group'];
     $sku = trim($_POST['sku']);
     //$sku         = getGoodsSn2($sku);
     $sku_num = $_POST['sku_num'];
     $assignId = $_POST['now_group_id'];
     //$now_pname 	    = $_POST['now_pname'];
     $assignStock = WhGoodsAssignModel::getAssignStock($sku);
     //获取该料号调拨库存
     if ($assignStock == 0) {
         self::$errCode = "004";
         self::$errMsg = "该调拨单无调拨库存,不能退库!";
         return FALSE;
     }
     if ($assignStock < $sku_num) {
         self::$errCode = "004";
         self::$errMsg = "退库数量大于调拨库存,不能退库!";
         return FALSE;
     }
     $sku_info = WhGoodsAssignModel::getDetail($assignId, " and a.sku='{$sku}'");
     if (empty($sku_info)) {
         self::$errCode = "004";
         self::$errMsg = "该调拨单无此料号!";
         return FALSE;
     }
     TransactionBaseModel::begin();
     $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 = "003";
         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 = "003";
         self::$errMsg = "更新仓位库存失败!";
         return false;
     }
     TransactionBaseModel::commit();
     self::$errCode = "0";
     self::$errMsg = "退库成功!";
     return true;
 }
Exemplo n.º 3
0
 function act_checkSkuNum()
 {
     $bool = false;
     //标志是否有摒弃订单
     $assignNUmber = $_POST['order_group'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $sku_num = intval($_POST['sku_num']);
     $goodsAssignId = intval($_POST['now_group_id']);
     $sku_info = WhGoodsAssignModel::getDetail($goodsAssignId, " and a.sku='{$sku}' and a.scanUid != 0");
     if (empty($sku_info)) {
         self::$errCode = "001";
         self::$errMsg = "该调拨单无此出库复核料号!";
         return FALSE;
     } else {
         if ($sku_info['assignNum'] <= $sku_info['outCheckNum']) {
             self::$errCode = "002";
             self::$errMsg = "该料号已完成出库复核!";
             return FALSE;
         }
         $outCheckNum = $sku_info['outCheckNum'] + $sku_num;
         //系统累计出库复核数量
         if ($outCheckNum > $sku_info['assignNum']) {
             self::$errCode = "003";
             self::$errMsg = "总复核数量不能大于配货数量,请确认!";
             return false;
         }
         //print_r($sku_info);exit;
         $where = array('goodsAssignId' => $goodsAssignId, 'sku' => $sku);
         //生成where条件
         $update = array('outCheckNum' => $outCheckNum);
         if ($outCheckNum >= $sku_info['assignNum']) {
             $update['checkTime'] = time();
             $update['checkUid'] = $_SESSION['userId'];
         }
         $arr = array('sku' => $sku, 'sku_amount' => $sku_info['assignNum'], 'check_num' => $outCheckNum);
         $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
         if (!$info) {
             self::$errCode = "004";
             self::$errMsg = "更新出库明细复核数量失败!";
             return $arr;
         }
         if (isset($update['checkUid'])) {
             $assignList = WhGoodsAssignModel::getDetail($goodsAssignId, ' and a.checkUid=0 and a.scanUid !=0');
             if (empty($assignList)) {
                 //该调拨单下所有料号复核完毕
                 $where = array('id' => $goodsAssignId);
                 $update = array('statusTime' => time(), 'status' => 103);
                 $info = WhGoodsAssignModel::updateAssignListStatus($where, $update);
                 if ($info) {
                     self::$errCode = "006";
                     self::$errMsg = "该调拨单出库复核完毕!";
                     return $arr;
                 } else {
                     self::$errCode = "005";
                     self::$errMsg = "调拨单更新失败!";
                     return FALSE;
                 }
             } else {
                 self::$errCode = "0";
                 self::$errMsg = "该料号复核完毕!";
                 return $arr;
             }
         } else {
             self::$errCode = "0";
             self::$errMsg = "该料号已复核,请录入下一料号!";
             return $arr;
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Pda_makeAssignListAct::act_makeAssignList()
  * 生成调拨单编号并更新调拨明细表 
  * @return void
  */
 public function act_makeAssignList()
 {
     $res = WhGoodsAssignModel::getDetail('0', '');
     //检测是否有未生成调拨单的料号信息
     if (empty($res)) {
         self::$errCode = '001';
         self::$errMsg = '没有可以生成调拨单的料号信息!';
         return FALSE;
     }
     $outStoreId = 1;
     $inStoreId = 2;
     $createdUid = $_SESSION['userId'];
     $whGoodsAssignAct = new WhGoodsAssignAct();
     $assignNumber = $whGoodsAssignAct->buildAssignNumber();
     //获取调拨单编号
     TransactionBaseModel::begin();
     //调拨单表中插入数据并获取插入id
     $goodsAssignId = WhGoodsAssignModel::addAssignList($assignNumber, $outStoreId, $inStoreId, time(), time(), $createdUid);
     if ($goodsAssignId == FALSE) {
         self::$errCode = 02;
         self::$errMsg = '生成调拨单失败!';
         return FALSE;
     }
     $where = array('goodsAssignId' => 0, 'is_delete' => 0);
     $update = array('goodsAssignId' => $goodsAssignId);
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if ($info) {
         TransactionBaseModel::commit();
         self::$errCode = '200';
         self::$errMsg = '生成调拨单【' . $assignNumber . '】!';
         return TRUE;
     } else {
         TransactionBaseModel::commit();
         self::$errCode = '003';
         self::$errMsg = '生成调拨单失败!';
         return FALSE;
     }
 }
Exemplo n.º 5
0
 function act_checkSkuNum()
 {
     $assignNUmber = $_POST['order_group'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $sku_num = intval($_POST['sku_num']);
     if (!is_numeric($sku_num)) {
         self::$errCode = '001';
         self::$errMsg = '请输入正确数量!';
         return false;
     }
     $goodsAssignId = intval($_POST['now_group_id']);
     $skuinfo = whShelfModel::selectSku(" where sku = '{$sku}'");
     //获取sku信息
     $sku_info = WhGoodsAssignModel::getDetail($goodsAssignId, " and a.sku='{$sku}'");
     //调拨单明细中的sku信息
     if ($sku_info['inCheckNum'] >= $sku_info['assignNum']) {
         self::$errCode = '002';
         self::$errMsg = '该料号已接收复核完毕!';
         return false;
     }
     $inCheckNum = $sku_info['inCheckNum'] + $sku_num;
     if ($inCheckNum > $sku_info['assignNum']) {
         self::$errCode = '003';
         self::$errMsg = '接收数不能大于配货数!';
         return false;
     }
     $where = array('goodsAssignId' => $goodsAssignId, 'sku' => $sku);
     //生成where条件
     $update = array('inCheckNum' => $inCheckNum);
     //if($inCheckNum == $sku_info['assignNum']){
     $update['inCheckTime'] = time();
     $update['inCheckUid'] = $_SESSION['userId'];
     $checkAssignList = true;
     //}
     $arr = array('sku' => $sku, 'sku_amount' => $sku_info['assignNum'], 'check_num' => $inCheckNum);
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if (!$info) {
         self::$errCode = "004";
         self::$errMsg = "更新接收明细失败!";
         return false;
     }
     self::$errCode = "200";
     self::$errMsg = isset($checkAssignList) ? '该料号接收复核完毕' : '该料号已复核,请录入下一料号!';
     return $arr;
 }
 public function act_whShelf()
 {
     //print_r($_POST);
     $log_file = 'whselfB_log/' . date('Ymd') . '.txt';
     //日志文件路径
     $date = date('Y-m-d H:i:s');
     $userCnName = $_SESSION['userCnName'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $nums = $_POST['nums'];
     $now_position_id = intval(trim($_POST['now_position_id']));
     //现在存放该料号的仓位id
     $goodsAssignId = intval(trim($_POST['now_group_id']));
     $positionId = intval(trim($_POST['position_id']));
     //分配的仓位id
     $assignList = WhGoodsAssignModel::getAssignList("and a.id = {$goodsAssignId}", '', '', '');
     if ($assignList[0]['status'] != 106) {
         self::$errCode = 400;
         self::$errMsg = "该调拨单不在等待上架状态!";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if (empty($sku)) {
         self::$errCode = 401;
         self::$errMsg = "sku不能为空";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if (empty($now_position_id) && !$positionId) {
         self::$errCode = 401;
         self::$errMsg = "上架仓位不能为空";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if ($nums < 1) {
         self::$errCode = 403;
         self::$errMsg = "上架数量不能小于1";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     $sku_info = WhGoodsAssignModel::getDetail($goodsAssignId, " and a.sku='{$sku}' and a.inCheckNum != 0");
     if (empty($sku_info)) {
         self::$errCode = "404";
         self::$errMsg = "该调拨单无此料号!";
         return FALSE;
     }
     $whselfNums = $nums + $sku_info['whselfNum'];
     if ($whselfNums > $sku_info['assignNum']) {
         self::$errCode = "405";
         self::$errMsg = "总上架数不能大于配货数!";
         return FALSE;
     }
     $where = " where sku = '{$sku}'";
     $skuinfo = whShelfModel::selectSku($where);
     if (empty($skuinfo)) {
         self::$errCode = 404;
         self::$errMsg = "无该料号信息";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     } else {
         $skuId = $skuinfo['id'];
         $purchaseId = $skuinfo['purchaseId'];
     }
     $ioTypeId = 35;
     //35 调拨入库上架 出入库类型表id
     $return_num = $nums;
     $in_positionId = 0;
     $userId = $_SESSION['userId'];
     //$where           =  "where pId ={$skuId} and positionId = {$now_position_id} and is_delete=0 and storeId = 2";
     TransactionBaseModel::begin();
     if ($now_position_id) {
         //存在料号仓位关系
         $positioninfo = whShelfModel::selectRelationShip('', '', 2, $now_position_id);
         //检测该料号是否有对应仓位关系
         /***无料号对应仓位的关系时更新关系表***/
         $relationId = $positioninfo[0]['id'];
         $positionId = $positioninfo[0]['positionId'];
         //仓位id
         $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$relationId}'");
         if (!$update_position) {
             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");
     } 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;
 }