<?php


namespace App\Services\marketing;

use App\Models\marketing\mysql\DistributorAuditRecord;
use Api\PhpUtils\Validate\Validate;
use Api\PhpServices\Idgen\Idgen;

class DistributionService
{
   

    public static function addDistribution($params)
    {
        $params = [

        ];
        DistributorAuditRecord::insertRecord($params);

    }


    public static function getDistributionList($params)
    {

        $where['ORDER'] = ["create_time" => "DESC"];
        $distributionList = DistributorAuditRecord::getRecords($where);

        $count = DistributorAuditRecord::getCount(['']);

        return $distributionList;
    }


     /**
     * 通过发号器拿 id （非雪花）
     * number，获取店铺shop_id用生活号id后两位，商品相关的这里是shop_id的后两位
     * @param $number
     * @param $type
     * @param int $count
     * @return array|mixed
     */
    public static function getIdgenId($number, $type, $count = 1)
    {
        $res = Idgen::get(appConfig('idgen.partner'), appConfig('idgen.key'), [], [[
            "type" => $type,
            'number' => (int)$number,
            "count" => $count]]);
        return $res['id_datetime'][$type] ?? [];
    }

    public static function getSnowIdgenId($type, $count = 1)
    {
        $res = Idgen::get(appConfig('idgen.partner'), appConfig('idgen.key'), [[
            "type" => $type,
            "count" => $count]], []);
        return $res['id_snow'][$type] ?? [];
    }
}