/** * TrackShipFeeModel::calcOpenShipFee() * 获取物流系统开发运费计算结果 * @param string $addId 发货地址ID * @param string $country 国家 * @param string $weight 重量 * @return array */ public static function calcOpenShipFee($addId, $country, $weight, $transitId, $postCode, $apiToken, $noShipId, $weightFlag) { $res = array(); $paramArr = array('method' => 'trans.open.ship.fee.get', 'format' => 'json', 'v' => '1.0', 'username' => C('OPEN_SYS_USER'), 'shipAddId' => $addId, 'country' => $country, 'weight' => $weight, 'apiToken' => $apiToken, 'transitId' => $transitId, 'postCode' => $postCode, 'noShipId' => $noShipId, 'weightFlag' => $weightFlag); $shipFeeInfo = callOpenSystem($paramArr); $shipFeeInfo = json_decode($shipFeeInfo, true); if (empty($shipFeeInfo['data'])) { self::$errCode = 20000; self::$errMsg = "Not to find the open freight, please confirm the selected conditions of this!"; return false; } else { $res = $shipFeeInfo['data']; } unset($paramArr); return $res; }
/** * TrackShipFeeAct::actGetShipFee() * 获取接口运费信息 * @param string $addId 发货地址ID * @param string $country 国家 * @param string $realWeight 重量 * @return array; */ public function actGetShipFee($addId, $country, $realWeight, $is_new = 0) { $key = md5($addId . $country . $realWeight); $cacheName = md5("track_ship_fee_" . $key); $memc_obj = new Cache(C('CACHEGROUP')); $shipFeeInfo = $memc_obj->get_extral($cacheName); if (!empty($shipFeeInfo) && empty($is_new)) { return unserialize($shipFeeInfo); } else { $shipFeeInfo = TrackShipFeeModel::calcOpenShipFee($addId, $country, $realWeight, '', '', $apiToken, $noShipId, $weightFlag); self::$errCode = TrackShipFeeModel::$errCode; self::$errMsg = TrackShipFeeModel::$errMsg; $isok = $memc_obj->set_extral($cacheName, serialize($shipFeeInfo), 86400); if (!$isok) { self::$errCode = 308; self::$errMsg = 'memcache缓存出错!'; //return false; } return $shipFeeInfo; } }