예제 #1
0
 function act_addOrderAPI()
 {
     $orderData = !empty($_POST['orderData']) ? trim($_POST['orderData']) : '';
     if ($orderData) {
     }
     $insert = OrderAddModel::insertAllOrderRowNoEvent($orderData);
     if ($_spitId = OrderAddModel::insertAllOrderRowNoEvent($insertOrderData)) {
         if (!OrderLogModel::insertOrderLog($_spitId, 'INSERT ORDER')) {
             self::$errCode = '001';
             self::$errMsg = "插入订单日志失败!";
             return false;
         }
         if (!OrderRecordModel::insertSpitRecords($orderId, $_spitId)) {
             self::$errCode = '002';
             self::$errMsg = "插入拆分日志失败!";
             return false;
         }
     } else {
         self::$errCode = 03;
         self::$errMsg = "订单插入成功!";
         return false;
     }
 }
예제 #2
0
 public static function combineOrder($orderIdArr)
 {
     self::initDB();
     BaseModel::begin();
     //开始事务
     $serchSql = "SELECT * FROM om_unshipped_order WHERE id in ('" . join("','", $orderIdArr) . "') and is_delete = 0 and storeId = 1 ";
     $querySql = self::$dbConn->query($serchSql);
     $serchSqlArr = self::$dbConn->fetch_array_all($querySql);
     //判断一:订单数量统计
     if (count($serchSqlArr) < 2) {
         self::$errCode = "1111";
         self::$errMsg = "合并订单最少需要选择两个或两个以上的订单!";
         return false;
     }
     $platfrom = omAccountModel::getPlatformSuffixById($serchSqlArr[0]['platformId']);
     $extension = $platfrom['suffix'];
     //获取后缀名称
     $temporderStatus = "";
     //相同状态一
     $temporderStatus2 = "";
     //相同状态二
     $userinfo = array();
     //订单相同条件
     $orderSn = array();
     //订单编号
     $onlineTotal = 0;
     //线上总价
     $actualTotal = 0;
     //实际收款总价
     $calcWeight = 0;
     //估算重量,单位是kg
     $calcShipping = 0;
     //估算运费
     foreach ($serchSqlArr as $selectArr) {
         $orderSn[] = $selectArr['id'];
         $onlineTotal += $selectArr['onlineTotal'];
         $actualTotal += $selectArr['actualTotal'];
         $calcWeight += $selectArr['calcWeight'];
         $calcShipping += $selectArr['calcShipping'];
         //判断二:订单被其他人 <锁定> 订单判断
         if ($selectArr['isLock'] == 1) {
             self::$errCode = "2222";
             self::$errMsg = "订单[" . $selectArr['id'] . "]已经被 [" . UserModel::getUsernameById($selectArr['lockUser']) . "] 锁定,不能合并操作。";
             return false;
         }
         //判断三:已合并订单,无法再次合并判断
         if (in_array($selectArr['combineOrder'], array(1, 2))) {
             self::$errCode = "3333";
             self::$errMsg = "订单[" . $selectArr['id'] . "]已经有订单合并操作,不能重复订单合并。";
             return false;
         }
         //判断四:已合并包裹订单,无法合并判断
         if (in_array($selectArr['combinePackage'], array(1, 2))) {
             self::$errCode = "4444";
             self::$errMsg = "订单[" . $selectArr['id'] . "]是合并包裹订单,不能订单合并操作。";
             return false;
         }
         //判断五:订单信息不相同判断
         $userinfsql = "SELECT * FROM om_unshipped_order_userInfo WHERE omOrderId = {$selectArr['id']}";
         $userinfsql = self::$dbConn->fetch_first($userinfsql);
         $tempArr = array();
         $tempArr['accountId'] = trim($selectArr['accountId']);
         $tempArr['platformUsername'] = trim($userinfsql['platformUsername']);
         $tempArr['username'] = trim($userinfsql['username']);
         $tempArr['countryName'] = trim($userinfsql['countryName']);
         $tempArr['state'] = trim($userinfsql['state']);
         $tempArr['city'] = trim($userinfsql['city']);
         $tempArr['street'] = trim($userinfsql['street']);
         $tempArr['currency'] = trim($userinfsql['currency']);
         //币种判断
         if (!empty($userinfo) && $userinfo != $tempArr) {
             self::$errCode = "5555";
             self::$errMsg = "订单信息不相同,无法合并订单操作。";
             return false;
         }
         $userinfo = $tempArr;
         //订单信息相同,进入下次比较。
         //判断六:同状态判断
         $orderStatus = "";
         //订单状态一
         $orderType = "";
         //订单状态二
         $orderStatus = $selectArr['orderStatus'];
         $orderType = $selectArr['orderType'];
         if (!empty($temporderStatus) && $temporderStatus != $orderStatus) {
             self::$errCode = "6666";
             self::$errMsg = "订单不在同一文件夹,无法合并订单操作。";
             return false;
         }
         $temporderStatus = $orderStatus;
         if (!empty($temporderStatus2) && $temporderStatus2 != $orderType) {
             self::$errCode = "6666";
             self::$errMsg = "订单不在同一文件夹,无法合并订单操作。";
             return false;
         }
         $orderExtensql = "SELECT * FROM om_unshipped_order_extension_" . $extension . " WHERE omOrderId = {$selectArr['id']}";
         $orderExtensql = self::$dbConn->fetch_first($orderExtensql);
         $temporderStatus2 = $orderType;
     }
     $insertOrder = array();
     $insertOrder['orderData'] = $serchSqlArr[0];
     $insert_userinfo = $userinfsql;
     unset($insert_userinfo['omOrderId']);
     $insertOrder['orderUserInfoData'] = $insert_userinfo;
     $insert_orderExtensql = $orderExtensql;
     unset($insert_orderExtensql['omOrderId']);
     $insertOrder['orderExtenData'] = $insert_orderExtensql;
     //$insertOrder['orderNote'] = $userinfsql;
     unset($insertOrder['orderData']['id']);
     $insertOrder['orderData']['onlineTotal'] = $onlineTotal;
     $insertOrder['orderData']['actualTotal'] = $actualTotal;
     $insertOrder['orderData']['calcWeight'] = $calcWeight;
     $insertOrder['orderData']['calcShipping'] = $calcShipping;
     $insertOrder['orderData']['orderAddTime'] = time();
     $insertOrder['orderData']['combineOrder'] = 2;
     $insertOrder['orderData']['orderAttribute'] = 3;
     //$insertOrder['orderDetail'] = array();
     $detailSql = "SELECT * FROM om_unshipped_order_detail WHERE omOrderId in ('" . join("','", $orderIdArr) . "') and is_delete = 0 and storeId = 1 ";
     $detailSql = self::$dbConn->query($detailSql);
     $detailSqlArr = self::$dbConn->fetch_array_all($detailSql);
     $orderDetail = array();
     foreach ($detailSqlArr as $value) {
         //$orderDetailData = array();
         //$orderDetailExtenData = array();
         $obj_orderDetail = $value;
         unset($obj_orderDetail['id']);
         unset($obj_orderDetail['omOrderId']);
         $orderDetailData = $obj_orderDetail;
         $detailExtenSql = "SELECT * FROM om_unshipped_order_detail_extension_" . $extension . " WHERE omOrderdetailId = '" . $value['id'] . "' ";
         $detailExtenSql = self::$dbConn->query($detailExtenSql);
         $detailExtenSqlArr = self::$dbConn->fetch_array($detailExtenSql);
         $obj_orderDetailExten = $detailExtenSqlArr;
         unset($obj_orderDetailExten['omOrderdetailId']);
         $orderDetailExtenData = $obj_orderDetailExten;
         $orderDetail[] = array('orderDetailData' => $orderDetailData, 'orderDetailExtenData' => $orderDetailExtenData);
     }
     $insertOrder['orderDetail'] = $orderDetail;
     //var_dump($insertOrder); exit;
     if ($insertId = OrderAddModel::insertAllOrderRowNoEvent($insertOrder)) {
         //echo $split_log .= 'insert success!' . "\n"; exit;
         //var_dump($_mainId,$_spitId); exit;
         if (!OrderLogModel::insertOrderLog($insertId, '合并产生新订单')) {
             BaseModel::rollback();
             self::$errCode = '001';
             self::$errMsg = "合并失败!";
             return false;
         }
         if (!OrderRecordModel::insertCombineRecord($serchSqlArr[0]['id'], $insertId)) {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "合并订单失败添加记录失败!";
             return false;
         }
         $updateOrder = array();
         $updateOrder['is_delete'] = 1;
         $updateOrder['combineOrder'] = 1;
         if (!OrderindexModel::updateOrder("om_unshipped_order", $updateOrder, " WHERE id in ('" . join("','", $orderSn) . "')")) {
             BaseModel::rollback();
             //事物回滚
             self::$errCode = "0012";
             self::$errMsg = "合并更新原始订单失败!";
             return false;
         }
     } else {
         //$split_log .= '补寄新订单产生失败!' . "\n";
         BaseModel::rollback();
         self::$errCode = '003';
         self::$errMsg = "合并新订单产生失败";
         return false;
     }
     BaseModel::commit();
     self::$errCode = '200';
     self::$errMsg = "合并新订单成功!";
     return TRUE;
 }
예제 #3
0
 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;
 }
예제 #4
0
 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;
 }
예제 #5
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;
 }
예제 #6
0
 public static function resendOrder($orderid, $note, $type, $old_ostatus, $old_otype)
 {
     !self::$dbConn ? self::initDB() : NULL;
     BaseModel::begin();
     //开始事务
     //$tableName = 'om_unshipped_order';
     //echo $old_ostatus; echo "<br>";
     //echo $old_otype; echo "<br>";
     $StatusMenuAct = new StatusMenuAct();
     $tableName = $StatusMenuAct->act_getOrderNameByStatus($old_ostatus, $old_otype);
     //echo $tableName;
     if ($type == 1) {
         $updatesql = 'update ' . $tableName . ' set isBuji=1,isCopy=1 where id=' . $orderid . ' and is_delete = 0 and storeId = 1';
     } else {
         $updatesql = 'update ' . $tableName . ' set isCopy=1 where id=' . $orderid . ' and is_delete = 0 and storeId = 1';
     }
     if (!self::$dbConn->query($updatesql)) {
         //更新状态失败
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         self::$errCode = '003';
         self::$errMsg = '订单信息不存在,无法复制!';
         return FALSE;
     }
     //产生新订单
     $where = ' WHERE id = ' . $orderid . ' and is_delete = 0 and storeId = 1';
     $orderData = OrderindexModel::showOrderList($tableName, $where);
     $orderDetail = $orderData[$orderid]['orderDetail'];
     if (!$orderDetail) {
         //更新状态失败
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         return FALSE;
     }
     $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);
     }
     $obj_order_data = $orderData[$orderid]['orderData'];
     if ($obj_order_data['isBuji'] == 2) {
         self::$errCode = '003';
         self::$errMsg = "补寄产生订单不能补寄!";
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         return FALSE;
     }
     if ($obj_order_data['isCopy'] == 2) {
         self::$errCode = '003';
         self::$errMsg = "复制产生订单不能复制!";
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         return FALSE;
     }
     unset($obj_order_data['id']);
     $orderExtenData = $orderData[$orderid]['orderExtenData'];
     unset($orderExtenData['omOrderId']);
     $orderUserInfoData = $orderData[$orderid]['orderUserInfoData'];
     unset($orderExtenData['omOrderId']);
     if ($type == 1) {
         $obj_order_data['isCopy'] = 2;
         $obj_order_data['actualTotal'] = 0.0;
     } else {
         $obj_order_data['isCopy'] = 2;
         $obj_order_data['isBuji'] = 2;
         $obj_order_data['actualTotal'] = 0.0;
         $obj_order_data['orderStatus'] = C('STATEBUJI');
         $obj_order_data['orderType'] = C('STATEBUJI_DONE');
     }
     $orderNote = array('content ' => $note, 'userId' => $_SESSION['sysUserId'], 'createdTime' => time());
     $insert_orderData = array();
     $insert_orderData = array('orderData' => $obj_order_data, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData, 'orderDetail' => $insert_orderDetail, 'orderNote' => $orderNote);
     //$orderNote = $orderData['orderNote'];
     //echo $insertsql;
     //var_dump($insert_orderData); exit;
     if ($insertId = OrderAddModel::insertAllOrderRowNoEvent($insert_orderData)) {
         //echo $split_log .= 'insert success!' . "\n"; exit;
         //var_dump($_mainId,$_spitId); exit;
         if (!OrderLogModel::insertOrderLog($insertId, '补寄产生订单')) {
             BaseModel::rollback();
             self::$errCode = '001';
             self::$errMsg = "补寄失败!";
             return false;
         }
         if (!OrderRecordModel::insertSendRecords($orderid, $insertId)) {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "补寄失败添加记录失败!";
             return false;
         }
     } else {
         //$split_log .= '补寄新订单产生失败!' . "\n";
         BaseModel::rollback();
         self::$errCode = '003';
         self::$errMsg = "补寄新订单产生失败";
         return false;
     }
     BaseModel::commit();
     self::$errCode = '200';
     self::$errMsg = "补寄新订单成功!";
     return TRUE;
 }