wanghousheng 10 months ago
parent 277c5efe1c
commit 05acbdd3da
  1. 45
      app/api/model/Order.php

@ -12,24 +12,23 @@ declare (strict_types=1);
namespace app\api\model; namespace app\api\model;
use app\common\model\TransferRecord;
use app\api\model\{Goods as GoodsModel, OrderRefund as OrderRefundModel, Setting as SettingModel, user\UserCoupon}; use app\api\model\{Goods as GoodsModel, OrderRefund as OrderRefundModel, Setting as SettingModel, user\UserCoupon};
use app\api\service\{User as UserService, order\source\Factory as OrderSourceFactory}; use app\api\service\{order\source\Factory as OrderSourceFactory, User as UserService};
use app\common\model\Order as OrderModel; use app\api\service\Store as StoreService;
use app\common\service\{Order as OrderService, order\Complete as OrderCompleteService}; use app\common\enum\{order\DeliveryStatus as DeliveryStatusEnum,
use app\common\enum\{OrderType,
RecoveryStatusEnum,
Setting as SettingEnum,
order\PayStatus as PayStatusEnum,
order\OrderStatus as OrderStatusEnum,
order\DeliveryType as DeliveryTypeEnum, order\DeliveryType as DeliveryTypeEnum,
order\OrderStatus as OrderStatusEnum,
order\PayStatus as PayStatusEnum,
order\ReceiptStatus as ReceiptStatusEnum, order\ReceiptStatus as ReceiptStatusEnum,
order\DeliveryStatus as DeliveryStatusEnum, OrderType,
user\UserTypeEnum}; RecoveryStatusEnum,
use app\api\service\Store as StoreService; Setting as SettingEnum};
use app\common\library\helper; use app\common\library\helper;
use app\common\model\Order as OrderModel;
use app\common\model\TransferRecord;
use app\common\service\{Order as OrderService, order\Complete as OrderCompleteService};
use cores\exception\BaseException; use cores\exception\BaseException;
use app\api\model\PreSaleLog;
/** /**
* 订单模型 * 订单模型
* Class Order * Class Order
@ -228,7 +227,7 @@ class Order extends OrderModel
// 查询数据 // 查询数据
$query = $this; $query = $this;
// 非店长不带入user_id查询 // 非店长不带入user_id查询
if(!UserService::isStore()) { if (!UserService::isStore()) {
$query = $this->where('user_id', '=', $userId); $query = $this->where('user_id', '=', $userId);
} }
@ -240,6 +239,7 @@ class Order extends OrderModel
->where('is_delete', '=', 0) ->where('is_delete', '=', 0)
->count(); ->count();
} }
/** /**
* 设置订单类型条件 * 设置订单类型条件
* @param string $dataType * @param string $dataType
@ -474,7 +474,7 @@ class Order extends OrderModel
//这边后面改成多商户的话需要根据storeid去获取信息 //这边后面改成多商户的话需要根据storeid去获取信息
$service = new StoreService; $service = new StoreService;
$info = $service->data()['storeInfo']->toArray(); $info = $service->data();
$order->storeInfo = $info; $order->storeInfo = $info;
return $order; return $order;
} }
@ -512,7 +512,7 @@ class Order extends OrderModel
'received_number' => $this->getCount('received'), // 待收货的订单 'received_number' => $this->getCount('received'), // 待收货的订单
'finish_number' => $this->getCount('complete'), // 已完成 'finish_number' => $this->getCount('complete'), // 已完成
]; ];
} elseif($order_type == OrderType::SERVER) {//服务 } elseif ($order_type == OrderType::SERVER) {//服务
$model = new Server\ServerOrder(); $model = new Server\ServerOrder();
return [ return [
'confirm_number' => $model->getCount('confirm'), // 待确认的订单 'confirm_number' => $model->getCount('confirm'), // 待确认的订单
@ -520,7 +520,7 @@ class Order extends OrderModel
'payment_number' => $model->getCount('payment'), // 待收货的订单 'payment_number' => $model->getCount('payment'), // 待收货的订单
'check_number' => $model->getCount('complete'), // 已完成的订单 'check_number' => $model->getCount('complete'), // 已完成的订单
]; ];
} elseif ($order_type == OrderType::RECOVERY){ } elseif ($order_type == OrderType::RECOVERY) {
$model = new RecoveryOrder(); $model = new RecoveryOrder();
return [ return [
'accepted_number' => $model->getCount(RecoveryStatusEnum::ACCEPTED), // 待确认的订单 'accepted_number' => $model->getCount(RecoveryStatusEnum::ACCEPTED), // 待确认的订单
@ -528,7 +528,7 @@ class Order extends OrderModel
'cancel_number' => $model->getCount(RecoveryStatusEnum::CANCEL), // 已取消的订单 'cancel_number' => $model->getCount(RecoveryStatusEnum::CANCEL), // 已取消的订单
'finish_number' => $model->getCount(RecoveryStatusEnum::FINISN), // 已完成的订单 'finish_number' => $model->getCount(RecoveryStatusEnum::FINISN), // 已完成的订单
]; ];
}elseif($order_type == OrderType::DEALER) {//分销 } elseif ($order_type == OrderType::DEALER) {//分销
$model = new dealer\Order(); $model = new dealer\Order();
$dealer_order_ids = $model->where('user_id', UserService::getCurrentLoginUserId())->column('order_id'); $dealer_order_ids = $model->where('user_id', UserService::getCurrentLoginUserId())->column('order_id');
return [ return [
@ -606,13 +606,14 @@ class Order extends OrderModel
'coupon_number' => UserCoupon::getCount(), // 优惠券 'coupon_number' => UserCoupon::getCount(), // 优惠券
'goods_collect_number' => 0, // 商品采集数量 'goods_collect_number' => 0, // 商品采集数量
'cart_number' => Cart::getCount(), // 购物车数量 'cart_number' => Cart::getCount(), // 购物车数量
'take_goods_number' => OrderModel::where('user_id', $userId)->where('delivery_type',20)->count(), // 发货记录&提货记录 'take_goods_number' => OrderModel::where('user_id', $userId)->where('delivery_type', 20)->count(), // 发货记录&提货记录
]; ];
} }
public function getZitiAddressAttr($value) { public function getZitiAddressAttr($value)
if(!empty($value)) return json_decode($value, true); {
return $value; if (!empty($value)) return json_decode($value, true);
return $value;
} }
} }

Loading…
Cancel
Save