完善默认商城设置

dev
李春波 2 years ago
parent c2c2cd9b54
commit 0920337efb
  1. 24
      app/common/service/Yinghuo.php
  2. 6
      app/common/service/wechat/FastRegisterApp.php
  3. 29
      app/functions.php

@ -109,7 +109,7 @@ class Yinghuo
]
]
];
return $this->curl('/store.module/edit', json_encode($data));
return $this->curl('/admin/store.module/edit', $data);
}
/**
@ -126,6 +126,24 @@ class Yinghuo
return error($result['message'], $result['status'], [], true);
}
/**
* 商城设置默认secret
* @param $appid
* @return array|mixed
*/
public function settingWxAppInfo($appid)
{
$data = [
"key" => "basic",
"form" => [
"enabled" => true,
"app_id" => $appid,
"app_secret" => "fastRegisterApp"
]
];
return $this->curl('/store/client.wxapp.setting/update', $data, 'store');
}
/**
* 商城设置上传CDN配置
* @return array|mixed
@ -161,7 +179,7 @@ class Yinghuo
]
]
];
return $this->curl('/store/setting/update', json_encode($data), 'store');
return $this->curl('/store/setting/update', $data, 'store');
}
/**
@ -185,7 +203,7 @@ class Yinghuo
"isPersonalMpweixin" => 1
]
];
return $this->curl('/store/setting/update', json_encode($data), 'store');
return $this->curl('/store/setting/update', $data, 'store');
}
private function curl($cmd, $data, $type = "admin", $needLogin = true, $method = 'POST')

@ -40,7 +40,7 @@ class FastRegisterApp
// 创建账号店铺、生成随机用户名、密码
$username = generateRandomString(6, false, true);
$password = generateRandomString(8, true);
self::addStore($trialRecords['store_id'], $storeName, $username, $password);
self::addStore($trialRecords['store_id'], $appid, $storeName, $username, $password);
// 推送创建结果
self::pushSuccessMsg($trialRecords['open_id'], $username, $password);
// 推送体验码
@ -124,7 +124,7 @@ class FastRegisterApp
}
// 创建店铺
static function addStore($storeId, $storeName, $username, $password)
static function addStore($storeId, $appid, $storeName, $username, $password)
{
$yinghuo = new Yinghuo();
// 登录运维平台
@ -135,6 +135,8 @@ class FastRegisterApp
$yinghuo->setModule($storeId);
// 登录商城
$yinghuo->superLogin($storeId);
// 设置默认secret
$yinghuo->settingWxAppInfo($appid);
// 设置商城默认上传文件设置
$yinghuo->settingUpload();
// 设置商城默认注册设置

@ -73,30 +73,31 @@ function verifySign($params, $secretKey, $sign): bool
* @param $method
* @return bool|string
*/
function curlRequest($url, $data = array(), $headers = array(), $method = 'GET')
function curlRequest($url, $data = [], $headers = [], $method = 'GET')
{
$ch = curl_init();
// 设置请求 URL
curl_setopt($ch, CURLOPT_URL, $url);
// 设置请求方法
// 设置请求方法和数据
if ($method === 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
// 设置请求头
if (!empty($headers)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// 设置其他选项
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// 禁止验证证书
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false
]);
// 发起请求并获取响应
$response = curl_exec($ch);
@ -105,10 +106,10 @@ function curlRequest($url, $data = array(), $headers = array(), $method = 'GET')
$error = curl_error($ch);
curl_close($ch);
return "Curl Error: " . $error;
} else {
curl_close($ch);
return $response;
}
curl_close($ch);
return $response;
}
/**

Loading…
Cancel
Save