作者 lms

合并分支 'lms' 到 'develop'

逻辑 - 代码优化



查看合并请求 !74
... ... @@ -74,15 +74,15 @@ class ProjectFilePDF extends Command
public function dataPush(array $items)
{
foreach ($items as $item) {
$project_id = $item->project_id;
$application_id = $item->wx_id;
$wx_user_id = $item->wx_user_id;
$project_id = $item->project_id;
$user_id = $item->user_id;
$friend_id = $item->friend_id;
// todo 根据项目查询数据
$project_data = [];
$html = $this->html($project_data);
$filename = hash('md5', $this->time . '-' . $project_id . '-' . $application_id);
$filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
$file_path = $this->savePDF($html, $filename);
$this->DataFile->saveData(compact('project_id', 'application_id', 'file_path') + ['time' => $this->time]);
$this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);
}
}
... ...
... ... @@ -58,7 +58,8 @@ class WebsiteData extends Command
public function post_data($data)
{
$url = env('AICC_URL');
return http_post("{$url}/api/save_file_data", json_encode(compact('data')));
$msg = http_post("{$url}/api/save_file_data", json_encode(compact('data')));
print_r($msg);
}
}
... ...
... ... @@ -31,19 +31,20 @@ class ProjectAssociationController extends BaseController
if (empty($project_id)) {
$this->fail('请选择项目!', Code::USER_PARAMS_ERROE);
}
$status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
$wx_user_id = (int)request()->post('user_id', 0);
if (empty($wx_user_id) && $status) {
$status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
$user_id = (int)request()->post('user_id', 0);
if (empty($user_id) && $status) {
$this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE);
}
$wx_id = (int)request()->post('wx_id', 0);
if (empty($wx_id) && $status) {
$this->fail('请选择要绑定的AICC项目!', Code::USER_PARAMS_ERROE);
$friend_id = (int)request()->post('friend_id', 0);
if (empty($friend_id) && $status) {
$this->fail('请选择要绑定的AICC用户列表!', Code::USER_PARAMS_ERROE);
}
$wx_nickname = request()->post('nickname', '');
$wx_user_name = request()->post('user_name', '');
$wx_image = request()->post('image', '');
$data = compact('project_id', 'wx_id', 'wx_nickname', 'wx_user_id', 'wx_user_name', 'wx_image');
$nickname = request()->post('nickname', '');
$user_name = request()->post('user_name', '');
$image = request()->post('image', '');
$data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image');
$this->ProjectAssociationLogic->saveWeChatData($data);
$this->response('success');
}
... ...
... ... @@ -10,14 +10,19 @@ class DataFile extends Base
public function saveData(array $data): bool
{
# v6项目ID
$project_id = (int)$data['project_id'] ?? 0;
$isRes = self::query()->where('project_id', $project_id)->where('created_at', 'like', $data['time'] . '%')->first();
if (!$isRes) {
$isRes = new self();
$isRes->project_id = $project_id;
}
$isRes->file_path = $data['file_path'];
$isRes->application_id = $data['application_id'];
# AICC用户ID
$isRes->user_id = $data['user_id'];
# 第三方朋友ID
$isRes->friend_id = $data['friend_id'];
# 生成文件路径
$isRes->file_path = $data['file_path'];
return $isRes->save();
}
... ...
... ... @@ -16,17 +16,23 @@ class ProjectAssociation extends Model
*/
public function saveData(array $data): bool
{
# V6项目ID
$project_id = (int)$data['project_id'] ?? 0;
$isRes = self::query()->where('project_id', $project_id)->first();
if (!$isRes) {
$isRes = new self();
$isRes->project_id = $project_id;
}
$isRes->wx_id = $data['wx_id'];
$isRes->wx_nickname = $data['wx_nickname'];
$isRes->wx_user_id = $data['wx_user_id'];
$isRes->wx_user_name = $data['wx_user_name'];
$isRes->wx_image = $data['wx_image'];
# AICC朋友ID
$isRes->friend_id = $data['friend_id'] ?? 0;
# AICC朋友昵称
$isRes->nickname = $data['nickname'] ?? 0;
# AICC用户ID
$isRes->user_id = $data['user_id'] ?? 0;
# AICC用户姓名
$isRes->user_name = $data['user_name'] ?? '';
# AICC朋友头像
$isRes->image = $data['image'] ?? '';
return $isRes->save();
}
... ... @@ -50,8 +56,9 @@ class ProjectAssociation extends Model
$status = 1; # 1 - 正常, 0 - 禁用
$lists = self::query()->where('status', $status)
->whereNotNull('project_id')
->whereNotNull('wx_user_id')
->paginate($perPage, ['project_id', 'wx_id', 'wx_user_id'], 'page', $page);
->whereNotNull('friend_id')
->whereNotNull('user_id')
->paginate($perPage, ['project_id', 'friend_id', 'user_id'], 'page', $page);
$items = $lists->Items();
$totalPage = $lists->lastPage();
$total = $lists->total();
... ...