<?php

namespace app\admin\logic\store_extract;


use app\common\model\store_extract\StoreExtract;
use app\common\logic\BaseLogic;
use think\facade\Db;


/**
 * 门店提现逻辑
 * Class StoreExtractLogic
 * @package app\admin\logic\store_extract
 */
class StoreExtractLogic extends BaseLogic
{


    /**
     * @notes 添加门店提现
     * @param array $params
     * @return bool
     * @author admin
     * @date 2024/05/31 17:09
     */
    public static function add(array $params): bool
    {
        Db::startTrans();
        try {
            StoreExtract::create([

            ]);

            Db::commit();
            return true;
        } catch (\Exception $e) {
            Db::rollback();
            self::setError($e->getMessage());
            return false;
        }
    }


    /**
     * @notes 编辑门店提现
     * @param array $params
     * @return bool
     * @author admin
     * @date 2024/05/31 17:09
     */
    public static function edit(array $params): bool
    {
        Db::startTrans();
        try {
            StoreExtract::where('id', $params['id'])->update([

            ]);

            Db::commit();
            return true;
        } catch (\Exception $e) {
            Db::rollback();
            self::setError($e->getMessage());
            return false;
        }
    }


    /**
     * @notes 删除门店提现
     * @param array $params
     * @return bool
     * @author admin
     * @date 2024/05/31 17:09
     */
    public static function delete(array $params): bool
    {
        return StoreExtract::destroy($params['id']);
    }


    /**
     * @notes 获取门店提现详情
     * @param $params
     * @return array
     * @author admin
     * @date 2024/05/31 17:09
     */
    public static function detail($params): array
    {
        return StoreExtract::findOrEmpty($params['id'])->toArray();
    }
}