You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/service/Feedback.php

71 lines
2.9 KiB

10 months ago
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\service;
9 months ago
use \app\common\model\UploadFile;
10 months ago
use app\common\model\UserFeedback;
use app\common\service\BaseService;
use cores\exception\BaseException;
/**
* 用户余额充值服务
* Class Recharge
* @package app\api\controller
*/
class Feedback extends BaseService
{
//添加反馈
public function addFeedback($data, $user_data)
{
$addData = [
'user_id' => $user_data['user_id'],
10 months ago
'shop_id' => $data['shop_id'] ?? 0,
10 months ago
'type' => $data['type'],
'object_type' => $data['object_type'],
'content' => $data['content'],
'user_name' => $user_data['user_name'],
'mobile' => $user_data['mobile'],
'status' => 0,
'created_at' => time(),
'store_id' => $this->storeId,
'image_id' => $data['image_id'] ?? ''
10 months ago
];
$model = new UserFeedback();
return $model->insert($addData);
}
//反馈列表
public function getFeedback($params, $listRows = 10)
{
$query = new UserFeedback();
if (!empty($params['is_my']) && !empty($params['user_id'])) {
$query = $query->where(['user_id' => $params['user_id']]);
}
9 months ago
$list = $query->with(['shop'])->order('id DESC')
10 months ago
->paginate($listRows)->toArray();
foreach ($list['data'] as $k => $v) {
10 months ago
$list['data'][$k]['shop_name'] = !empty($v['shop']['shop_name']) ? $v['shop']['shop_name'] : '';
$list['data'][$k]['created_at'] = !empty($v['created_at']) ? date('Y-m-d H:i:s', $v['created_at']) : '';
$list['data'][$k]['replay_at'] = !empty($v['replay_at']) ? date('Y-m-d H:i:s', $v['replay_at']) : '';
9 months ago
$images = UploadFile::whereIn('file_id', explode(",", $v['image_id']))->field('file_path,domain')->select();
$files = [];
foreach ($images as $image) {
$files[] = getUrl($image['file_path'], $image['domain']);
}
$list['data'][$k]['file_path'] = $files ? implode(',', $files) : '';
$list['data'][$k]['reply'] = $v['reply'] ?? '';
10 months ago
unset($list['data'][$k]['shop']);
10 months ago
}
return $list;
}
}