订单发货状态
parent
8c83eb5027
commit
ffa9bc4086
|
|
@ -15,7 +15,7 @@ class OrderFilter extends ModelFilter
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unreceived':
|
case 'unreceived':
|
||||||
$this->whereIn('status', [Order::STATUS_PAID, Order::STATUS_SHIPPED]);
|
$this->where('status', Order::STATUS_PAID);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'completed':
|
case 'completed':
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,13 @@ class Order extends Model
|
||||||
|
|
||||||
public const STATUS_PENDING = 0; // 待付款
|
public const STATUS_PENDING = 0; // 待付款
|
||||||
public const STATUS_PAID = 1; // 已付款
|
public const STATUS_PAID = 1; // 已付款
|
||||||
public const STATUS_SHIPPED = 2; // 已发货
|
|
||||||
public const STATUS_COMPLETED = 9; // 已完成
|
public const STATUS_COMPLETED = 9; // 已完成
|
||||||
public const STATUS_CANCELLED = 10; // 已取消
|
public const STATUS_CANCELLED = 10; // 已取消
|
||||||
|
|
||||||
|
public const SHIPPING_STATE_PENDING = 0; // 待发货
|
||||||
|
public const SHIPPING_STATE_PROCESSING = 1; // 发货中
|
||||||
|
public const SHIPPING_STATE_PROCESSED = 2; // 已完成
|
||||||
|
|
||||||
public const PAY_WAY_ALIPAY = 'alipay';
|
public const PAY_WAY_ALIPAY = 'alipay';
|
||||||
public const PAY_WAY_WXPAY = 'wxpay';
|
public const PAY_WAY_WXPAY = 'wxpay';
|
||||||
public const PAY_WAY_BALANCE = 'balance';
|
public const PAY_WAY_BALANCE = 'balance';
|
||||||
|
|
@ -58,6 +61,7 @@ class Order extends Model
|
||||||
'consignee_telephone',
|
'consignee_telephone',
|
||||||
'consignee_zone',
|
'consignee_zone',
|
||||||
'consignee_address',
|
'consignee_address',
|
||||||
|
'shipping_state',
|
||||||
'status',
|
'status',
|
||||||
'completed_at',
|
'completed_at',
|
||||||
];
|
];
|
||||||
|
|
@ -94,7 +98,7 @@ class Order extends Model
|
||||||
*/
|
*/
|
||||||
public function isConfirmable(): bool
|
public function isConfirmable(): bool
|
||||||
{
|
{
|
||||||
return in_array($this->status, [static::STATUS_PAID, static::STATUS_SHIPPED]);
|
return $this->isPaid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -104,7 +108,11 @@ class Order extends Model
|
||||||
*/
|
*/
|
||||||
public function isCancelable(): bool
|
public function isCancelable(): bool
|
||||||
{
|
{
|
||||||
return in_array($this->status, [static::STATUS_PENDING, static::STATUS_PAID]);
|
if ($this->isPaid()) {
|
||||||
|
return $this->shipping_state === static::SHIPPING_STATE_PENDING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->isPending();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -117,6 +125,16 @@ class Order extends Model
|
||||||
return $this->status === static::STATUS_PENDING;
|
return $this->status === static::STATUS_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认此订单是否是已付款
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isPaid(): bool
|
||||||
|
{
|
||||||
|
return $this->status === static::STATUS_PENDING;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取订单券优惠金额
|
* 获取订单券优惠金额
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddShippingStateToOrdersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('orders', function (Blueprint $table) {
|
||||||
|
$table->tinyInteger('shipping_state')->index()->default(0)->comment('发货状态');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('orders', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['shipping_state']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue