Commit 173e63d1 by wenyi.chen

綫上0322完整版本

parent 7ae05594
...@@ -105,7 +105,7 @@ class Norm ...@@ -105,7 +105,7 @@ class Norm
// 开启数据库事务 // 开启数据库事务
Db::startTrans(); Db::startTrans();
$index = 1; $control = 1;
// 指标数据 // 指标数据
$normData = [ $normData = [
'task_id'=>$data['task_id'], 'task_id'=>$data['task_id'],
...@@ -120,14 +120,13 @@ class Norm ...@@ -120,14 +120,13 @@ class Norm
$normBus = new CommonBus('NormBus'); // 通过公共业务初始化指标类 $normBus = new CommonBus('NormBus'); // 通过公共业务初始化指标类
// 检查指标名称是否有重复 // 检查指标名称是否有重复
$query = $normBus->getConditionalQuery(['task_id'=>$data['task_id'],'name'=>$data['name']]); $query = $normBus->getConditionalQuery(['task_id'=>$data['task_id'],'name'=>$data['name']]);
var_dump($query);
if ($query){ if ($query){
return returnResult(config("config.code.error"),'指标名称已存在!'); return returnResult(config("config.code.error"),'指标名称已存在!');
} }
// 添加到指标表中 // 添加到指标表中
$normId = $normBus->addData($normData); $normId = $normBus->addData($normData);
if(empty($normId)){ if(empty($normId)){
$index++; $control++;
} }
// 指标扩展数据 // 指标扩展数据
$normExtendList=[]; $normExtendList=[];
...@@ -145,7 +144,7 @@ class Norm ...@@ -145,7 +144,7 @@ class Norm
// 添加自定义数据到指标扩展表中 // 添加自定义数据到指标扩展表中
$normExtend = $normExtendBus->addData($normExtendList); $normExtend = $normExtendBus->addData($normExtendList);
if(empty($normExtend)){ if(empty($normExtend)){
$index++; $control++;
} }
// 格式化数据 // 格式化数据
...@@ -156,28 +155,22 @@ class Norm ...@@ -156,28 +155,22 @@ class Norm
array_push($extend,['name'=>$value['name'],'value'=>$value['value']]); array_push($extend,['name'=>$value['name'],'value'=>$value['value']]);
} }
} }
$keyName = []; //每个值对应的名称
$ordering= []; // 需要排列组合的数据 $ordering= []; // 需要排列组合的数据
foreach ($extend as $value){ foreach ($extend as $value){
$exp = explode(',',$value['value']); $exp = explode(',',$value['value']);
array_push($ordering,$exp); array_push($ordering,$exp);
foreach ($exp as $value1){
array_push($keyName,[$value['name']=>$value1]);
}
} }
// 格式化数据 // 格式化数据
$processedData = \app\common\lib\Arr::format($ordering); $processedData = \app\common\lib\Arr::format($ordering);
// 格式化每个数据表需要的数据格式 // 格式化每个数据表需要的数据格式
foreach ($processedData as $value){ foreach ($processedData as $value){
$exp = explode(',',$value); $exp = explode(',',$value);
foreach ($exp as $value1){ foreach ($exp as $index=> $value1){
$normList = []; // 指标待领取数据 $normList = []; // 指标待领取数据
$normListExtend = []; // 指标待领取数据扩展 $normListExtend = []; // 指标待领取数据扩展
$key = \app\common\lib\Arr::deepGetKey($value1,$keyName);
// 添加到用户待领取数据表 // 添加到用户待领取数据表
if($key=='名称'){ if($index==0){
$normList['task_id'] = $data['task_id']; $normList['task_id'] = $data['task_id'];
$normList['norm_id']=$normId; $normList['norm_id']=$normId;
$normList['name']=$value1; $normList['name']=$value1;
...@@ -191,29 +184,29 @@ class Norm ...@@ -191,29 +184,29 @@ class Norm
$normListBus = new CommonBus('NormListBus'); // 通过公共业务初始化用户待领取指标类 $normListBus = new CommonBus('NormListBus'); // 通过公共业务初始化用户待领取指标类
$normListId =$normListBus->addData($normList); $normListId =$normListBus->addData($normList);
if(empty($normListId)){ if(empty($normListId)){
$index++; $control++;
} }
// 添加到用户待领取扩展数据表 // 添加到用户待领取扩展数据表
}else{ }else{
$normListExtend['norm_id'] = $normId; $normListExtend['norm_id'] = $normId;
$normListExtend['norm_list_id'] = $normListId; $normListExtend['norm_list_id'] = $normListId;
$normListExtend['extend_name'] = $key; $normListExtend['extend_name'] = $extend[$index]['name'];
$normListExtend['extend_value'] = $value1; $normListExtend['extend_value'] = $value1;
$normListExtend['extend_type'] = 1; $normListExtend['extend_type'] = 1;
$normListExtendBus = new CommonBus('NormListExtendBus');// 通过公共业务初始化用户待领取指标扩展类 $normListExtendBus = new CommonBus('NormListExtendBus');// 通过公共业务初始化用户待领取指标扩展类
$res = $normListExtendBus->addData($normListExtend); $res = $normListExtendBus->addData($normListExtend);
if(empty($res)){ if(empty($res)){
$index++; $control++;
} }
} }
} }
} }
// 全部添加完成提交 // 全部添加完成提交
if($index ==1){ if($control ==1){
Db::commit(); Db::commit();
return returnResult(config("config.code.success"),config("config.describe.success"),$res); return returnResult(config("config.code.success"),config("config.describe.success"),[]);
}else{ }else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),[]); return returnResult(config("config.code.error"),config("config.describe.add_error"),[]);
} }
}catch (\Exception $e){ }catch (\Exception $e){
Db::rollback(); Db::rollback();
......
...@@ -39,9 +39,6 @@ class NormReceives extends AuthBase ...@@ -39,9 +39,6 @@ class NormReceives extends AuthBase
$result = $NormReceivesBus->listData($data);//获取所有账号信息 $result = $NormReceivesBus->listData($data);//获取所有账号信息
foreach ($result as $index => $value){ foreach ($result as $index => $value){
$normListInfo = $NormListBus->getConditionalQueryAll(['id'=>$value['norm_list_id']]); $normListInfo = $NormListBus->getConditionalQueryAll(['id'=>$value['norm_list_id']]);
if (empty($normListInfo)){
return returnResult(config("config.code.error"),'无法获取领取指标信息!','');
}
$result[$index]['norm_list_info'] = $normListInfo; $result[$index]['norm_list_info'] = $normListInfo;
$NormExtendBus = new \app\api\business\CommonBus('NormExtendBus'); // 通过公共业务初始化用户待领取指标类 $NormExtendBus = new \app\api\business\CommonBus('NormExtendBus'); // 通过公共业务初始化用户待领取指标类
$user_filled = $NormExtendBus->getConditionalQuery(['norm_id'=>$value['norm_id'],'user_filled'=>1]); $user_filled = $NormExtendBus->getConditionalQuery(['norm_id'=>$value['norm_id'],'user_filled'=>1]);
...@@ -61,9 +58,6 @@ class NormReceives extends AuthBase ...@@ -61,9 +58,6 @@ class NormReceives extends AuthBase
$result = $NormReceivesBus->pagingListData($data);//获取所有账号信息 $result = $NormReceivesBus->pagingListData($data);//获取所有账号信息
foreach ($result['data'] as $index => $value){ foreach ($result['data'] as $index => $value){
$normListInfo = $NormListBus->getConditionalQuery(['id'=>$value['norm_list_id']]); $normListInfo = $NormListBus->getConditionalQuery(['id'=>$value['norm_list_id']]);
if (empty($normListInfo)){
return returnResult(config("config.code.error"),'无法获取领取指标信息!','');
}
$result['data'][$index]['norm_list_info'] = $normListInfo; $result['data'][$index]['norm_list_info'] = $normListInfo;
$NormExtendBus = new \app\api\business\CommonBus('NormExtendBus'); // 通过公共业务初始化用户待领取指标类 $NormExtendBus = new \app\api\business\CommonBus('NormExtendBus'); // 通过公共业务初始化用户待领取指标类
$user_filled = $NormExtendBus->getConditionalQueryAll(['norm_id'=>$value['norm_id'],'user_filled'=>1]); $user_filled = $NormExtendBus->getConditionalQueryAll(['norm_id'=>$value['norm_id'],'user_filled'=>1]);
......
...@@ -265,29 +265,65 @@ class UserInfo extends AuthBase ...@@ -265,29 +265,65 @@ class UserInfo extends AuthBase
} }
/** /**
* 重置密码 * 修改密码
* @return \josn * @return \josn
* @throws \think\Exception * @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function resetPassword() public function changePassword()
{ {
$id = input('param.id','',"intval"); try{
$password= input('param.password');
$newPassword= input('param.newPassword');
$confirmNewPassword= input('param.confirmNewPassword');
if ($newPassword !== $confirmNewPassword){
return returnResult(config("config.code.error"),'新密码与确认密码正确!','');
}
// 业务处理 // 业务处理
$bus = new UserInfoBus(); $bus = new UserInfoBus();
$info = $bus->getUserByUserId($id); $info = $bus->getUserByUserId($this->userId);
if(empty($info)){ if(empty($info)){
return returnResult(config("config.code.error"),'ID不存在!',''); return returnResult(config("config.code.error"),'用戶不存在!','');
}
if($info['password']!==md5($password)){
return returnResult(config("config.code.error"),'原始密码有误!','');
}
$data = ['id'=>$this->userId,'password'=>md5($newPassword)];
$result = $bus->updateData($data);
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),[]);
}else{
return returnResult(config("config.code.success"),config("config.describe.deletion_failed"),[]);
}
}catch (\Exception $e){
exception($e,'UserInfo.changePassword');
} }
$data = ['id'=>$id,'password'=>md5(123456)]; }
/**
* 重置密码
* @return \josn
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function resetPassword()
{
try{
$bus = new UserInfoBus();
$data = ['id'=>$this->userId,'password'=>md5('123456')];
$result = $bus->updateData($data); $result = $bus->updateData($data);
if($result){ if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),[]); return returnResult(config("config.code.success"),config("config.describe.success"),[]);
}else{ }else{
return returnResult(config("config.code.success"),config("config.describe.deletion_failed"),[]); return returnResult(config("config.code.success"),config("config.describe.deletion_failed"),[]);
} }
}catch (\Exception $e){
exception($e,'UserInfo.resetPassword');
}
} }
/** /**
......
...@@ -12,7 +12,6 @@ Route::miss(function() { ...@@ -12,7 +12,6 @@ Route::miss(function() {
/***************************鉴权相关 */ /***************************鉴权相关 */
Route::rule("auth/login","login/signIn"); // 登录 Route::rule("auth/login","login/signIn"); // 登录
Route::rule("getToken","login/getToken"); // 登录获取token Route::rule("getToken","login/getToken"); // 登录获取token
Route::rule("logout","UserInfo/logout"); // 退出登录
/***************************账号信息相关 */ /***************************账号信息相关 */
Route::rule("user/list","UserInfo/list"); // 获取账号信息 Route::rule("user/list","UserInfo/list"); // 获取账号信息
...@@ -23,6 +22,8 @@ Route::rule("user/delete","UserInfo/delete"); // 删除用户信息 ...@@ -23,6 +22,8 @@ Route::rule("user/delete","UserInfo/delete"); // 删除用户信息
Route::rule("user/heartbeat","UserInfo/heartbeat"); // 更新token时间 Route::rule("user/heartbeat","UserInfo/heartbeat"); // 更新token时间
Route::rule("user/tokenInfo","UserInfo/tokenInfo"); // 获取信息 Route::rule("user/tokenInfo","UserInfo/tokenInfo"); // 获取信息
Route::rule("user/changeStatus","UserInfo/changeStatus"); // 修改账号状态 Route::rule("user/changeStatus","UserInfo/changeStatus"); // 修改账号状态
Route::rule("user/changePassword","UserInfo/changePassword"); // 重置密码
Route::rule("logout","UserInfo/logout"); // 退出登录
Route::rule("user/resetPassword","UserInfo/resetPassword"); // 重置密码 Route::rule("user/resetPassword","UserInfo/resetPassword"); // 重置密码
Route::rule("user/me","UserInfo/me"); // 查看个人详细信息 Route::rule("user/me","UserInfo/me"); // 查看个人详细信息
......
...@@ -102,6 +102,7 @@ class Arr ...@@ -102,6 +102,7 @@ class Arr
} }
/***********************==============================二位数组排列组合 /***********************==============================二位数组排列组合
*
/** /**
* 二位数组排列组合 * 二位数组排列组合
* @param $arr1 * @param $arr1
......
...@@ -85,6 +85,7 @@ class Norm extends Model ...@@ -85,6 +85,7 @@ class Norm extends Model
{ {
try{ try{
return $this->where($where)->find(); return $this->where($where)->find();
}catch (\Exception $e){ }catch (\Exception $e){
exception($e,'mysql.Norm.getFindModel'); exception($e,'mysql.Norm.getFindModel');
} }
......
...@@ -69,5 +69,5 @@ return [ ...@@ -69,5 +69,5 @@ return [
"table_delete" =>99, // 删除 "table_delete" =>99, // 删除
], ],
// "resource_address"=>'https://data-collect.raisound.com/data-collect-api/', // "resource_address"=>'https://data-collect.raisound.com/data-collect-api/',
"resource_address"=>'http://192.168.10.168/data-collect-api/', "resource_address"=>'http://192.168.10.168/data-collect-api/'
]; ];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment