$user['cp_name'], 'is_enabled' => 1, 'is_show_total_amount' => $user['is_show_total_amount'] ?? 0, 'is_union_sign' => $user['is_union_sign'] ?? 0, 'timestamp' => time(), ]; $params['sign'] = self::getSign($params['timestamp']); $url = config('contentManage.zhushuyunpublicapi.public_domain', 'https://pubapi.zhuishuyun.com') . '/inapi/cpUers/createUser'; $client = new Client(['base_uri' => $url,'timeout' => 2]); $response = $client->request('post','',['query' => $params]); $result = $response->getBody()->getContents(); $result = json_decode($result, true); if (!isset($result['code']) || $result['code'] != 0) { Log::error("cp创建用户接口请求异常,请求结果为:" . var_export($result, true)); throw new \Exception("cp创建用户接口请求异常"); } return true; } private static function getSign(mixed $timestamp) { $key = config('contentManage.zhushuyunpublicapi.external_private_key', 'ZSY_2021!KEY'); $string = md5($timestamp . $key) . $key; return md5($string); } public static function selectOptions($cpName = "") { $list = Cps::select('cp_id','cp_name','cp_nick','cp_company'); if (!empty($cpName)){ $list->where('cp_name','like',"%{$cpName}%"); } return $list->get(); } /** * 查询产品列表 * name: getCpList * @param $where * @param int $pageSize * @return LengthAwarePaginator * date 2023/03/22 20:49 */ public static function getCpList($where , int $pageSize = 20) { $list = DB::table('cps')->where($where)->orderBy('cp_id','desc')->paginate($pageSize); if(!$list->isEmpty()){ foreach ($list as $value){ $value->book_count = Book::where('cp_id', $value->cp_id)->count(); } } return $list; } }