|
@@ -259,7 +259,7 @@ class Jiashicang extends Api
|
|
|
$rsautil = new RsaUtil($public_key,$private_key);
|
|
|
|
|
|
$sign = $rsautil->publicEncrypt(json_encode($biz_content));
|
|
|
-dump($sign);
|
|
|
+
|
|
|
|
|
|
$data = [
|
|
|
'app_id' => '10000000000004096993',
|
|
@@ -278,5 +278,96 @@ dump($sign);
|
|
|
dump($rs);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 积分维护接口 - 推送积分数据到工行
|
|
|
+ * @param string $mobile_phone 用户手机号
|
|
|
+ * @param int $integral_value 变动的积分值(整数)
|
|
|
+ * @param string $integral_type 积分类型
|
|
|
+ * @param array $remarks 备用字段数组(可选,最多7个)
|
|
|
+ * @return array 返回接口响应结果
|
|
|
+ */
|
|
|
+ public function update_villager_integral($mobile_phone = '', $integral_value = 0, $integral_type = '', $remarks = [])
|
|
|
+ {
|
|
|
+ // 正式环境URL,需要替换为实际的工行API网关地址
|
|
|
+ //$url = 'https://gw.dccnet.com.cn:8082/api/mybank/farm/farmplatf/updateVillagerIntegral/V1';
|
|
|
+ $url = 'https://gw.open.icbc.com.cn/api/mybank/farm/farmplatf/syncCommunityData/V1';
|
|
|
+
|
|
|
+ // 如果没有传入手机号,尝试从登录用户获取
|
|
|
+ if (empty($mobile_phone) && isset($this->auth->mobile)) {
|
|
|
+ $mobile_phone = $this->auth->mobile;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成唯一序列号
|
|
|
+ $fSeqNo = createUniqueNo('fseq', time());
|
|
|
+
|
|
|
+ // 构建业务参数
|
|
|
+ $biz_content = [
|
|
|
+ 'fSeqNo' => $fSeqNo,
|
|
|
+ 'corpCode' => 'icbc',
|
|
|
+ 'mobilePhone' => $mobile_phone,
|
|
|
+ 'integralValue' => (string)$integral_value, // 确保是字符串类型
|
|
|
+ 'integralType' => $integral_type,
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 添加备用字段(如果有)
|
|
|
+ for ($i = 1; $i <= 7; $i++) {
|
|
|
+ if (isset($remarks[$i - 1]) && !empty($remarks[$i - 1])) {
|
|
|
+ $biz_content['remark' . $i] = $remarks[$i - 1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载RSA密钥
|
|
|
+ $public_key = APP_PATH . '/common/certs/icbc/public_key.pem';
|
|
|
+ $private_key = APP_PATH . '/common/certs/icbc/private_key.pem';
|
|
|
+ $rsautil = new RsaUtil($public_key, $private_key);
|
|
|
+
|
|
|
+ // 生成签名
|
|
|
+ $sign = $rsautil->publicEncrypt(json_encode($biz_content));
|
|
|
+
|
|
|
+ // 构建通用请求参数
|
|
|
+ $data = [
|
|
|
+ 'app_id' => '10000000000004096993',
|
|
|
+ 'msg_id' => createUniqueNo('msg', time()),
|
|
|
+ 'format' => 'json',
|
|
|
+ 'charset' => 'UTF-8',
|
|
|
+ 'sign_type' => 'RSA',
|
|
|
+ 'sign' => $sign,
|
|
|
+ 'timestamp' => date('Y-m-d H:i:s'),
|
|
|
+ 'biz_content' => $biz_content,
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ $response = curl_post($url, json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
+
|
|
|
+ // 解析响应
|
|
|
+ $result = json_decode($response, true);
|
|
|
+
|
|
|
+ // 返回结果
|
|
|
+ return $result ? $result : ['return_code' => '-1', 'return_msg' => '接口调用失败', 'response' => $response];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 积分维护测试接口
|
|
|
+ * 可通过浏览器直接访问测试
|
|
|
+ */
|
|
|
+ public function test_integral()
|
|
|
+ {
|
|
|
+ // 测试参数
|
|
|
+ $mobile_phone = '13792965609'; // 测试手机号
|
|
|
+ $integral_value = 10; // 增加10分
|
|
|
+ $integral_type = 'test'; // 积分类型
|
|
|
+ $remarks = ['陈冲']; // 备用字段
|
|
|
+
|
|
|
+ // 调用积分维护接口
|
|
|
+ $result = $this->update_villager_integral($mobile_phone, $integral_value, $integral_type, $remarks);
|
|
|
+var_dump($result);exit;
|
|
|
+ // 输出结果
|
|
|
+ if ($result['return_code'] == 0) {
|
|
|
+ $this->success('积分推送成功', $result);
|
|
|
+ } else {
|
|
|
+ $this->error('积分推送失败:' . $result['return_msg'], $result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|