53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
| <?php
 | |
| 
 | |
| namespace app\model;
 | |
| 
 | |
| use think\model\relation\HasOne;
 | |
| 
 | |
| class OrderSku extends Base
 | |
| {
 | |
|     public const STATUS_NORMAL   = 'normal';//正常
 | |
|     public const STATUS_REFUNDED = 'refunded';//已退货
 | |
|     public const STATUS_CLOSED   = 'closed';//已关闭
 | |
| 
 | |
|     public const HAS_COMMENT_YES = 'yes'; // 有评论
 | |
|     public const HAS_COMMENT_NO  = 'no'; // 无评论
 | |
| 
 | |
|     public function sku(): HasOne
 | |
|     {
 | |
|         return $this->hasOne(Sku::class, 'id', 'sku_id');
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 设为已付款
 | |
|      *
 | |
|      * @param  string  $orderCoding
 | |
|      * @return bool
 | |
|      */
 | |
|     public static function setPaid(string $orderCoding): bool
 | |
|     {
 | |
|         return self::where('coding', $orderCoding)->save([
 | |
|             'is_paid' => self::COMMON_ON,
 | |
|             'paid_at' => date('Y-m-d H:i:s')
 | |
|         ]);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 订单相关信息取消(软删除)
 | |
|      *
 | |
|      * @param  string  $orderCoding
 | |
|      * @return bool
 | |
|      */
 | |
|     public static function cancel(string $orderCoding): bool
 | |
|     {
 | |
|         return self::where('coding', $orderCoding)->save([
 | |
|             'status'  => self::STATUS_CLOSED,
 | |
|             'deleted_at' => date('Y-m-d H:i:s')
 | |
|         ]);
 | |
|     }
 | |
| 
 | |
|     public static function history(array $where, array $field = [])
 | |
|     {
 | |
|         return self::where($where)->field($field)->select();
 | |
|     }
 | |
| } |