コード例 #1
0
ファイル: goods.view.php プロジェクト: ohjack/newErp
 public function view_addCombineOn()
 {
     $combineSpu = $_POST['combineSpu'] ? post_check(trim($_POST['combineSpu'])) : '';
     if (empty($combineSpu)) {
         $status = "空的SPU";
         echo '<script language="javascript">
                 alert("' . $status . '");      
               </script>';
         exit;
     }
     if (intval($_SESSION['userId']) <= 0) {
         $status = "登陆超时!";
         echo '<script language="javascript">
                 alert("' . $status . '");      
               </script>';
         exit;
     }
     $tName = 'pc_auto_create_spu';
     $select = 'status';
     $where = "WHERE spu='{$combineSpu}' and is_delete=0";
     $autoSpuList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($autoSpuList)) {
         $status = "自动生成SPU列表中不存在 {$combineSpu}";
         echo '<script language="javascript">
                 alert("' . $status . '");      
               </script>';
         exit;
     }
     $amount = $_POST['amount'] ? post_check(trim($_POST['amount'])) : 0;
     $amount = intval($amount);
     if ($amount <= 0 || $amount > 500) {
         $status = "数量必须在1-500之间";
         echo '<script language="javascript">
                 alert("' . $status . '");      
               </script>';
         exit;
     }
     $tName = 'pc_goods_combine';
     $where = "WHERE is_delete=0 AND combineSpu='{$combineSpu}'";
     $countComSpu = OmAvailableModel::getTNameCount($tName, $where);
     $tmpArr = array();
     for ($index = 0; $index <= $amount; $index++) {
         $combineSku = $_POST['combineSku' . $index] ? post_check(trim($_POST['combineSku' . $index])) : '';
         $combineSku = $combineSpu . $combineSku;
         if ($index == 0 && $countComSpu > 0 && $combineSku == $combineSpu) {
             $status = "存在为空的子料号,请检查!";
             echo '<script language="javascript">
                     alert("' . $status . '");      
                   </script>';
             exit;
         }
         if ($index > 0 && $combineSku == $combineSpu) {
             //只可能index=0时候,$combineSku==$combineSpu,其他表示无效
             continue;
         }
         $combineLength = $_POST['combineLength' . $index] ? post_check(trim($_POST['combineLength' . $index])) : '';
         $combineWidth = $_POST['combineWidth' . $index] ? post_check(trim($_POST['combineWidth' . $index])) : '';
         $combineHeight = $_POST['combineHeight' . $index] ? post_check(trim($_POST['combineHeight' . $index])) : '';
         $combineNote = $_POST['combineNote' . $index] ? trim($_POST['combineNote' . $index]) : '';
         $skuArr = $_POST['sku' . $index];
         $countArr = $_POST['count' . $index];
         if (strlen($combineSku) > 30) {
             $status = "{$combineSku} 字符长度大于30,错误!";
             echo '<script language="javascript">
                     alert("' . $status . '");      
                   </script>';
             exit;
         }
         if (!preg_match("/^{$combineSpu}(_[A-Z0-9]+)*\$/", $combineSku)) {
             $status = "{$combineSku} 不规范,请检查格式是否正确";
             echo '<script language="javascript">
                     alert("' . $status . '");      
                   </script>';
             exit;
         }
         if ($combineSku == $combineSpu && $amount > 1) {
             $status = "存在SKU为空的参数";
             echo '<script language="javascript">
                     alert("' . $status . '");
                   </script>';
             exit;
         }
         $tmpArr[] = $combineSku;
         if (!empty($combineLength)) {
             if (!is_numeric($combineLength) || $combineLength < 0) {
                 $status = "{$combineSku} 长度必须为数字";
                 echo '<script language="javascript">
                         alert("' . $status . '");
                       </script>';
                 exit;
             }
         }
         if (!empty($combineWidth)) {
             if (!is_numeric($combineWidth) || $combineWidth < 0) {
                 $status = "{$combineSku} 宽度必须为数字";
                 echo '<script language="javascript">
                         alert("' . $status . '");
                       </script>';
                 exit;
             }
         }
         if (!empty($combineHeight)) {
             if (!is_numeric($combineHeight) || $combineHeight < 0) {
                 $status = "{$combineSku} 高度必须为数字";
                 echo '<script language="javascript">
                         alert("' . $status . '");
                       </script>';
                 exit;
             }
         }
         if (empty($skuArr[0]) || empty($countArr[0])) {
             $status = "{$combineSku} 至少要包含一条不为空的真实料号对应记录";
             echo '<script language="javascript">
                     alert("' . $status . '");
                   </script>';
             exit;
         }
         $tName = 'pc_goods_combine';
         $where = "WHERE combineSku='{$combineSku}' and is_delete=0";
         $count = OmAvailableModel::getTNameCount($tName, $where);
         if ($count) {
             $status = "{$combineSku} 已经存在";
             echo '<script language="javascript">
                     alert("' . $status . '");
                   </script>';
             exit;
         }
         if (count($skuArr) != count(array_unique($skuArr))) {
             $status = "{$combineSku} 中存在重复的真实料号,请检查";
             echo '<script language="javascript">
                     alert("' . $status . '");
                   </script>';
             exit;
         }
         $tName = 'pc_goods';
         foreach ($skuArr as $value) {
             if (!empty($value)) {
                 $where = "WHERE sku='{$value}' and is_delete=0";
                 $count = OmAvailableModel::getTNameCount($tName, $where);
                 if (!$count) {
                     $status = "{$combineSku} 真实料号 {$value} 不存在";
                     echo '<script language="javascript">
                             alert("' . $status . '");
                           </script>';
                     exit;
                 }
             }
         }
         foreach ($countArr as $value) {
             if (intval($value) <= 0) {
                 $status = "{$combineSku} 对应真实料号的数量有误";
                 echo '<script language="javascript">
                         alert("' . $status . '");
                       </script>';
                 exit;
             }
         }
     }
     $tmpArr = array_filter($tmpArr);
     if (count($tmpArr) != count(array_unique($tmpArr))) {
         $status = "存在重复的虚拟子料号,请检查!";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     try {
         $ebayGoodsArr = array();
         //同步数据数组
         BaseModel::begin();
         for ($index = 0; $index <= $amount; $index++) {
             $combineSku = $_POST['combineSku' . $index] ? post_check(trim($_POST['combineSku' . $index])) : '';
             $combineSku = $combineSpu . $combineSku;
             if ($index > 0 && $combineSku == $combineSpu) {
                 //只可能index=0时候,$combineSku==$combineSpu,其他表示无效
                 continue;
             }
             $combineLength = $_POST['combineLength' . $index] ? post_check(trim($_POST['combineLength' . $index])) : '';
             $combineWidth = $_POST['combineWidth' . $index] ? post_check(trim($_POST['combineWidth' . $index])) : '';
             $combineHeight = $_POST['combineHeight' . $index] ? post_check(trim($_POST['combineHeight' . $index])) : '';
             $combineNote = $_POST['combineNote' . $index] ? trim($_POST['combineNote' . $index]) : '';
             $skuArr = $_POST['sku' . $index];
             $countArr = $_POST['count' . $index];
             $dataCom = array();
             $dataCom['combineSpu'] = $combineSpu;
             $dataCom['combineSku'] = $combineSku;
             $dataCom['combineCost'] = $combineCost;
             $dataCom['combineWeight'] = $combineWeight;
             $dataCom['combineLength'] = $combineLength;
             $dataCom['combineWidth'] = $combineWidth;
             $dataCom['combineHeight'] = $combineHeight;
             $dataCom['combineNote'] = $combineNote;
             $dataCom['combineUserId'] = $_SESSION['userId'];
             $dataCom['addTime'] = time();
             $tName = 'pc_goods_combine';
             $insertIdCom = OmAvailableModel::addTNameRow2arr($tName, $dataCom);
             if (!$insertIdCom) {
                 throw new Exception('add combine error');
             }
             $dataRelation = array();
             $dataRelationMem = array();
             for ($i = 0; $i < count($skuArr); $i++) {
                 if (!empty($skuArr[$i]) && !empty($countArr[$i])) {
                     $dataRelation[] = array('combineSku' => $combineSku, 'sku' => $skuArr[$i], 'count' => $countArr[$i]);
                     $dataRelationMem[] = array('sku' => $skuArr[$i], 'count' => $countArr[$i]);
                 }
             }
             if (!empty($dataRelation)) {
                 $tName = 'pc_sku_combine_relation';
                 $where = "WHERE combineSku='{$combineSku}'";
                 $dataRelationCount = OmAvailableModel::getTNameCount($tName, $where);
                 if ($dataRelationCount) {
                     OmAvailableModel::deleteTNameRow($tName, $where);
                 }
                 foreach ($dataRelation as $value) {
                     if (!empty($value['combineSku']) && !empty($value['sku']) && !empty($value['count'])) {
                         $insertId = OmAvailableModel::addTNameRow2arr($tName, $value);
                     }
                 }
             }
             if ($autoSpuList[0]['status'] != 2) {
                 $tName = 'pc_auto_create_spu';
                 $set = "SET status=2";
                 $where = "WHERE spu='{$combineSpu}'";
                 $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where);
             }
             //将新添加的sku添加到mem中
             $key = 'pc_goods_combine_' . $combineSku;
             $dataCom['detail'] = $dataRelationMem;
             $value = $dataCom;
             setMemNewByKey($key, $value);
             //这里不保证能添加成功
             //同步新数据到旧系统中
             $ebayProductsCombine = array();
             $ebayProductsCombine['id'] = $insertIdCom;
             $ebayProductsCombine['goods_sn'] = $combineSku;
             $goods_sncombine = array();
             $truesku = array();
             foreach ($dataRelationMem as $value) {
                 $str = '';
                 $strTrue = '';
                 $str = $value['sku'] . '*' . $value['count'];
                 $strTrue = '[' . $value['sku'] . ']';
                 $goods_sncombine[] = $str;
                 $truesku[] = $strTrue;
             }
             $ebayProductsCombine['goods_sncombine'] = implode(',', $goods_sncombine);
             $ebayProductsCombine['notes'] = $combineNote;
             $ebayProductsCombine['goods_price'] = $combineCost;
             $ebayProductsCombine['goods_weight'] = $combineWeight;
             $ebayProductsCombine['cguser'] = getPersonNameById($_SESSION['userId']);
             $ebayProductsCombine['ebay_user'] = '******';
             $ebayProductsCombine['createdtime'] = time();
             $ebayProductsCombine['truesku'] = implode(',', $truesku);
             $ebayGoodsArr[] = $ebayProductsCombine;
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         addSalerInfoForAny($combineSpu, 2, $_SESSION['userId'], $_SESSION['userId']);
         //add by zqt 20140519,添加销售人逻辑
         //同步数据到深圳ERP
         foreach ($ebayGoodsArr as $value) {
             $ret = OmAvailableModel::newData2ErpInterfOpen('pc.erp.addGoodsCombine', $value, 'gw88');
         }
         $status = "添加成功";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 window.parent.location.href = "index.php?mod=goods&act=getCombineList&searchComField=1&fieldValue=' . $combineSpu . '";
               </script>';
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         echo $e->getMessage();
         $status = "添加失败,请联系系统技术部,谢谢";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
     }
 }
コード例 #2
0
ファイル: orderModify.action.php プロジェクト: ohjack/newErp
 public function act_modifyOrder()
 {
     if (isset($_POST) && !empty($_POST)) {
         //$OrderModifyAct->act_modifyOrder();
         $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : '';
         $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus'];
         $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype'];
         $update_order = array();
         $update_userinfo = array();
         $update_tracknumber = array();
         //$orderid = $_POST['orderid'];
         //var_dump($_POST); exit;
         $updatestatus = false;
         if (!empty($_POST['data'])) {
             $data = $_POST['data'];
         }
         if (isset($data['username'])) {
             $update_userinfo['username'] = $data['username'];
         }
         if (isset($data['orderStatus'])) {
             $update_order['orderStatus'] = $data['orderStatus'];
         }
         if (isset($data['orderType'])) {
             $update_order['orderType'] = $data['orderType'];
             $updatestatus = true;
         }
         if (isset($data['street'])) {
             $update_userinfo['street'] = $data['street'];
         }
         if (isset($data['platformUsername'])) {
             $update_userinfo['platformUsername'] = $data['platformUsername'];
         }
         if (isset($data['address2'])) {
             $update_userinfo['address2'] = $data['address2'];
         }
         if (isset($data['actualShipping'])) {
             $update_order['actualShipping'] = $data['actualShipping'];
         }
         if (isset($data['city'])) {
             $update_userinfo['city'] = $data['city'];
         }
         if (isset($data['state'])) {
             $update_userinfo['state'] = $data['state'];
         }
         if (isset($data['countryName'])) {
             $update_userinfo['countryName'] = $data['countryName'];
         }
         if (isset($data['zipCode'])) {
             $update_userinfo['zipCode'] = $data['zipCode'];
         }
         if (isset($data['landline'])) {
             $update_userinfo['landline'] = $data['landline'];
         }
         if (isset($data['phone'])) {
             $update_userinfo['phone'] = $data['phone'];
         }
         if (isset($data['transportId'])) {
             $update_order['transportId'] = $data['transportId'];
         }
         if (isset($data['update_notes'])) {
             $update_note = $data['update_notes'];
         }
         if (isset($data['note_new'])) {
             $add_note = $data['note_new'];
         }
         if ($data['edit_tracknumber']) {
             $update_tracknumber['omOrderId'] = $orderid;
             $update_tracknumber['tracknumber'] = $data['edit_tracknumber'];
             $update_tracknumber['addUser'] = $_SESSION['sysUserId'];
             $update_tracknumber['createdTime'] = time();
             //var_dump($update_tracknumber); exit;
         }
         BaseModel::begin();
         //开始事务
         if ($update_order) {
             //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid;
             //$msg = commonModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql);
             if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) {
                 if ($updatestatus) {
                     $ProductStatus = new ProductStatus();
                     if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) {
                         BaseModel::rollback();
                     }
                 }
                 $modify_showerrorinfo = "<font color='green'>更新成功</font>";
             } else {
                 self::$errCode = "001";
                 self::$errMsg = "更新订单信息失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_userinfo) {
             //var_dump($update_userinfo);
             if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) {
                 $modify_showerrorinfo = "<font color='green'>更新成功</font>";
             } else {
                 self::$errCode = "002";
                 self::$errMsg = "更新订单用户信息失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_tracknumber) {
             //echo $msg;
             if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) {
                 self::$errCode = "003";
                 self::$errMsg = "更新订单跟踪号插入失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_note) {
             foreach ($update_note as $key => $value) {
                 $notes = explode("###", $value);
                 $where = " where content='{$notes[0]}' and omOrderId={$orderid}";
                 $set = "set content='{$notes[1]}',userId={$_SESSION['sysUserId']},createdTime=" . time();
                 $msg = OmAvailableModel::updateTNameRow("om_order_notes", $set, $where);
                 if (!$msg) {
                     self::$errCode = "004";
                     self::$errMsg = "更新订单备注失败!";
                     BaseModel::rollback();
                     return false;
                 }
             }
         }
         if ($add_note) {
             foreach ($add_note as $key => $value) {
                 $set = "set omOrderId={$orderid},content='{$value}',userId={$_SESSION['sysUserId']},createdTime=" . time();
                 $msg = OmAvailableModel::insertRow("om_order_notes", $set);
                 if (!$msg) {
                     self::$errCode = "005";
                     self::$errMsg = "插入订单备注失败!";
                     BaseModel::rollback();
                     return false;
                 }
             }
         }
         self::$errCode = "200";
         self::$errMsg = "整个订单信息更新成功!";
         BaseModel::commit();
         BaseModel::autoCommit();
     }
 }
コード例 #3
0
 /**
  *功能:提供给仓库系统的接口,审核领料单
  * */
 public function act_auditIoStoreInWh()
 {
     $ordersn = isset($_GET['ordersn']) ? $_GET['ordersn'] : "";
     $isAudit = isset($_GET['isAudit']) ? $_GET['isAudit'] : 0;
     $auditorId = isset($_GET['auditorId']) ? $_GET['auditorId'] : 0;
     $now = time();
     if (intval($auditorId) <= 0) {
         self::$errCode = 101;
         self::$errMsg = "审核人有误";
         return false;
     }
     if (empty($ordersn)) {
         self::$errCode = 102;
         self::$errMsg = "单号不能为空!";
         return false;
     }
     if ($isAudit != 2 && $isAudit != 3) {
         //isAudit=2为审核通过,3为审核不通过
         self::$errCode = 102;
         self::$errMsg = "审核状态值有误,只能为通过或不通过";
         return false;
     }
     $tName = 'pc_products_iostore';
     $select = '*';
     $where = "WHERE is_delete=0 and isAudit=1 and ordersn='{$ordersn}'";
     $ioStoreList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($ioStoreList)) {
         self::$errCode = 103;
         self::$errMsg = "该单据号不存在或者已经审核过";
         return false;
     }
     try {
         BaseModel::begin();
         //$tName = 'pc_products_iostore';
         $dataIostore = array();
         $dataIostore['isAudit'] = $isAudit;
         $dataIostore['auditorId'] = $userId;
         $dataIostore['auditTime'] = $now;
         OmAvailableModel::updateTNameRow2arr($tName, $dataIostore, $where);
         //将表头改为审核状态
         $tName = 'pc_products_iostore_detail';
         $dataIostoreDetail = array();
         $dataIostoreDetail['isAudit'] = $isAudit;
         $where = "WHERE is_delete=0 AND iostoreId='{$ioStoreList[0]['id']}'";
         OmAvailableModel::updateTNameRow2arr($tName, $dataIostoreDetail, $where);
         //将表体的料号(is_delete=0)改为审核状态
         //if($ioStoreList[0]['iostoreTypeId'] == 1 && $ioStoreList[0]['useTypeId'] == 1){//如果该单是制作领料单(新品下单的),则要将该单据下的料号加到新品列表去
         //                $select = 'sku';
         //                $skuList = OmAvailableModel::getTNameList($tName, $select, $where);
         //                foreach($skuList as $value){
         //                    $sku = $value['sku'];
         //                    $tName = 'pc_products';
         //                    $dataProducts = array();
         //                    $dataProducts['sku'] = $sku;
         //                    OmAvailableModel::addTNameRow2arr($tName, $dataProducts);//将detail中的sku加入到产品制作表中
         //                }
         //            }
         if ($ioStoreList[0]['iostoreTypeId'] == 2 && $ioStoreList[0]['useTypeId'] == 1) {
             //如果该单是制作退料单,则要将该单中的料号状态改变为已经归还
             $select = 'sku';
             $skuList = OmAvailableModel::getTNameList($tName, $select, $where);
             foreach ($skuList as $value) {
                 $sku = $value['sku'];
                 $tName = 'pc_products';
                 $dataProducts = array();
                 $dataProducts['productsReturnerId'] = $ioStoreList[0]['addUserId'];
                 //归还人即该单据的添加人
                 $dataProducts['productsReturnTime'] = $now;
                 //归还人即该单据的添加人
                 $where = "WHERE sku='{$sku}'";
                 OmAvailableModel::updateTNameRow2arr($tName, $dataProducts, $where);
                 //将detail中的sku加入到产品制作表中
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
     }
 }
コード例 #4
0
 function act_updateSkuConversion()
 {
     $id = $_GET['id'] ? post_check(trim($_GET['id'])) : 0;
     $id = intval($id);
     $new_sku = $_GET['new_sku'] ? post_check(trim($_GET['new_sku'])) : '';
     //new_sku
     $modifiedUserId = intval($_SESSION['userId']);
     $modifiedTime = time();
     if ($modifiedUserId <= 0) {
         self::$errCode = '103';
         self::$errMsg = "登陆超时,请重试";
         return;
     }
     if ($id <= 0) {
         self::$errCode = '100';
         self::$errMsg = "异常";
         return;
     }
     if (empty($new_sku)) {
         self::$errCode = '101';
         self::$errMsg = "新料号不能为空";
         return;
     }
     if (!preg_match("/^[A-Z0-9]+(_[A-Z0-9]+)*\$/", $new_sku)) {
         self::$errCode = '100';
         self::$errMsg = "新料号 {$new_sku} 格式不合法";
         return;
     }
     if ($modifiedUserId <= 0) {
         self::$errCode = '103';
         self::$errMsg = "登陆超时,请重试";
         return;
     }
     $tName = 'pc_sku_conversion';
     $select = 'new_sku';
     $where = "WHERE id={$id} and is_delete=0";
     $skuConNewSkuList = OmAvailableModel::getTNameList($tName, $select, $where);
     //在料号转换表中找到id所在记录的新料号new_sku
     $skuConNewSku = $skuConNewSkuList[0]['new_sku'];
     if (empty($skuConNewSku)) {
         self::$errCode = '104';
         self::$errMsg = "记录的新料号不存在";
         return;
     }
     if ($skuConNewSku == $new_sku) {
         self::$errCode = '111';
         self::$errMsg = "修改前后料号相同,无修改";
         return;
     }
     $tName = 'pc_goods';
     $select = '*';
     $where = "WHERE is_delete=0 AND sku='{$skuConNewSku}'";
     $newSkuPcList = OmAvailableModel::getTNameList($tName, $select, $where);
     //在产品表里找是否存在未修改前的料号
     $newSkuPc = $newSkuPcList[0];
     //未修改前的料号信息
     if (empty($newSkuPc)) {
         self::$errCode = '105';
         self::$errMsg = "修改前的料号 {$skuConNewSku} 在产品列表中不存在";
         return;
     }
     $newSkuPcSku = $newSkuPc['sku'];
     //$newSkuPcArr = array_filter(explode('_',$newSkuPc));//修改前的sku按照_来截取
     //        $newSpuPc = $newSkuPcArr[0];//取得新料号的SPU
     //        $newSkuArr = array_filter(explode('_',$new_sku));//修改后的sku按照_来截取
     //        $newSpu = $newSkuArr[0];//取得新料号的SPU
     //        if($newSpuPc != $newSpu){
     //            self::$errCode = '107';
     //            self::$errMsg = "修改前后的SPU不符,请检查";
     //            return;
     //        }
     try {
         BaseModel::begin();
         $tName = 'pc_sku_conversion';
         $set = "SET new_sku='{$new_sku}',modifiedUserId='{$modifiedUserId}',modifiedTime='{$modifiedTime}'";
         $where = "WHERE id={$id} and is_delete=0";
         OmAvailableModel::updateTNameRow($tName, $set, $where);
         //先将转换记录修改
         $tName = 'pc_goods';
         $set = "SET goodsStatus=101,is_delete=1";
         //将未修改前的sku状态改为 料号转化,并delete
         $where = "WHERE is_delete=0 and sku='{$newSkuPcSku}'";
         OmAvailableModel::updateTNameRow($tName, $set, $where);
         $where = "WHERE is_delete=0 and sku='{$new_sku}'";
         $newSkuCount = OmAvailableModel::getTNameCount($tName, $where);
         if ($newSkuCount) {
             //如果新料号在产品中已经存在,则只添加转换记录
             self::$errCode = '200';
             self::$errMsg = "修改转换记录成功,新料号:{$new_sku} 已经存在记录";
         } else {
             //如果新料号在产品表中不存在,则自动添加旧料号的记录进去
             unset($newSkuPc['id']);
             //去掉旧记录的id
             $newSkuPc['sku'] = $new_sku;
             //将旧的sku换成新的sku
             OmAvailableModel::addTNameRow2arr($tName, $newSkuPc);
             self::$errCode = '200';
             self::$errMsg = "修改转换记录成功,新料号:{$new_sku} 记录已插入成功";
         }
         //下面对关联单料号的组合料号进行修改
         $tName = 'pc_sku_combine_relation';
         $select = '*';
         $where = "WHERE sku='{$newSkuPcSku}' group by combineSku";
         $skuRelationList = OmAvailableModel::getTNameList($tName, $select, $where);
         if (empty($skuRelationList)) {
             self::$errMsg .= "<br/>其中,无关联组合料号被更新";
         } else {
             $combineSkuArr = array();
             foreach ($skuRelationList as $value) {
                 $combineSkuArr[] = $value['combineSku'];
             }
             $combineSkuStr = implode(',', $combineSkuArr);
             $set = "SET sku='{$new_sku}'";
             $where = "WHERE sku='{$newSkuPcSku}'";
             $affectRows = OmAvailableModel::updateTNameRow($tName, $set, $where);
             self::$errMsg .= "<br/>";
             self::$errMsg .= "其中,组合料号 {$combineSkuStr} 中共有 {$affectRows} 条单料号数据已更新";
         }
         //////
         BaseModel::commit();
         BaseModel::autoCommit();
         return;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         self::$errCode = '404';
         self::$errMsg = $e->getMessage();
         return;
     }
 }
コード例 #5
0
ファイル: expressRemark.model.php プロジェクト: ohjack/newErp
 public static function addExpressRemark($omOrderId, $data)
 {
     !self::$dbConn ? self::initDB() : null;
     BaseModel::begin();
     //开始事务
     if (!self::deleteExpressRemark($omOrderId)) {
         BaseModel::rollback();
         self::$errCode = "001";
         self::$errMsg = " 删除数据失败! ";
         return false;
         //失败则设置错误码和错误信息, 返回false
     }
     if (!empty($data)) {
         //var_dump($data);
         foreach ($data as $datavalue) {
             $string = array2sql_extral($datavalue);
             //$string = "('".$datavalue['omOrderId']."','". $datavalue['price']."','". $datavalue['amount']."','". $datavalue['hamcodes']."','". $datavalue['isBrand']."','". $datavalue['description']."','". $datavalue['creatorId']."','". $datavalue['createdTime'] ."'),";
             $sql = "INSERT INTO " . self::$Table . " SET {$string} ";
             //echo $sql;
             if (!self::$dbConn->query($sql)) {
                 BaseModel::rollback();
                 self::$errCode = "002";
                 self::$errMsg = " 插入数据失败! ";
                 return false;
                 //失败则设置错误码和错误信息, 返回false
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         self::$errCode = "200";
         self::$errMsg = " 插入数据成功! ";
         return true;
         //失败则设置错误码和错误信息, 返回false
     }
 }
コード例 #6
0
ファイル: products.view.php プロジェクト: ohjack/newErp
 public function view_productsCombineSpuComplete()
 {
     $combineSpu = $_GET['combineSpu'] ? $_GET['combineSpu'] : '';
     $id = $_GET['id'] ? $_GET['id'] : '';
     $userId = $_SESSION['userId'];
     $now = time();
     if (intval($userId) <= 0) {
         $status = "未登录";
         header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}");
         exit;
     }
     if (empty($id)) {
         $status = "id为空";
         header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}");
         exit;
     }
     $idArr = array_filter(explode(',', $id));
     foreach ($idArr as $value) {
         if (intval($value) <= 0) {
             $status = "含有非法id";
             header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}");
             exit;
         }
     }
     $newIdArr = implode(',', $idArr);
     try {
         BaseModel::begin();
         $tName = 'pc_spu_web_maker';
         $set = "SET isComplete=1,completeTime='{$now}'";
         $where = "WHERE id in({$newIdArr})";
         OmAvailableModel::updateTNameRow($tName, $set, $where);
         BaseModel::commit();
         BaseModel::autoCommit();
         $status = "制作完成成功";
         header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}");
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = $e->getMessage();
         header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}");
     }
 }
コード例 #7
0
ファイル: property.view.php プロジェクト: ohjack/newErp
 public function view_updatePropertyOn()
 {
     $id = $_GET['id'];
     $propertyName = $_GET['propertyName'] ? post_check(trim($_GET['propertyName'])) : '';
     $pid = $_GET['pid'] ? post_check(trim($_GET['pid'])) : '';
     $isRadio = $_GET['isRadio'] ? post_check(trim($_GET['isRadio'])) : '';
     $isRequired = $_GET['isRequired'] ? post_check(trim($_GET['isRequired'])) : '';
     if (intval($id) == 0) {
         $status = "属性Id错误";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     if (empty($propertyName)) {
         if (intval($id) == 0) {
             $status = "属性Id错误";
             header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
             exit;
         }
         $tName = 'pc_archive_spu_property_value_relation';
         $where = "WHERE propertyId={$id}";
         $countPP = OmAvailableModel::getTNameCount($tName, $where);
         if ($countPP) {
             $status = "该属性已经绑定了SPU,不能删除";
             header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
             exit;
         }
         $tName = 'pc_archive_property_value';
         $select = 'id';
         $where = "WHERE propertyId={$id}";
         $ppvList = OmAvailableModel::getTNameList($tName, $select, $where);
         //该属性下所有的属性值
         foreach ($ppvList as $value) {
             $propertyValueId = $value['id'];
             if (intval($propertyValueId) != 0) {
                 $tName = 'pc_archive_spu_property_value_relation';
                 $where = "WHERE propertyId={$id} and propertyValueId={$propertyValueId}";
                 $countPPV = OmAvailableModel::getTNameCount($tName, $where);
                 if ($countPPV) {
                     $status = "该属性下已有属性值绑定了SPU,不能删除";
                     header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
                     exit;
                 }
             }
         }
         try {
             BaseModel::begin();
             foreach ($ppvList as $value) {
                 $propertyValueId = $value['id'];
                 if (intval($propertyValueId) != 0) {
                     $tName = 'pc_archive_property_value';
                     $where = "WHERE id={$propertyValueId}";
                     OmAvailableModel::deleteTNameRow($tName, $where);
                 }
             }
             $tName = 'pc_archive_property';
             $where = "WHERE id={$id}";
             OmAvailableModel::deleteTNameRow($tName, $where);
             BaseModel::commit();
             BaseModel::autoCommit();
             $status = "属性删除成功";
             header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
             exit;
         } catch (Exception $e) {
             BaseModel::rollback();
             BaseModel::autoCommit();
             $status = $e->getMessage();
             header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
             exit;
         }
     }
     if (empty($pid)) {
         $status = "类型不能为空";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     if (empty($isRadio)) {
         $status = "录入方式不能为空";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     if (intval($isRequired) == 0) {
         $status = "是否必填不能为空";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     $tName = 'pc_archive_property';
     $select = '*';
     $where = "WHERE id='{$id}'";
     $propertyList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($propertyList)) {
         $status = "不存在该属性记录";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     $categoryName = getAllCateNameByPath($pid);
     $pathImplodeStr = getAllPathBypid($pid);
     $i = strrpos($pathImplodeStr, ',');
     if ($i !== false) {
         $pathImplodeStr = substr($pathImplodeStr, 0, $i);
     }
     $where = "WHERE propertyName='{$propertyName}' and categoryPath IN ({$pathImplodeStr})";
     $count = OmAvailableModel::getTNameCount($tName, $where);
     if ($count) {
         $status = "{$categoryName} 其父类已经存在 {$propertyName} 属性";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     $where = "WHERE propertyName='{$propertyName}' and categoryPath='{$pid}' and id<>{$id}";
     $count = OmAvailableModel::getTNameCount($tName, $where);
     if ($count) {
         $status = "{$categoryName} 已经存在 {$propertyName} 属性";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     $set = "SET propertyName='{$propertyName}',categoryPath='{$pid}',isRadio='{$isRadio}',isRequired='{$isRequired}'";
     $where = "WHERE id='{$id}'";
     $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where);
     if (!$affectRow) {
         $status = "无数据修改";
         header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
         exit;
     }
     $categoryName1 = CategoryModel::getCategoryNameByPath($propertyList[0]['categoryPath']);
     $categoryName2 = CategoryModel::getCategoryNameByPath($pid);
     $isRadioStr = $isRadio == 1 ? '单选' : '多选';
     $status = "{$categoryName1} 下 {$propertyList[0]['propertyName']} 修改为 {$categoryName2} 下 {$propertyName} 成功,录入方式为 {$isRadioStr}";
     header("Location:index.php?mod=property&act=getPropertyList&status={$status}");
 }
コード例 #8
0
ファイル: owOrder.action.php プロジェクト: ohjack/newErp
 /**
  * 生成海外备货单,根据下单人合并订单明细
  * Enter description here ...
  */
 public function createOwOrder()
 {
     global $dbConn;
     $skulist = $_POST['skulist'];
     $operator_id = $_SESSION[C('USER_AUTH_SYS_ID')];
     //操作人员ID
     $comid = $_SESSION[C('USER_COM_ID')];
     //公司ID
     $type = $_POST['type'];
     $rollback = false;
     $existSku = '';
     $ismark = 0;
     BaseModel::begin();
     //开始事务
     foreach ($skulist as $key => $sku) {
         $price = PurchaseOrderModel::getPriceBySku($sku['sku']);
         //SKU单价
         $purid = OwOrderModel::getPurchaseidBySku($sku['sku']);
         $parid = OwOrderModel::getPartnerId($sku['sku']);
         //供应商ID
         $parid = $parid['partnerId'];
         $storeid = 1;
         //仓库ID
         $orderData = OwOrderModel::getOwOrderNum($operator_id);
         //判断同操作员跟踪号是否已存在(未审核状态下)
         $orderSN = $orderData['recordnumber'];
         $main = array();
         $detail = array();
         if (!empty($orderSN)) {
             //存在符合条件的跟踪号,直接插入采购订单明细
             /*
             				$orderHasSku                        = OwOrderModel::orderExistSku($sku['sku']);
             				if($orderHasSku){
             					$existSku .= '['.$sku['sku'].'],';
             					continue;
             				}*/
             $detail['sku'] = $sku['sku'];
             $detail['price'] = $price;
             //单价
             $detail['count'] = $sku['rec'];
             //采购数量
             $detail['goods_recommend_count'] = $sku['rec'];
             //采购数量
             $detail['recordnumber'] = $orderData['recordnumber'];
             $poid = $orderData['id'];
             //根据跟踪号取采购主订单编号
             $detail['parid'] = $parid;
             //料号供应商ID
             $detail['po_id'] = $poid;
             $dataSet = array2sql($detail);
             $sql = "insert into ph_ow_order_detail set {$dataSet}  ";
             $rtndetail = $dbConn->execute($sql);
             if ($rtndetail === false) {
                 $rollback = true;
             } else {
                 $ismark = 1;
             }
         } else {
             //不存在符合条件的跟踪号重新生成
             $recordnumber = PurchaseOrderModel::autoCreateOrderSn($purid, $comid);
             //生成对应公司的采购订单跟踪号
             if (!empty($recordnumber)) {
                 //生成采购订单号成功
                 $main['recordnumber'] = $recordnumber;
                 //跟踪号
                 $main['purchaseuser_id'] = $purid;
                 //采购员ID
                 $main['operator_id'] = $operator_id;
                 //操作人员id
                 $main['warehouse_id'] = $storeid;
                 //仓库ID
                 $main['company_id'] = $comid;
                 //公司编号
                 $main['partner_id'] = $parid;
                 //供应商ID
                 $main['addtime'] = time();
                 if ($type == "oversea") {
                     $main['order_type'] = 5;
                     // 给海外仓备货的订单
                 } else {
                     $main['order_type'] = 1;
                     // 正常订单
                 }
                 $dataSet = array2sql($main);
                 $sql = "insert into ph_ow_order set {$dataSet}  ";
                 $rtnmain = $dbConn->execute($sql);
                 if ($rtnmain) {
                     //主订单添加成功
                     /*
                     						$orderHasSku                        = OwOrderModel::orderExistSku($sku['sku']);
                     						if($orderHasSku){
                     							$existSku .= '['.$sku['sku'].'],';
                     							continue;
                     						}*/
                     $detail['sku'] = $sku['sku'];
                     $detail['price'] = $price;
                     //单价
                     $detail['count'] = $sku['rec'];
                     //采购数量
                     $detail['goods_recommend_count'] = $sku['rec'];
                     //采购数量
                     $detail['parid'] = $parid;
                     //料号供应商ID
                     $detail['recordnumber'] = $recordnumber;
                     $poid = OwOrderModel::getOwPoid($recordnumber);
                     //根据跟踪号取采购主订单编号
                     $detail['po_id'] = $poid;
                     $dataSet = array2sql($detail);
                     $sql = "insert into ph_ow_order_detail set {$dataSet}  ";
                     $rtndetail = $dbConn->execute($sql);
                     if ($rtndetail === false) {
                         $rollback = true;
                     } else {
                         $ismark = 1;
                     }
                 } else {
                     $rollback = true;
                 }
             } else {
                 $rollback = true;
             }
         }
     }
     //$existSku = substr($existSku, 0, strlen($existSku) - 1);
     if ($rollback == false) {
         //if($ismark == 1){
         BaseModel::commit();
         BaseModel::autoCommit();
         $result['msg'] = 'yes';
         //}else{
         //	$result['msg'] = 'warn';
         //}
         //$result['tip'] = $existSku;
     } else {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $result['msg'] = 'no';
     }
     return json_encode($result);
 }
コード例 #9
0
ファイル: autoCreateSpu.view.php プロジェクト: ohjack/newErp
 public function view_updateSpuPersonOn()
 {
     $spu = $_POST['spu'] ? post_check(trim($_POST['spu'])) : '';
     $isSingSpu = $_POST['isSingSpu'] ? post_check(trim($_POST['isSingSpu'])) : 0;
     $ebaySalerId = $_POST['ebaySalerId'] ? post_check(trim($_POST['ebaySalerId'])) : 0;
     $aliexpressSalerId = $_POST['aliexpressSalerId'] ? post_check(trim($_POST['aliexpressSalerId'])) : 0;
     $amazonSalerId = $_POST['amazonSalerId'] ? post_check(trim($_POST['amazonSalerId'])) : 0;
     $overseaSalerId = $_POST['overseaSalerId'] ? post_check(trim($_POST['overseaSalerId'])) : 0;
     $webMakerId = $_POST['webMakerId'] ? post_check(trim($_POST['webMakerId'])) : 0;
     if ($isSingSpu != 1 && $isSingSpu != 2) {
         $status = "基础数据 单/虚拟料号出错!";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     if (intval($_SESSION['userId']) <= 0) {
         $status = "登陆超时,请重新登陆";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     if (intval($ebaySalerId) <= 0 && intval($aliexpressSalerId) <= 0 && intval($amazonSalerId) <= 0 && !isAccessAll('autoCreateSpu', 'isCanUpdateWebMakerPower')) {
         $status = "ebay/aliexpress/amazon 平台中至少要存在一个销售人员记录才能提交";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     try {
         BaseModel::begin();
         $status = '';
         if ($isSingSpu == 1) {
             $tName = 'pc_spu_saler_single';
         } else {
             $tName = 'pc_spu_saler_combine';
         }
         $select = 'isAgree,salerId';
         if (!empty($ebaySalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=1";
             //ebay平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $ebaySalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $ebaySalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $ebaySalerId;
                 $dataEbayArr['platformId'] = 1;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($aliexpressSalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=2";
             //ali平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $aliexpressSalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $aliexpressSalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $aliexpressSalerId;
                 $dataEbayArr['platformId'] = 2;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($amazonSalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=11";
             //amazon平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $amazonSalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $amazonSalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $amazonSalerId;
                 $dataEbayArr['platformId'] = 11;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($overseaSalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=14";
             //amazon平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $overseaSalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $overseaSalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $overseaSalerId;
                 $dataEbayArr['platformId'] = 14;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($webMakerId)) {
             $tName = 'pc_spu_web_maker';
             $select = 'webMakerId,isAgree,isTake';
             $where = "WHERE is_delete=0 AND spu='{$spu}' order by id desc limit 1";
             $spuWebMakerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (empty($spuWebMakerList)) {
                 //不存在该SPU的指派记录
                 $dataWebMakerArr = array();
                 $dataWebMakerArr['spu'] = $spu;
                 $dataWebMakerArr['isSingSpu'] = $isSingSpu;
                 $dataWebMakerArr['webMakerId'] = $webMakerId;
                 $dataWebMakerArr['isAgree'] = 1;
                 //add by 20140513,待定状态
                 $dataWebMakerArr['addTime'] = time();
                 OmAvailableModel::addTNameRow2arr($tName, $dataWebMakerArr);
             } else {
                 //存在指派记录时
                 if ($spuWebMakerList[0]['webMakerId'] != $webMakerId) {
                     //提交的人和之前的不一致则修改/添加,否则不变
                     if ($spuWebMakerList[0]['isTake'] == 1) {
                         //如果是已经被工程师领取,则表示接手
                         $dataWebMakerArr = array();
                         $dataWebMakerArr['spu'] = $spu;
                         $dataWebMakerArr['isSingSpu'] = $isSingSpu;
                         $dataWebMakerArr['webMakerId'] = $webMakerId;
                         $dataWebMakerArr['addTime'] = time();
                         $dataWebMakerArr['isAgree'] = $spuWebMakerList[0]['isAgree'];
                         //add by 20140513,同意/拒绝状态不变
                         $dataWebMakerArr['isHandsOn'] = 1;
                         OmAvailableModel::addTNameRow2arr($tName, $dataWebMakerArr);
                     } else {
                         //如果未被领取,则只是修改记录
                         $dataWebMakerArr = array();
                         $dataWebMakerArr['webMakerId'] = $webMakerId;
                         $dataWebMakerArr['addTime'] = time();
                         $dataWebMakerArr['isAgree'] = 1;
                         //add by 20140513,未领取的话,重新变成待定状态
                         OmAvailableModel::updateTNameRow2arr($tName, $dataWebMakerArr, $where);
                     }
                 }
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         $status = "更新成功";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = $e->getMessage();
         echo '<script language="javascript">
                 alert("' . '添加失败——' . $status . '");
               </script>';
         exit;
     }
 }
コード例 #10
0
 public function act_updateSpecialTMTCOn()
 {
     $id = $_POST['id'] ? trim($_POST['id']) : 0;
     $specialTransportManagerName = $_POST['specialTransportManagerName'] ? trim($_POST['specialTransportManagerName']) : '';
     $isOn = $_POST['isOn'] ? trim($_POST['isOn']) : '';
     //$canOrNot = $_POST['canOrNot'] ? (trim($_POST['canOrNot'])) : '';
     $transportIdArr = !empty($_POST['transportId']) ? $_POST['transportId'] : array();
     //选中的transportId数组
     //print_r($transportIdArr);exit;
     $tName = 'pc_special_transport_manager';
     $where = "WHERE id='{$id}'";
     $pspIsExist = OmAvailableModel::getTNameCount($tName, $where);
     if (!$pspIsExist) {
         $status = "记录不存在,错误";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     if (empty($specialTransportManagerName)) {
         $status = "特殊运输方式名称为空";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     if (intval($isOn) <= 0) {
         $status = "是否启用有误";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     if (empty($transportIdArr)) {
         $status = "所选的运输方式为空,错误";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     $tName = 'pc_special_transport_manager';
     $where = "WHERE specialTransportManagerName='{$specialTransportManagerName}' AND id<>'{$id}'";
     $properNameIsExist = OmAvailableModel::getTNameCount($tName, $where);
     if ($properNameIsExist) {
         $status = "该特殊运输方式名称已经存在,请检查";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     try {
         BaseModel::begin();
         $tName = 'pc_special_transport_manager';
         $dataTmpArr = array();
         $dataTmpArr['specialTransportManagerName'] = $specialTransportManagerName;
         $dataTmpArr['isOn'] = $isOn;
         $where = "WHERE id='{$id}'";
         OmAvailableModel::updateTNameRow2arr($tName, $dataTmpArr, $where);
         $tName = 'pc_special_stmnid_transportid';
         $select = '*';
         $where = "WHERE stmnId='{$id}'";
         $psptList = OmAvailableModel::getTNameList($tName, $select, $where);
         $psptIdArr = array();
         foreach ($psptList as $value) {
             $psptIdArr[] = $value['id'];
         }
         $psptIdStr = !empty($psptIdArr) ? implode(',', $psptIdArr) : 0;
         $tName = 'pc_special_stid_channel';
         $where = "WHERE stId in({$psptIdStr})";
         OmAvailableModel::deleteTNameRow($tName, $where);
         //删除渠道关系表的相关数据
         $tName = 'pc_special_stmnid_transportid';
         $where = "WHERE stmnId='{$id}'";
         OmAvailableModel::deleteTNameRow($tName, $where);
         //删除运输方式关系表的相关数据
         foreach ($transportIdArr as $transportId) {
             if (intval($transportId) > 0) {
                 $channelIdArr = !empty($_POST['tc' . $transportId]) ? $_POST['tc' . $transportId] : array();
                 //该transpordeId下的channel数组
                 $tName = 'pc_special_stmnid_transportid';
                 $dataTmpArr = array();
                 $dataTmpArr['stmnId'] = $id;
                 $dataTmpArr['transportId'] = $transportId;
                 $insertPTId = OmAvailableModel::addTNameRow2arr($tName, $dataTmpArr);
                 if (intval($insertPTId) <= 0) {
                     throw new Exception('insertPTId 错误');
                 }
                 foreach ($channelIdArr as $channelId) {
                     if (intval($channelId) > 0) {
                         $tName = 'pc_special_stid_channel';
                         $dataTmpArr = array();
                         $dataTmpArr['stId'] = $insertPTId;
                         $dataTmpArr['channelId'] = $channelId;
                         OmAvailableModel::addTNameRow2arr($tName, $dataTmpArr);
                     }
                 }
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         $status = "修改成功";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = '失败,原因为:' . $e->getMessage();
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
 }
コード例 #11
0
ファイル: orderindex.model.php プロジェクト: ohjack/newErp
 public static function shiftOrderList($where)
 {
     BaseModel::begin();
     //开始事务
     $unshipped_tableName = 'om_unshipped_order';
     $shipped_tableName = 'om_shipped_order';
     $orderList = self::showOrderList($unshipped_tableName, $where);
     //echo "<pre>"; print_r($orderList); exit;
     if (empty($orderList)) {
         self::$errCode = '000';
         self::$errMsg = "无操作数据!";
         return false;
     }
     foreach ($orderList as $omOrderId => $orderData) {
         $obj_order_data = $orderData['orderData'];
         $orderDetail = $orderData['orderDetail'];
         $insert_orderDetail = array();
         foreach ($orderDetail as $detail) {
             $insert_orderDetailData = $detail['orderDetailData'];
             //unset ($insert_orderDetailData['id']);
             $insert_orderDetailExtenData = $detail['orderDetailExtenData'];
             //unset ($insert_orderDetailExtenData['omOrderdetailId']);
             $insert_orderDetail[] = array('orderDetailData' => $insert_orderDetailData, 'orderDetailExtenData' => $insert_orderDetailExtenData);
         }
         //BaseModel :: rollback();\
         //self :: $dbConn->query('SET AUTOCOMMIT=1');
         //return FALSE;
         //unset ($obj_order_data['id']);
         $orderExtenData = $orderData['orderExtenData'];
         //unset ($orderExtenData['omOrderId']);
         $orderUserInfoData = $orderData['orderUserInfoData'];
         //unset ($orderExtenData['omOrderId']);
         $orderWhInfoData = $orderData['orderWhInfoData'];
         //unset ($orderWhInfoData['omOrderId']);
         //$obj_order_data['orderStatus'] = C('STATEBUJI');
         //$obj_order_data['orderType'] = C('STATEBUJI_DONE');
         $insert_orderData = array();
         $insert_orderData = array('orderData' => $obj_order_data, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData, 'orderDetail' => $insert_orderDetail, 'orderWhInfoData' => $orderWhInfoData);
         //var_dump($insert_orderData); exit;
         if ($insertId = OrderAddModel::shiftAllOrderRowNoEvent($insert_orderData)) {
             //echo $split_log .= 'insert success!' . "\n"; exit;
             //var_dump($_mainId,$_spitId); exit;
             if (!OrderLogModel::insertOrderLog($insertId, '从unshipped表转移数据到shipped表中,第一步:添加shipped表数据')) {
                 BaseModel::rollback();
                 self::$errCode = '001';
                 self::$errMsg = "转移数据添加日志失败,第一步:添加shipped表数据失败!";
                 return false;
             }
         } else {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "INSERT数据失败!";
             return false;
         }
         if (self::killAllOrderRowNoEvent($omOrderId, $obj_order_data['platformId'])) {
             //echo $split_log .= 'insert success!' . "\n"; exit;
             //var_dump($_mainId,$_spitId); exit;
             if (!OrderLogModel::insertOrderLog($omOrderId, '从unshipped表转移数据到shipped表中,第二步:删除unshipped表中数据')) {
                 BaseModel::rollback();
                 self::$errCode = '003';
                 self::$errMsg = "转移数据添加日志失败,第二步:删除unshipped表中数据失败!";
                 return false;
             }
         } else {
             BaseModel::rollback();
             self::$errCode = '004';
             self::$errMsg = "KILL数据失败!";
             return false;
         }
     }
     BaseModel::commit();
     BaseModel::autoCommit();
     self::$errCode = '200';
     self::$errMsg = "转移数据成功!";
     return TRUE;
 }
コード例 #12
0
ファイル: orderAdd.model.php プロジェクト: ohjack/newErp
 /**
  * 插入订单对应下的总表信息
  * @para $data as array
  * @add by Herman.Xi
  * @last modified 20131022
  * $in 默认为进入订单模式
  */
 public static function insertAllOrderRow($orderData, $extension = 'ebay', $in = true)
 {
     self::initDB();
     //var_dump($orderData); exit;
     $obj_order_data = $orderData['orderData'];
     $orderExtenData = $orderData['orderExtenData'];
     $orderUserInfoData = $orderData['orderUserInfoData'];
     $orderDetailArr = $orderData['orderDetail'];
     if ($obj_order_data['platformId'] == "2") {
         //ebay
         $ebay_orderid = $orderExtenData['orderId'];
         $tName = 'om_unshipped_order_extension_ebay';
         $where = "WHERE orderId='{$ebay_orderid}'";
         $flagCountUnshipped = OmAvailableModel::getTNameCount($tName, $where);
         $tName = 'om_shipped_order_extension_ebay';
         $flagCountshipped = OmAvailableModel::getTNameCount($tName, $where);
     } else {
         $tName = 'om_unshipped_order';
         $where = "WHERE accountId='{$obj_order_data['accountId']}' AND recordNumber='{$obj_order_data['recordNumber']}' AND platformId={$obj_order_data['platformId']} and is_delete ='0'";
         $flagCountUnshipped = OmAvailableModel::getTNameCount($tName, $where);
         $tName = 'om_shipped_order';
         $flagCountshipped = OmAvailableModel::getTNameCount($tName, $where);
     }
     //if (empty ($flagCountUnshipped) && empty ($flagCountshipped)) { //判断订单是否已经在系统2个订单表(未发货和已发货)中存在
     if (empty($flagCountUnshipped) && empty($flagCountshipped)) {
         $platfrom = omAccountModel::getPlatformSuffixById($obj_order_data['platformId']);
         $extension = $platfrom['suffix'];
         //获取后缀名称
         BaseModel::begin();
         //开始事务
         $insertOrderDataRow = self::insertOrderRow($obj_order_data);
         //插入到order表
         if (empty($insertOrderDataRow)) {
             BaseModel::rollback();
             //throw new Exception('insert orderData error');
         }
         $orderExtenData['omOrderId'] = $insertOrderDataRow;
         $orderUserInfoData['omOrderId'] = $insertOrderDataRow;
         $resultExten = self::insertExtension($orderExtenData, $extension);
         //插入到order_extend表
         if (!$resultExten) {
             BaseModel::rollback();
             //throw new Exception('insert orderExtenData error');
         }
         $resultUserInfo = self::insertUserinfoRow($orderUserInfoData);
         //插入到order_userInfo表
         if (!$resultUserInfo) {
             BaseModel::rollback();
             //throw new Exception('insert orderUserInfoData error');
         }
         foreach ($orderDetailArr as $orderDetail) {
             $orderDetailData = $orderDetail['orderDetailData'];
             $orderDetailExtenData = $orderDetail['orderDetailExtenData'];
             $orderDetailData['omOrderId'] = $insertOrderDataRow;
             $orderDetailData['createdTime'] = time();
             $insertOrderDatilRow = self::insertOrderdetail($orderDetailData);
             //插入到detail表
             if (empty($insertOrderDatilRow)) {
                 BaseModel::rollback();
                 //throw new Exception('insert orderDetailData error');
             }
             $orderDetailExtenData['omOrderdetailId'] = $insertOrderDatilRow;
             if ($orderDetailExtenData) {
                 $resultOrderDetailExten = self::insertDetailExtension($orderDetailExtenData, $extension);
                 //插入到detailExtend
                 if (!$resultOrderDetailExten) {
                     BaseModel::rollback();
                     //throw new Exception('insert orderDetailExtenData error');
                 }
             }
         }
         if ($obj_order_data['platformId'] == 1) {
             $insertOrderidsDada = array('omOrderId' => $insertOrderDataRow, 'PayPalPaymentId' => $orderData['orderExtenData']['PayPalPaymentId'], 'orderid' => $orderData['orderExtenData']['orderId'], 'accountId' => $orderData['orderData']['accountId'], 'saletime' => time());
             $insertOrderids = OrderidsModel::insertOrderidsList($insertOrderidsDada);
             if (!$insertOrderids) {
                 BaseModel::rollback();
                 //throw new Exception('insert orderIds error');
             }
         }
         if (isset($orderData['orderNote']) && !empty($orderData['orderNote'])) {
             $orderNote = $orderData['orderNote'];
             $insertOrderNoteDada = array('omOrderId' => $insertOrderDataRow, 'content' => $orderNote['content'], 'userId' => $orderNote['userId'], 'createdTime' => $orderNote['createdTime']);
             $insertOrderNoteids = OrderAddModel::insertOrderNotesRow($insertOrderNoteDada);
             if (!$insertOrderNoteids) {
                 BaseModel::rollback();
                 //throw new Exception('insert orderNote error');
             }
         }
         $buyerInfo = $orderUserInfoData;
         $buyerInfo['platformId'] = $obj_order_data['platformId'];
         unset($buyerInfo['omOrderId']);
         unset($buyerInfo['countrySn']);
         unset($buyerInfo['currency']);
         unset($buyerInfo['currency']);
         $insertBuyerInfo = self::insertBuyerInfoRow($buyerInfo);
         if (!$insertBuyerInfo) {
             BaseModel::rollback();
             //throw new Exception('insert BuyerInfo error');
         }
         $ProductStatus = new ProductStatus();
         if (!$ProductStatus->updateSkuStatusByOrderStatus(array($insertOrderDataRow))) {
             BaseModel::rollback();
             //throw new Exception('update puchaseinfo error');
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         return $insertOrderDataRow;
     } else {
         self::$errCode = "400";
         self::$errMsg = "已经包含订单信息,不能重复插入!";
         return false;
     }
 }
コード例 #13
0
 public function act_operateAbOrderAPI()
 {
     if (!isset($_POST['omData'])) {
         self::$errCode = 500;
         self::$errMsg = '未成功接收数据!';
         return false;
     }
     $ostatus = 770;
     $otype = 0;
     $storeId = 1;
     $orderstr = $_POST['omData'];
     $orderstr2 = $_POST['omData2'];
     $orderids = array_unique(explode(',', $orderstr));
     $invoiceids = array_unique(explode(',', $orderstr2));
     if (!$orderids) {
         self::$errCode = 400;
         self::$errMsg = '未获取订单编号信息!';
         return false;
     }
     //var_dump($orderids); exit;
     $OrderindexAct = new OrderindexAct();
     $WarehouseAPIAct = new WarehouseAPIAct();
     foreach ($orderids as $k => $orderId) {
         BaseModel::begin();
         //开始事务
         $insertOrderData = array();
         $AbOrderInfo = $WarehouseAPIAct->act_getAbOrderInfo($invoiceids[$k]);
         //var_dump($AbOrderInfo); echo "<br>";
         //exit;
         $where = ' WHERE id = ' . $orderId . ' and is_delete = 0 AND storeId = ' . $storeId . ' LIMIT 1';
         $orderList = $OrderindexAct->act_showOrderList($ostatus, $otype, $where);
         //var_dump($orderList);exit;
         $order = $orderList[$orderId];
         $orderData = $order['orderData'];
         $insert_orderData = $orderData;
         unset($insert_orderData['id']);
         $insert_orderData['orderStatus'] = C('STATEOUTOFSTOCK');
         $insert_orderData['orderType'] = C('STATEOUTOFSTOCK_ABNORMAL');
         $orderExtenData = $order['orderExtenData'];
         $insert_orderExtenData = $orderExtenData;
         unset($insert_orderExtenData['omOrderId']);
         $orderUserInfoData = $order['orderUserInfoData'];
         $insert_orderUserInfoData = $orderUserInfoData;
         unset($insert_orderUserInfoData['omOrderId']);
         //$orderTracknumber = $order['orderTracknumber'];
         //$orderAudit = $order['orderAudit'];
         $orderDetail = $order['orderDetail'];
         $insertOrderData['orderData'] = $insert_orderData;
         $insertOrderData['orderExtenData'] = $insert_orderExtenData;
         $insertOrderData['orderUserInfoData'] = $insert_orderUserInfoData;
         $insert_orderDetail = array();
         $need_delete_ids = array();
         foreach ($orderDetail as $dkey => $detailValue) {
             $orderDetailData = $detailValue['orderDetailData'];
             $orderDetailExtenData = $detailValue['orderDetailExtenData'];
             if (!isset($AbOrderInfo[$orderDetailData['sku']]) || $AbOrderInfo[$orderDetailData['sku']] == 0) {
                 $insert_orderDetailData = $orderDetailData;
                 unset($insert_orderDetailData['id']);
                 unset($insert_orderDetailData['omOrderId']);
                 $insert_orderDetailExtenData = $orderDetailExtenData;
                 unset($insert_orderDetailExtenData['omOrderdetailId']);
                 $insert_orderDetail[$dkey]['orderDetailData'] = $insert_orderDetailData;
                 $insert_orderDetail[$dkey]['orderDetailExtenData'] = $insert_orderDetailExtenData;
                 $need_delete_ids[] = $orderDetailData['id'];
             }
         }
         $insertOrderData['orderDetail'] = $insert_orderDetail;
         $count_insert_orderDetail = count($insert_orderDetail);
         $count_orderDetail = count($orderDetail);
         $tableName = "om_unshipped_order";
         if ($count_insert_orderDetail > 0 && $count_insert_orderDetail < $count_orderDetail) {
             $calcWeight = CommonModel::calcNowOrderWeight($orderId);
             //重新计算原来订单的重量
             if (!OrderindexModel::deleteOrderDetail(array('is_delete' => 1), ' where id in(' . join(',', $need_delete_ids) . ')')) {
                 BaseModel::rollback();
                 self::$errCode = '005';
                 self::$errMsg = "删除原订单明细失败!";
                 return false;
             }
             $insertOrderData['orderData']['isCopy'] = 2;
             $insertOrderData['orderData']['actualTotal'] = 0.0;
             //var_dump($orderData);exit;
             $calcInfo = CommonModel::calcAddOrderWeight($insert_orderDetail);
             //计算重量和包材
             //var_dump($calcInfo); exit;
             $insertOrderData['orderData']['calcWeight'] = $calcInfo[0];
             $insertOrderData['orderData']['pmId'] = $calcInfo[1];
             if (count($insertOrderData['orderDetail']) > 1) {
                 $insertOrderData['orderData']['orderAttribute'] = 3;
             } else {
                 if (isset($insertOrderData['orderDetail'][0]['orderDetailData']['amount']) && $insertOrderData['orderDetail'][0]['orderDetailData']['amount'] > 1) {
                     $insertOrderData['orderData']['orderAttribute'] = 2;
                 }
             }
             $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, 1);
             //计算运费
             $insertOrderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
             $insertOrderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
             //print_r($insertOrderData); exit;
             if ($_spitId = OrderAddModel::insertAllOrderRowNoEvent($insertOrderData)) {
                 if (!OrderLogModel::insertOrderLog($_spitId, 'INSERT ORDER')) {
                     BaseModel::rollback();
                     self::$errCode = '001';
                     self::$errMsg = "插入订单日志失败!";
                     return false;
                 }
                 if (!OrderRecordModel::insertSpitRecords($orderId, $_spitId)) {
                     BaseModel::rollback();
                     self::$errCode = '002';
                     self::$errMsg = "插入拆分日志失败!";
                     return false;
                 }
             } else {
                 BaseModel::rollback();
                 self::$errCode = '010';
                 self::$errMsg = "插入订单信息失败!";
                 return false;
             }
             $returnStatus0 = array('isCopy' => 1, 'calcWeight' => $calcWeight);
             $rtn = $WarehouseAPIAct->act_operateAbOrder($invoiceids[$k], $calcWeight);
             if (!$rtn) {
                 BaseModel::rollback();
                 self::$errCode = '011';
                 self::$errMsg = "调用仓库系统拆分功能失败!";
                 return false;
             }
         } else {
             $returnStatus0 = array('orderStatus' => $insert_orderData['orderStatus'], 'orderType' => $insert_orderData['orderType']);
         }
         if (!OrderindexModel::updateOrder($tableName, $returnStatus0, $where)) {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "订单移动到缺货异常失败!";
             return false;
         }
         BaseModel::commit();
         BaseModel::autoCommit();
     }
     self::$errCode = 200;
     self::$errMsg = '缺货拆分完成!';
     return true;
 }
コード例 #14
0
ファイル: ioStore.action.php プロジェクト: ohjack/newErp
 function act_confirmReceivingByMFG()
 {
     $ioStoreId = !empty($_POST['ioStoreId']) ? $_POST['ioStoreId'] : 0;
     $comfirmUserId = $_SESSION['userId'];
     $now = time();
     if (intval($ioStoreId) <= 0) {
         self::$errCode = '101';
         self::$errMsg = "id有误";
         return false;
     }
     if (intval($comfirmUserId) <= 0) {
         self::$errCode = '102';
         self::$errMsg = "登陆超时,请重试";
         return false;
     }
     $tName = 'pc_products_iostore';
     $select = '*';
     $where = "WHERE is_delete=0 AND isAudit=2 AND id='{$ioStoreId}'";
     $ioStoreList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($ioStoreList)) {
         self::$errCode = '103';
         self::$errMsg = "该单据不存在或者未审核通过";
         return false;
     }
     try {
         BaseModel::begin();
         //标记表头已经确认
         $dataIoStore = array();
         $dataIoStore['isComfirm'] = 2;
         //标记单据已经确认
         $dataIoStore['comfirmUserId'] = $comfirmUserId;
         $dataIoStore['comfirmTime'] = $now;
         OmAvailableModel::updateTNameRow2arr($tName, $dataIoStore, $where);
         //标记表体确认
         $tName = 'pc_products_iostore_detail';
         $dataIoStoreDetail = array();
         $dataIoStoreDetail['isComfirm'] = 2;
         $where = "WHERE iostoreId='{$ioStoreId}'";
         OmAvailableModel::updateTNameRow2arr($tName, $dataIoStoreDetail, $where);
         //如果是新品领料单,则产品部确认后,该单据下的sku才进入产品制作表
         if ($ioStoreList[0]['iostoreTypeId'] == 1 && $ioStoreList[0]['useTypeId'] == 1) {
             $select = 'sku';
             $skuList = OmAvailableModel::getTNameList($tName, $select, $where);
             foreach ($skuList as $value) {
                 $sku = $value['sku'];
                 $tName = 'pc_products';
                 $dataProducts = array();
                 $dataProducts['sku'] = $sku;
                 OmAvailableModel::addTNameRow2arr($tName, $dataProducts);
                 //将detail中的sku加入到产品制作表中
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         self::$errCode = '200';
         self::$errMsg = "确认收货成功";
         return true;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         self::$errCode = '404';
         self::$errMsg = $e->getMessage();
         return false;
     }
 }
コード例 #15
0
ファイル: om_express_remark.php プロジェクト: ohjack/newErp
    $osql = "select * from om_express_remark where omOrderId = '{$omOrderId}' ";
    $query = $dbConn->query($osql);
    $oldremarks = $dbConn->fetch_array_all($query);
    if ($oldremarks) {
        $usql = "delete from om_express_remark where omOrderId = '{$omOrderId}' ";
        if (!$dbConn->query($usql)) {
            echo $usql;
            echo "\n";
            BaseModel::rollback();
        } else {
            $osql = "select * from om_express_remark_bak where omOrderId = '{$omOrderId}' ";
            $query = $dbConn->query($osql);
            $remarkValues = $dbConn->fetch_array_all($query);
            foreach ($remarkValues as $info) {
                $info['lastModified'] = time();
                $info['description'] = mysql_real_escape_string(trim($info['description']));
                $string = array2sql_extral($info);
                $sql = "insert into om_express_remark set " . $string;
                //echo $sql; echo "\n";
                if (!$dbConn->query($sql)) {
                    echo $sql;
                    echo "\n";
                    BaseModel::rollback();
                }
            }
        }
    }
    BaseModel::commit();
    BaseModel::autoCommit();
}
exit;
コード例 #16
0
ファイル: splitOrder.model.php プロジェクト: ohjack/newErp
 public static function overWeightSplitB2B($omOrderId)
 {
     !self::$dbConn ? self::initDB() : null;
     global $memc_obj;
     //调用memcache获取sku信息
     $mctime = time();
     //var_dump($moOrderIdArr);
     $tableName = 'om_unshipped_order';
     $where = ' WHERE id = ' . $omOrderId . ' and is_delete = 0 and storeId = 1';
     $orderData = OrderindexModel::showOrderList($tableName, $where);
     $orderDetail = $orderData[$omOrderId]['orderDetail'];
     $obj_order_data = $orderData[$omOrderId]['orderData'];
     $orderExtenData = $orderData[$omOrderId]['orderExtenData'];
     $orderUserInfoData = $orderData[$omOrderId]['orderUserInfoData'];
     $_actualTotal = $obj_order_data['actualTotal'];
     $_actualShipping = $obj_order_data['actualShipping'];
     $_platformId = $obj_order_data['platformId'];
     $_mainId = $obj_order_data['id'];
     $_transportId = $obj_order_data['transportId'];
     //var_dump($orderDetail); exit;
     $omAvailableAct = new OmAvailableAct();
     $GLOBAL_EBAY_ACCOUNT = $omAvailableAct->act_getTNameList2arrById('om_account', 'id', 'account', ' WHERE is_delete=0 AND platformId in(1,5) ');
     $weightlists = array();
     $skuinfo = array();
     $goods_sn_nums = 0;
     $shippfee_arr = array();
     $ebay_total_be = 0;
     foreach ($orderDetail as $k => $f) {
         $sku = trim($f['orderDetailData']['sku']);
         $amount = $f['orderDetailData']['amount'];
         $shippingFee = $f['orderDetailData']['shippingFee'];
         $goods_sn_nums += $amount;
         $ebay_total_be += $f['orderDetailData']['amount'] * $f['orderDetailData']['itemPrice'];
         $shippfee_arr[$sku] = round($shippingFee / $amount, 3);
         //单个料号的运费
         $skuinfo[$sku] = $f;
         for ($i = 1; $i <= $amount; $i++) {
             $var = $sku;
             $oneskuweight = CommonModel::calcOnlySkuWeight($var, 1);
             //一个sku的重量
             $weightlists[$var][] = $oneskuweight[0];
         }
     }
     $rate = $_actualTotal / $ebay_total_be;
     //var_dump($weightlists); exit;
     if ($goods_sn_nums <= 1) {
         self::$errCode = '0020';
         self::$errMsg = "只有一个料号组成,不允许超重拆分";
         return false;
     }
     //echo "==========="; exit;
     $keyarray = array();
     $keyarrays = array();
     $checkweight = 0;
     $arrinfo = CommonModel::calcNowOrderWeight($omOrderId);
     //var_dump($arrinfo); exit;
     $realweight = $arrinfo[0];
     $realcosts = $arrinfo[2];
     $itemprices = $arrinfo[3];
     foreach ($weightlists as $wk => $wv) {
         foreach ($wv as $weightlist) {
             $checkweight += $weightlist;
             if ($checkweight > 1.85) {
                 $keyarrays[] = $keyarray;
                 $keyarray = array();
                 $checkweight = $weightlist;
                 $keyarray[$wk][] = $wk;
             } else {
                 $keyarray[$wk][] = $wk;
             }
         }
     }
     if (!empty($keyarray)) {
         $keyarrays[] = $keyarray;
     }
     //var_dump($keyarrays); exit;
     BaseModel::begin();
     //开始事务
     $insert_orderData = array();
     foreach ($keyarrays as $keyarray) {
         $ebay_total = 0;
         $totalweight = 0;
         $insert_ebay_ids = array();
         //var_dump($skuinfo); echo "<br>";
         foreach ($keyarray as $k => $kav) {
             //var_dump($skuinfo[$k]['orderDetailData']['itemPrice'], count($kav));
             //$ebay_total += ($skuinfo[$k]['orderDetailData']['itemPrice'] + $shippfee_arr[$k]) * count($kav);
             $ebay_total += $skuinfo[$k]['orderDetailData']['itemPrice'] * count($kav);
         }
         $ebay_total = $rate * $ebay_total;
         $shipfee = 0;
         //$val = generateOrdersn();
         $insert_obj_order_data = $obj_order_data;
         unset($insert_obj_order_data['id']);
         $insert_obj_order_data['actualTotal'] = $ebay_total;
         $insert_obj_order_data['orderType'] = C('STATEPENDING_OWDONE');
         $insert_obj_order_data['orderAddTime'] = $mctime;
         $insert_obj_order_data['isSplit'] = 2;
         $insert_orderExtenData = $orderExtenData;
         unset($insert_orderExtenData['id']);
         $insert_orderUserInfoData = $orderUserInfoData;
         unset($insert_orderUserInfoData['id']);
         $insert_orderData = array('orderData' => $insert_obj_order_data, 'orderExtenData' => $insert_orderExtenData, 'orderUserInfoData' => $insert_orderUserInfoData);
         /*$sql = "insert into ebay_splitorder (recordnumber, main_order_id, split_order_id, create_date) values ('$recordnumber', '$ebay_id', '$insert_ebay_id', '".date("Y-m-d H:i:s")."')";
         		$split_log .= "添加主定单和拆分订单到关系表中\r\n".$sql ."\r\n";
         		$dbcon->execute($sql) or die("Fail : $sql");*/
         $obj_order_detail_data = array();
         foreach ($keyarray as $k => $kav) {
             $sku = $k;
             $amount = count($kav);
             $insert_orderDetailData = $skuinfo[$k]['orderDetailData'];
             unset($insert_orderDetailData['id']);
             $insert_orderDetailData['sku'] = strtoupper($sku);
             $insert_orderDetailData['amount'] = $amount;
             $insert_orderDetailData['createdTime'] = $mctime;
             if (isset($shippfee_arr[$sku])) {
                 $insert_orderDetailData['shippingFee'] = $shippfee_arr[$sku] * $amount;
                 //相同料号运费拆分
             }
             $insert_orderDetailExtenData = $skuinfo[$k]['orderDetailExtenData'];
             unset($insert_orderDetailExtenData['id']);
             $obj_order_detail_data[] = array('orderDetailData' => $insert_orderDetailData, 'orderDetailExtenData' => $insert_orderDetailExtenData);
         }
         $insert_orderData['orderDetail'] = $obj_order_detail_data;
         //echo "<pre>";
         //var_dump($obj_order_detail_data); exit;
         $calcInfo = CommonModel::calcAddOrderWeight($obj_order_detail_data);
         //计算重量和包材
         //var_dump($calcInfo); exit;
         $insert_orderData['orderData']['calcWeight'] = $calcInfo[0];
         $insert_orderData['orderData']['pmId'] = $calcInfo[1];
         //var_dump($insert_orderData); exit;
         $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insert_orderData, 1);
         //计算运费
         //var_dump($calcShippingInfo); exit;
         $insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
         $insert_orderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
         /*$interceptInfo = CommonModel :: auto_contrast_intercept($orderData);
         		//print_r($interceptInfo); exit;
         		$orderData['orderData']['orderStatus'] = $interceptInfo['orderStatus'];
         		$orderData['orderData']['orderType'] = $interceptInfo['orderType'];*/
         if ($_spitId = OrderAddModel::insertAllOrderRowNoEvent($insert_orderData)) {
             //echo $split_log .= 'insert success!' . "\n"; exit;
             //var_dump($_mainId,$_spitId); exit;
             if (!OrderLogModel::insertOrderLog($_spitId, 'INSERT ORDER')) {
                 BaseModel::rollback();
                 self::$errCode = '0021';
                 self::$errMsg = "split error!";
                 return false;
             }
             if (!OrderRecordModel::insertSpitRecords($_mainId, $_spitId)) {
                 BaseModel::rollback();
                 self::$errCode = '0022';
                 self::$errMsg = "split error!";
                 return false;
             }
         } else {
             $split_log .= 'insert error!' . "\n";
             BaseModel::rollback();
             self::$errCode = '0023';
             self::$errMsg = "split error!";
             return false;
         }
         if (!OrderindexModel::deleteOrderData($tableName, $where)) {
             self::$errCode = '0024';
             self::$errMsg = "split error!";
             return false;
         }
         if (!OrderLogModel::insertOrderLog($_mainId, 'DELETE ORDER')) {
             BaseModel::rollback();
             self::$errCode = '0025';
             self::$errMsg = "split error!";
             return false;
         }
         BaseModel::commit();
         BaseModel::autoCommit();
     }
     self::$errCode = '200';
     self::$errMsg = "split success!";
     return true;
 }
コード例 #17
0
 function act_invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request, $account, $site, $accountId, $flip_transportList, $message)
 {
     //		/global $account, $site, $accountId, $flip_transportList , $message;
     try {
         $response = $service->getOrder($request);
         //echo ("Service Response\n");
         //echo ("=============================================================================\n");
         if ($response->isSetGetOrderResult()) {
             //echo ("ListOrdersResult\n");
             $listOrdersResult = $response->getGetOrderResult();
             /*if ($listOrdersResult->isSetNextToken()) {
             			//echo ("	NextToken----");
             			//echo ($listOrdersResult->getNextToken() . "\n");
             		}
             		
             		if ($listOrdersResult->isSetCreatedBefore()) {
             			//echo ("CreatedBefore----");
             			//echo ($listOrdersResult->getCreatedBefore() . "\n");
             		}
             		if ($listOrdersResult->isSetLastUpdatedBefore()) {
             			//echo ("LastUpdatedBefore----");
             			//echo ($listOrdersResult->getLastUpdatedBefore() . "\n");
             		}*/
             if ($listOrdersResult->isSetOrders()) {
                 $orders = $listOrdersResult->getOrders();
                 $orderList = $orders->getOrder();
                 $orderIndex = 1;
                 $now = time();
                 //BaseModel :: begin(); //开始事务
                 foreach ($orderList as $order) {
                     //echo ("***********Orders $orderIndex************\n\n");
                     $orderIndex++;
                     $orderData = array();
                     //om_unshipped_order
                     $orderUserInfoData = array();
                     //om_unshipped_order_userInfo
                     $orderExtenData = array();
                     //om_unshipped_order_extension
                     $street2 = '';
                     //街道2
                     $street3 = '';
                     //街道3
                     if ($order->isSetAmazonOrderId() && $order->isSetOrderStatus() && $order->getOrderStatus() == 'Unshipped') {
                         //$orderData['ebay_status'] = 1; //同步进来的订单的状态
                         $orderData['recordNumber'] = $order->getAmazonOrderId();
                         //平台上的订单id
                         //echo "AmazonOrderId ==== {$orderData['recordNumber']}\n";
                     } else {
                         //echo 'getOrderStatus======' . $order->getOrderStatus() . "\n";
                         if ($order->getOrderStatus() == 'Shipped') {
                             //表示已经发货了的订单
                             $shippedRecordNum = $order->getAmazonOrderId();
                             $tName = 'om_shipped_order';
                             $where = "WHERE recordNumber='{$shippedRecordNum}' and accountId='{$accountId}' and ShippedTime=''";
                             $set = "SET ShippedTime='{$now}'";
                             //标记发货时间
                             $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where);
                             if ($affectRow) {
                                 $message .= "<font color='green'>update {$shippedRecordNum} ShippedTime success" . "</font><br>";
                             } else {
                                 $message .= "<font color='red'>update {$shippedRecordNum} ShippedTime fail may be has shippedTime or had no this recordNumber" . "</font><br>";
                             }
                         }
                         continue;
                     }
                     if ($order->isSetPurchaseDate()) {
                         //亚马逊平台上的下单时间
                         $orderData['ordersTime'] = strtotime($order->getPurchaseDate());
                         //echo ("addTime  ==== {$order->getPurchaseDate()}\n");
                     }
                     if ($order->isSetLastUpdateDate()) {
                         //支付时间
                         $orderData['paymentTime'] = strtotime($order->getLastUpdateDate());
                         //echo ("paidTime  ==== {$order->getLastUpdateDate()}\n");
                     }
                     $orderstatus = '';
                     //订单状态
                     //if ($order->isSetOrderStatus()) {
                     //                    	if($order->getOrderStatus() == 'Unshipped'){
                     //							$orderstatus				= 1;
                     //						}
                     //					}
                     if ($order->isSetFulfillmentChannel()) {
                         $orderExtenData['FulfillmentChannel'] = $order->getFulfillmentChannel();
                         //echo ("FulfillmentChannel  ==== "); //订单配送方式
                         //echo ($orderExtenData['FulfillmentChannel'] . "\n");
                     }
                     if ($order->isSetSalesChannel()) {
                         $orderExtenData['SalesChannel'] = $order->getSalesChannel();
                         //echo ("SalesChannel ==== ");
                         //echo ($orderExtenData['SalesChannel'] . "\n");
                     }
                     if ($order->isSetOrderChannel()) {
                         $orderExtenData['OrderChannel'] = $order->getOrderChannel();
                         //echo ("OrderChannel ====");
                         //echo ($orderExtenData['OrderChannel'] . "\n");
                     }
                     if ($order->isSetShipServiceLevel()) {
                         $orderExtenData['ShipServiceLevel'] = $order->getShipServiceLevel();
                         //echo ("ShipServiceLevel ==== ");
                         //echo ($orderExtenData['ShipServiceLevel'] . "\n");
                     }
                     if ($order->isSetShippingAddress()) {
                         //判断是否设置了地址
                         $shippingAddress = $order->getShippingAddress();
                         if ($shippingAddress->isSetName()) {
                             //获取收件人姓名
                             $orderUserInfoData['username'] = htmlentities($shippingAddress->getName(), ENT_QUOTES);
                             //echo ("username ==== ");
                             //echo ($orderUserInfoData['username'] . "\n");
                         }
                         if ($shippingAddress->isSetAddressLine1()) {
                             //街道1
                             $orderUserInfoData['street'] = htmlentities($shippingAddress->getAddressLine1(), ENT_QUOTES);
                             //echo ("street ==== ");
                             //echo ($orderUserInfoData['street'] . "\n");
                         }
                         if ($shippingAddress->isSetAddressLine2()) {
                             //街道2
                             $street2 = htmlentities($shippingAddress->getAddressLine2(), ENT_QUOTES);
                         }
                         if ($shippingAddress->isSetAddressLine3()) {
                             //街道3
                             $street3 = htmlentities($shippingAddress->getAddressLine3(), ENT_QUOTES);
                         }
                         if ($shippingAddress->isSetCity()) {
                             //城市
                             $orderUserInfoData['city'] = htmlentities($shippingAddress->getCity(), ENT_QUOTES);
                             //echo ("city ==== ");
                             //echo ($orderUserInfoData['city'] . "\n");
                         }
                         if ($shippingAddress->isSetCounty()) {
                             //郡,县
                             $orderUserInfoData['address2'] = htmlentities($shippingAddress->getCounty() . ' ' . $street2, ENT_QUOTES);
                             $orderUserInfoData['address3'] = htmlentities($shippingAddress->getCounty() . ' ' . $street3, ENT_QUOTES);
                             //echo ("address2 ==== ");
                             //echo ($orderUserInfoData['address2'] . "\n");
                             //echo ("address3 ==== ");
                             //echo ($orderUserInfoData['address3'] . "\n");
                         }
                         if ($shippingAddress->isSetDistrict()) {
                             //地方,区
                             //echo ("District ==== " . $shippingAddress->getDistrict() . "\n");
                         }
                         if ($shippingAddress->isSetStateOrRegion()) {
                             //州
                             $orderUserInfoData['state'] = htmlentities($shippingAddress->getStateOrRegion(), ENT_QUOTES);
                             //echo ("state ==== ");
                             //echo ($orderUserInfoData['state'] . "\n");
                         }
                         if ($shippingAddress->isSetPostalCode()) {
                             //邮编
                             $orderUserInfoData['zipCode'] = htmlentities($shippingAddress->getPostalCode(), ENT_QUOTES);
                             //echo ("zipCode ==== ");
                             //echo ($orderUserInfoData['zipCode'] . "\n");
                         }
                         if ($shippingAddress->isSetCountryCode()) {
                             //国家简称
                             /*$ebay_countrynames = array('US'=>'United States', "UK"=>"United Kingdom");
                             		$orderData['ebay_couny'] 	= 	$shippingAddress->getCountryCode() ;
                             		$orderData['ebay_site'] 	= 	$shippingAddress->getCountryCode() ;
                             		$orderData['ebay_countryname'] 	= 	$ebay_countrynames[$shippingAddress->getCountryCode()];*/
                             //$sql = "SELECT regions_en FROM  ebay_region WHERE  regions_jc =  '".$shippingAddress->getCountryCode()."'";
                             //                        	$sql	= $dbcon->execute($sql);
                             //							$amazon_countryname	= $dbcon->fetch_one($sql);
                             $orderUserInfoData['countrySn'] = $shippingAddress->getCountryCode();
                             //这里要调用运输方式管理系统的数据,获取国家简称对应的国家名称
                             $countryNameInfo = CommonModel::getCountrieInfoBySn($orderUserInfoData['countrySn']);
                             //根据国家简称获取该国家的信息
                             //$orderData['ebay_site'] = $shippingAddress->getCountryCode() ;
                             $orderUserInfoData['countryName'] = trim($countryNameInfo['regions_en']);
                             //获得国家名称
                             //echo ("getCountryCode==== " . $orderUserInfoData['countrySn'] . "\n");
                         }
                         if ($shippingAddress->isSetPhone()) {
                             //手机
                             $orderUserInfoData['phone'] = $shippingAddress->getPhone();
                             //echo ("phone ==== ");
                             //echo ($orderUserInfoData['phone'] . "\n");
                         }
                     }
                     if ($order->isSetOrderTotal()) {
                         $orderTotal = $order->getOrderTotal();
                         if ($orderTotal->isSetCurrencyCode()) {
                             //币种
                             $orderUserInfoData['currency'] = $orderTotal->getCurrencyCode();
                             //echo ("currency ==== ");
                             //echo ($orderUserInfoData['currency'] . "\n");
                         }
                         if ($orderTotal->isSetAmount()) {
                             //订单总价,线上总价
                             $orderData['onlineTotal'] = $orderTotal->getAmount();
                             $orderData['actualTotal'] = $orderTotal->getAmount();
                             //echo ("onlineTotal ==== ");
                             //echo ($orderData['onlineTotal'] . "\n");
                         }
                     }
                     if ($order->isSetNumberOfItemsShipped()) {
                         //echo ("ItemsShipped ==== " . $order->getNumberOfItemsShipped() . "\n");
                     }
                     if ($order->isSetNumberOfItemsUnshipped()) {
                         //echo ("NumberOfItemsUnshipped ==== " . $order->getNumberOfItemsUnshipped() . "\n");
                     }
                     if ($order->isSetPaymentExecutionDetail()) {
                         $paymentExecutionDetail = $order->getPaymentExecutionDetail();
                         $paymentExecutionDetailItemList = $paymentExecutionDetail->getPaymentExecutionDetailItem();
                         foreach ($paymentExecutionDetailItemList as $paymentExecutionDetailItem) {
                             echo "######PaymentExecutionDetailItem######\n";
                             if ($paymentExecutionDetailItem->isSetPayment()) {
                                 $payment = $paymentExecutionDetailItem->getPayment();
                                 if ($payment->isSetCurrencyCode()) {
                                     //echo ("CurrencyCode ==== ");
                                     //echo ($payment->getCurrencyCode() . "\n");
                                 }
                                 if ($payment->isSetAmount()) {
                                     //echo (" Amount ==== ");
                                     //echo ($payment->getAmount() . "\n");
                                 }
                             }
                             if ($paymentExecutionDetailItem->isSetSubPaymentMethod()) {
                                 //echo ("SubPaymentMethod ==== ");
                                 //echo ($paymentExecutionDetailItem->getSubPaymentMethod() . "\n");
                             }
                         }
                     }
                     if ($order->isSetPaymentMethod()) {
                         $orderExtenData['PaymentMethod'] = $order->getPaymentMethod();
                         //echo ("PaymentMethod ==== ");
                         //echo ($orderExtenData['PaymentMethod'] . "\n");
                     }
                     if ($order->isSetMarketplaceId()) {
                         $orderExtenData['MarketplaceId'] = $order->getMarketplaceId();
                         //echo ("MarketplaceId ==== ");
                         //echo ($orderExtenData['MarketplaceId'] . "\n");
                     }
                     if ($order->isSetBuyerName()) {
                         //买家ID
                         $orderUserInfoData['platformUsername'] = htmlentities($order->getBuyerName(), ENT_QUOTES);
                         //echo ("platformUsername ==== ");
                         //echo ($orderUserInfoData['platformUsername'] . "\n");
                     }
                     if ($order->isSetBuyerEmail()) {
                         //买家email
                         $orderUserInfoData['email'] = $order->getBuyerEmail();
                         //echo ("email ==== ");
                         //echo ($orderUserInfoData['email'] . "\n");
                     }
                     if ($order->isSetShipmentServiceLevelCategory()) {
                         $orderExtenData['ShipmentServiceLevelCategory'] = $order->getShipmentServiceLevelCategory();
                         //echo ("ShipmentServiceLevelCategory ==== ");
                         //echo ($orderExtenData['ShipmentServiceLevelCategory'] . "\n");
                     }
                     //$orderData['ebay_user']			=	$user;
                     $orderData['platformId'] = 11;
                     //amazon的平台ID为11
                     $orderData['accountId'] = $accountId;
                     //amazon的账号ID
                     //echo ("accountId ==== ");
                     //echo ($orderData['accountId'] . "\n");
                     $orderData['orderAddTime'] = time();
                     //添加到系统的时间
                     //echo ("orderAddTime ==== ");
                     //echo ($orderData['orderAddTime'] . "\n");
                     $orderData['orderStatus'] = C('STATEPENDING');
                     //默认订单状态
                     $orderData['orderType'] = C('STATEPENDING_INITIAL');
                     //默认订单类型
                     $orderData = array('orderData' => $orderData, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData);
                     $tName = 'om_unshipped_order';
                     $where = "WHERE recordNumber='{$orderData['orderData']['recordNumber']}' AND platformId={$orderData['orderData']['platformId']} and is_delete ='0'";
                     $flagCountUnshipped = OmAvailableModel::getTNameCount($tName, $where);
                     $tName = 'om_shipped_order';
                     $flagCountshipped = OmAvailableModel::getTNameCount($tName, $where);
                     if (empty($flagCountUnshipped) && empty($flagCountshipped)) {
                         //判断订单是否已经在系统2个订单表(未发货和已发货)中存在
                         //$orderData['ebay_ordersn']	=	generateOrdersn();
                         $detailrequest = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest();
                         $detailrequest->setSellerId(MERCHANT_ID);
                         $detailrequest->setAmazonOrderId($orderData['orderData']['recordNumber']);
                         $orderDetailArr = self::act_invokeListOrderItems($service, $detailrequest);
                         //var_dump($orderDetailArr); exit;
                         for ($i = 0; $i < count($orderDetailArr); $i++) {
                             $orderDetailArr[$i]['orderDetailData']['recordNumber'] = $orderData['orderData']['recordNumber'];
                         }
                         //print_r($orderDetailArr);
                         if (!empty($orderDetailArr)) {
                             $orderData['orderDetail'] = $orderDetailArr;
                             $insertData = array();
                             //var_dump($obj_order_detail_data); echo "<br>";
                             $calcInfo = CommonModel::calcAddOrderWeight($orderDetailArr);
                             //计算重量和包材
                             //var_dump($calcInfo); exit;
                             $orderData['orderData']['ORcalcWeight'] = $calcInfo[0];
                             $orderData['orderData']['calcWeight'] = $calcInfo[0];
                             $orderData['orderData']['pmId'] = $calcInfo[1];
                             if ($orderData['orderData']['calcWeight'] != $totalweight) {
                                 $insertData['old_totalweight'] = $totalweight;
                                 $insertData['new_totalweight'] = $orderData['orderData']['calcWeight'];
                             }
                             if ($orderData['orderData']['pmId'] != $pmId) {
                                 $insertData['old_pmId'] = $pmId;
                                 $insertData['new_pmId'] = $orderData['orderData']['pmId'];
                             }
                             $newcarrier = get_carrier($orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName'], $account, $orderData['orderUserInfoData']['currency']);
                             $orderData['orderData']['transportId'] = $flip_transportList[$newcarrier];
                             $orderData['orderData']['ORtransportId'] = $flip_transportList[$newcarrier];
                             $rtn = OldsystemModel::orderErpInsertorder($orderData);
                             //var_dump($rtn);
                             if ($rtn['errcode'] == 200) {
                                 //var_dump($rtn);
                                 $rtn_data = $rtn['data'];
                                 $orderId = $rtn_data['orderId'];
                                 $message .= "<font color='green'>" . date("Y-m-d H:i:s") . " 插入老系统成功,订单编号 [{$orderId}] </font><br>";
                                 $pmId = $rtn_data['pmId'];
                                 $totalweight = $rtn_data['totalweight'];
                                 $shipfee = $rtn_data['shipfee'];
                                 $carrier = $rtn_data['carrier'];
                                 $carrierId = $rtn_data['carrierId'];
                                 $status = $rtn_data['status'];
                                 $orderData['orderData']['id'] = $orderId;
                                 //赋予新系统订单编号@20140501
                                 if (count($orderData['orderDetail']) > 1) {
                                     $orderData['orderData']['orderAttribute'] = 3;
                                 } else {
                                     if (isset($orderData['orderDetail'][0]['orderDetailData']['amount']) && $orderData['orderDetail'][0]['orderDetailData']['amount'] > 1) {
                                         $orderData['orderData']['orderAttribute'] = 2;
                                     }
                                 }
                                 /*$calcShippingInfo = CommonModel :: calcAddOrderShippingFee($orderData,1);//计算运费
                                 		//var_dump($calcShippingInfo); exit;
                                 		//$insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
                                 		$orderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];*/
                                 $calcShippingInfo = TransAPIModel::trans_carriers_fix_get($orderData['orderData']['transportId'], $orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName']);
                                 //计算运费
                                 //var_dump($calcShippingInfo);
                                 $orderData['orderData']['calcShipping'] = $calcShippingInfo['fee'];
                                 //$orderData['orderData']['transportId'] = $calcShippingInfo['carrierId'];
                                 $orderData['orderData']['channelId'] = $calcShippingInfo['channelId'];
                                 $orderData['orderData']['ORchannelId'] = $calcShippingInfo['channelId'];
                                 if ($orderData['orderData']['calcShipping'] != $shipfee) {
                                     $insertData['old_shippfee'] = $shipfee;
                                     $insertData['new_shippfee'] = $orderData['orderData']['calcShipping'];
                                 }
                                 if ($orderData['orderData']['transportId'] != $carrierId) {
                                     $insertData['old_carrierId'] = $carrierId;
                                     $insertData['new_carrierId'] = $orderData['orderData']['transportId'];
                                 }
                                 if (!empty($insertData)) {
                                     $insertData['ebay_id'] = $orderId;
                                     $insertData['addtime'] = time();
                                     //var_dump($insertData);
                                     OldsystemModel::insertTempSyncRecords($insertData);
                                     // 插入临时对比记录表
                                 }
                                 $orderData = AutoModel::auto_contrast_intercept($orderData);
                                 //print_r($interceptInfo); exit;
                                 /*$orderData['orderData']['orderStatus'] = $interceptInfo['orderStatus'];
                                 		$orderData['orderData']['orderType'] = $interceptInfo['orderType'];*/
                                 //var_dump($orderData); exit;
                                 if (OrderAddModel::insertAllOrderRow($orderData)) {
                                     //echo 'insert success!' . "\n";
                                     $message .= "<font color='green'>" . date("Y-m-d H:i:s") . ", 新增订单{$orderData['orderData']['recordNumber']}成功</font><br>";
                                 } else {
                                     $message .= "<font color='red'>" . date("Y-m-d H:i:s") . ", 新增订单{$orderData['orderData']['recordNumber']}失败</font><br>";
                                     //echo OrderAddModel :: $errMsg;
                                 }
                             }
                         } else {
                             //echo "Amazon ID: ".$orderData['recordnumber']." 订单详情添加失败\n";
                             $message .= "<font color='red'>Amazon ID: " . $orderData['orderData']['recordNumber'] . " has no detail </font><br>";
                         }
                     } else {
                         $message .= "<font color='red'>Amazon ID: " . $orderData['orderData']['recordNumber'] . " had exist</font><br>";
                     }
                 }
             }
         }
     } catch (MarketplaceWebServiceOrders_Exception $ex) {
         $message .= "Caught Exception: " . $ex->getMessage() . "<br>";
         $message .= "Response Status Code: " . $ex->getStatusCode() . "<br>";
         $message .= "Error Code: " . $ex->getErrorCode() . "<br>";
         $message .= "Error Type: " . $ex->getErrorType() . "<br>";
         $message .= "Request ID: " . $ex->getRequestId() . "<br>";
         $message .= "XML: " . $ex->getXML() . "<br>";
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $message .= $e->getMessage() . "<br>";
     }
     return $message;
 }
コード例 #18
0
ファイル: property.action.php プロジェクト: ohjack/newErp
 function act_addInput()
 {
     //$pidNew = $_POST['pidNew']?post_check($_POST['pidNew']):'';//类别
     $finalIdArr = $_POST['finalIdStr'];
     //新建属性-类别4
     $inputName = $_POST['inputName'] ? post_check($_POST['inputName']) : '';
     //类别
     $textStatus = $_POST['textStatus'] ? post_check($_POST['textStatus']) : '';
     //文本方式
     if (empty($finalIdArr) || empty($inputName)) {
         self::$errCode = 101;
         self::$errMsg = '类别或属性名不能为空';
         return false;
     }
     if (intval($textStatus) <= 0) {
         self::$errCode = 102;
         self::$errMsg = '文本方式有误';
         return false;
     }
     $tmpArr = array();
     if (!is_array($finalIdArr)) {
         $tmpArr[] = $finalIdArr;
         $finalIdArr = $tmpArr;
     }
     $finalPathArr = array();
     foreach ($finalIdArr as $cid) {
         $catePath = CategoryModel::getCategoryPathById($cid);
         if (empty($catePath)) {
             self::$errCode = 109;
             self::$errMsg = '类别有误';
             return false;
         }
         $finalPathArr[] = $catePath;
     }
     $tName = 'pc_goods_category';
     foreach ($finalPathArr as $value) {
         $where = "WHERE path like'%{$value}-%' and is_delete=0";
         $count = OmAvailableModel::getTNameCount($tName, $where);
         if ($count) {
             self::$errCode = 105;
             self::$errMsg = '只能在最小分类进行复制';
             return false;
         }
     }
     try {
         $pidNewStr = '';
         BaseModel::begin();
         $tName = 'pc_archive_input';
         foreach ($finalPathArr as $value) {
             $where = "WHERE inputName='{$inputName}' AND categoryPath='{$value}'";
             $countIN = OmAvailableModel::getTNameCount($tName, $where);
             if (!$countIN) {
                 $pidNewStr .= CategoryModel::getCategoryNameByPath($value) . ' ';
                 $set = "SET inputName='{$inputName}',categoryPath='{$value}',textStatus='{$textStatus}'";
                 OmAvailableModel::addTNameRow($tName, $set);
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         self::$errCode = 200;
         self::$errMsg = "{$inputName} 添加到 {$pidNewStr} 成功";
         return true;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         self::$errCode = 201;
         self::$errMsg = $e->getMessage();
         return false;
     }
 }
コード例 #19
0
ファイル: omAccount.model.php プロジェクト: ohjack/newErp
 public static function addUserCompense($uid, $data)
 {
     !self::$dbConn ? self::initDB() : null;
     BaseModel::begin();
     //开始事务
     //var_dump($data);
     $string = array2sql_extral($data);
     if (self::selectUserCompense($uid)) {
         $sql = "UPDATE " . self::$UserCompenseTable . " SET {$string} WHERE global_user_id = " . $uid;
         //echo $sql;
         if (!self::$dbConn->query($sql)) {
             BaseModel::rollback();
             self::$errCode = "002";
             self::$errMsg = " 插入数据失败!";
             return false;
             //失败则设置错误码和错误信息, 返回false
         }
     } else {
         $data['global_user_id'] = $uid;
         //$data['type'] = 1;
         $string = array2sql($data);
         $sql = "INSERT INTO " . self::$UserCompenseTable . " SET {$string} ";
         //echo $sql;
         if (!self::$dbConn->query($sql)) {
             BaseModel::rollback();
             self::$errCode = "002";
             self::$errMsg = " 插入数据失败!";
             return false;
             //失败则设置错误码和错误信息, 返回false
         }
     }
     BaseModel::commit();
     BaseModel::autoCommit();
     self::$errCode = "200";
     self::$errMsg = " 插入数据成功!";
     return true;
     //失败则设置错误码和错误信息, 返回false
 }
コード例 #20
0
 public function pickupOrder()
 {
     global $dbConn;
     $skulist = $_POST['skulist'];
     $operator_id = $_SESSION[C('USER_AUTH_SYS_ID')];
     //操作人员ID
     $comid = $_SESSION[C('USER_COM_ID')];
     //公司ID
     $type = $_POST['type'];
     BaseModel::begin();
     //开始事务
     $rollback = false;
     foreach ($skulist as $key => $sku) {
         $price = PurchaseOrderModel::getPriceBySku($sku['sku']);
         //SKU单价
         //$parid      = CommonAct::actgetPartnerIdBySku($sku['sku']);//供应商ID
         $purid = $this->getPurchaseidBySku($sku['sku']);
         $parid = $this->getPartnerId($sku['sku']);
         //供应商ID
         $parid = $parid['partnerId'];
         $storeid = 1;
         //仓库ID
         $orderData = $this->getOwOrderSN($parid, $purid);
         //判断同供应商、采购员跟踪号是否已存在
         $orderSN = $orderData['recordnumber'];
         if ($key == 0 && $type == "oversea") {
             $orderSN = null;
         }
         $main = array();
         $detail = array();
         if (!empty($orderSN)) {
             //存在符合条件的跟踪号,直接插入采购订单明细
             //$detail['sku_id'] = $skuid;//SKU编号
             $detail['sku'] = $sku['sku'];
             $detail['price'] = $price;
             //单价
             $detail['count'] = $sku['rec'];
             //采购数量
             //$detail['is_new']  = $sku['is_new'];// 是否是新品
             $detail['goods_recommend_count'] = $sku['rec'];
             //采购数量
             $detail['recordnumber'] = $orderData['recordnumber'];
             $poid = $orderData['id'];
             //根据跟踪号取采购主订单编号
             $detail['po_id'] = $poid;
             $dataSet = array2sql($detail);
             $sql = "insert into ph_ow_order_detail set {$dataSet}  ";
             $rtndetail = $dbConn->execute($sql);
             if ($rtndetail === false) {
                 $rollback = true;
             }
         } else {
             //不存在符合条件的跟踪号重新生成
             //生成跟踪号需通过公司编号生成前缀
             $recordnumber = PurchaseOrderModel::autoCreateOrderSn($purid, $comid);
             //生成对应公司的采购订单跟踪号
             if (!empty($recordnumber)) {
                 //生成采购订单号成功
                 $main['recordnumber'] = $recordnumber;
                 //跟踪号
                 $main['purchaseuser_id'] = $purid;
                 //采购员ID
                 $main['operator_id'] = $operator_id;
                 //操作人员id
                 $main['warehouse_id'] = $storeid;
                 //仓库ID
                 $main['partner_id'] = $parid;
                 //供应商ID
                 $main['company_id'] = $comid;
                 //公司编号
                 $main['addtime'] = time();
                 if ($type == "oversea") {
                     $main['order_type'] = 5;
                     // 给海外仓备货的订单
                 } else {
                     $main['order_type'] = 1;
                     // 正常订单
                 }
                 $dataSet = array2sql($main);
                 $sql = "insert into ph_ow_order set {$dataSet}  ";
                 $rtnmain = $dbConn->execute($sql);
                 if ($rtnmain) {
                     //主订单添加成功
                     $detail['sku'] = $sku['sku'];
                     $detail['price'] = $price;
                     //单价
                     $detail['count'] = $sku['rec'];
                     //采购数量
                     $detail['goods_recommend_count'] = $sku['rec'];
                     //采购数量
                     //$detail['is_new']  = $sku['is_new'];// 是否是新品
                     $detail['recordnumber'] = $recordnumber;
                     $poid = PurchaseOrderModel::getOrderIdByNum($recordnumber);
                     //根据跟踪号取采购主订单编号
                     $detail['po_id'] = $poid;
                     $dataSet = array2sql($detail);
                     $sql = "insert into ph_ow_order_detail set {$dataSet}  ";
                     $dbConn->execute($sql);
                     if ($rtndetail === false) {
                         $rollback = true;
                     }
                 } else {
                     $rollback = true;
                 }
             } else {
                 $rollback = true;
             }
         }
     }
     if ($rollback == false) {
         BaseModel::commit();
         BaseModel::autoCommit();
         $result['msg'] = 'success';
     } else {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $result['msg'] = '';
     }
     return json_encode($result);
 }
コード例 #21
0
ファイル: goods.action.php プロジェクト: ohjack/newErp
 function act_updateSpuArchivePid()
 {
     $spu = $_POST['spu'];
     $pid = $_POST['pid'];
     $userId = $_SESSION['userId'];
     if (intval($userId) <= 0) {
         self::$errCode = '100';
         self::$errMsg = "登陆超时,请重试";
         return false;
     }
     if (empty($spu) || empty($pid)) {
         self::$errCode = '101';
         self::$errMsg = "异常,错误!";
         return false;
     }
     $tName = 'pc_spu_archive';
     $select = 'categoryPath';
     $where = "WHERE is_delete=0 AND spu='{$spu}'";
     $spuList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($spuList)) {
         self::$errCode = '102';
         self::$errMsg = "该SPU档案不存在";
         return false;
     }
     if ($spuList[0]['categoryPath'] == $pid) {
         self::$errCode = '110';
         self::$errMsg = "类别无修改";
         return false;
     }
     $tName = 'pc_goods_category';
     $where = "WHERE path='{$pid}' and is_delete=0";
     $count = OmAvailableModel::getTNameCount($tName, $where);
     if (!$count) {
         self::$errCode = '103';
         self::$errMsg = "所选类别不存在,请刷新重试!";
         return false;
     }
     $where = "WHERE path like'{$pid}-%' and is_delete=0";
     $count = OmAvailableModel::getTNameCount($tName, $where);
     if ($count) {
         self::$errCode = '104';
         self::$errMsg = "产品档案只能建立在最小分类下,请选择最小分类";
         return false;
     }
     try {
         BaseModel::begin();
         $tName = 'pc_spu_archive';
         $where = "WHERE spu='{$spu}'";
         $dataTmpArr = array();
         $dataTmpArr['categoryPath'] = $pid;
         OmAvailableModel::updateTNameRow2arr($tName, $dataTmpArr, $where);
         //更新SPU档案的类别
         $tName = 'pc_archive_spu_property_value_relation';
         $where = "WHERE spu='{$spu}'";
         OmAvailableModel::deleteTNameRow($tName, $where);
         //物理删除该SPU产品档案选择属性记录
         $tName = 'pc_archive_spu_input_value_relation';
         $where = "WHERE spu='{$spu}'";
         OmAvailableModel::deleteTNameRow($tName, $where);
         //物理删除SPU产品档案文本记录
         $tName = 'pc_goods';
         $where = "WHERE is_delete=0 AND spu='{$spu}'";
         $dataTmpArr = array();
         $dataTmpArr['goodsCategory'] = $pid;
         OmAvailableModel::updateTNameRow2arr($tName, $dataTmpArr, $where);
         //更新该SPU下所有SKU的类别
         BaseModel::commit();
         BaseModel::autoCommit();
         OmAvailableModel::newData2ErpInterfOpen('pc.erp.updateGoodsCategoryBySpu', array('spu' => $spu, 'pid' => $pid), 'gw88');
         $personName = getPersonNameById($userId);
         error_log(date('Y-m-d_H:i') . " {$personName} 将SPU:{$spu} 类别改为 {$pid} 原始类别为: {$spuList[0]['categoryPath']} \r\n", 3, WEB_PATH . "log/updateSpuCategoryLog.txt");
         self::$errCode = 200;
         self::$errMsg = "修改成功";
         return true;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         self::$errCode = 404;
         self::$errMsg = '修改失败,原因为:' . $e->getMessage();
         return false;
     }
 }
コード例 #22
0
 public static function combinePackage($tableName, $plateform_arr, $carrierIds, $id_array, $storeId = 1)
 {
     self::initDB();
     $list = self::selectList($tableName, $plateform_arr, $carrierIds, $id_array);
     //var_dump($list); exit;
     if (!$list) {
         self::$errCode = 301;
         self::$errMsg = "没有需要合并的订单!";
         return false;
     }
     /*foreach($list as $key=>$value){
     			$key = $value['id'];
     		}
     		var_dump($key); exit;*/
     BaseModel::begin();
     $combineNum = 0;
     foreach ($list as $key => $value) {
         $where = "b.userName = '******'userName']}' \n\t\t\t\t\tAND b.countryName = '{$value['countryName']}' \n\t\t\t\t\tAND a.accountId = {$value['accountId']} \n\t\t\t\t\tAND a.transportId = {$value['transportId']} \n\t\t\t\t\tAND b.state='{$value['state']}' \n\t\t\t\t\tAND b.city='{$value['city']}' \n\t\t\t\t\tAND b.street='{$value['street']}' \n\t\t\t\t\tAND a.orderType={$value['orderType']}\n\t\t\t\t\tAND a.calcWeight<=2 \n\t\t\t\t\tAND a.isLock=0 \n\t\t\t\t\tAND a.is_delete=0 \n\t\t\t\t\tAND a.combinePackage=0 \n\t\t\t\t\tAND a.orderStatus={$value['orderStatus']}\n\t\t\t\t\tAND a.orderType={$value['orderType']}\n\t\t\t\t\tAND is_delete = 0 AND storeId = " . $storeId;
         $records = combinePackageModel::selectRecord($tableName, $where, $id_array);
         //var_dump($records); exit;
         if (!$records) {
             continue;
         } else {
             $weightlists = array();
             $orderinfo = array();
             $countryName = $records[0]['countryName'];
             $transportId = $records[0]['transportId'];
             foreach ($records as $record) {
                 $omOrderId = $record['id'];
                 $omOrderId = $record['id'];
                 $orderinfo[$record['id']] = $record;
                 $arrinfo = CommonModel::calcNowOrderWeight($omOrderId);
                 //var_dump($arrinfo); exit;
                 $realweight = $arrinfo[0];
                 $realcosts = $arrinfo[2];
                 $itemprices = $arrinfo[3];
                 $weightlists[$omOrderId] = $realweight;
             }
             //var_dump($weightlists); exit;
             $keyarray = array();
             $keyarrays = array();
             $checkweight = 0;
             foreach ($weightlists as $wk => $weightlist) {
                 $checkweight += $weightlist;
                 if ($checkweight > 1.85) {
                     $keyarrays[] = $keyarray;
                     $keyarray = array();
                     $checkweight = $weightlist;
                     $keyarray[] = $wk;
                 } else {
                     $keyarray[] = $wk;
                 }
             }
             if (!empty($keyarray)) {
                 $keyarrays[] = $keyarray;
             }
             //var_dump($keyarrays); echo "<br>";
             foreach ($keyarrays as $orderlist) {
                 if (count($orderlist) < 2) {
                     continue;
                 }
                 $ordervalueweight = array();
                 $ordervalueactualTotal = array();
                 foreach ($orderlist as $orderid) {
                     $ordervalueweight[$orderid] = $weightlists[$orderid];
                     $ordervalueactualTotal[$orderid] = $orderinfo[$orderid]['actualTotal'];
                 }
                 //var_dump($ordervalueactualTotal); exit;
                 //var_dump($ordervalueweight); exit;
                 $firstorder = array_shift($orderlist);
                 //第一个订单编号信息
                 //var_dump($firstorder);
                 $combineInfo = CommonModel::calcshippingfee(array_sum($ordervalueweight), $countryName, array_sum($ordervalueactualTotal), $transportId);
                 //邮寄方式计算
                 //var_dump($combineInfo); exit;
                 $weight2fee = calceveryweight($ordervalueweight, $combineInfo['fee']['fee']);
                 //var_dump($weight2fee); exit;
                 $firstweightfee = array_shift($weight2fee);
                 //第一个订单重量运费信息
                 $data = array();
                 $data['combinePackage'] = 1;
                 $data['orderStatus'] = C('STATEPENDING');
                 $data['orderType'] = C('STATEPENDING_CONPACK');
                 $where = ' WHERE id = ' . $firstorder;
                 if (!OrderindexModel::updateOrder($tableName, $data, $where)) {
                     self::$errCode = 303;
                     self::$errMsg = "更新主订单失败!";
                     BaseModel::rollback();
                     return false;
                 }
                 foreach ($orderlist as $sonorder) {
                     $data['combinePackage'] = 2;
                     $data['orderStatus'] = C('STATEPENDING');
                     $data['orderType'] = C('STATEPENDING_CONPACK');
                     $where = ' WHERE id = ' . $sonorder;
                     if (!OrderindexModel::updateOrder($tableName, $data, $where)) {
                         self::$errCode = 304;
                         self::$errMsg = "更新子订单失败!";
                         BaseModel::rollback();
                         return false;
                     }
                     if (!OrderRecordModel::insertCombineRecord($firstorder, $sonorder)) {
                         self::$errCode = 305;
                         self::$errMsg = "插入订单合并记录失败!";
                         BaseModel::rollback();
                         return false;
                     }
                 }
                 $combineNum++;
             }
         }
     }
     self::$errCode = 200;
     self::$errMsg = "合并包裹操作成功!";
     BaseModel::commit();
     BaseModel::autoCommit();
     return $combineNum;
 }
コード例 #23
0
ファイル: api.action.php プロジェクト: ohjack/newErp
 function act_processPurchaseOrder()
 {
     $sku = isset($_GET['sku']) ? trim($_GET['sku']) : '';
     $num = isset($_GET['num']) ? trim($_GET['num']) : '';
     if ($sku == '' || $num == '') {
         self::$errCode = 101;
         self::$errMsg = '参数不合法';
         return false;
     }
     $now_num = $num;
     $purchase_list = self::checkPurchaseSkuIsExist($sku);
     //api拉取采购订单
     BaseModel::begin();
     //开始事务
     $rollback = false;
     if (!empty($purchase_list)) {
         /*** 计算采购成本算法 Start step1 获取原有库存成本***/
         $rtnData = ApiModel::getQtyAndPriceBySku($sku);
         //返回料号未入库的库存及成本单价
         $stockmoney = 0;
         $before_qty = 0;
         $before_price = 0;
         $skumoney = 0;
         $skuqty = 0;
         if (!empty($rtnData)) {
             $before_qty = $rtnData[0]['stock_qty'];
             $before_price = $rtnData[0]['goodsCost'];
             $stockmoney = $before_price * $before_qty;
             //未入库前库存成本
         }
         /*** 计算采购成本算法 End step1 获取原有库存成本***/
         foreach ($purchase_list as $purchase) {
             if ($now_num < 1) {
                 break;
             }
             $orderId = $purchase['id'];
             $sku_id = $purchase['sku_id'];
             $lessnum = $purchase['count'] - $purchase['stockqty'];
             $price = $purchase['price'];
             //采购成本
             $adduserid = $purchase['purchaseuser_id'];
             //采购员编号
             if ($lessnum > 0) {
                 if ($now_num < $lessnum) {
                     $total_num = $purchase['stockqty'] + $now_num;
                     $ret = OmAvailableAct::act_updateTNameRow("ph_order_detail", "SET stockqty = '{$total_num}'", "WHERE po_id = '{$orderId}' AND sku_id = '{$sku_id}'");
                     if ($ret === false) {
                         self::$errCode = 405;
                         self::$errMsg = '更新采购订单料号数量出错!';
                         $rollback = false;
                     } else {
                         $now_num = 0;
                     }
                 } else {
                     $totalCount = $purchase['count'];
                     $reach_time = time();
                     $ret = OmAvailableAct::act_updateTNameRow("ph_order_detail", "SET stockqty = '{$totalCount}', reach_time = '{$reach_time}'", "WHERE po_id = '{$orderId}' AND sku_id = '{$sku_id}'");
                     if ($ret === false) {
                         self::$errCode = 406;
                         self::$errMsg = '更新采购订单料号数量出错!';
                         $rollback = false;
                     } else {
                         $now_num = $now_num - $lessnum;
                         /*** 计算采购成本算法 Start step2 获取订单明细表已到货完成的料号***/
                         $skumoney += $price * $purchase['count'];
                         //采购订单中单个料号的采购总金额
                         $skuqty += $purchase['count'];
                         /*** 计算采购成本算法 End step2 获取订单明细表已到货完成的料号***/
                     }
                 }
                 //检测订单是否完结
                 $otherskus = self::getOrderDetailsById($orderId);
                 $status = true;
                 foreach ($otherskus as $othersku) {
                     if ($othersku['count'] != $othersku['stockqty']) {
                         $status = false;
                         break;
                     }
                 }
                 if ($status) {
                     $ret = OmAvailableAct::act_updateTNameRow("ph_order", "SET status = '4'", "WHERE id = '{$orderId}'");
                     if ($ret === false) {
                         self::$errCode = 407;
                         self::$errMsg = '更新采购订单状态出错!';
                         $rollback = false;
                     }
                 }
             }
         }
         /*** 计算采购成本算法 Start step3 重新计算料号采购成本***/
         $totalmoney = $stockmoney + $skumoney;
         $totalqty = $before_qty + $skuqty;
         $newprice = round($totalmoney / $totalqty, 2);
         //新的料号采购成本
         $rtnApiData = self::updatePcApiPrice($sku, $newprice, $adduserid);
         $errorCode = $rtnApiData['errCode'];
         if ($errCode != 200) {
             $rollback = true;
         }
         if ($rollback == false) {
             BaseModel::commit();
             BaseModel::autoCommit();
         } else {
             BaseModel::rollback();
             BaseModel::autoCommit();
         }
         /*** 计算采购成本算法 End step3 重新计算料号采购成本***/
     }
     return $now_num;
 }
コード例 #24
0
ファイル: orderModify.view.php プロジェクト: ohjack/newErp
 public function view_modifyOrderList()
 {
     global $memc_obj;
     $sysUserId = $_SESSION['sysUserId'];
     $modify_showerrorinfo = '';
     $OrderModifyAct = new OrderModifyAct();
     $OrderindexAct = new OrderindexAct();
     $UserCompetenceAct = new UserCompetenceAct();
     //var_dump($_GET); exit;
     if (isset($_GET) && !empty($_GET)) {
         $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
         $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
         $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
     }
     if (isset($_POST) && !empty($_POST)) {
         //var_dump($_POST); echo "<br>"; exit;
         $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : '';
         $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus'];
         $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype'];
         $update_order = array();
         $update_userinfo = array();
         $update_tracknumber = array();
         //$orderid = $_POST['orderid'];
         //var_dump($_POST); exit;
         $updatestatus = false;
         if ($_POST['action'] == 'addDetail') {
             //var_dump($_GET); echo "<br>"; exit;
             $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
             $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
             $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
             if ($OrderModifyAct->act_batchAdd($orderid, $_POST)) {
                 $modify_showerrorinfo = "<font color='green'>添加成功</font>";
             } else {
                 $modify_showerrorinfo = "<font color='red'>添加失败</font>";
             }
         } else {
             if ($_POST['action'] == 'addNote') {
                 //var_dump($_GET); echo "<br>"; exit;
                 $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
                 $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
                 $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
                 if ($OrderModifyAct->act_addNote($orderid, $_POST)) {
                     $modify_showerrorinfo = "<font color='green'>添加成功</font>";
                 } else {
                     $modify_showerrorinfo = "<font color='red'>添加失败</font>";
                 }
             } else {
                 $visible_movefolder = $UserCompetenceAct->act_getInStatusIds($_POST['otype'], $sysUserId);
                 if (!in_array($_POST['edit_otype'], $visible_movefolder)) {
                     $modify_showerrorinfo = "<font color='red'>您没有改变订单状态的权限</font>";
                 } else {
                     if ($_POST['username'] != $_POST['edit_username']) {
                         $update_userinfo['username'] = $_POST['edit_username'];
                     }
                     if ($_POST['ostatus'] != $_POST['edit_ostatus']) {
                         $update_order['orderStatus'] = $_POST['edit_ostatus'];
                     }
                     if ($_POST['otype'] != $_POST['edit_otype']) {
                         $update_order['orderType'] = $_POST['edit_otype'];
                         $updatestatus = true;
                     }
                     if ($_POST['street'] != $_POST['edit_street']) {
                         $update_userinfo['street'] = $_POST['edit_street'];
                     }
                     if ($_POST['platformUsername'] != $_POST['edit_platformUsername']) {
                         $update_userinfo['platformUsername'] = $_POST['edit_platformUsername'];
                     }
                     if ($_POST['address2'] != $_POST['edit_address2']) {
                         $update_userinfo['address2'] = $_POST['edit_address2'];
                     }
                     if ($_POST['actualShipping'] != $_POST['edit_actualShipping']) {
                         $update_order['actualShipping'] = $_POST['edit_actualShipping'];
                     }
                     if ($_POST['city'] != $_POST['edit_city']) {
                         $update_userinfo['city'] = $_POST['edit_city'];
                     }
                     if ($_POST['state'] != $_POST['edit_state']) {
                         $update_userinfo['state'] = $_POST['edit_state'];
                     }
                     if ($_POST['countryName'] != $_POST['edit_countryName']) {
                         $update_userinfo['countryName'] = $_POST['edit_countryName'];
                     }
                     if ($_POST['zipCode'] != $_POST['edit_zipCode']) {
                         $update_userinfo['zipCode'] = $_POST['edit_zipCode'];
                     }
                     if ($_POST['landline'] != $_POST['edit_landline']) {
                         $update_userinfo['landline'] = $_POST['edit_landline'];
                     }
                     if ($_POST['phone'] != $_POST['edit_phone']) {
                         $update_userinfo['phone'] = $_POST['edit_phone'];
                     }
                     if ($_POST['transportId'] != $_POST['edit_transportId']) {
                         $update_order['transportId'] = $_POST['edit_transportId'];
                     }
                     if ($_POST['edit_tracknumber']) {
                         $update_tracknumber['omOrderId'] = $orderid;
                         $update_tracknumber['tracknumber'] = $_POST['edit_tracknumber'];
                         $update_tracknumber['addUser'] = $sysUserId;
                         $update_tracknumber['createdTime'] = time();
                         //var_dump($update_tracknumber); exit;
                     }
                     BaseModel::begin();
                     //开始事务
                     if ($update_order) {
                         //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid;
                         //$msg = OrderLogModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql);
                         if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) {
                             if ($updatestatus) {
                                 $ProductStatus = new ProductStatus();
                                 if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) {
                                     BaseModel::rollback();
                                 }
                             }
                             $modify_showerrorinfo = "<font color='green'>更新成功</font>";
                         } else {
                             $modify_showerrorinfo = "<font color='red'>更新失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     if ($update_userinfo) {
                         //var_dump($update_userinfo);
                         if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) {
                             $modify_showerrorinfo = "<font color='green'>更新成功</font>";
                         } else {
                             $modify_showerrorinfo = "<font color='red'>更新失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     if ($update_tracknumber) {
                         //echo $msg;
                         if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) {
                             /*self :: $errCode = "001";
                             		self :: $errMsg =  "跟踪号插入失败";
                             		return false;*/
                             $modify_showerrorinfo = "<font color='red'>跟踪号插入失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     BaseModel::commit();
                     BaseModel::autoCommit();
                 }
             }
         }
     }
     $this->smarty->assign('modify_showerrorinfo', $modify_showerrorinfo);
     $omAvailableAct = new OmAvailableAct();
     //平台信息
     $platform = $omAvailableAct->act_getTNameList('om_platform', 'id,platform', 'WHERE is_delete=0');
     //var_dump($platform);
     $platformList = array();
     foreach ($platform as $v) {
         $platformList[$v['id']] = $v['platform'];
     }
     $this->smarty->assign('platformList', $platformList);
     /**导航 start**/
     $this->smarty->assign('ostatus', $ostatus);
     $this->smarty->assign('otype', $otype);
     //二级目录
     $StatusMenuAct = new StatusMenuAct();
     $ostatusList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = 0 AND is_delete=0');
     //var_dump($ostatusList);
     $this->smarty->assign('ostatusList', $ostatusList);
     $otypeList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = "' . $ostatus . '" AND is_delete=0');
     //var_dump($otypeList);
     $this->smarty->assign('otypeList', $otypeList);
     /*$o_secondlevel =  $omAvailableAct->act_getTNameList('om_status_menu','*','WHERE is_delete=0 and groupId=0 order by sort asc');
     		$this->smarty->assign('o_secondlevel', $o_secondlevel);*/
     $second_count = array();
     $second_type = array();
     foreach ($ostatusList as $o_secondinfo) {
         $orderStatus = $o_secondinfo['statusCode'];
         /*$accountacc = $_SESSION['accountacc'];
         		$oc_where = " where orderStatus='$orderStatus' ";
         		if($accountacc){
         			$oc_where .= ' AND ('.$accountacc.') ';
         		}*/
         $s_total = $OrderindexAct->act_showSearchOrderNum($orderStatus);
         //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order", $oc_where);
         $second_count[$o_secondinfo['statusCode']] = $s_total;
         $s_type = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$orderStatus}' order by sort asc");
         $second_type[$o_secondinfo['statusCode']] = $s_type[0]['statusCode'];
     }
     //var_dump($second_count);
     $this->smarty->assign('second_count', $second_count);
     $this->smarty->assign('second_type', $second_type);
     //退款数量
     $refund_total = $omAvailableAct->act_getTNameCount("om_order_refund", " where is_delete=0");
     $this->smarty->assign('refund_total', $refund_total);
     //三级目录
     $o_threelevel = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$ostatus}' order by sort asc");
     $this->smarty->assign('o_threelevel', $o_threelevel);
     $three_count = array();
     foreach ($o_threelevel as $o_threeinfo) {
         $orderType = $o_threeinfo['statusCode'];
         $s_total = $OrderindexAct->act_showSearchOrderNum($ostatus, $orderType);
         //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order"," where orderStatus='$ostatus' and orderType='$orderType' and storeId=1 and is_delete=0");
         $three_count[$o_threeinfo['statusCode']] = $s_total;
     }
     $this->smarty->assign('three_count', $three_count);
     $toptitle = '订单显示页面';
     //头部title
     $this->smarty->assign('toptitle', $toptitle);
     $this->smarty->assign('toplevel', 0);
     $threelevel = '1';
     //当前的三级菜单
     $this->smarty->assign('threelevel', $threelevel);
     $statusMenu = $omAvailableAct->act_getTNameList('om_status_menu', ' * ', 'WHERE is_delete=0 ');
     $this->smarty->assign('statusMenu', $statusMenu);
     $value = '';
     $where = '';
     switch ($searchTransportationType) {
         case '1':
             $transportation = CommonModel::getCarrierList(1);
             //快递
             break;
         case '2':
             $transportation = CommonModel::getCarrierList(0);
             //平邮
             break;
         default:
             $transportation = CommonModel::getCarrierList();
             //所有的
             break;
     }
     //var_dump($transportation); exit;
     $transportationList = array();
     foreach ($transportation as $tranValue) {
         $transportationList[$tranValue['id']] = $tranValue['carrierNameCn'];
     }
     //var_dump($transportationList); exit;
     $this->smarty->assign('transportation', $transportation);
     $this->smarty->assign('transportationList', $transportationList);
     //var_dump($orderid, $ostatus,$otype);
     $omOrderList = $OrderModifyAct->act_getModifyOrderList($orderid, $ostatus, $otype, $storeId = 1);
     //var_dump($omOrderList);
     //$sku	=	array();
     $account_where = ' WHERE is_delete = 0 ';
     if ($searchPlatformId) {
         $account_where .= ' AND platformId = ' . $searchPlatformId;
     }
     $accountList = $UserCompetenceAct->act_showGlobalUser();
     if ($accountList) {
         $account_where .= ' AND id in ( ' . join(',', $accountList) . ' ) ';
     }
     //帐号信息
     $accountList = $omAvailableAct->act_getTNameList('om_account', '*', $account_where);
     //var_dump($accountList); exit;
     $account = array();
     foreach ($accountList as $v) {
         $account[$v['id']] = $v['account'];
     }
     //包材信息
     $pm = GoodsModel::getMaterInfoByList();
     //获取系统所有状态
     $statusList = copyOrderModel::selectStatusList();
     $CurrencyAct = new CurrencyAct();
     $currencyList = $CurrencyAct->act_getCurrencyListById();
     //echo "<pre>"; print_r($currencyList); exit;
     $this->smarty->assign('currencyList', $currencyList);
     $this->smarty->assign('statusList', $statusList);
     $this->smarty->assign('show_page', $show_page);
     $this->smarty->assign('account', $account);
     $this->smarty->assign('accountList', $accountList);
     $this->smarty->assign('pm', $pm);
     $this->smarty->assign('omOrderList', $omOrderList);
     $this->smarty->display('orderModify.htm');
 }
コード例 #25
0
 function act_applyTheLineEUBTrackNumber()
 {
     global $memc_obj;
     //调用memcache获取sku信息
     //var_dump($SYSTEM_ACCOUNTS);
     require_once WEB_PATH . "lib/PHPExcel.php";
     //PHPExcel
     //exit;
     $addUser = $_SESSION['sysUserId'];
     $filePath = WEB_PATH . "html/upload/eub/";
     //var_dump($_FILES); exit;
     if (!empty($_FILES['theline_upfile']['tmp_name'])) {
         $uploadfile = date("Y") . date("m") . date("d") . rand(1, 3009) . ".xls";
         $filePath .= $uploadfile;
         //echo $filePath;
         if (!move_uploaded_file($_FILES['theline_upfile']['tmp_name'], $filePath)) {
             self::$errCode = '003';
             self::$errMsg = "文件上传失败!";
             echo self::$errMsg;
             return false;
         }
     } else {
         self::$errCode = '003';
         self::$errMsg = "文件上传不成功!";
         echo self::$errMsg;
         return false;
     }
     //var_dump($addUser);
     $PHPExcel = new PHPExcel();
     //var_dump($PHPExcel); exit;
     $PHPReader = new PHPExcel_Reader_Excel2007();
     //var_dump($PHPReader); exit;
     //exit;
     //var_dump($PHPReader->canRead($filePath)); exit;
     if (!$PHPReader->canRead($filePath)) {
         $PHPReader = new PHPExcel_Reader_Excel5();
         //var_dump($PHPReader); exit;
         if (!$PHPReader->canRead($filePath)) {
             echo 'no Excel';
             return;
         }
     }
     //exit;
     $PHPExcel = $PHPReader->load($filePath);
     $excellists = excel2array($PHPExcel, $filePath, 2, 0);
     //echo "<pre>";print_r($excellists); exit;
     $adjust_time = date('Y-m-d H:i:s');
     $recordnumbers = array();
     $tracknumbers = array();
     foreach ($excellists as $key => $excellist) {
         $recordnumbers[] = array_shift($excellist);
         $tracknumbers[] = array_shift($excellist);
     }
     $total = count($recordnumbers);
     BaseModel::begin();
     //开始事务
     for ($ii = 1; $ii < $total; $ii++) {
         $recordnumber = $recordnumbers[$ii];
         $tracknumber = $tracknumbers[$ii];
         //盘点数量
         $row = $ii;
         if (!preg_match('/^LN[0-9]{9}CN$/', $tracknumber)) {
             self::$errMsg .= "   第" . $row . "行" . $tracknumber . " 跟踪号格式有误<br>";
         }
         if ($tracknumber == "") {
             self::$errMsg .= "   第" . $row . "行跟踪号为空请查证<br>";
         }
         if (!OmEUBTrackNumberModel::applyTheLineEUBTrackNumber($recordnumber, $tracknumber)) {
             BaseModel::rollback();
         }
     }
     self::$errCode .= OmEUBTrackNumberModel::$errCode;
     self::$errMsg .= OmEUBTrackNumberModel::$errMsg;
     BaseModel::commit();
     BaseModel::autoCommit();
     return true;
 }