wanghousheng 10 months ago
parent 595f9ca75d
commit 6e6092015a
  1. 25
      app/api/controller/Order.php
  2. 32
      app/api/model/Order.php
  3. 39
      app/store/controller/Order.php
  4. 2
      app/store/model/Order.php

@ -12,19 +12,17 @@ declare (strict_types=1);
namespace app\api\controller;
use app\api\model\RecoveryOrder;
use app\common\enum\OrderType;
use app\common\enum\user\UserTypeEnum;
use think\response\Json;
use app\api\model\Order as OrderModel;
use app\api\model\Setting as SettingModel;
use app\api\service\User as UserService;
use app\api\service\Order as OrderService;
use app\common\service\qrcode\Extract as ExtractQRcode;
use cores\exception\BaseException;
use app\api\service\TransferRecord;
use app\api\service\User as UserService;
use app\common\enum\OrderType;
use app\common\model\TransferRecord as TransferRecordModel;
use app\common\model\UploadFile;
use app\common\service\qrcode\Extract as ExtractQRcode;
use cores\exception\BaseException;
use think\response\Json;
/**
* 我的订单控制器
@ -93,6 +91,7 @@ class Order extends Controller
],
]);
}
/**
* 获取调货单物流跟踪信息
* @param int $orderId 订单ID
@ -119,6 +118,7 @@ class Order extends Controller
return $this->renderError('暂无物流信息');
}
/**
* 获取物流跟踪信息
* @param int $orderId 订单ID
@ -164,6 +164,7 @@ class Order extends Controller
}
return $this->renderError($model->getError());
}
/**
* 获取当前用户行为数量
* @return Json
@ -185,6 +186,7 @@ class Order extends Controller
];
return $this->renderSuccess($data);
}
/**
* 获取当前用户待处理的订单数量
* @return Json
@ -325,13 +327,4 @@ class Order extends Controller
}
}

@ -111,30 +111,16 @@ class Order extends OrderModel
*/
public function getList(string $dataType = 'all')
{
$keyword = $_GET['keyword'];
// 设置订单类型条件
$dataTypeFilter = $this->getFilterDataType($dataType);
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
$query = $this->with(['goods.image']);
if (!empty($keyword) && $keyword !== 'undefined') {
$query->where('order_no', 'like', "%{$keyword}%");
}
$query->where($dataTypeFilter)
->where('user_id', '=', $userId)
->where('is_delete', '=', 0)
->order(['create_time' => 'desc']);
$list = $query->paginate(15)->toArray();
//这边后面改成多商户的话需要根据storeid去获取信息
$service = new StoreService;
$info = $service->data()['storeInfo']->toArray();
foreach ($list['data'] as &$v) {
$v['storeInfo'] = $info;
}
return $list;
return $query->paginate(15);
}
/**
@ -253,15 +239,12 @@ class Order extends OrderModel
switch ($dataType) {
case 'all':
break;
case 'pay':
case 'payment':
$filter[] = ['pay_status', '=', PayStatusEnum::PENDING];
$filter[] = ['order_status', '=', OrderStatusEnum::NORMAL];
break;
//待付款
case 'pay':
$filter[] = ['pay_status', '=', PayStatusEnum::PENDING];
$filter[] = ['order_status', '=', OrderStatusEnum::NORMAL];
break;
//待发货
case 'delivery':
$filter = [
@ -272,6 +255,7 @@ class Order extends OrderModel
];
break;
//待收货
case 'received':
case 'receipt':
$filter = [
['pay_status', '=', PayStatusEnum::SUCCESS],
@ -281,14 +265,6 @@ class Order extends OrderModel
];
break;
//待收货
case 'received':
$filter = [
['pay_status', '=', PayStatusEnum::SUCCESS],
['delivery_status', '=', DeliveryStatusEnum::DELIVERED],
['receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED],
['order_status', '=', OrderStatusEnum::NORMAL]
];
break;
//已完成
case 'complete':
$filter = [
@ -315,6 +291,8 @@ class Order extends OrderModel
];
break;
}
//非售后订单
$filter[] = ['is_refund', '=', 10];
return $filter;
}

@ -12,8 +12,8 @@ declare (strict_types=1);
namespace app\store\controller;
use think\response\Json;
use app\store\model\Order as OrderModel;
use think\response\Json;
/**
* 订单管理
@ -31,10 +31,45 @@ class Order extends Controller
{
// 订单列表
$model = new OrderModel;
$list = $model->getList($this->request->param());
$result = $model->getList($this->request->param());
$data = $result->items();
if (!empty($data)) {
foreach ($data as $key => $value) {
$copy_text = "订单号:{$value['order_no']}\n";
foreach ($value['goods'] as $good) {
$copy_text .= "商品名称:{$good['goods_name']}\n";
if (!empty($good['goods_no'])) {
$copy_text .= "商品编号:{$good['goods_name']}\n";
}
$copy_text .= "商品单价:{$good['goods_price']}\n";
$copy_text .= "商品数量:{$good['total_num']}\n";
$copy_text .= "商品总价:{$good['total_price']}\n";
$copy_text .= "\n";
}
if (!empty($value['address'])) {
$copy_text .= "收件人:{$value['address']['name']}\n";
$copy_text .= "收件电话:{$value['address']['phone']}\n";
$address = '';
if (!empty($value['address']['region'])) {
$address = $value['address']['region']['province'] . $value['address']['region']['city'] . $value['address']['region']['region'];
}
$copy_text .= "收件地址:$address{$value['address']['detail']}\n";
}
$data[$key]['copy_text'] = $copy_text;
}
}
$list['current_page'] = $result->currentPage();
$list['last_page'] = $result->lastPage();
$list['total'] = $result->total();
$list['data'] = $data;
return $this->renderSuccess(compact('dataType', 'list'));
}
private function getText()
{
}
/**
* 订单详情
* @param int $orderId

@ -221,6 +221,8 @@ class Order extends OrderModel
$params['extractShopId'] > 0 && $filter[] = ['extract_shop_id', '=', (int)$params['extractShopId']];
// 会员ID
$params['userId'] > 0 && $filter[] = ['order.user_id', '=', (int)$params['userId']];
//非售后订单
$filter[] = ['is_refund', '=', 10];
return $filter;
}

Loading…
Cancel
Save