前端联调

pull/1/head
ztt 9 months ago
parent 8c7087fd41
commit f536152b20
  1. 66
      app/api/controller/Active.php
  2. 2
      app/api/controller/User.php
  3. 18
      app/api/controller/active.php
  4. 17
      app/api/model/user/UserInvoice.php
  5. 10
      app/api/service/Feedback.php

@ -0,0 +1,66 @@
<?php
namespace app\api\controller;
use app\api\model\Goods as GoodsModel;
use app\common\model\ActiveMain;
use app\common\model\Goods;
use think\response\Json;
/**
* 活动相关接口
*/
class Active extends Controller
{
/**
* 新年换新机活动详情
* @return void
*/
public function detail(): Json {
$param = $this->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());
}
}

@ -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);

@ -1,18 +0,0 @@
<?php
namespace app\api\controller;
/**
* 活动相关接口
*/
class active extends Controller
{
/**
* 新年换新机活动
* @return void
*/
public function getList() {
$param = $this->request->param();
}
}

@ -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('未找到该抬头');

@ -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;

Loading…
Cancel
Save