作者 Cool

商圈信息发布修改

... ... @@ -615,6 +615,7 @@ class Store extends Api
* @ApiParams (name="inform_id", type="string", required=false, description="信息id")
* @ApiParams (name="content", type="string", required=true, description="详细内容")
* @ApiParams (name="images", type="string", required=true, description="图片")
* @ApiParams (name="video", type="string", required=true, description="视频")
* @ApiParams (name="house_ids", type="string", required=true, description="推广社区")
* @ApiParams (name="type", type="integer", required=true, description="推广类型1=红包推送信息2=一般信息")
* @ApiParams (name="red_package", type="string", required=false, description="红包总金额")
... ... @@ -640,6 +641,14 @@ class Store extends Api
$this->error('包含未绑定的社区,请重新选择');
}
}
$img_count = count(explode(',',$param['images']));
$video_count = !empty($param['video']) ? count(explode(',',$param['video'])) : 0;
if($video_count > 1) {
$this->error('视频只能上传一个');
}
if(($video_count == 1 && $img_count > 8) || $img_count > 9) {
$this->error('最多上传9张图片或1个视频及8张图片');
}
if($param['type'] == 1) {
$param['single'] = $param['red_package'] / $param['number'];
$param['score'] = bcadd(config('site.send_score'),$param['red_package'] * config('site.withdraw_percent'),2);
... ...
... ... @@ -8,7 +8,8 @@ class StoreInform extends Base
{
protected $append = [
'image_arr'
'image_arr',
'video_image'
];
public function getImageArrAttr($value,$data)
... ... @@ -23,6 +24,27 @@ class StoreInform extends Base
return $image_arr;
}
public function getVideoAttr($value)
{
$video = '';
if($value) {
// 获取视频第一帧图片
$video = cdnurl($value, true);
}
return $video;
}
public function getVideoImageAttr($value,$data)
{
$img = '';
if($data['video']) {
// 获取视频第一帧图片
$video_info = json_decode(file_get_contents(cdnurl($data['video'], true) . '?avinfo'), true);
$lesson_matter['video_image'] = get_video_first_image(cdnurl($data['video'],true), $video_info);
}
return $img;
}
// public function getCreatetimeAttr($value)
// {
// return date('Y-m-d H:i:s',$value);
... ...
... ... @@ -453,4 +453,25 @@ if(!function_exists('httpPost')){
curl_close($curl); // 关键CURL会话
return json_decode($result,true); // 返回数据
}
}
if(!function_exists('get_video_first_image')) {
/**
* 获取视频第一帧图片
* @param $video_url 视频地址
* @param $video_info 视频数据
*/
function get_video_first_image($video_url,$video_info) {
if(empty($video_info['streams'][0]['width'])) {
$width = $video_info['streams'][1]['width'];
$height = $video_info['streams'][1]['height'];
} else {
$width = $video_info['streams'][0]['width'];
$height = $video_info['streams'][0]['height'];
}
return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height;
}
}
\ No newline at end of file
... ...