|
|
@@ -310,6 +310,70 @@ class ShansongAdapter extends Shansong implements Adapter
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public function addTip($data)
|
|
|
+ {
|
|
|
+ $orderNo = $data['orderId'] ?? null;
|
|
|
+ $additionAmount = $data['tips'] ?? null;
|
|
|
+
|
|
|
+ if (empty($orderNo)) {
|
|
|
+ return [
|
|
|
+ 'code' => -1,
|
|
|
+ 'platform' => 'shansong',
|
|
|
+ 'msg' => 'issOrderNo不能为空',
|
|
|
+ 'data' => null,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isset($additionAmount) || (int)$additionAmount <= 0) {
|
|
|
+ return [
|
|
|
+ 'code' => -1,
|
|
|
+ 'platform' => 'shansong',
|
|
|
+ 'msg' => 'additionAmount必须为正整数(单位:分)',
|
|
|
+ 'data' => null,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (((int)$additionAmount) % 100 !== 0) {
|
|
|
+ return [
|
|
|
+ 'code' => -1,
|
|
|
+ 'platform' => 'shansong',
|
|
|
+ 'msg' => 'additionAmount需被100整除(最小单位为1元)',
|
|
|
+ 'data' => null,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $requestData = json_encode([
|
|
|
+ 'issOrderNo' => $orderNo,
|
|
|
+ 'additionAmount' => (int)$additionAmount,
|
|
|
+ ], JSON_UNESCAPED_UNICODE);
|
|
|
+ $payload = [
|
|
|
+ 'clientId' => $this->clientId,
|
|
|
+ 'accessToken' => $this->accessToken,
|
|
|
+ 'timestamp' => (int)(microtime(true) * 1000),
|
|
|
+ 'data' => $requestData,
|
|
|
+ ];
|
|
|
+ $sign = SignHelper::makeSign($payload, $this->appSecret, 'md5', true, 'shansong');
|
|
|
+ $payload['sign'] = $sign;
|
|
|
+ $resp = HttpClient::post("{$this->baseUrl}/openapi/developer/v5/addition", $payload);
|
|
|
+
|
|
|
+ if (isset($resp['status']) && $resp['status'] == 200) {
|
|
|
+ return [
|
|
|
+ 'code' => 0,
|
|
|
+ 'platform' => 'shansong',
|
|
|
+ 'data' => $resp['data'] ?? null,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ Yii::error('[ShansongAdapter] addTip failed: ' . json_encode($resp, JSON_UNESCAPED_UNICODE));
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'code' => $resp['status'] ?? -1,
|
|
|
+ 'platform' => 'shansong',
|
|
|
+ 'msg' => $resp['msg'] ?? 'Unknown error',
|
|
|
+ 'data' => null,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 递归过滤数组中的空值(null、空字符串、空数组)
|
|
|
* 确保签名时不包含空值参数
|