<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台（PHP版）
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码，建议反馈是我们前进的动力
// | 开源版本可自由商用，可去除界面版权logo
// | gitee下载：https://gitee.com/likeshop_gitee/likeadmin
// | github下载：https://github.com/likeshop-github/likeadmin
// | 访问官网：https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------

namespace app\common\model\group_activity;


use app\common\model\BaseModel;
use app\adminapi\logic\ConfigLogic;
use think\model\concern\SoftDelete;


/**
 * 拼团活动模型
 * Class GroupUserOrder
 * @package app\common\model\group_user_order
 */
class GroupUserOrder extends BaseModel
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $name = 'group_user_order';

    public function groupOrder(){
        return $this->hasOne(GroupOrder::class,'id','group_order_id')->field('id,equity_id,goods_id,sn,status,num,create_time,end_time');
    }
    public function getCreateTimeAttr($value,$data)
    {
        return !empty($data['create_time'])?date('Y-m-d H:i:s',$data['create_time']):'';
    }
    
    public function getPayTimeAttr($value,$data)
    {
        return !empty($data['pay_time'])?date('Y-m-d H:i:s',$data['pay_time']):'';
    }

    public function getGroupOrderStatusTextAttr($value,$data)
    {
        $dictType = array_column(ConfigLogic::getDictByType('group_order_status')['group_order_status'],'name','value');
        return $dictType[$data['group_order_status']];
    }
    public function getStatusTextAttr($value,$data)
    {
        $dictType = array_column(ConfigLogic::getDictByType('group_user_order_status')['group_user_order_status'],'name','value');
        return $dictType[$data['status']];
    }
    public function getPayStatusTextAttr($value,$data)
    {
        $dictType = array_column(ConfigLogic::getDictByType('pay_status')['pay_status'],'name','value');
        return $dictType[$data['pay_status']];
    }
    public function getRefundStatusTextAttr($value,$data)
    {
        $dictType = array_column(ConfigLogic::getDictByType('group_refund_status')['group_refund_status'],'name','value');
        return $dictType[$data['refund_status']];
    }
    public function getPayWayTextAttr($value,$data)
    {
        $dictType = array_column(ConfigLogic::getDictByType('pay_way')['pay_way'],'name','value');
        return $dictType[$data['pay_way']];
    }
}