ztt 9 months ago
parent f9fa7df920
commit 3c41a28530
  1. 2
      app/api/controller/Address.php
  2. 7
      app/api/controller/Order.php
  3. 17
      app/api/model/Order.php
  4. 6
      app/api/model/RecoveryOrder.php
  5. 5
      app/api/model/UserAddress.php
  6. 7
      app/common/enum/OrderType.php

@ -37,7 +37,7 @@ class Address extends Controller
{
// 获取收货地址列表
$model = new UserAddressModel;
$list = $model->getList();
$list = $model->getList($this->request->param('user_id'));
return $this->renderSuccess(compact('list'));
}

@ -195,6 +195,7 @@ class Order extends Controller
$model = new OrderModel;
$goods_counts = $model->getTodoCounts(OrderType::ORDER);
$service_counts = $model->getTodoCounts(OrderType::SERVER);
$recovery_counts = $model->getTodoCounts(OrderType::RECOVERY);
$dealer_counts = $model->getTodoCounts(OrderType::DEALER);
// var_dump($dealer_counts);
$data = [
@ -210,6 +211,12 @@ class Order extends Controller
'payment_number' => $service_counts['payment_number'],//待支付
'check_number' => $service_counts['check_number'],//已完成
],
'recovery_order' => [
'accepted_number' => $recovery_counts['accepted_number'],//待确认
'already_number' => $recovery_counts['already_number'],//待服务ALREADY
'cancel_number' => $recovery_counts['cancel_number'],//已取消
'finish_number' => $recovery_counts['finish_number'],//已完成
],
'distribution_order' => [//分销订单
'payment_number' => $dealer_counts['payment_number'],//待付款
'delivery_number' => $dealer_counts['delivery_number'],//待发货

@ -18,6 +18,7 @@ use app\api\service\{User as UserService, order\source\Factory as OrderSourceFac
use app\common\model\Order as OrderModel;
use app\common\service\{Order as OrderService, order\Complete as OrderCompleteService};
use app\common\enum\{OrderType,
RecoveryStatusEnum,
Setting as SettingEnum,
order\PayStatus as PayStatusEnum,
order\OrderStatus as OrderStatusEnum,
@ -495,17 +496,17 @@ class Order extends OrderModel
* @return array
* @throws BaseException
*/
public function getTodoCounts($user_type): array
public function getTodoCounts($order_type): array
{
if ($user_type == OrderType::ORDER) {//商城
if ($order_type == OrderType::ORDER) {//商城
return [
'payment_number' => $this->getCount('payment'), // 待付款的订单
'delivery_number' => $this->getCount('delivery'), // 待发货的订单
'received_number' => $this->getCount('received'), // 待收货的订单
'finish_number' => $this->getCount('complete'), // 已完成
];
} elseif($user_type == OrderType::SERVER) {//服务
} elseif($order_type == OrderType::SERVER) {//服务
$model = new Server\ServerOrder();
return [
'confirm_number' => $model->getCount('confirm'), // 待确认的订单
@ -513,7 +514,15 @@ class Order extends OrderModel
'payment_number' => $model->getCount('payment'), // 待收货的订单
'check_number' => $model->getCount('complete'), // 已完成的订单
];
} elseif($user_type == OrderType::DEALER) {//分销
} elseif ($order_type == OrderType::RECOVERY){
$model = new RecoveryOrder();
return [
'accepted_number' => $model->getCount(RecoveryStatusEnum::ACCEPTED), // 待确认的订单
'already_number' => $model->getCount(RecoveryStatusEnum::ALREADY), // 待发货的订单
'cancel_number' => $model->getCount(RecoveryStatusEnum::CANCEL), // 已取消的订单
'finish_number' => $model->getCount(RecoveryStatusEnum::FINISN), // 已完成的订单
];
}elseif($order_type == OrderType::DEALER) {//分销
$model = new dealer\Order();
$dealer_order_ids = $model->where('user_id', UserService::getCurrentLoginUserId())->column('order_id');
return [

@ -131,13 +131,13 @@ class RecoveryOrder extends BaseRecoveryOrder
* 获取回收单记录
* @return int
*/
public static function getCount(): int {
public static function getCount($type): int {
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
// 查询数据
return self::where('user_id', '=', $userId)
->where('order_status', '=', 10)
->where('order_status', '=', $type)
->count();
}
}

@ -43,9 +43,12 @@ class UserAddress extends UserAddressModel
* @throws \think\db\exception\ModelNotFoundException
* @throws BaseException
*/
public function getList(): \think\Collection
public function getList($user_id = 0): \think\Collection
{
$userId = UserService::getCurrentLoginUserId();
if (!empty($user_id)) {
$userId = $user_id;
}
return $this->where('user_id', '=', $userId)
->where('is_delete', '=', 0)
->select();

@ -31,6 +31,9 @@ class OrderType extends EnumBasics
// 开通分销订单
const DEALER = 40;
// 回收订单
const RECOVERY = 50;
// 余额充值订单
const RECHARGE = 100;
@ -54,6 +57,10 @@ class OrderType extends EnumBasics
'name' => '服务订单',
'value' => self::SERVER,
],
self::RECOVERY => [
'name' => '回收订单',
'value' => self::RECOVERY,
],
self::MEMBER => [
'name' => '开通会员订单',
'value' => self::MEMBER,

Loading…
Cancel
Save