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

@ -12,24 +12,23 @@ declare (strict_types=1);
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\service\{User as UserService, order\source\Factory as OrderSourceFactory};
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,
use app\api\service\{order\source\Factory as OrderSourceFactory, User as UserService};
use app\api\service\Store as StoreService;
use app\common\enum\{order\DeliveryStatus as DeliveryStatusEnum,
order\DeliveryType as DeliveryTypeEnum,
order\OrderStatus as OrderStatusEnum,
order\PayStatus as PayStatusEnum,
order\ReceiptStatus as ReceiptStatusEnum,
order\DeliveryStatus as DeliveryStatusEnum,
user\UserTypeEnum};
use app\api\service\Store as StoreService;
OrderType,
RecoveryStatusEnum,
Setting as SettingEnum};
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 app\api\model\PreSaleLog;
/**
* 订单模型
* Class Order
@ -90,7 +89,7 @@ class Order extends OrderModel
$item['skuInfo'] = GoodsModel::getSkuInfo($item, $goodsSkuId, false);
// 商品封面 (优先sku封面)
$item['goods_image'] = $item['skuInfo']['goods_image'] ?: $item['goods_image'];
// 商品单价
$item['goods_price'] = \app\api\service\Goods::getGoodsPrice($item['goods_id'], $item['skuInfo']['goods_price'], $item['skuInfo']['cost_price']);
// 商品购买数量
@ -228,7 +227,7 @@ class Order extends OrderModel
// 查询数据
$query = $this;
// 非店长不带入user_id查询
if(!UserService::isStore()) {
if (!UserService::isStore()) {
$query = $this->where('user_id', '=', $userId);
}
@ -240,6 +239,7 @@ class Order extends OrderModel
->where('is_delete', '=', 0)
->count();
}
/**
* 设置订单类型条件
* @param string $dataType
@ -339,7 +339,7 @@ class Order extends OrderModel
case 'pay':
$filter[] = ['a.pay_status', '=', PayStatusEnum::PENDING];
$filter[] = ['a.order_status', '=', OrderStatusEnum::NORMAL];
break;
break;
//待发货
case 'delivery':
$filter = [
@ -347,7 +347,7 @@ class Order extends OrderModel
['a.delivery_status', '<>', DeliveryStatusEnum::DELIVERED],
['a.order_status', 'in', [OrderStatusEnum::NORMAL, OrderStatusEnum::APPLY_CANCEL]]
];
break;
break;
//待收货
case 'receipt':
$filter = [
@ -356,7 +356,7 @@ class Order extends OrderModel
['a.receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED],
['a.order_status', '=', OrderStatusEnum::NORMAL]
];
break;
break;
//待收货
case 'received':
$filter = [
@ -474,7 +474,7 @@ class Order extends OrderModel
//这边后面改成多商户的话需要根据storeid去获取信息
$service = new StoreService;
$info = $service->data()['storeInfo']->toArray();
$info = $service->data();
$order->storeInfo = $info;
return $order;
}
@ -512,7 +512,7 @@ class Order extends OrderModel
'received_number' => $this->getCount('received'), // 待收货的订单
'finish_number' => $this->getCount('complete'), // 已完成
];
} elseif($order_type == OrderType::SERVER) {//服务
} elseif ($order_type == OrderType::SERVER) {//服务
$model = new Server\ServerOrder();
return [
'confirm_number' => $model->getCount('confirm'), // 待确认的订单
@ -520,7 +520,7 @@ class Order extends OrderModel
'payment_number' => $model->getCount('payment'), // 待收货的订单
'check_number' => $model->getCount('complete'), // 已完成的订单
];
} elseif ($order_type == OrderType::RECOVERY){
} elseif ($order_type == OrderType::RECOVERY) {
$model = new RecoveryOrder();
return [
'accepted_number' => $model->getCount(RecoveryStatusEnum::ACCEPTED), // 待确认的订单
@ -528,7 +528,7 @@ class Order extends OrderModel
'cancel_number' => $model->getCount(RecoveryStatusEnum::CANCEL), // 已取消的订单
'finish_number' => $model->getCount(RecoveryStatusEnum::FINISN), // 已完成的订单
];
}elseif($order_type == OrderType::DEALER) {//分销
} elseif ($order_type == OrderType::DEALER) {//分销
$model = new dealer\Order();
$dealer_order_ids = $model->where('user_id', UserService::getCurrentLoginUserId())->column('order_id');
return [
@ -606,13 +606,14 @@ class Order extends OrderModel
'coupon_number' => UserCoupon::getCount(), // 优惠券
'goods_collect_number' => 0, // 商品采集数量
'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) {
if(!empty($value)) return json_decode($value, true);
return $value;
public function getZitiAddressAttr($value)
{
if (!empty($value)) return json_decode($value, true);
return $value;
}
}

Loading…
Cancel
Save