pull/1/head
wanghousheng 12 months ago
parent a4b5fc1cff
commit 886b1e4710
  1. 70
      app/api/controller/Recovery.php
  2. 53
      app/api/model/Server/RecoveryCategory.php
  3. 21
      app/api/model/Server/ServerRecovery.php

@ -4,15 +4,70 @@ declare (strict_types=1);
namespace app\api\controller;
use app\api\model\RecoveryOrder;
use app\api\model\Server\RecoveryCategory;
use app\api\model\Server\ServerRecovery;
use app\common\enum\RecoveryStatusEnum;
use app\common\enum\RecoveryTypeEnum;
use app\common\library\helper;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\Json;
class Recovery extends Controller
{
/**
* @notes:分类列表
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function categoryList(): Json
{
$model = new RecoveryCategory();
$list = $model->list();
if (!empty($list)) {
foreach ($list as $key => $value) {
unset($list[$key]['image']);
}
}
return $this->renderSuccess(compact('list'));
}
/**
* @notes:服务列表页
* @throws DbException
* @author: wanghousheng
*/
public function recoveryList(): Json
{
$recovery_name = $this->request->post('recovery_name');
$category_id = intval($this->request->post('category_id'));
$where = [];
if ($recovery_name) {
$where[] = ['recovery.recovery_name', 'like', "%$recovery_name%"];
}
if ($category_id) {
$where[] = ['recovery.category_id', '=', $category_id];
}
$where[] = ['recovery.status', '=', 1];
$model = new ServerRecovery();
$list = $model->getList($where);
$data['list'] = $list->items();
$data['total'] = $list->total();
if (!$list->isEmpty()) {
foreach ($data['list'] as $key => $value) {
unset($data['list'][$key]['image']);
unset($data['list'][$key]['category']);
}
}
return $this->renderSuccess($data);
}
/**
* @notes:用户回收订单列表
* @return Json
@ -20,7 +75,7 @@ class Recovery extends Controller
* @throws DbException
* @author: wanghousheng
*/
public function list(): Json
public function orderList(): Json
{
$where = [];
$order_status = intval($this->request->post('order_status'));
@ -59,7 +114,7 @@ class Recovery extends Controller
* @throws BaseException
* @author: wanghousheng
*/
public function detail(): Json
public function orderDetail(): Json
{
$orderId = intval($this->request->post('order_id'));
if (!$orderId) {
@ -89,7 +144,7 @@ class Recovery extends Controller
* @throws BaseException
* @author: wanghousheng
*/
public function cancel(): Json
public function cancelOrder(): Json
{
$orderId = intval($this->request->post('order_id'));
if (!$orderId) {
@ -109,7 +164,7 @@ class Recovery extends Controller
* @throws BaseException
* @author: wanghousheng
*/
public function add(): Json
public function addOrder(): Json
{
$imageIds = $this->request->post('image_ids');
if ($imageIds) {
@ -123,6 +178,10 @@ class Recovery extends Controller
if (!$shop_id) {
return $this->renderError('门店不能为空');
}
$recovery_id = intval($this->request->post('recovery_id'));
if (!$recovery_id) {
return $this->renderError('缺少必要参数');
}
$recovery_type_arr = array_values(RecoveryStatusEnum::data());
$recovery_type_arr = array_column($recovery_type_arr, 'value');
$recovery_type = intval($this->request->post('recovery_type'));
@ -171,6 +230,7 @@ class Recovery extends Controller
$express_id = intval($this->request->post('express_id'));
$express_no = $this->request->post('express_no');
$data = [
'recovery_id' => $recovery_id,
'express_id' => $express_id,
'express_no' => $express_no,
'shipping_address' => $shipping_address,
@ -198,7 +258,7 @@ class Recovery extends Controller
* @return Json
* @author: wanghousheng
*/
public function update(): Json
public function updateOrder(): Json
{
$order_id = intval($this->request->post('order_id'));
if (!$order_id) {

@ -0,0 +1,53 @@
<?php
declare (strict_types=1);
namespace app\api\model\Server;
use app\api\model\UploadFile;
use app\common\model\server\RecoveryCategory as BaseRecoveryCategory;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\model\relation\HasOne;
class RecoveryCategory extends BaseRecoveryCategory
{
/**
* 隐藏字段
* @var array
*/
protected $hidden = [
'store_id',
'create_time',
'update_time',
'status',
'image_id',
];
/**
* 分类图片
* @return HasOne
*/
public function image(): HasOne
{
return $this->hasOne(UploadFile::class, 'file_id', 'image_id')
->bind(['image_url' => 'preview_url']);
}
/**
* @notes:获取全部记录
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function list(): array
{
return $this->with(['image'])
->where(['status' => 1])
->order(['sort', 'create_time'])
->select()
->toArray();
}
}

@ -0,0 +1,21 @@
<?php
namespace app\api\model\Server;
use app\common\model\server\ServerRecovery as BaseServerRecovery;
class ServerRecovery extends BaseServerRecovery
{
/**
* 隐藏字段
* @var array
*/
protected $hidden = [
'store_id',
'create_time',
'update_time',
'status',
'image_id',
'delete_time',
];
}
Loading…
Cancel
Save