Files
OMS/app/erpapi/lib/dchain/request/abstract.php
2025-12-28 23:13:25 +08:00

89 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
abstract class erpapi_dchain_request_abstract
{
/**
* @var erpapi_channel_dchain
* */
protected $__channelObj;
/**
* @var erpapi_result
*/
protected $__resultObj;
/**
* @var erpapi_caller
*/
protected $__caller;
/**
* 初始化
* @param erpapi_channel_abstract $channel channel
* @param erpapi_config $config 配置
* @param erpapi_result $result result
* @return mixed 返回值
*/
final public function init(erpapi_channel_abstract $channel, erpapi_config $config, erpapi_result $result)
{
$this->__channelObj = $channel;
$this->__resultObj = $result;
// 默认以JSON格式返回
$callerObj = new erpapi_caller();
$this->__caller = $callerObj
->set_config($config)
->set_channel($channel)
->set_result($result);
}
/**
* succ
* @param mixed $msg msg
* @param mixed $msgcode msgcode
* @param mixed $data 数据
* @return mixed 返回值
*/
final public function succ($msg = '', $msgcode = '', $data = null)
{
return array('rsp' => 'succ', 'msg' => $msg, 'msg_code' => $msgcode, 'data' => $data);
}
/**
* error
* @param mixed $msg msg
* @param mixed $msgcode msgcode
* @param mixed $data 数据
* @return mixed 返回值
*/
final public function error($msg, $msgcode, $data = null)
{
return array('rsp' => 'fail', 'msg' => $msg, 'err_msg' => $msg, 'msg_code' => $msgcode, 'data' => $data);
}
/**
* uniqid
* @return mixed 返回值
*/
final public function uniqid()
{
$microtime = utils::microtime();
$unique_key = str_replace('.', '', strval($microtime));
$randval = uniqid('', true);
$unique_key .= strval($randval);
return md5($unique_key);
}
/**
* 回调
* @param $response Array
* @param $callback_params Array
* @return Array
**/
public function callback($response, $callback_params)
{
return $response;
}
}