public static function applyTheLineEUBTrackNumber($recordnumber, $tracknumber)
 {
     !self::$dbConn ? self::initDB() : null;
     $SYSTEM_ACCOUNTS = OmAvailableModel::getPlatformAccount();
     $accountIds = array();
     foreach ($SYSTEM_ACCOUNTS['Amazon'] as $id => $account) {
         $accountIds[] = $id;
     }
     //print_r($SYSTEM_ACCOUNTS['Amazon']);
     $tableName = 'om_unshipped_order';
     $where = " WHERE recordNumber='{$recordnumber}' AND accountId in ('" . join("','", $accountIds) . "') AND is_delete =0 AND storeId=1 ";
     $tinfo = OrderindexModel::showOnlyOrderList($tableName, $where);
     self::$errMsg = '';
     if ($tinfo) {
         $omOrderId = $tinfo[0]['id'];
         $trackinfo = OrderindexModel::selectOrderTracknumber(" WHERE tracknumber = '" . $tracknumber . "' AND is_delete = 0 ");
         //var_dump($trackinfo);
         if ($trackinfo) {
             self::$errCode = "001";
             self::$errMsg = "  第" . $row . "行已经存在跟踪" . $tinfo['ebay_tracknumber'] . " 新跟踪号[{$tracknumber}]更新失败<br>";
             return false;
         } else {
             $data['omOrderId'] = $omOrderId;
             $data['tracknumber'] = $tracknumber;
             $data['addUser'] = $_SESSION['sysUserId'];
             $data['createdTime'] = time();
             $msg = OrderRecordModel::insertOrderTrackRow($data);
             //echo $msg;
             if (!$msg) {
                 self::$errCode = "001";
                 self::$errMsg = "   第" . $row . "行订单号[{$recordnumber}]添加跟踪号[{$tracknumber}]失败<br>";
                 return false;
             }
         }
         self::$errCode = "200";
         self::$errMsg = "获取数据成功";
         return true;
         //失败则设置错误码和错误信息, 返回false
     } else {
         self::$errCode = "001";
         self::$errMsg = "   第" . $row . "行订单号[{$recordnumber}]不是亚马孙订单或者不存在系统<br>";
         return false;
     }
 }
Beispiel #2
0
 public static function auto_contrast_intercept($orderData)
 {
     global $SYSTEM_ACCOUNTS, $__liquid_items_fenmocsku, $__liquid_items_BuiltinBattery, $__liquid_items_SuperSpecific, $__liquid_items_Paste;
     global $GLOBAL_EBAY_ACCOUNT;
     global $express_delivery, $no_express_delivery;
     if (!$SYSTEM_ACCOUNTS) {
         $__liquid_items_array = PurchaseAPIModel::getAdjustransportFromPurchase();
         //var_dump($__liquid_items_array);
         //echo time(); echo "<br>";
         $__liquid_items_postbyhkpost = array_filter(explode(",", $__liquid_items_array['液体产品']));
         //液体产品
         $__liquid_items_postbyfedex = array_filter(explode(",", $__liquid_items_array['贵重产品']));
         //贵重物品走联邦
         $__liquid_items_cptohkpost = array_filter(explode(",", $__liquid_items_array['指甲油产品']));
         //指甲油转香港小包
         $__liquid_items_elecsku = array_filter(explode(",", $__liquid_items_array['电子类产品']));
         //电子类产品走香港小包
         //$__elecsku_countrycn_array = array_filter(explode(",", $__liquid_items_array['']));//电子类产品指定国家
         $__liquid_items_fenmocsku = array_filter(explode(",", $__liquid_items_array['粉末状产品']));
         //粉末状SKU
         $__liquid_items_BuiltinBattery = array_filter(explode(",", $__liquid_items_array['内置电池产品']));
         //内置电池类产品
         $__liquid_items_SuperSpecific = array('6471', '14995');
         //超规格的产品,长度大于60cm, 三边大于 90cm
         $__liquid_items_Paste = array_filter(explode(",", $__liquid_items_array['膏状产品']));
         //膏状SKU*/
         $__liquid_items_elecWithoutBattery = array_filter(explode(",", $__liquid_items_array['电子类【不带电池】']));
         //电子类【不带电池】*/
         $__liquid_items_OutWeight = array_filter(explode(",", $__liquid_items_array['超重产品>=1.9kg']));
         //超重产品>=1.9kg*/
         //取统一包装材料重量数据
         //$MaterInfo = CommonModel::getMaterInfo();
         //取统一国家中文名对应英文名
         /*$ec = "select * from ebay_countrys where ebay_user='******' ";
         		$result = $dbConn->execute($ec);
         		$ebay_country_lists = $dbConn->getResultArray($result);
         		$global_countrycn_coutryen = array();
         		foreach($ebay_country_lists AS $ebay_country_list){
         			$global_countrycn_coutryen[trim($ebay_country_list['countryen'])] = trim($ebay_country_list['countrycn']);
         		}*/
         //取各个平台的账号名称
         $SYSTEM_ACCOUNTS = OmAvailableModel::getPlatformAccount();
         //echo "<pre>";print_r($SYSTEM_ACCOUNTS);
         $express_delivery = array();
         $express_delivery_value = array();
         $no_express_delivery = array();
         $no_express_delivery_value = array();
         $express_delivery_value = CommonModel::getCarrierListById(1);
         /*foreach($express_delivery_arr as $value){
         			$express_delivery_value[$value['id']] = $value['carrierNameCn'];
         		}*/
         $express_delivery = array_keys($express_delivery_value);
         //var_dump($express_delivery);
         $no_express_delivery_value = CommonModel::getCarrierListById(0);
         /*foreach($no_express_delivery_arr as $value){
         			$no_express_delivery_value[$value['id']] = $value['carrierNameCn'];
         		}*/
         $no_express_delivery = array_keys($no_express_delivery_value);
     }
     if (!$GLOBAL_EBAY_ACCOUNT) {
         $GLOBAL_EBAY_ACCOUNT = array();
         foreach ($SYSTEM_ACCOUNTS as $acct) {
             foreach ($acct as $key => $value) {
                 $GLOBAL_EBAY_ACCOUNT[$key] = $value;
             }
         }
     }
     //var_dump($GLOBAL_EBAY_ACCOUNT);exit;
     self::initDB();
     //var_dump($orderData); echo "\n";
     $log_data = "";
     $actualTotal0 = 0;
     //该订单实际总数
     //$ebay_id = $orderData['orderData']['id'];
     $orderStatus = empty($orderData['orderData']['orderStatus']) ? C('STATEPENDING') : $orderData['orderData']['orderStatus'];
     $orderType = empty($orderData['orderData']['orderType']) ? C('STATEPENDING_CONV') : $orderData['orderData']['orderType'];
     $returnStatus = array('orderStatus' => $orderStatus, 'orderType' => $orderType);
     $isNote = $orderData['orderData']['isNote'];
     if ($isNote) {
         $orderType = C('STATEPENDING_MSG');
     }
     $calcWeight = $orderData['orderData']['calcWeight'];
     $pmId = $orderData['orderData']['pmId'];
     //var_dump($calcWeight); echo "\n";
     $orderdetaillist = $orderData['orderDetail'];
     if (empty($calcWeight)) {
         $calcInfo = CommonModel::calcAddOrderWeight($orderdetaillist);
         //计算重量和包材
         $calcWeight = $calcInfo[0];
         $pmId = $calcInfo[1];
         $orderData['orderData']['calcWeight'] = $calcWeight;
         $orderData['orderData']['pmId'] = $pmId;
     }
     //var_dump($calcWeight); echo "\n";
     $transportId = @$orderData['orderData']['transportId'];
     $countryName = $orderData['orderUserInfoData']['countryName'];
     $accountId = $orderData['orderData']['accountId'];
     $actualTotal = $orderData['orderData']['actualTotal'];
     $ebay_username = $orderData['orderUserInfoData']['username'];
     $orderDataid = $orderData['orderExtenData']['orderId'];
     $ebay_usermail = $orderData['orderUserInfoData']['email'];
     $PayPalEmailAddress = @$orderData['orderExtenData']['PayPalEmailAddress'];
     //echo "------$countryName-----\n";
     //echo "订单计算重量:$calcWeight\t\n";
     $contain_special_item = false;
     $contain_os_item = false;
     $ow_status = array();
     //foreach ($orderdetaillist AS $orderdetail){
     for ($i = 0; $i < count($orderdetaillist); $i++) {
         $sku = $orderdetaillist[$i]['orderDetailData']['sku'];
         $itemPrice = $orderdetaillist[$i]['orderDetailData']['itemPrice'];
         $amount = $orderdetaillist[$i]['orderDetailData']['amount'];
         $shippingFee = $orderdetaillist[$i]['orderDetailData']['shippingFee'];
         //var_dump($sku);
         $sku_arr = GoodsModel::get_realskuinfo($sku);
         //var_dump($sku_arr); exit;
         $actualTotal0 += $itemPrice * $amount + $shippingFee;
         foreach ($sku_arr as $or_sku => $or_nums) {
             if (in_array($or_sku, $__liquid_items_fenmocsku) || in_array($or_sku, $__liquid_items_SuperSpecific) || in_array($or_sku, $__liquid_items_BuiltinBattery)) {
                 //粉末状,超规格产品 走福建邮局
                 $contain_special_item = true;
             }
             if (preg_match("/^US01\\+.*/", $or_sku, $matchArr) || preg_match("/^US1\\+.*/", $or_sku, $matchArr)) {
                 //$log_data .= "[".date("Y-m-d H:i:s")."]\t包含海外仓料号订单---{$ebay_id}-----料号:{$or_sku}--!\n\n";
                 $contain_os_item = true;
                 if (strpos($or_sku, "US01+") !== false) {
                     $matchStr = substr($matchArr[0], 5);
                     //去除前面
                     //$matchStr = str_replace("US1+", "", $or_sku);
                 } else {
                     //$matchStr=substr($matchArr[0],5);//去除前面
                     $matchStr = str_replace("US1+", "", $or_sku);
                 }
                 $n = strpos($matchStr, ':');
                 //寻找位置
                 if ($n) {
                     $matchStr = substr($matchStr, 0, $n);
                 }
                 //删除后面
                 if (preg_match("/^0+(\\w+)/", $matchStr, $matchArr)) {
                     $matchStr = $matchArr[1];
                 }
                 $orderData['orderDetail'][$i]['orderDetailData']['sku'] = $matchStr;
                 //OrderAddModel::updateDetailExtension(array('sku'=>$matchStr), " id = {$orderdetail['ebay_id']} ");
                 //$virtualnum = check_oversea_stock($matchStr); //检查海外仓虚拟库存
                 $virtualnum = 1;
                 //预留获取海外仓虚拟库存接口 20131225
                 if ($virtualnum >= 0) {
                     $ow_status[] = C('STATEPENDING_OVERSEA');
                     //海外仓待处理
                 } else {
                     $ow_status[] = C('STATEOUTOFSTOCK_OVERSEA');
                     //海外仓缺货
                 }
             }
         }
     }
     if ($contain_special_item) {
         /*$sql = "update ebay_order set ebay_carrierstyle ='1' where ebay_id ={$ebay_id}"; //add by Herman.Xi 记录该订单含有特殊料号
         		$dbConnn->query($sql);
         		$log_data .= "[".date("Y-m-d H:i:s")."]\t包含粉末状超规格产品---{$ebay_id}---!\n\n";*/
     }
     if ($contain_os_item) {
         if (in_array(C('STATEOUTOFSTOCK_OVERSEA'), $ow_status)) {
             $orderData['orderData']['orderStatus'] = C('STATEPENDING_OS');
             $orderData['orderData']['orderType'] = C('STATEOUTOFSTOCK_OVERSEA');
         } else {
             $orderData['orderData']['orderStatus'] = C('STATEPENDING_OS');
             $orderData['orderData']['orderType'] = C('STATEPENDING_OVERSEA');
         }
         //$log_data .= "[".date("Y-m-d H:i:s")."]\t更新海外仓料号订单状态为{$final_status}---{$ebay_id}--{$sql}-!\n\n";
         /*if($final_status == C('STATEPENDING_OVERSEA')){
         
         				$calcWeight = calcWeight($ebay_id);
         				$skunums	 = checkSkuNum($ebay_id);
         				if($skunums === true){
         					continue;
         				}else if ($calcWeight>20) {
         					if($skunums==1){
         						usCalcShipCost($ebay_id);
         					}
         				} else {
         					 usCalcShipCost($ebay_id);
         				}
         			}*/
         //$calcWeight = recalcorderweight($order_sn, $ebay_packingmaterial); //modified by Herman.Xi 2012-10-17
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t包含海外仓料号---自动跳转---的状态为---{$final_status}!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
         //continue;
     }
     $interceptrtn = self::intercept_exception_orders($orderData);
     //var_dump($interceptrtn);
     if ($interceptrtn) {
         $orderData['orderData']['orderStatus'] = $interceptrtn['orderStatus'];
         $orderData['orderData']['orderType'] = $interceptrtn['orderType'];
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
     }
     $record_details = array();
     $is_640 = false;
     //var_dump($orderdetaillist); exit;
     foreach ($orderdetaillist as $orderdetail) {
         //var_dump($orderdetail['sku']);
         $sku = $orderdetail['orderDetailData']['sku'];
         //$itemPrice = $orderdetail['orderDetailData']['itemPrice'];
         $amount = $orderdetail['orderDetailData']['amount'];
         //$shippingFee = $orderdetail['orderDetailData']['shippingFee'];
         $sku_arr = GoodsModel::get_realskuinfo($sku);
         //var_dump($sku_arr); exit;
         $hava_goodscount = true;
         foreach ($sku_arr as $or_sku => $or_nums) {
             $allnums = $or_nums * $amount;
             if (!CommonModel::check_sku($or_sku, $allnums)) {
                 //超大订单状态
                 $orderStatus = C('STATEOVERSIZEDORDERS');
                 if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['aliexpress']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['DHgate']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['出口通']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['线下结算客户'])) {
                     $orderType = C('STATEOVERSIZEDORDERS_CONFIRM');
                 } else {
                     $orderType = C('STATEOVERSIZEDORDERS_PEND');
                 }
                 //self::insert_mark_shipping($ebay_id);
                 $is_640 = true;
                 break;
             } else {
                 $skuinfo = CommonModel::get_sku_info($or_sku);
                 $salensend = CommonModel::getpartsaleandnosendall($or_sku);
                 //$log_data .= "[".date("Y-m-d H:i:s")."]\t---{$sql}\n\n";
                 $log_data .= "订单==={$ebay_id}===料号=={$or_sku}===实际库存为{$skuinfo['realnums']}===需求量为{$allnums}===待发货数量为{$salensend}===\n";
                 if (!isset($skuinfo['realnums']) || empty($skuinfo['realnums']) || $skuinfo['realnums'] - $salensend - $allnums < 0) {
                     $hava_goodscount = false;
                     break;
                 }
             }
         }
         if ($hava_goodscount) {
             $record_details[] = $orderdetail;
         }
     }
     if ($is_640) {
         $orderData['orderData']['orderStatus'] = $orderStatus;
         $orderData['orderData']['orderType'] = $orderType;
         //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
     }
     $count_record_details = count($record_details);
     $count_orderdetaillist = count($orderdetaillist);
     $final_status = $orderStatus;
     //原始状态
     if ($count_record_details == 0) {
         //更新至自动拦截发货状态
         /*if (!in_array($ebay_carrier, $no_express_delivery)){
         			$final_status = 658;
         		}else {
         			$final_status = 661;
         		}*/
         //$sql = "UPDATE ebay_order SET ebay_status='$final_status' WHERE ebay_id ='$ebay_id' and ebay_status = '{$orderStatus}' ";
         $orderStatus = C('STATEOUTOFSTOCK');
         $orderType = C('STATEOUTOFSTOCK_AO');
         //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为---".C('STATEOUTOFSTOCK_AO')."!\n\n";
         //self::insert_mark_shipping($ebay_id);
         //self::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
         $orderData['orderData']['orderStatus'] = $orderStatus;
         $orderData['orderData']['orderType'] = $orderType;
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
     } else {
         if ($count_record_details < $count_orderdetaillist) {
             //更新至自动部分发货状态
             /*if (!in_array($ebay_carrier, $no_express_delivery)){
             			//$final_status = 659;
             			$final_status = 640;
             		}else {
             			$final_status = 660;
             		}*/
             $orderStatus = C('STATEOUTOFSTOCK');
             $orderType = C('STATEOUTOFSTOCK_PO');
             //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为---".C('STATEOUTOFSTOCK_PO')."!\n\n";
             //self::insert_mark_shipping($ebay_id);
             //$returnStatus = array('orderStatus'=>C('STATEOUTOFSTOCK'), 'orderType'=>C('STATEOUTOFSTOCK_PO'));
             //self::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
             //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
             $orderData['orderData']['orderStatus'] = $orderStatus;
             $orderData['orderData']['orderType'] = $orderType;
             $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
             CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
             return $orderData;
         } else {
             if ($count_record_details == $count_orderdetaillist) {
                 //正常发货状态
                 if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['ebay'])) {
                     if (in_array($orderStatus, array(C('STATEOUTOFSTOCK_PO'), C('STATEOUTOFSTOCK_PO')))) {
                         //$final_status = 618;//ebay订单自动拦截有货不能移动到待处理和有留言 modified by Herman.Xi @ 20130325(移动到缺货需打印中)
                         $orderStatus = C('STATEPENDING');
                         if ($isNote == 1) {
                             echo "有留言\t";
                             $orderType = C('STATEPENDING_MSG');
                         } else {
                             $orderType = C('STATEPENDING_HASARRIVED');
                         }
                     } else {
                         $orderStatus = C('STATEPENDING');
                         if ($isNote == 1) {
                             echo "有留言\t";
                             $orderType = C('STATEPENDING_MSG');
                         } else {
                             $orderType = C('STATEPENDING_CONV');
                         }
                     }
                 } else {
                     if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['aliexpress'])) {
                         if (in_array($countryName, array('Russian Federation', 'Russia')) && strpos($ebay_carrier, '中国邮政') !== false && str_word_count($ebay_username) < 2) {
                             $orderStatus = C('STATESYNCINTERCEPT');
                             $orderType = C('STATESYNCINTERCEPT_AB');
                             $orderData['orderData']['orderStatus'] = $orderStatus;
                             $orderData['orderData']['orderType'] = $orderType;
                             $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
                             CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
                             return $orderData;
                         }
                     } else {
                         if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['DHgate'])) {
                             $orderStatus = C('STATEPENDING');
                             $orderType = C('STATEPENDING_CONV');
                         } else {
                             if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['dresslink.com'])) {
                                 $orderStatus = C('STATEPENDING');
                                 $orderType = C('STATEPENDING_CONV');
                             } else {
                                 if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['cndirect.com'])) {
                                     $orderStatus = C('STATEPENDING');
                                     $orderType = C('STATEPENDING_CONV');
                                 } else {
                                     if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['Amazon'])) {
                                         $orderStatus = C('STATEPENDING');
                                         $orderType = C('STATEPENDING_CONV');
                                     } else {
                                         $orderStatus = C('STATEPENDING');
                                         $orderType = C('STATEPENDING_CONV');
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($isNote == 1) {
                     echo "有留言\t";
                     $orderType = C('STATEPENDING_MSG');
                 }
                 /*if(self::judge_contain_combinesku_new($orderdetaillist)){
                 			$final_status = 606;
                 		}*/
                 if ($calcWeight > 2) {
                     echo "\t 超重订单";
                     $orderStatus = C('STATEPENDING');
                     $orderType = C('STATEPENDING_OW');
                 }
                 $expressArr = CommonModel::getCarrierInfoById(1);
                 if (in_array($transportId, $expressArr)) {
                     $orderType = C('STATEPENDING_HASARRIVED');
                 }
                 /*if (!in_array($ebay_carrier, $no_express_delivery) && !empty($ebay_carrier)){
                 			if(in_array($GLOBAL_EBAY_ACCOUNT[$accountId],$SYSTEM_ACCOUNTS['ebay']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId],$SYSTEM_ACCOUNTS['海外销售平台'])){
                 				$final_status = 641;//ebay和海外都跳转到 待打印线下和异常订单
                 			}else{
                 				$final_status = 639;
                 			}
                 		}*/
             } else {
                 $log_data .= "[" . date("Y-m-d H:i:s") . "]\t订单同步状态有误,请联系IT解决!";
             }
         }
     }
     //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
     $orderData['orderData']['orderStatus'] = $orderStatus;
     $orderData['orderData']['orderType'] = $orderType;
     $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
     //print_r($GLOBAL_EBAY_ACCOUNT);
     CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
     return $orderData;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
$__liquid_items_elecWithoutBattery = array_filter(explode(",", $__liquid_items_array['电子类【不带电池】']));
//电子类【不带电池】*/
$__liquid_items_OutWeight = array_filter(explode(",", $__liquid_items_array['超重产品>=1.9kg']));
//超重产品>=1.9kg*/
//取统一包装材料重量数据
//$MaterInfo = CommonModel::getMaterInfo();
//取统一国家中文名对应英文名
/*$ec = "select * from ebay_countrys where ebay_user='******' ";
	$result = $dbConn->execute($ec);
	$ebay_country_lists = $dbConn->getResultArray($result);
	$global_countrycn_coutryen = array();
	foreach($ebay_country_lists AS $ebay_country_list){
		$global_countrycn_coutryen[trim($ebay_country_list['countryen'])] = trim($ebay_country_list['countrycn']);
	}*/
//取各个平台的账号名称
$SYSTEM_ACCOUNTS = OmAvailableModel::getPlatformAccount();
//echo "<pre>";print_r($SYSTEM_ACCOUNTS);
$express_delivery = array();
$express_delivery_value = array();
$no_express_delivery = array();
$no_express_delivery_value = array();
$express_delivery_value = CommonModel::getCarrierListById(1);
/*foreach($express_delivery_arr as $value){
		$express_delivery_value[$value['id']] = $value['carrierNameCn'];
	}*/
$express_delivery = array_keys($express_delivery_value);
//var_dump($express_delivery);
$no_express_delivery_value = CommonModel::getCarrierListById(0);
/*foreach($no_express_delivery_arr as $value){
		$no_express_delivery_value[$value['id']] = $value['carrierNameCn'];
	}*/
 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');
 }
Beispiel #6
0
 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');
 }