|
@@ -164,49 +164,8 @@ class AlbumPosterController extends Controller
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * @api {post} /api/album_post/create 生成海报(create)
|
|
|
|
- * @apiDescription 生成海报(create)
|
|
|
|
- * @apiGroup Album_Post
|
|
|
|
- * @apiPermission 需要登录
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiParam {int} [store_id] 商户id
|
|
|
|
- * @apiParam {string} [image] 图片
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
- * {
|
|
|
|
- * "status": true,
|
|
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": [
|
|
|
|
- * 'real_url':'asdawd', //海报
|
|
|
|
- * ]
|
|
|
|
- * }
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- * {
|
|
|
|
- * "state": false,
|
|
|
|
- * "code": 1000,
|
|
|
|
- * "message": "传入参数不正确",
|
|
|
|
- * "data": null or []
|
|
|
|
- * }
|
|
|
|
- * 可能出现的错误代码:
|
|
|
|
- * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
|
- */
|
|
|
|
- public function createPoster(Request $request)
|
|
|
|
|
|
+ private function createPoster($userAuth, $store_id)
|
|
{
|
|
{
|
|
- $userAuth = Auth('api')->user();
|
|
|
|
-
|
|
|
|
- $validator = Validator::make($request->all(), [
|
|
|
|
- 'store_id' => 'required',
|
|
|
|
- 'image' => 'required',
|
|
|
|
- ], [
|
|
|
|
- 'store_id.required' => '店铺信息未知',
|
|
|
|
- 'image' => '缺少图片链接'
|
|
|
|
- ]);
|
|
|
|
- if ($validator->fails()) {
|
|
|
|
- return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
|
|
|
|
- }
|
|
|
|
if ($userAuth->is_dealer == 1) {
|
|
if ($userAuth->is_dealer == 1) {
|
|
$user_agent = AlbumAgentModel::where([['user_id',$userAuth->id],['status',1]])->first();
|
|
$user_agent = AlbumAgentModel::where([['user_id',$userAuth->id],['status',1]])->first();
|
|
$agent_id = $user_agent['id'];
|
|
$agent_id = $user_agent['id'];
|
|
@@ -214,13 +173,12 @@ class AlbumPosterController extends Controller
|
|
$agent_id = $userAuth->up_agent_id == 0 ? 0 : $userAuth->up_agent_id;
|
|
$agent_id = $userAuth->up_agent_id == 0 ? 0 : $userAuth->up_agent_id;
|
|
}
|
|
}
|
|
|
|
|
|
- $data = $request->input();
|
|
|
|
|
|
|
|
if ($userAuth->up_agent_id != 0) {
|
|
if ($userAuth->up_agent_id != 0) {
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
$add_record['action'] = 9;
|
|
$add_record['action'] = 9;
|
|
- $add_record['store_id'] = $data['store_id'];
|
|
|
|
|
|
+ $add_record['store_id'] = $store_id;
|
|
$add_record['detail'] = '保存了图片';
|
|
$add_record['detail'] = '保存了图片';
|
|
$user_agent = AlbumAgentModel::where('id', $userAuth->up_agent_id)->first();
|
|
$user_agent = AlbumAgentModel::where('id', $userAuth->up_agent_id)->first();
|
|
$user_agent->share_times++;
|
|
$user_agent->share_times++;
|
|
@@ -231,76 +189,29 @@ class AlbumPosterController extends Controller
|
|
AlbumWatchRecord::create($add_record);
|
|
AlbumWatchRecord::create($add_record);
|
|
}
|
|
}
|
|
|
|
|
|
- $info = AlbumPosterModel::where('store_id', $data['store_id'])->first()->toArray();
|
|
|
|
|
|
+ $info = AlbumPosterModel::where('store_id', $store_id)->first()->toArray();
|
|
$editor = Grafika::createEditor();
|
|
$editor = Grafika::createEditor();
|
|
- $editor->open($image_poster, public_path() . '/base/poster/img/poster_canvas.png');
|
|
|
|
- $editor->open($image_poduct, str_replace(env('CDN_URL'), public_path(), $data['image']));
|
|
|
|
- $editor->resizeExactWidth($image_poduct, 440);
|
|
|
|
- $editor->resizeExactHeight($image_poduct, 440);
|
|
|
|
- $editor->blend($image_poster, $image_poduct, 'normal', 1, 'top-left', 10, 10);
|
|
|
|
- $font_bold = public_path() . '/base/poster/font/msyhbd.ttc';
|
|
|
|
- $font = public_path() . '/base/poster/font/msyh.ttc';
|
|
|
|
- for ($i = 0; $i <= 1; $i++) {
|
|
|
|
- $len = mb_strlen($info['introduce']);
|
|
|
|
- if ($len <= 17) {
|
|
|
|
- $editor->text($image_poster, $info['introduce'], 19, 10, 460, new Color("#000000"), $font_bold, 0);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if ($i == 0) {
|
|
|
|
- $text = mb_substr($info['introduce'], $i * 17, 17);
|
|
|
|
- } else {
|
|
|
|
- $text = mb_substr($info['introduce'], $i * 17, ($len - 17) > 10 ? 10 : ($len - 17));
|
|
|
|
- }
|
|
|
|
- $editor->text($image_poster, $text, 19, 10, 460 + 50 * $i, new Color("#000000"), $font_bold, 0);
|
|
|
|
- }
|
|
|
|
- $editor->open($image_icon, public_path() . '/base/poster/img/phone.png');
|
|
|
|
- $editor->resizeExactWidth($image_icon, 40);
|
|
|
|
- $editor->resizeExactHeight($image_icon, 40);
|
|
|
|
- $editor->blend($image_poster, $image_icon, 'normal', 1, 'top-left', 10, 570);
|
|
|
|
- $WeChatApp = AlbumManufacturerModel::where('store_id', $data['store_id'])->first();
|
|
|
|
- if ($userAuth->is_dealer != 1) {
|
|
|
|
- if ($userAuth->up_agent_id == 0) {
|
|
|
|
- $name = $WeChatApp->name;
|
|
|
|
- $phone = $WeChatApp->phone;
|
|
|
|
- } else {
|
|
|
|
- $agent_check = AlbumAgentModel::where([
|
|
|
|
- ['store_id',$data['store_id']],
|
|
|
|
- ['id',$userAuth->up_agent_id]
|
|
|
|
- ])->first();
|
|
|
|
- $name = $agent_check->realname;
|
|
|
|
- $phone = $agent_check->phone;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- $agent_check = AlbumAgentModel::where([
|
|
|
|
- ['store_id',$data['store_id']],
|
|
|
|
- ['user_id',$userAuth->id]
|
|
|
|
- ])->first();
|
|
|
|
- $name = $agent_check->realname;
|
|
|
|
- $phone = $agent_check->phone;
|
|
|
|
- }
|
|
|
|
- $editor->text($image_poster, $phone, 20, 55, 577, new Color("#eb7a48"), $font, 0);
|
|
|
|
- $editor->text($image_poster, '长按识别二维码 展示家具画册', 16, 10, 650, new Color("#666666"), $font, 0);
|
|
|
|
|
|
+
|
|
|
|
+ $WeChatApp = AlbumManufacturerModel::where('store_id', $store_id)->first();
|
|
|
|
+
|
|
if ($agent_id == 0) {
|
|
if ($agent_id == 0) {
|
|
$editor->open($image_qrcode, str_replace(env('CDN_URL'), public_path(), $info['qrcode']));
|
|
$editor->open($image_qrcode, str_replace(env('CDN_URL'), public_path(), $info['qrcode']));
|
|
- $editor->resizeExactWidth($image_qrcode, 140);
|
|
|
|
- $editor->resizeExactHeight($image_qrcode, 140);
|
|
|
|
|
|
+ $editor->resizeExactWidth($image_qrcode, 430);
|
|
|
|
+ $editor->resizeExactHeight($image_qrcode, 430);
|
|
} else {
|
|
} else {
|
|
- $file = $this->getQrCodeEasy($WeChatApp->xyx_id, $WeChatApp->xyx_secret, $agent_id, $data['store_id'], $userAuth->id);
|
|
|
|
|
|
+ $file = $this->getQrCodeEasy($WeChatApp->xyx_id, $WeChatApp->xyx_secret, $agent_id, $store_id, $userAuth->id);
|
|
if (!$file) {
|
|
if (!$file) {
|
|
return $this->error(0, '参数错误,请检查配置', []);
|
|
return $this->error(0, '参数错误,请检查配置', []);
|
|
}
|
|
}
|
|
$editor->open($image_qrcode, $file);
|
|
$editor->open($image_qrcode, $file);
|
|
- $editor->resizeExactWidth($image_qrcode, 140);
|
|
|
|
- $editor->resizeExactHeight($image_qrcode, 140);
|
|
|
|
|
|
+ $editor->resizeExactWidth($image_qrcode, 430);
|
|
|
|
+ $editor->resizeExactHeight($image_qrcode, 430);
|
|
}
|
|
}
|
|
-
|
|
|
|
- $editor->blend($image_poster, $image_qrcode, 'normal', 1, 'top-left', 310, 500);
|
|
|
|
- $editor->open($image_avatar, public_path() . '/base/poster/avatar/' . $data['store_id'] . "/$userAuth->id.jpg");
|
|
|
|
- $editor->resizeExactWidth($image_avatar, 64);
|
|
|
|
- $editor->resizeExactHeight($image_avatar, 64);
|
|
|
|
- $editor->blend($image_poster, $image_avatar, 'normal', 1, 'top-left', 348, 538);
|
|
|
|
- $editor->text($image_poster, $name, 16, 380 - (22 * (mb_strlen($name) / 2)), 650, new Color("#666666"), $font, 0);
|
|
|
|
- $editor->save($image_poster, public_path() . '/download/' . $userAuth->id . '.png');
|
|
|
|
|
|
+ $editor->open($image_avatar, public_path() . '/base/poster/avatar/' . $store_id . "/$userAuth->id.jpg");
|
|
|
|
+ $editor->resizeExactWidth($image_avatar, 190);
|
|
|
|
+ $editor->resizeExactHeight($image_avatar, 190);
|
|
|
|
+ $editor->blend($image_qrcode, $image_avatar, 'normal', 1, 'top-left', 120, 120);
|
|
|
|
+ $editor->save($image_qrcode, public_path() . '/download/' . $userAuth->id . '.png');
|
|
$real_url = env('CDN_URL') . '/download/' . $userAuth->id . '.png';
|
|
$real_url = env('CDN_URL') . '/download/' . $userAuth->id . '.png';
|
|
return $this->api(compact('real_url'));
|
|
return $this->api(compact('real_url'));
|
|
}
|
|
}
|