You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pdd-order-api/app/libs/tool/class.IsvLogClient.php

50 lines
1.3 KiB
PHP

<?php
class IsvLogClient {
/**
* @var Redis
*/
private static $redis;
private static function initRedis() {
if (self::$redis) {
return self::$redis;
}
self::$redis = RedisExt::factory('bizCache');
return self::$redis;
}
public static function getIsvLogRedisBizKey($isAdminSelf) {
$key = Zc::C('appName') . '_isvLogList';
if ($isAdminSelf) {
$key .= '_self';
}
return $key;
}
public static function saveIsvOrderLogisticsInfoToRedis($mallId, $orderSn, $logisticsId, $trackingNumber, $bizName, $operatorInfo = null) {
$operatorInfo = $operatorInfo ?: CommonTool::getOperatorInfo();
$type = IsvLogConst::typeLogistics;
$isAdminSelf = in_array($operatorInfo['mallId'], CommonTool::adminSelfMallIds());
$bizKey = self::getIsvLogRedisBizKey($isAdminSelf);
self::initRedis();
$data = [
'type' => $type,
'mallId' => $mallId,
'orderSn' => $orderSn,
'logisticsId' => $logisticsId,
'trackingNumber' => $trackingNumber,
'bizName' => $bizName,
'operatorInfo' => $operatorInfo,
'retry' => 3,
];
$dataJson = json_encode($data);
self::$redis->rPush($bizKey, $dataJson);
self::$redis->expire($bizKey, 3600 * 24);
return true;
}
}