<?php
// +----------------------------------------------------------------------
// | A3Mall
// +----------------------------------------------------------------------
// | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: xzncit <158373108@qq.com>
// +----------------------------------------------------------------------

namespace app\adminapi\service\promotion;

use app\common\model\promotion\Award as AwardModel;

/**
 * @package app\adminapi\service\promotion
 * @class Award
 * @author xzncit 2024-02-18
 */
class Award {

    /**
     * 获取
     * @return array|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function detail(){
        return AwardModel::where("1=1")->find();
    }

    /**
     * 保存
     * @param array $params
     * @return bool|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function save($params=[]){
        $row = AwardModel::where("1=1")->find();
        if(empty($row)){
            $params["create_time"] = time();
            return AwardModel::create($params)->id;
        }

        return AwardModel::where("id",$row["id"])->save($params);
    }

}