function act_sureAddOrder() { $order_data = array(); $detail_data = array(); $exten_data = array(); $userinfo_data = array(); $buyer_data = array(); $time = time(); $platform_id = trim($_POST['platform']); $username = trim($_POST['fullname']); $account_id = trim($_POST['account']); $street1 = trim($_POST['street1']); $platformUsername = trim($_POST['userid']); $email = trim($_POST['ebay_usermail1']); $street2 = trim($_POST['street2']); $recordNumber = trim($_POST['orderid']); $city = trim($_POST['city']); $ordersTime = strtotime(trim($_POST['ebay_createdtime'])); $state = trim($_POST['state']); $paymentTime = strtotime(trim($_POST['ebay_paidtime'])); $countryname = trim($_POST['country']); $ebay_itemprice = trim($_POST['ebay_itemprice']); $zipCode = trim($_POST['zip']); $shippingFee = trim($_POST['ebay_shipfee']); $ebay_tel1 = trim($_POST['tel1']); $actualTotal = trim($_POST['ebay_total']); $ebay_tel2 = trim($_POST['tel2']); $ebay_tel3 = trim($_POST['tel3']); $currency = trim($_POST['ebay_currency']); $other_currency = trim($_POST['other_currency']); $isCheckOrder = self::act_checkOrder(); $returnArr = array(); //返回的数组信息 if (!$isCheckOrder) { $returnArr['errCode'] = self::$errCode; $returnArr['errMsg'] = self::$errMsg; return $returnArr; } if ($currency == '其他') { $currency = $other_currency; } $phone = trim($_POST['tel1']); $transId = trim($_POST['ebay_ptid']); $other_ptid = trim($_POST['other_ptid']); if ($transId == 'paypal' || $transId == 'Escrow' || $transId == '其他') { $transId = $other_ptid; } $PayPalPaymentId = $transId; $orderweight = trim($_POST['orderweight']); $ebay_usermail2 = trim($_POST['ebay_usermail2']); $ebay_carrier = trim($_POST['ebay_carrier']); $ebay_usermail3 = trim($_POST['ebay_usermail3']); $ebay_tracknumber = trim($_POST['ebay_tracknumber']); $ebay_noteb = trim($_POST['ebay_noteb']); $orderStatus = 100; $orderType = 101; $tracknumber = trim($_POST['ebay_tracknumber']); //order信息 $orderData[$recordNumber]['orderData']['recordNumber'] = $recordNumber; $orderData[$recordNumber]['orderData']['ordersTime'] = $ordersTime; $orderData[$recordNumber]['orderData']['paymentTime'] = $paymentTime; $orderData[$recordNumber]['orderData']['actualTotal'] = $actualTotal; $orderData[$recordNumber]['orderData']['onlineTotal'] = $actualTotal; //默认线上总价和实际总价一样 $orderData[$recordNumber]['orderData']['orderAddTime'] = time(); //$orderData[$recordNumber]['orderData']['calcWeight'] = $orderweight;//估算重量 $orderData[$recordNumber]['orderData']['accountId'] = $account_id; $orderData[$recordNumber]['orderData']['platformId'] = $platform_id; //添加状态信息 $orderData[$recordNumber]['orderData']['orderStatus'] = 100; $orderData[$recordNumber]['orderData']['orderType'] = 101; $SYS_ACCOUNTS = OmAvailableModel::getPlatformAccount(); foreach ($SYS_ACCOUNTS as $platform => $accounts) { foreach ($accounts as $accountId => $accountname) { if ($account_id == $accountId) { if ($platform == 'ebay') { //为ebay平台 $orderData[$recordNumber]['orderData']['isFixed'] = 2; } else { $orderData[$recordNumber]['orderData']['isFixed'] = 1; } } } } $transportation = CommonModel::getCarrierList(); //所有的 foreach ($transportation as $tranValue) { if ($tranValue['id'] == $ebay_carrier) { $orderData[$recordNumber]['orderData']['transportId'] = $tranValue['id']; break; } } //order扩展信息 $orderData[$recordNumber]['orderExtenData']['currency'] = $currency; $orderData[$recordNumber]['orderExtenData']['paymentStatus'] = "PAY_SUCCESS"; //$orderData[$recordNumber]['orderExtenData']['transId'] = $transId; $orderData[$recordNumber]['orderExtenData']['PayPalPaymentId'] = $PayPalPaymentId; $orderData[$recordNumber]['orderExtenData']['platformUsername'] = $platformUsername; //user信息 $orderData[$recordNumber]['orderUserInfoData']['platformUsername'] = $platformUsername; $orderData[$recordNumber]['orderUserInfoData']['username'] = $username; $orderData[$recordNumber]['orderUserInfoData']['email'] = $email; $orderData[$recordNumber]['orderUserInfoData']['street'] = $street1; $orderData[$recordNumber]['orderUserInfoData']['currency'] = $currency; $orderData[$recordNumber]['orderUserInfoData']['address2'] = $street2; $orderData[$recordNumber]['orderUserInfoData']['city'] = $city; $orderData[$recordNumber]['orderUserInfoData']['state'] = $state; $orderData[$recordNumber]['orderUserInfoData']['zipCode'] = $zipCode; $orderData[$recordNumber]['orderUserInfoData']['countryName'] = $countryname; $orderData[$recordNumber]['orderUserInfoData']['landline'] = !empty($ebay_tel2) ? $ebay_tel2 : $ebay_tel3; $orderData[$recordNumber]['orderUserInfoData']['phone'] = $phone; //note信息 if (!empty($ebay_noteb)) { $orderData[$recordNumber]['orderNote']['content'] = $ebay_noteb; $orderData[$recordNumber]['orderNote']['userId'] = $_SESSION['sysUserId']; $orderData[$recordNumber]['orderNote']['createdTime'] = time(); } //tracknumer信息 $orderData[$recordNumber]['orderTrack']['tracknumber'] = $tracknumber; $sku_list = $_POST['sku']; $sku_count = $_POST['qty']; $ebay_itemtitle = $_POST['name']; $count = count($sku_list); for ($i = 0; $i < $count; $i++) { //detail信息 $sku = $sku_list[$i]; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku_list[$i]; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] += $sku_count[$i]; //累加 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['recordNumber'] = $recordNumber; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['createdTime'] = time(); $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $ebay_itemtitle[$i]; } foreach ($orderData as $id => $order) { //$orderData 中第一维只有一个元素,方便起见这里用foreach,虽然只循环一次 $ret = commonModel::checkOrder($recordNumber); if ($ret) { $returnArr['errCode'] = 101; $returnArr['errMsg'] = "订单{$recordNumber}已存在!"; return $returnArr; } //计算订单属性 if (count($order['orderDetail']) == 1) { $detail = current($order['orderDetail']); if ($detail['orderDetailData']['amount'] == 1) { $orderData[$id]['orderData']['orderAttribute'] = 1; } else { $orderData[$id]['orderData']['orderAttribute'] = 2; } } else { $orderData[$id]['orderData']['orderAttribute'] = 3; } //计算订单重量及包材 $obj_order_detail_data = array(); foreach ($order['orderDetail'] as $sku => $detail) { $obj_order_detail_data[] = $detail['orderDetailData']; } $weightfee = commonModel::calcOrderWeight($obj_order_detail_data); $orderData[$id]['orderData']['calcWeight'] = $weightfee[0]; $orderData[$id]['orderData']['pmId'] = $weightfee[1]; $calcShippingInfo = CommonModel::calcAddOrderShippingFee($orderData[$id], $orderData[$id]['orderData']['isFixed']); //计算运费 $orderData[$id]['orderData']['channelId'] = $calcShippingInfo['channelId']; $orderData[$id]['orderData']['calcShipping'] = $calcShippingInfo['fee']; //调用旧系统接口,先插入数据到旧系统 $rtn = OldsystemModel::orderErpInsertorder($orderData[$id]); $insertData = array(); if (empty($rtn)) { $returnArr['errCode'] = 102; $returnArr['errMsg'] = "接口返回异常,请重试!"; return $returnArr; } if ($rtn['errcode'] == 200) { $rtn_data = $rtn['data']; $orderId = $rtn_data['orderId']; //echo "插入老系统成功,订单编号 [$orderId] \n"; $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[$id]['orderData']['id'] = $orderId; //赋予新系统订单编号 if ($orderData['orderData']['calcWeight'] != $totalweight) { $insertData['old_totalweight'] = $totalweight; $insertData['new_totalweight'] = $orderData[$id]['orderData']['calcWeight']; $orderData[$id]['orderData']['calcWeight'] = $totalweight; } if ($orderData['orderData']['pmId'] != $pmId) { $insertData['old_pmId'] = $pmId; $insertData['new_pmId'] = $orderData[$id]['orderData']['pmId']; $orderData[$id]['orderData']['pmId'] = $pmId; } if ($orderData['orderData']['calcShipping'] != $shipfee) { $insertData['old_shippfee'] = $shipfee; $insertData['new_shippfee'] = $orderData[$id]['orderData']['calcShipping']; $orderData[$id]['orderData']['calcShipping'] = $shipfee; } if ($orderData['orderData']['transportId'] != $carrierId) { $insertData['old_carrierId'] = $carrierId; $insertData['new_carrierId'] = $orderData[$id]['orderData']['transportId']; $orderData[$id]['orderData']['transportId'] = $carrierId; } if (!empty($insertData)) { $insertData['ebay_id'] = $orderId; $insertData['addtime'] = time(); //var_dump($insertData); OldsystemModel::insertTempSyncRecords($insertData); // 插入临时对比记录表 } //缺货拦截 $orderData[$id] = AutoModel::auto_contrast_intercept($orderData[$id]); //插入订单 $info = OrderAddModel::insertAllOrderRowNoEvent($orderData[$id]); if ($info) { $returnArr['errCode'] = 200; $returnArr['errMsg'] = "订单{$id}上传成功!"; } else { $returnArr['errCode'] = 404; $returnArr['errMsg'] = "订单{$id}上传失败!"; } } else { $returnArr['errCode'] = 400; $returnArr['errMsg'] = "添加失败,原因为:{$rtn['msg']}!"; } } return $returnArr; }
public function act_transportFee() { $omOrderId = $_POST['id']; $tableName = 'om_unshipped_order'; $where = ' WHERE id = ' . $omOrderId; $orderList = OrderindexModel::showOrderList($tableName, $where); $orderData = $orderList[$omOrderId]; $data = array(); //print_r($orderData); $obj_order_detail_data = array(); foreach ($orderData['orderDetail'] as $sku => $detail) { $obj_order_detail_data[] = $detail['orderDetailData']; } $weightfee = commonModel::calcOrderWeight($obj_order_detail_data); $data['calcWeight'] = $weightfee[0]; $calcShippingInfo = CommonModel::calcAddOrderShippingFee($orderData, 1); //计算运费 //var_dump($calcShippingInfo); exit; $calcInfo = CommonModel::calcAddOrderWeight($orderData['orderDetail']); //计算重量和包材 //var_dump($calcInfo); exit; $data['calcWeight'] = $calcInfo[0]; $data['pmId'] = $calcInfo[1]; $data['calcShipping'] = $calcShippingInfo['fee']['fee']; $data['channelId'] = $calcShippingInfo['fee']['channelId']; if (OrderindexModel::updateOrder($tableName, $data, $where)) { self::$errCode = OrderindexModel::$errCode; self::$errMsg = OrderindexModel::$errMsg; return true; } else { self::$errCode = OrderindexModel::$errCode; self::$errMsg = OrderindexModel::$errMsg; return false; } }
public function view_guoneiSaleImport() { //var_dump($_POST);//exit; include_once WEB_PATH . "lib/PHPExcel.php"; //phpexcel include_once WEB_PATH . "conf/scripts/script.ebay.config.php"; //global $SYSTEM_ACCOUNTS,$__liquid_items_fenmocsku,$__liquid_items_BuiltinBattery,$__liquid_items_SuperSpecific,$__liquid_items_Paste; $toptitle = '速卖通线下订单导入'; //头部title $this->smarty->assign('toptitle', $toptitle); $this->smarty->assign('toplevel', 2); $this->smarty->assign('secondlevel', 220); $OmAccountAct = new OmAccountAct(); $aliexpressAccountList = $OmAccountAct->act_getINNERAccountList(); $this->smarty->assign("aliexpressAccountList", $aliexpressAccountList); if (isset($_FILES['aliexpressFile']['tmp_name'])) { $filePath = $_FILES['aliexpressFile']['tmp_name']; $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel2007(); if (!$PHPReader->canRead($filePath)) { $PHPReader = new PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return; } } $PHPExcel = $PHPReader->load($filePath); $currentSheet = $PHPExcel->getSheet(0); //$excellists = excel2array($PHPExcel, $filePath, 0, 0); //print_r($excellists);print_r($_SESSION); $orderid = array(); $orderData = array(); //$orderarr = OrderindexModel::showSearchOrderList("om_unshipped_order","where da.id=14448"); //echo "<pre>";print_r($orderarr); $account = $_POST['aliexpressAccount']; $transportation = CommonModel::getCarrierList(); //所有的 $c = 2; while (true) { $aa = 'A' . $c; $bb = 'B' . $c; $cc = 'C' . $c; $dd = 'D' . $c; $ee = 'E' . $c; $ff = 'F' . $c; $gg = 'G' . $c; $hh = 'H' . $c; $ii = 'I' . $c; $jj = 'J' . $c; $kk = 'K' . $c; $ll = 'L' . $c; $mm = 'M' . $c; $nn = 'N' . $c; $oo = 'O' . $c; $pp = 'P' . $c; $qq = 'Q' . $c; $rr = 'R' . $c; $ss = 'S' . $c; $tt = 'T' . $c; $uu = 'U' . $c; $vv = 'V' . $c; $ww = 'W' . $c; $xx = 'X' . $c; $yy = 'Y' . $c; $zz = 'Z' . $c; $c++; $recordNumber = trim($currentSheet->getCell($aa)->getValue()); $userId = trim($currentSheet->getCell($bb)->getValue()); $skuStr = trim($currentSheet->getCell($cc)->getValue()); $amount = trim($currentSheet->getCell($dd)->getValue()); $countryName = trim($currentSheet->getCell($ee)->getValue()); $actualTotal = trim($currentSheet->getCell($ff)->getValue()); $currency = trim($currentSheet->getCell($gg)->getValue()); $street1 = trim($currentSheet->getCell($hh)->getValue()); $street2 = trim($currentSheet->getCell($ii)->getValue()); $carrierNameCn = trim($currentSheet->getCell($jj)->getValue()); $city = trim($currentSheet->getCell($kk)->getValue()); $state = trim($currentSheet->getCell($ll)->getValue()); $zipCode = trim($currentSheet->getCell($mm)->getValue()); $phone = trim($currentSheet->getCell($nn)->getValue()); $trackNumber = trim($currentSheet->getCell($oo)->getValue()); $noteStr = trim($currentSheet->getCell($pp)->getValue()); $ordersTime = time(); $paymentTime = time(); $email = ''; $onlineTotal = ''; $shippingFee = ''; $transId = ''; $note = ''; $username = $userId; $platformUsername = $userId; $PayPalPaymentId = $transId; if (empty($recordNumber)) { break; } $skuArrlist = explode(',', $skuStr); $noteArr = explode(',', $noteStr); $skuCount = count($skuArrlist); for ($i = 0; $i < $skuCount; $i++) { list($sku, $amount) = explode('*', $skuArrlist[$i]); //echo "--sku=$sku---amount=$amount-------"; //detail信息 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] = $amount; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['recordNumber'] = $recordNumber; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['createdTime'] = time(); $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $noteArr[$i]; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['transId'] = $transId; if (!empty($note)) { $orderData[$recordNumber]['orderNote'][$c]['content'] = $note; $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId']; } } //order信息 $orderData[$recordNumber]['orderData']['recordNumber'] = $recordNumber; $orderData[$recordNumber]['orderData']['ordersTime'] = $ordersTime; $orderData[$recordNumber]['orderData']['paymentTime'] = $paymentTime; $orderData[$recordNumber]['orderData']['onlineTotal'] = $onlineTotal; $orderData[$recordNumber]['orderData']['actualTotal'] = $actualTotal; $orderData[$recordNumber]['orderData']['actualShipping'] = $shippingFee; $orderData[$recordNumber]['orderData']['calcShipping'] = $shippingFee; $orderData[$recordNumber]['orderData']['orderAddTime'] = time(); $orderData[$recordNumber]['orderData']['orderStatus'] = 100; $orderData[$recordNumber]['orderData']['orderType'] = 101; $SYS_ACCOUNTS = OmAvailableModel::getTNameList("om_account", "*", " where account='{$account}'"); $orderData[$recordNumber]['orderData']['accountId'] = $SYS_ACCOUNTS[0]['id']; $orderData[$recordNumber]['orderData']['platformId'] = $SYS_ACCOUNTS[0]['platformId']; $plataccountId = $SYS_ACCOUNTS[0]['id']; $platformId = $SYS_ACCOUNTS[0]['platformId']; $SYS_ACCOUNTS = OmAvailableModel::getPlatformAccount(); foreach ($SYS_ACCOUNTS as $platform => $accounts) { foreach ($accounts as $accountId => $accountname) { if ($account == $accountname) { if ($platform == "ebay") { $orderData[$recordNumber]['orderData']['isFixed'] = 2; } else { $orderData[$recordNumber]['orderData']['isFixed'] = 1; } } } } foreach ($transportation as $tranValue) { if ($tranValue['carrierNameCn'] == $carrierNameCn) { $orderData[$recordNumber]['orderData']['transportId'] = $tranValue['id']; break; } } if ($trackNumber != '') { $orderData[$recordNumber]['orderTrack']['tracknumber'] = $trackNumber; $orderData[$recordNumber]['orderTrack']['addUser'] = $_SESSION['sysUserId']; $orderData[$recordNumber]['orderTrack']['createdTime'] = time(); } //order扩展信息 $orderData[$recordNumber]['orderExtenData']['currency'] = $currency; $orderData[$recordNumber]['orderExtenData']['paymentStatus'] = "PAY_SUCCESS"; $orderData[$recordNumber]['orderExtenData']['transId'] = $recordNumber; // 交易id;; $orderData[$recordNumber]['orderExtenData']['PayPalPaymentId'] = $PayPalPaymentId; $orderData[$recordNumber]['orderExtenData']['platformUsername'] = $platformUsername; $orderData[$recordNumber]['orderExtenData']['currency'] = $currency; //user信息 $orderData[$recordNumber]['orderUserInfoData']['platformUsername'] = $platformUsername; $orderData[$recordNumber]['orderUserInfoData']['username'] = $username; $orderData[$recordNumber]['orderUserInfoData']['email'] = $email; $orderData[$recordNumber]['orderUserInfoData']['street'] = $street1; $orderData[$recordNumber]['orderUserInfoData']['address2'] = ${$street2}; $orderData[$recordNumber]['orderUserInfoData']['currency'] = $currency; //$orderData[$recordNumber]['orderUserInfoData']['address3'] = $address3; $orderData[$recordNumber]['orderUserInfoData']['city'] = $city; $orderData[$recordNumber]['orderUserInfoData']['state'] = $state; $orderData[$recordNumber]['orderUserInfoData']['zipCode'] = $zipCode; $orderData[$recordNumber]['orderUserInfoData']['countryName'] = $countryName; $orderData[$recordNumber]['orderUserInfoData']['landline'] = $phone; $orderData[$recordNumber]['orderUserInfoData']['phone'] = $phone; //note信息 if (!empty($note)) { $orderData[$recordNumber]['orderNote'][$c]['content'] = $note; $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId']; } } //print_r($orderData); //echo "<pre>";print_r($orderData);//exit; $message = ""; foreach ($orderData as $id => $order) { //echo $id; //$msg = commonModel::checkOrder($id); $msg = commonModel::checkRecordNumber($id, $platformId, $plataccountId); if ($msg) { $message .= "<font color='red'>订单{$id}已存在!</font><br>"; continue; } //计算订单属性 if (count($order['orderDetail']) == 1) { $detail = current($order['orderDetail']); if ($detail['orderDetailData']['amount'] == 1) { $orderData[id]['orderData']['orderAttribute'] = 1; } else { $orderData[id]['orderData']['orderAttribute'] = 2; } } else { $orderData[id]['orderData']['orderAttribute'] = 3; } //计算订单重量及包材 $obj_order_detail_data = array(); foreach ($order['orderDetail'] as $sku => $detail) { $obj_order_detail_data[] = $detail['orderDetailData']; } $weightfee = commonModel::calcOrderWeight($obj_order_detail_data); $orderData[$id]['orderData']['calcWeight'] = $weightfee[0]; //$orderData[$value[0]]['orderData']['calcShipping'] = $weightfee[3]; $orderData[$id]['orderData']['pmId'] = $weightfee[1]; //计算运费 $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, $orderData[$id]['orderData']['isFixed']); //计算运费 $orderData[$id]['orderData']['channelId'] = $calcShippingInfo['fee']['channelId']; //$orderData[$id]['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee']; //缺货拦截 $orderData[$id] = AutoModel::auto_contrast_intercept($orderData[$id]); /*$orderData[$id]['orderData']['orderStatus'] = $status['orderStatus']; $orderData[$id]['orderData']['orderType'] = $status['orderType'];*/ //echo "<pre>";print_r($orderData[$id]); //print_r($orderData); //exit; //插入订单 $info = OrderAddModel::insertAllOrderRowNoEvent($orderData[$id]); if ($info) { $message .= "<font color='green'>订单{$id}上传成功!</font><br>"; } else { $message .= "<font color='red'>订单{$id}上传失败!</font><br>"; } } $this->smarty->assign("showerrorinfo", $message); //header("location:index.php?mod=underLineOrderImport&act=importOrder"); } $this->smarty->display('guoneiSaleImport.htm'); }
public function view_aliexpressimport() { $this->smarty->assign('toplevel', 2); $this->smarty->assign('secondlevel', 24); $OmAccountAct = new OmAccountAct(); //$aliexpressAccountList = $OmAccountAct->act_getAccountListByPid(2); $aliexpressAccountList = $OmAccountAct->act_getAccountListAliexpress(); var_dump($aliexpressAccountList); $aliexpressAccountList = json_decode($aliexpressAccountList, true); $this->smarty->assign("aliexpressAccountList", $aliexpressAccountList); $this->smarty->display('aliexpressImport.htm'); include_once WEB_PATH . "lib/PHPExcel.php"; //phpexcel $toptitle = 'underLineOrderImport'; //头部title $this->smarty->assign('toptitle', $toptitle); $this->smarty->assign('toplevel', 2); $this->smarty->assign('secondlevel', 22); if (isset($_FILES['orderUpfile']['tmp_name'])) { $filePath = $_FILES['orderUpfile']['tmp_name']; $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel2007(); if (!$PHPReader->canRead($filePath)) { $PHPReader = new PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return; } } $PHPExcel = $PHPReader->load($filePath); $currentSheet = $PHPExcel->getSheet(0); //$excellists = excel2array($PHPExcel, $filePath, 0, 0); //print_r($excellists);print_r($_SESSION); $orderid = array(); $orderData = array(); //$orderarr = OrderindexModel::showSearchOrderList("om_unshipped_order","where da.id=14448"); //echo "<pre>";print_r($orderarr); $c = 2; while (true) { $aa = 'A' . $c; $bb = 'B' . $c; $cc = 'C' . $c; $dd = 'D' . $c; $ee = 'E' . $c; $ff = 'F' . $c; $gg = 'G' . $c; $hh = 'H' . $c; $ii = 'I' . $c; $jj = 'J' . $c; $kk = 'K' . $c; $ll = 'L' . $c; $mm = 'M' . $c; $nn = 'N' . $c; $oo = 'O' . $c; $pp = 'P' . $c; $qq = 'Q' . $c; $rr = 'R' . $c; $ss = 'S' . $c; $tt = 'T' . $c; $uu = 'U' . $c; $vv = 'V' . $c; $ww = 'W' . $c; $xx = 'X' . $c; $yy = 'Y' . $c; $zz = 'Z' . $c; $c++; $account = trim($currentSheet->getCell($aa)->getValue()); $recordNumber = trim($currentSheet->getCell($bb)->getValue()); $platformUsername = trim($currentSheet->getCell($cc)->getValue()); $email = trim($currentSheet->getCell($dd)->getValue()); $ordersTime = trim($currentSheet->getCell($ee)->getValue()); $paymentTime = trim($currentSheet->getCell($ff)->getValue()); $sku = trim($currentSheet->getCell($gg)->getValue()); $amount = trim($currentSheet->getCell($hh)->getValue()); $itemTitle = trim($currentSheet->getCell($ii)->getValue()); $note = trim($currentSheet->getCell($jj)->getValue()); $itemPrice = trim($currentSheet->getCell($kk)->getValue()); $shippingFee = trim($currentSheet->getCell($ll)->getValue()); $actualTotal = trim($currentSheet->getCell($mm)->getValue()); $currency = trim($currentSheet->getCell($nn)->getValue()); $transId = trim($currentSheet->getCell($oo)->getValue()); $username = trim($currentSheet->getCell($pp)->getValue()); $street = trim($currentSheet->getCell($qq)->getValue()); $address2 = trim($currentSheet->getCell($rr)->getValue()); $address3 = trim($currentSheet->getCell($ss)->getValue()); $city = trim($currentSheet->getCell($tt)->getValue()); $state = trim($currentSheet->getCell($uu)->getValue()); $zipCode = trim($currentSheet->getCell($vv)->getValue()); $countryName = trim($currentSheet->getCell($ww)->getValue()); $landline = trim($currentSheet->getCell($xx)->getValue()); $carrierNameCn = trim($currentSheet->getCell($yy)->getValue()); if (empty($account)) { break; } if (in_array($recordNumber, $orderid)) { $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] = $amount; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['itemPrice'] = $itemPrice; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['shippingFee'] = $shippingFee; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $itemTitle; //$orderData['orderDetail']['orderDetailExtenData']['note'] = $value[10]; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['transId'] = $transId; if (!empty($note)) { $orderData[$recordNumber]['orderNote'][$c]['content'] = $note; $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId']; } } else { $orderid[] = $recordNumber; //order信息 $orderData[$recordNumber]['orderData']['recordNumber'] = $recordNumber; $orderData[$recordNumber]['orderData']['ordersTime'] = strtotime($ordersTime); $orderData[$recordNumber]['orderData']['paymentTime'] = strtotime($paymentTime); $orderData[$recordNumber]['orderData']['actualTotal'] = $actualTotal; $orderData[$recordNumber]['orderData']['orderAddTime'] = time(); $SYSTEM_ACCOUNTS = OmAvailableModel::getTNameList("om_account", "*", " where account='{$account}'"); $orderData[$recordNumber]['orderData']['accountId'] = $SYSTEM_ACCOUNTS[0]['id']; $orderData[$recordNumber]['orderData']['platformId'] = $SYSTEM_ACCOUNTS[0]['platformId']; $SYSTEM_ACCOUNTS = OmAvailableModel::getPlatformAccount(); foreach ($SYSTEM_ACCOUNTS as $platform => $accounts) { foreach ($accounts as $accountId => $accountname) { if ($account == $accountname) { if ($platform == "ebay") { $orderData[$recordNumber]['orderData']['isFixed'] = 2; } else { $orderData[$recordNumber]['orderData']['isFixed'] = 1; } } } } $transportation = CommonModel::getCarrierList(); //所有的 foreach ($transportation as $tranValue) { if ($tranValue['carrierNameCn'] == $carrierNameCn) { $orderData[$recordNumber]['orderData']['transportId'] = $tranValue['id']; break; } //$transportationList[$tranValue['id']] = $tranValue['carrierNameCn']; } //order扩展信息 $orderData[$recordNumber]['orderExtenData']['currency'] = $currency; $orderData[$recordNumber]['orderExtenData']['paymentStatus'] = "PAY_SUCCESS"; $orderData[$recordNumber]['orderExtenData']['transId'] = $recordNumber; // 交易id;; $orderData[$recordNumber]['orderExtenData']['platformUsername'] = $platformUsername; //$orderData[$recordNumber]['orderExtenData']['currency'] = $currency; //user信息 $orderData[$recordNumber]['orderUserInfoData']['platformUsername'] = $platformUsername; $orderData[$recordNumber]['orderUserInfoData']['username'] = $username; $orderData[$recordNumber]['orderUserInfoData']['email'] = $email; $orderData[$recordNumber]['orderUserInfoData']['street'] = $street; $orderData[$recordNumber]['orderUserInfoData']['currency'] = $currency; $orderData[$recordNumber]['orderUserInfoData']['address2'] = $address2; $orderData[$recordNumber]['orderUserInfoData']['address3'] = $address3; $orderData[$recordNumber]['orderUserInfoData']['city'] = $city; $orderData[$recordNumber]['orderUserInfoData']['state'] = $state; $orderData[$recordNumber]['orderUserInfoData']['zipCode'] = $zipCode; $orderData[$recordNumber]['orderUserInfoData']['countryName'] = $countryName; $orderData[$recordNumber]['orderUserInfoData']['landline'] = $landline; //detail信息 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] = $amount; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['itemPrice'] = $itemPrice; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['shippingFee'] = $shippingFee; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['recordNumber'] = $recordNumber; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['createdTime'] = time(); $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $itemTitle; //$orderData['orderDetail']['orderDetailExtenData']['note'] = $value[10]; $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['transId'] = $transId; //note信息 if (!empty($note)) { $orderData[$recordNumber]['orderNote'][$c]['content'] = $note; $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId']; } } } //echo "<pre>";print_r($orderData); $message = ""; foreach ($orderData as $id => $order) { $msg = commonModel::checkOrder($id); if ($msg) { $message .= "<font color='red'>订单{$id}已存在!</font><br>"; continue; } //计算订单属性 if (count($order['orderDetail']) == 1) { $detail = current($order['orderDetail']); if ($detail['orderDetailData']['amount'] == 1) { $orderData[id]['orderData']['orderAttribute'] = 1; } else { $orderData[id]['orderData']['orderAttribute'] = 2; } } else { $orderData[id]['orderData']['orderAttribute'] = 3; } //计算订单重量及包材 $obj_order_detail_data = array(); foreach ($order['orderDetail'] as $sku => $detail) { $obj_order_detail_data[] = $detail['orderDetailData']; } $weightfee = commonModel::calcOrderWeight($obj_order_detail_data); $orderData[$id]['orderData']['calcWeight'] = $weightfee[0]; //$orderData[$value[0]]['orderData']['calcShipping'] = $weightfee[3]; $orderData[$id]['orderData']['pmId'] = $weightfee[1]; //计算运费 $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, $orderData[$id]['orderData']['isFixed']); //计算运费 $orderData[$id]['orderData']['channelId'] = $calcShippingInfo['fee']['channelId']; //缺货拦截 $status = commonModel::auto_contrast_intercept($orderData[$id]); $orderData[$id]['orderData']['orderStatus'] = $status['orderStatus']; $orderData[$id]['orderData']['orderType'] = $status['orderType']; //print_r($order); //插入订单 $info = OrderAddModel::insertAllOrderRowNoEvent($order); if ($info) { $message .= "<font color='green'>订单{$id}上传成功!</font><br>"; } else { $message .= "<font color='red'>订单{$id}上传失败!</font><br>"; } } $this->smarty->assign("showerrorinfo", $message); //header("location:index.php?mod=underLineOrderImport&act=importOrder"); } $this->smarty->display('underLineOrderImport.htm'); }