// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\service; 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'], 'store_id' => $data['store_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(), ]; $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(['store']) ->order('replay_at desc,created_at desc') ->paginate($listRows)->toArray(); foreach ($list['data'] as $k => $v) { $list['data'][$k]['store_name'] = !empty($v['store']['store_name']) ? $v['store']['store_name'] : ''; unset($list['data'][$k]['store']); } return $list; } }