WeGuideUseRepository.php
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Created by PhpStorm.
* User: machengjun
* Date: 2018/2/4
* Time: 下午5:14
*/
namespace App\Repositories\Customers;
use App\Common\Enums\HtTab;
use App\Exceptions\Api\ApiException;
use App\Modules\Enums\ErrorCode;
use App\Modules\Models\Share\Share;
use App\Modules\Repositories\BaseRepository;
class WeGuideUseRepository extends BaseRepository
{
function shareSpotInfo($order_no)
{
$where = [
['order_no', '=', $order_no],
];
$spot_info = Share::with(['spot', 'guideRule'])->where($where)->first();
if ($spot_info == null) {
throw new ApiException(ErrorCode::SHARE_NOT_ENOUGH, trans('api.error.share_not_enough'));
}
return $spot_info;
}
/**
* @param $share_info
* @param $language
* @return mixed
*/
function spot_explain($share_info, $language)
{
$infos = $share_info->explain()->with(['info' => function ($query) use ($language) {
$query->where('language', '=', $language);
}, 'beacon'])->get();
$data = [];
$i = 0;
$list = [];
foreach ($infos as $info) {
if ($info->beacon != null) {
foreach ($info->beacon as $beacon) {
$k = $beacon->major . $beacon->minor;
$data["$k"]['title'] = $info->info[0]['title'];
$data["$k"]['mp3'] = HtTab::AUDIO_HEAD_URL.$info->info[0]['audio_url'];
$data["$k"]['img'] = HtTab::IMG_HEAD_URL.$info->info[0]['img_url'];
$data["$k"]['content'] = $info->info[0]['describetion'];
$data["$k"]['rssi'] = $beacon['rssi'];
$data["$k"]['sd'] = $beacon['sd'];
$list[$i]['major_minor'] = $k;
$list[$i]['title'] = $info->info[0]['title'];
$i++;
}
}
}
return ['data' => $data,'list' => $list];
}
function getSpotInfo($spot_id)
{
$spot = Spot::where('id', $spot_id)->first();
$data = [
'spot_name' => $spot->spotname,
'wx_logo' => $spot->spotname,
];
}
}