wanghousheng 8 months ago
parent 2ccae36c19
commit cea284153f
  1. 41
      app/common/model/Order.php
  2. 22
      app/store/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 ?: '';
}
}

@ -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,12 +101,12 @@ class Order extends OrderModel
// 检索查询条件
$filter = $this->getQueryFilter($param);
//不是店长查询当前用户订单
if(!UserService::isStore()) {
$filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ];
if (!UserService::isStore()) {
$filter[] = ['user.user_id', '=', UserService::getCurrentLoginUserId()];
}
//普通会员和plus会员查询条件
if (!empty($param['user_id'])) {
$filter[] = ['user.user_id' ,'=', $param['user_id']];
$filter[] = ['user.user_id', '=', $param['user_id']];
}
if (!empty($param['delivery_type'])) {
$filter[] = ['order.delivery_type', '=', DeliveryType::EXPRESS];
@ -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);

Loading…
Cancel
Save