public static function auditOrder($orderid, $sku, $type, $status, $purchaseId, $note = '', $storeId = 1) { //exit; !self::$dbConn ? self::initDB() : NULL; $res = array(); //var_dump($orderid, $sku, $type, $status, $purchaseId); $ordercheck = "select * from om_unshipped_order where id = {$orderid} and is_delete = 0 and storeId = " . $storeId; $ordercheck = self::$dbConn->query($ordercheck); $ordercheck = self::$dbConn->fetch_array($ordercheck); if (empty($ordercheck)) { self::$errCode = 502; self::$errMsg = '未找到对应的订单!'; return false; } else { $notecontent = ''; if (!empty($note)) { $notecontent = " , note = '{$note}' "; } $c_sql = "select * from om_records_order_audit where omOrderId={$orderid} and sku='{$sku}' "; //echo $c_sql; $c_sql = self::$dbConn->query($c_sql); $c_sql = self::$dbConn->fetch_array_all($c_sql); //var_dump($c_sql); if (empty($c_sql)) { $sql = "INSERT INTO om_records_order_audit SET omOrderId={$orderid},sku='{$sku}',auditUser='******',auditTime=" . time() . ",lastModified=" . time() . ",auditStatus='{$status}'" . $notecontent; //echo $sql; } else { $sql = "UPDATE om_records_order_audit SET lastModified=" . time() . ",auditStatus='{$status}'" . $notecontent . " WHERE omOrderId={$orderid} AND sku='{$sku}'"; } if (self::$dbConn->query($sql)) { //echo "insert auit log"; echo "<br>"; } //BaseModel :: begin(); //开始事务 /*if($type=='1'){*/ $ch_sql = "SELECT a.sku,a.omOrderId as detail_id FROM om_unshipped_order_detail AS a WHERE a.omOrderId='{$orderid}' "; $ch_sql = self::$dbConn->query($ch_sql); $check_array = self::$dbConn->fetch_array_all($ch_sql); $isend = true; $status_arr = array(); $array_sku = array(); //echo "<pre>"; //var_dump($check_array); foreach ($check_array as $check_sku) { $array_sku = GoodsModel::get_realskuinfo($check_sku['sku']); //var_dump($array_sku); foreach ($array_sku as $key_sku => $num) { $compare_sql = "SELECT sku,auditStatus FROM om_records_order_audit WHERE omOrderId='{$orderid}' and sku='{$key_sku}' "; //echo $compare_sql; echo "<br>"; $compare_sql = self::$dbConn->query($compare_sql); $compare_sql = self::$dbConn->fetch_array($compare_sql); if (empty($compare_sql)) { $isend = false; break; } else { if (!in_array($compare_sql['auditStatus'], $status_arr)) { array_push($status_arr, $compare_sql['auditStatus']); } } } } //var_dump($isend); //var_dump($status_arr); exit; if ($isend) { if (in_array(1, $status_arr) && in_array(2, $status_arr)) { $updateArr = array('orderStatus' => C('STATEOVERSIZEDORDERS'), 'orderType' => C('STATEOVERSIZEDORDERS_PA')); } else { if (in_array(1, $status_arr)) { if ($ordercheck['calcWeight'] > 2) { $updateArr = array('orderStatus' => C('STATEPENDING'), 'orderType' => C('STATEPENDING_OW')); } else { $updateArr = array('orderStatus' => C('STATEOVERSIZEDORDERS'), 'orderType' => C('STATEOVERSIZEDORDERS_TA')); } } else { if (in_array(2, $status_arr)) { $updateArr = array('orderStatus' => C('STATEOVERSIZEDORDERS'), 'orderType' => C('STATEOVERSIZEDORDERS_WB')); } } } /*else{ }*/ //var_dump($updateArr); //$sql = "UPDATE om_unshipped_order SET ".array2sql($updateArr)." where id={$orderid} AND orderStatus = '".C('STATEOVERSIZEDORDERS')."' AND orderType = '".C('STATEOVERSIZEDORDERS_PEND')."' AND is_delete = 0 "; $sql = "UPDATE om_unshipped_order SET " . array2sql($updateArr) . " where id={$orderid} AND orderStatus = '" . C('STATEOVERSIZEDORDERS') . "' AND is_delete = 0 "; //$log_data .= $sql."\n"; if (self::$dbConn->query($sql)) { //echo "update order success"; } /*else{ echo "update order error"; }*/ //BaseModel :: commit(); //BaseModel :: autoCommit(); } else { /*self::$errCode = 040; self::$errMsg = '审核异常,有审核通过!'; return false;*/ //$log_data .= "isend is false!\n"; } /*}else */ if ($type == '2') { $sql = "UPDATE om_records_order_audit SET lastModified=" . time() . ",note='{$note}' WHERE omOrderId={$orderid} AND sku='{$sku}' "; if (self::$dbConn->query($sql)) { //BaseModel :: commit(); //BaseModel :: autoCommit(); self::$errCode = 200; self::$errMsg = '添加备注成功!'; return true; } else { self::$errCode = 03; self::$errMsg = '添加备注失败!'; return false; } } self::$errCode = 200; self::$errMsg = '审核完成!'; return true; } }
public static function showSearchOrderList($tableName, $where, $extenwhere = '') { //数据查找 !self::$dbConn ? self::initDB() : null; $orderDetailForm = $tableName . '_detail'; $accountList = $_SESSION['accountList']; $platformList = $_SESSION['platformList']; //echo "<pre>"; print_r($accountList); exit; $platformsee = array(); for ($i = 0; $i < count($platformList); $i++) { $platformsee[] = $platformList[$i]; } if ($platformsee) { $where .= ' AND da.platformId IN ( ' . join(',', $platformsee) . ' ) '; } $accountsee = array(); for ($i = 0; $i < count($accountList); $i++) { $accountsee[] = $accountList[$i]; } if ($accountsee) { $where .= ' AND da.accountId IN ( ' . join(",", $accountsee) . ' ) '; } $sql = "SELECT\n\t\t\t\t\tda.*\n\t\t\t\tFROM\n\t\t\t\t\t" . $tableName . " AS da\n\t\t\t\tLEFT JOIN " . $orderDetailForm . " AS db ON db.omOrderId = da.id \n\t\t\t\t" . $where . $extenwhere; //echo $sql; echo "<br>"; $query = self::$dbConn->query($sql); if ($query) { //$ret = self::$dbConn->fetch_array_all($query); $orderList = array(); while ($orderData = self::$dbConn->fetch_array($query)) { $omOrderId = $orderData['id']; //echo $omOrderId; echo "<br>"; $orderList[$omOrderId]['orderData'] = $orderData; $platfrom = omAccountModel::getPlatformSuffixById($orderData['platformId']); $extension = $platfrom['suffix']; //获取后缀名称 $orderExtenData = self::selectOrderExtenData($tableName, 'where omOrderId = ' . $omOrderId, $extension); //var_dump($orderExtenData); $orderList[$omOrderId]['orderExtenData'] = $orderExtenData; $orderUserInfoData = self::selectOrderUserInfoData($tableName, 'where omOrderId = ' . $omOrderId, $extension); $orderList[$omOrderId]['orderUserInfoData'] = $orderUserInfoData; $orderNote = self::selectOrderNote('where omOrderId = ' . $omOrderId); $orderList[$omOrderId]['orderNote'] = $orderNote; $orderTracknumber = self::selectOrderTracknumber('where omOrderId = ' . $omOrderId); $orderList[$omOrderId]['orderTracknumber'] = $orderTracknumber; $orderWarehouse = self::selectOrderWarehouse('where omOrderId = ' . $omOrderId, $tableName); $orderList[$omOrderId]['orderWarehouse'] = $orderWarehouse; $orderAudit = SuperOrderModel::selectResult("om_records_order_audit", "omOrderdetailId,sku,auditStatus,appStatus", ' omOrderId = ' . $omOrderId); $orderList[$omOrderId]['orderAudit'] = $orderAudit; $orderCombinePackage = OrderRecordModel::getCombinePackageRecords($omOrderId); $orderList[$omOrderId]['combinePackage'] = $orderCombinePackage; $orderDetail = self::showOrderDetailList($tableName, 'where is_delete = 0 and omOrderId = ' . $omOrderId, $extension); $orderList[$omOrderId]['orderDetail'] = $orderDetail; //echo "<pre>"; //var_dump($orderList);exit; //var_dump($orderDetail); echo "<br>"; //echo $extension; echo "<br>"; } self::$errCode = "200"; self::$errMsg = "get success"; return $orderList; } else { self::$errCode = "004"; self::$errMsg = "get error"; return false; } }