From cea284153f8a73c5e4095f6dd2901737cd4b11c7 Mon Sep 17 00:00:00 2001 From: wanghousheng Date: Fri, 22 Mar 2024 16:48:39 +0800 Subject: [PATCH] 1 --- app/common/model/Order.php | 41 ++++++++++++++++++++++---------------- app/store/model/Order.php | 36 ++++++++++++++++----------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/app/common/model/Order.php b/app/common/model/Order.php index a8082a41..288fd7c7 100644 --- a/app/common/model/Order.php +++ b/app/common/model/Order.php @@ -12,23 +12,23 @@ declare (strict_types=1); namespace app\common\model; +use app\common\enum\order\DeliveryStatus as DeliveryStatusEnum; use app\common\enum\order\DeliveryType; +use app\common\enum\order\DeliveryType as DeliveryTypeEnum; +use app\common\enum\order\OrderStatus as OrderStatusEnum; +use app\common\enum\order\PayStatus as PayStatusEnum; +use app\common\enum\order\ReceiptStatus as ReceiptStatusEnum; use app\common\enum\payment\Method; -use cores\BaseModel; +use app\common\library\helper; use app\common\model\store\shop\Order as ShopOrder; use app\common\service\Order as OrderService; -use app\common\service\order\Shipping as ShippingService; use app\common\service\order\Complete as OrderCompleteService; +use app\common\service\order\Shipping as ShippingService; use app\common\service\order\source\Factory as OrderSourceFactory; -use app\common\enum\order\PayStatus as PayStatusEnum; -use app\common\enum\order\OrderStatus as OrderStatusEnum; -use app\common\enum\order\DeliveryType as DeliveryTypeEnum; -use app\common\enum\order\ReceiptStatus as ReceiptStatusEnum; -use app\common\enum\order\DeliveryStatus as DeliveryStatusEnum; -use app\common\library\helper; -use think\model\relation\HasOne; -use think\model\relation\HasMany; +use cores\BaseModel; use think\model\relation\BelongsTo; +use think\model\relation\HasMany; +use think\model\relation\HasOne; /** * 订单模型 @@ -111,6 +111,12 @@ class Order extends BaseModel return $this->belongsTo("app\\{$module}\\model\\store\\Shop", 'extract_shop_id'); } + //TransferRecordModel + public function transfer(): HasOne + { + return $this->hasOne(TransferRecord::class, 'order_id'); + } + /** * 关联门店店员表 * @return BelongsTo @@ -399,19 +405,19 @@ class Order extends BaseModel } - public function getPayMethodTextAttr($value,$data): string + public function getPayMethodTextAttr($value, $data): string { - return !empty(Method::data()[$data['pay_method']])?Method::data()[$data['pay_method']]['name']:'';//支付方式 + return !empty(Method::data()[$data['pay_method']]) ? Method::data()[$data['pay_method']]['name'] : '';//支付方式 } - public function getDeliveryTypeTextAttr($value,$data): string + public function getDeliveryTypeTextAttr($value, $data): string { - return !empty(DeliveryType::data()[$data['delivery_type']])? DeliveryType::data()[$data['delivery_type']]['name']: '';//配送方式 + return !empty(DeliveryType::data()[$data['delivery_type']]) ? DeliveryType::data()[$data['delivery_type']]['name'] : '';//配送方式 } - public function getTimeTextAttr($value, $data) : int + public function getTimeTextAttr($value, $data): int { - $diffTime = 60*60*24;//24小时倒计时 + $diffTime = 60 * 60 * 24;//24小时倒计时 // 付款状态 if ($data['pay_status'] == PayStatusEnum::PENDING) { return (($data['create_time'] + $diffTime) - time()) * 1000; @@ -424,7 +430,8 @@ class Order extends BaseModel return 0; } - public function getStorePhoneAttr($value,$data) { + public function getStorePhoneAttr($value, $data) + { return Store::get($data['store_id'])->phone ?: ''; } } diff --git a/app/store/model/Order.php b/app/store/model/Order.php index 0177190a..3a4ead57 100644 --- a/app/store/model/Order.php +++ b/app/store/model/Order.php @@ -13,18 +13,17 @@ declare (strict_types=1); namespace app\store\model; use app\api\service\User as UserService; -use app\common\enum\payment\Method; -use app\common\model\Order as OrderModel; -use app\common\service\Order as OrderService; -use app\common\service\order\Refund as RefundService; -use app\common\service\order\Printer as PrinterService; use app\common\enum\order\{DataType as DataTypeEnum, + DeliveryStatus as DeliveryStatusEnum, DeliveryType, - PayStatus as PayStatusEnum, OrderStatus as OrderStatusEnum, - ReceiptStatus as ReceiptStatusEnum, - DeliveryStatus as DeliveryStatusEnum}; + PayStatus as PayStatusEnum, + ReceiptStatus as ReceiptStatusEnum}; use app\common\library\helper; +use app\common\model\Order as OrderModel; +use app\common\service\Order as OrderService; +use app\common\service\order\Printer as PrinterService; +use app\common\service\order\Refund as RefundService; use cores\exception\BaseException; /** @@ -102,16 +101,16 @@ class Order extends OrderModel // 检索查询条件 $filter = $this->getQueryFilter($param); //不是店长查询当前用户订单 - if(!UserService::isStore()) { - $filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ]; - } - //普通会员和plus会员查询条件 - if (!empty($param['user_id'])) { - $filter[] = ['user.user_id' ,'=', $param['user_id']]; - } - if (!empty($param['delivery_type'])) { - $filter[] = ['order.delivery_type', '=', DeliveryType::EXPRESS]; - } + if (!UserService::isStore()) { + $filter[] = ['user.user_id', '=', UserService::getCurrentLoginUserId()]; + } + //普通会员和plus会员查询条件 + if (!empty($param['user_id'])) { + $filter[] = ['user.user_id', '=', $param['user_id']]; + } + if (!empty($param['delivery_type'])) { + $filter[] = ['order.delivery_type', '=', DeliveryType::EXPRESS]; + } $filterOr = []; if (!empty($param['searchValue']) && $param['searchType'] == 'all') { // $filterOr = [ @@ -135,6 +134,7 @@ class Order extends OrderModel ->leftJoin('order_address address', 'address.order_id = order.order_id') ->where($dataTypeFilter) ->where($filter) + ->with(['transfer']) ->where('order.is_delete', '=', 0); if (!empty($filterOr)) { // $query = $query->whereOr($filterOr);