|
|
|
<?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;
|
|
|
|
|
|
|
|
use \app\common\model\UploadFile;
|
|
|
|
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'],
|
|
|
|
'shop_id' => $data['shop_id'] ?? 0,
|
|
|
|
'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'] ?? ''
|
|
|
|
];
|
|
|
|
$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']]);
|
|
|
|
}
|
|
|
|
$list = $query->with(['shop'])->order('id DESC')
|
|
|
|
->paginate($listRows)->toArray();
|
|
|
|
foreach ($list['data'] as $k => $v) {
|
|
|
|
$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']) : '';
|
|
|
|
$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'] ?? '';
|
|
|
|
unset($list['data'][$k]['shop']);
|
|
|
|
}
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
}
|