From f536152b2064b0650590f5af8ca379439dde1b7d Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sat, 24 Feb 2024 13:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Active.php | 66 ++++++++++++++++++++++++++++++ app/api/controller/User.php | 2 +- app/api/controller/active.php | 18 -------- app/api/model/user/UserInvoice.php | 17 +++++--- app/api/service/Feedback.php | 10 ++++- 5 files changed, 87 insertions(+), 26 deletions(-) create mode 100644 app/api/controller/Active.php delete mode 100644 app/api/controller/active.php diff --git a/app/api/controller/Active.php b/app/api/controller/Active.php new file mode 100644 index 00000000..12883e02 --- /dev/null +++ b/app/api/controller/Active.php @@ -0,0 +1,66 @@ +request->param(); + if (empty($param['active_id'])) { + return $this->renderSuccess('活动ID必填'); + } + $model = new ActiveMain(); + $list = $model->with('col') + ->where('status', '=', 1) + ->where('id', $param['active_id'])->find(); + if ($list) { + foreach ($list['col'] as $k => $row) { + $goodsModel = new GoodsModel(); + $goods_list = $goodsModel->getListByIdsFromApi(explode(',', $row['col_goods_ids'])); + $list['col'][$k]['goods_list'] = $goods_list; + } + return $this->renderSuccess($list->toArray()); + } + return $this->renderSuccess('暂无数据'); + } + + /** + * 新年换新机活动 + * @return Json + */ + public function info(): Json{ + $model = new ActiveMain(); + $data = $model->where('id',1) + ->where('') + ->field('id,name,title,index_icon')->find(); + if (!$data) { + return $this->renderSuccess('暂无数据'); + } + return $this->renderSuccess($data->toArray()); + } + + /** + * 活动商品分页加载 + * @return Json + * @throws ] + */ + public function getGoodsByPage(): Json { + $page = $this->request->get('page'); + $limit = $this->request->get('limit'); + $goodsModel = new GoodsModel(); + $goods_list = $goodsModel->getList([], $limit); + return $this->renderSuccess($goods_list->toArray()); + } +} \ No newline at end of file diff --git a/app/api/controller/User.php b/app/api/controller/User.php index c0073103..88c89b80 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -149,7 +149,7 @@ class User extends Controller $userData = [ 'user_id' => $userInfo->user_id, 'user_name' => $params['user_name'] ?? $userInfo->nick_name, - 'mobile' => $params['mobile'] ? substr_replace($params['mobile'], '****', 3, 4) : $userInfo->mobile, + 'mobile' => $params['mobile'] ? hide_mobile($params['mobile']) : $userInfo->mobile, ]; $service = new Feedback(); $res = $service->addFeedback($params, $userData); diff --git a/app/api/controller/active.php b/app/api/controller/active.php deleted file mode 100644 index 388e2f02..00000000 --- a/app/api/controller/active.php +++ /dev/null @@ -1,18 +0,0 @@ -request->param(); - - } -} \ No newline at end of file diff --git a/app/api/model/user/UserInvoice.php b/app/api/model/user/UserInvoice.php index 4f09060f..95ef6558 100644 --- a/app/api/model/user/UserInvoice.php +++ b/app/api/model/user/UserInvoice.php @@ -48,9 +48,11 @@ class UserInvoice extends UserInvoiceModel // 当前用户ID $userId = UserService::getCurrentLoginUserId(); $store_id = app()->request->storeId(); - if (empty($data['header']) || empty($data['duty_no'])) { - $this->error = '请补全信息'; - return false; + if($data['source'] == 2) {//单位发票 + if (empty($data['header']) || empty($data['duty_no'])) { + $this->error = '请补全信息'; + return false; + } } return $this->save(array_merge($data, [ 'user_id' => $userId, @@ -61,10 +63,13 @@ class UserInvoice extends UserInvoiceModel public function edit($data) { - if (empty($data['header']) || empty($data['duty_no'])) { - $this->error = '请补全信息'; - return false; + if($data['source'] == 2) {//单位发票 + if (empty($data['header']) || empty($data['duty_no'])) { + $this->error = '请补全信息'; + return false; + } } + $userId = UserService::getCurrentLoginUserId(); $detail = self::get(['user_id' => $userId, 'id' => $data['id']]); empty($detail) && throwError('未找到该抬头'); diff --git a/app/api/service/Feedback.php b/app/api/service/Feedback.php index 5f100e79..2158ab3f 100644 --- a/app/api/service/Feedback.php +++ b/app/api/service/Feedback.php @@ -12,6 +12,7 @@ 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; @@ -50,12 +51,19 @@ class Feedback extends BaseService if (!empty($params['is_my']) && !empty($params['user_id'])) { $query = $query->where(['user_id' => $params['user_id']]); } - $list = $query->with(['shop']) + $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;