优化界面 + 新增修改密码功能

This commit is contained in:
wong
2025-12-19 14:46:14 +08:00
parent bc6421b1af
commit 0c8f1d6419
3 changed files with 138 additions and 1 deletions

View File

@@ -36,7 +36,17 @@ class DouBaoAI extends Controller
{
if (empty($params)){
return json_encode(['code' => 500, 'msg' => '提示词缺失']);
$content = $this->request->param('content', '');
if(empty($content)){
return json_encode(['code' => 500, 'msg' => '提示词缺失']);
}
$params = [
'model' => 'doubao-seed-1-8-251215',
'messages' => [
['role' => 'system', 'content' => '你现在是存客宝的AI助理你精通中国大陆的法律'],
['role' => 'user', 'content' => $content],
],
];
}
$result = requestCurl($this->apiUrl, $params, 'POST', $this->headers, 'json');
$result = json_decode($result, true);
@@ -46,6 +56,8 @@ class DouBaoAI extends Controller
}else{
$content = $result['choices'][0]['message']['content'];
$token = intval($result['usage']['total_tokens']) * 20;
exit_data($content);
return json_encode(['code' => 200, 'msg' => '成功','data' => ['token' => $token,'content' => $content]]);
}

View File

@@ -259,6 +259,7 @@ Route::group('v1/frontend', function () {
Route::get('home', 'app\cunkebao\controller\distribution\ChannelUserController@index'); // 获取渠道首页数据
Route::get('revenue-records', 'app\cunkebao\controller\distribution\ChannelUserController@revenueRecords'); // 获取收益明细列表
Route::get('withdrawal-records', 'app\cunkebao\controller\distribution\ChannelUserController@withdrawalRecords'); // 获取提现明细列表
Route::post('change-password', 'app\cunkebao\controller\distribution\ChannelUserController@changePassword'); // 修改密码
});
});

View File

@@ -586,5 +586,129 @@ class ChannelUserController extends Controller
]));
}
}
/**
* 修改渠道分销员密码
* @return \think\response\Json
*/
public function changePassword()
{
try {
// 获取参数并去除首尾空格
$channelCode = trim($this->request->param('channelCode', ''));
$oldPassword = trim($this->request->param('oldPassword', ''));
$newPassword = trim($this->request->param('newPassword', ''));
// 参数验证
if (empty($channelCode)) {
return $this->setCorsHeaders(json([
'code' => 400,
'success' => false,
'msg' => '渠道编码不能为空',
'data' => null
]));
}
if (empty($oldPassword)) {
return $this->setCorsHeaders(json([
'code' => 400,
'success' => false,
'msg' => '原密码不能为空',
'data' => null
]));
}
if (empty($newPassword)) {
return $this->setCorsHeaders(json([
'code' => 400,
'success' => false,
'msg' => '新密码不能为空',
'data' => null
]));
}
// 验证新密码长度至少6位
if (mb_strlen($newPassword) < 6) {
return $this->setCorsHeaders(json([
'code' => 400,
'success' => false,
'msg' => '新密码长度至少为6位',
'data' => null
]));
}
// 查询渠道信息
$channel = Db::name('distribution_channel')
->where([
['code', '=', $channelCode],
['status', '=', DistributionChannel::STATUS_ENABLED],
['deleteTime', '=', 0]
])
->find();
if (!$channel) {
return $this->setCorsHeaders(json([
'code' => 404,
'success' => false,
'msg' => '渠道不存在或已被禁用',
'data' => null
]));
}
// 验证原密码MD5加密
$oldPasswordMd5 = md5($oldPassword);
if ($channel['password'] !== $oldPasswordMd5) {
return $this->setCorsHeaders(json([
'code' => 401,
'success' => false,
'msg' => '原密码错误',
'data' => null
]));
}
// 检查新密码是否与原密码相同
$newPasswordMd5 = md5($newPassword);
if ($channel['password'] === $newPasswordMd5) {
return $this->setCorsHeaders(json([
'code' => 400,
'success' => false,
'msg' => '新密码不能与原密码相同',
'data' => null
]));
}
// 更新密码
$updateResult = Db::name('distribution_channel')
->where('id', $channel['id'])
->update([
'password' => $newPasswordMd5,
'updateTime' => time()
]);
if ($updateResult === false) {
return $this->setCorsHeaders(json([
'code' => 500,
'success' => false,
'msg' => '密码修改失败,请稍后重试',
'data' => null
]));
}
return $this->setCorsHeaders(json([
'code' => 200,
'success' => true,
'msg' => '密码修改成功',
'data' => null
]));
} catch (Exception $e) {
return $this->setCorsHeaders(json([
'code' => $e->getCode() ?: 500,
'success' => false,
'msg' => '密码修改失败:' . $e->getMessage(),
'data' => null
]));
}
}
}