love_php/app/Http/Controllers/Controller.php
2026-04-09 13:52:20 +08:00

4309 lines
228 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Controllers;
use App\Events\News;
use App\Exports\MessengerExport;
use App\Exports\ReportExport;
use App\Facades\QrcodeRectService;
use App\Facades\WechatService;
use App\Jobs\AddUnionUser;
use App\Jobs\MakeSurveyQrcode;
use App\Jobs\SaasEarningMPNotice;
use App\Jobs\SendEarningMessage;
use App\Jobs\SendEarningMessageV2;
use App\Jobs\SendEasySms;
use App\Jobs\SendTemplateMsg;
use App\Jobs\SyncClientComment;
use App\Jobs\SyncOrderRemark;
use App\Mail\AppointmentMember;
use App\Models\CheckMobile;
use App\Models\CloseProfileHistory;
use App\Models\Earning;
use App\Models\ErrorLog;
use App\Models\ErrorPhoto;
use App\Models\Live\Messenger as LiveMessenger;
use App\Models\Live\Video;
use App\Models\LoveLink;
use App\Models\MAdvanceEarning;
use App\Models\Server\EvaluateAnswer;
use App\Models\Server\EvaluateDetail;
use App\Models\Server\EvaluateList;
use App\Models\Server\EvaluateQuestion;
use App\Models\Server\EvaluateQuestionGroup;
use App\Models\Server\MEarning;
use App\Models\Server\MerchantEvaluate;
use App\Models\Server\MerchantServiceStatus;
use App\Models\Server\MerchantUser;
use App\Models\Server\ShopAgentOrder;
use App\Models\Server\Survey;
use App\Models\UnionUser;
use App\Server\ReportFile;
use App\Services\LiveAlipayService;
use App\Services\OrderService;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use App\Models\Wechat;
use App\Models\User;
use App\Models\InviteHistory;
use App\Models\VipQuestion;
use App\Models\VipQuestionOption;
use App\Models\Character;
use App\Models\FormId;
use EasyWechat;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Route;
use Intervention\Image\ImageManagerStatic as Image;
use App\Http\Controllers\UploadController;
use Illuminate\Http\Request;
use Faker\Generator as Faker;
use Illuminate\Support\Facades\Redis;
use App\Utils\Http;
use App\Models\Score;
use App\Models\ScoreHistory;
use App\Models\Notice;
use App\Events\ChatMessages;
use App\Models\ProfileCourtship;
use App\Models\ProfilePhoto;
use App\Models\Address;
use App\Models\RankHistory;
use App\Models\Rank;
use App\Models\Platform;
use App\Models\ReferreAwardHistory;
use App\Events\NoticeServer;
use App\Exports\ReferreExport;
use App\Models\Referre;
use App\Models\AddedBonus;
use App\Models\ActivityMember;
use App\Models\Activity;
use App\Exports\ActivityMemberExport;
use App\Exports\MarriageExport;
use App\Exports\SingleExport;
use App\Models\RedPacketOrder;
use App\Exports\RedPacketExport;
use App\Models\Matchmaker;
use App\Exports\MatchmakerExport;
use App\Models\UserProfile;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\Cache;
use App\Jobs\FaceDelect;
use App\Models\Order;
use App\Exports\OrdersExport;
use DateTime;
use App\Jobs\SendAGRecommend;
use App\Models\SingleProfile;
use App\Services\UserService;
use App\Utils\IP;
use App\Jobs\ParticipantShareNotice;
use App\Models\Participant;
use App\Jobs\UpdateWechatUserInfo;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use App\Models\Dynamic;
use OSS\OssClient;
use App\Jobs\ParticipantPacketNotice;
use App\Models\ParticipantRedPacket;
use App\Facades\CommonUtilsService;
use App\Models\Live\Viewer;
use App\Models\Live\ViewerShare;
use App\Jobs\MakeOldShareCash;
use App\Jobs\SendSpreaderNote;
use App\Utils\Messenger;
use App\Services\IMService;
use App\Http\Response\ResponseJson;
use App\Jobs\MakeShareCash;
use App\Models\Community;
use App\Exports\DailyMessengerData;
use App\Exports\DailyViewerData;
use App\Exports\TongMessengerData;
use App\Models\Live\ShareRoleViewer;
use App\Models\Live\ShareRole;
use App\Models\InteractLive;
use App\Models\InteractLiveLog;
use App\Models\InteractLiveMember;
use App\Models\ApproveHistory;
use App\Models\TemplateMsgLog;
use Illuminate\Support\Facades\DB;
//阿里云SDK
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use App\Exports\TouristOrdersExport;
use App\Models\CommunityActivity;
use App\Models\Consultation;
use App\Models\ConsultationRecords;
use App\Models\Course\Course;
use App\Models\Live\Anchor;
use App\Models\MerchantShop;
use App\Models\Message;
use App\Models\Score\CashoutLog;
use App\Models\Server\MerchantAccount;
use App\Models\Server\MerchantAdmins;
use App\Models\Server\TouristOrder;
use Illuminate\Support\Facades\Hash;
use App\Imports\TestImport;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, ResponseJson;
public function success($msg, $data = [], $cookie = null, $jsonp = false)
{
$result = [
'code' => 0,
'message' => $msg,
'data' => $data,
];
if ($jsonp) {
return Response()->jsonp('callback', $result);
} else {
$response = Response()->json($result);
if ($cookie) {
$response = $response->cookie($cookie);
}
if (request()->input('xdebug') == 1) {
return 'xdebug';
} else {
return $response;
}
}
}
//接口返回失败
public function failure($msg = '服务器休息,请稍后再试', $data = [], $jsonp = false)
{
$result = [
'code' => 1,
'message' => $msg,
'data' => $data,
];
if ($jsonp) {
return Response()->jsonp('callback', $result);
} else {
return Response()->json($result);
}
}
//接口返回失败
public function failureV2($msg, $data = [], $jsonp = false)
{
$result = [
'code' => 7,
'message' => $msg,
'data' => $data,
];
if ($jsonp) {
return Response()->jsonp('callback', $result);
} else {
return Response()->json($result);
}
}
//接口返回失败
public function fail($msg, $code = 5, $path = '', $operate = '', $notice = '')
{
$result = [
'code' => $code,
'path' => $path,
'message' => $msg,
'operate' => $operate,
'notice' => $notice,
];
return Response()->json($result);
}
//接口返回成功
public function resp($msg, $data = [], $status = 0)
{
$result = [
'code' => 0,
'message' => $msg,
'status' => $status,
'data' => $data,
];
return Response()->json($result);
}
public function respv2($msg, $data = [], $status = 0)
{
$result = [
'code' => $data['status'],
'message' => $msg,
'status' => $status,
'data' => $data,
];
return Response()->json($result);
}
/**根据页数转换偏移量 */
function getPageOffset()
{
$page = request()->input('page');
$offset = 0;
if ($page == 0) {
$offset = 0;
} else if ($page == 1) {
$offset = 0;
} else {
$offset = ($page - 1) * 15;
}
return $offset;
}
/**输出数据库打印语句 */
function toRawSql($getQueryLog)
{
$sqlArr = [];
foreach ($getQueryLog as $k => $log) {
$sql = $log['query'];
foreach ($log['bindings'] as $binding) {
$binding = is_numeric($binding) ? $binding : "'" . $binding . "'";
//正则匹配替换
$sql = preg_replace('/\?/', $binding, $sql, 1);
}
//输出sql语句
$sqlArr[$k]['sql'] = $sql;
//执行时间
$sqlArr[$k]['time'] = $log['time'];
//使用explain分析sql语句
$sqlArr[$k]['explain'] = \DB::select('explain ' . $log['query'], $log['bindings']);
}
return $sqlArr;
}
public function indexhome()
{
$host = request()->gethost();
if ($host == 'ufutx.cn' || $host == "www.ufutx.cn") {
return redirect('http://www.ufutx.com');
}
if (env('APP_ENV') != 'production') {
return view('welcomeOfficial');
} else {
return redirect(env("APP_URL") . '/web');
}
}
public function appHome()
{
return redirect('https://apps.apple.com/cn/app/id1483551530');
}
public function mobileHome()
{
return redirect('mobile/#/upgrade');
}
public function exportHome(Request $request)
{
if ($request->code != '19940202') {
return $this->failure('请携带授权码');
}
return view('export');
}
/*
* 检查是否登录
* 针对没有auth验证的路由下需要检查用户是否登录
*
*/
public function authCheck()
{
$guards = config('auth.guards');
$result = false;
foreach ($guards as $key => $guard) {
if (\Auth::guard($key)->check()) {
$result = \Auth::guard($key)->user();
continue;
}
}
return $result;
}
public function getMyUserinfo()
{
$login_user = null;
if (\Auth::guard('api')->check()) {
$login_user = \Auth::guard('api')->user();
}
return $login_user;
}
//发送普通消息
function sentMessage($mobile, $message)
{
if (empty($mobile)) {
return true;
}
Message::create([
'phone' => $mobile,
'message' => $message,
'confirmed' => 1,
'ip' => request() ? request()->ip() : '127.0.0.1',
]);
Messenger::sendSMS($mobile, $message);
return true;
}
/**
* 随机生成16位数作为本地服务器的支付订单ID
* @return type
*/
public function getTradeNO()
{
$dateline = time();
$mix_1 = rand(100, 999);
$mix_2 = rand(100, 999);
return $dateline . $mix_1 . $mix_2;
}
/**
* 随机生成16位数退款订单号
* @return string 退款订单号
*/
public function getRefundTradeNo()
{
$dateline = time();
$mix_1 = rand(100, 999);
$mix_2 = rand(10, 99);
return 'r' . $dateline . $mix_1 . $mix_2;
}
public function getOpenid()
{
$user_id = auth()->id();
$openid = Wechat::where('user_id', $user_id)->value('openid');
return $openid;
}
/**
* 图片添加图片
* @param string $image1 第一张图片
* @param string $image2 第二张图片
* @param int $image2_w 图片宽度
* @param int $image2_h 图片高度
* @param integer $offset_x 文字X轴偏移
* @param integer $offset_y 文字Y轴偏移
* @param string $offset
* @return image 新图片
*/
public function imageAddImage($image1, $image2, $image2_w, $image2_h, $offset_x = 0, $offset_y = 0, $offset = 'top-left')
{
Image::configure(['driver' => 'gd']);
$image = Image::make($image1);
$image_v2 = Image::make($image2)->resize($image2_w, $image2_h);
$image_width = $image->width();
$image_height = $image->height();
$image_copy = $image->insert($image_v2, $offset, $offset_x, $offset_y);
return $image_copy;
}
/**
* 图片添加文字
* @param string $image 图片
* @param string $text 文字
* @param int $text_size 文字尺寸
* @param int $offset_x 文字X轴偏移
* @param int $offset_y 文字Y轴偏移
* @param string $color 文字颜色
* @param string $align 文字位置
* @param string $valign
* @return image 新图片
*/
public function textAddImage($image, $text, $text_size, $offset_x, $offset_y, $color = '#000000', $align = 'center', $valign = 'top')
{
Image::configure(['driver' => 'gd']);
$image = Image::make($image);
$image->text($text, $offset_x, $offset_y, function ($font) use ($text_size, $color, $align, $valign) {
$font->file(storage_path() . '/font/wr.ttf');
$font->size($text_size);
$font->color($color);
$font->align($align);
$font->valign($valign);
});
return $image;
}
/**
* 分享记录
*/
public function addInviteHistory($openid, $from_openid)
{
if (empty($from_openid)) {
return;
}
$user_id = Wechat::where('openid', $openid)->value('user_id');
$invite_user_id = Wechat::where('openid', $from_openid)->value('user_id');
$history = InviteHistory::firstOrCreate(['openid' => $openid, 'invite_openid' => $from_openid]);
$history->user_id = $user_id;
$history->invite_user_id = $invite_user_id;
if ($history->user_id && $history->invite_user_id && $history->openid && $history->invite_openid) {
$history->status = 1;
}
$history->save();
return;
}
/**
* 获取年龄
* @param string $birthday 生日
* @return integer 年龄
*/
public function getAge($birthday)
{
if (empty($birthday)) {
return '未知';
}
$age = strtotime($birthday);
if ($age === false) {
return null;
}
list($y1, $m1, $d1) = explode("-", date("Y-m-d", $age));
$now = strtotime("now");
list($y2, $m2, $d2) = explode("-", date("Y-m-d", $now));
$age = $y2 - $y1;
if ((int) ($m2 . $d2) < (int) ($m1 . $d1))
$age -= 1;
return $age;
}
//文件地址上传
public function uploadFile($file)
{
$ossClient = UploadController::getOssClient();
//生成file
$object = date('Y') . date('m') . "/" . date('d') . "/" . basename($file);
$url = 'https://' . config('alioss.picture_domain') . '/' . $object;
try {
//$result = $ossClient->putObject(config('alioss.buckets.picture'), $object, $file);
$result = $ossClient->uploadFile(config('alioss.buckets.picture'), $object, $file);
// if(!empty($result) && !empty($result['info'])){
// $url = $result['info']['url'];
// $url = str_replace('-internal','',$url);
// }else{
// return false;
// }
} catch (\OSS\Core\OssException $e) {
// return $this->failure('oss_put_failure', $e->getMessage());
return false;
}
return $url;
}
/**
* 时间差
*/
public function getTime($begin_time, $end_time)
{
$begin_time = strtotime($begin_time);
$end_time = strtotime($end_time);
if ($begin_time < $end_time) {
$starttime = $begin_time;
$endtime = $end_time;
} else {
$starttime = $end_time;
$endtime = $begin_time;
}
$timediff = $endtime - $starttime;
$days = intval($timediff / 86400);
$remain = $timediff % 86400;
$hours = intval($remain / 3600);
$remain = $remain % 3600;
$mins = intval($remain / 60);
$secs = $remain % 60;
$res = array("day" => $days, "hour" => $hours, "min" => $mins, "sec" => $secs);
return $res;
}
/**
* 获取对应的formid
*/
public function formId($openid)
{
$now_time = time();
$end_time = $now_time - 7 * 24 * 60 * 60;
$time = date('Y-m-d H:i:s', $end_time);
$form_id = FormId::where('openid', $openid)->where('status', 0)->where('form_id', '<>', 'the formId is a mock one')->where('created_at', '>', $time)->orderBy('id', 'asc')->first();
return $form_id;
}
public function addAccountDynamic($user_id, $content)
{
$uid = $this->getUid($user_id);
$data_v2 = [
'content' => $content,
'mp' => 'LOVE',
];
$url = config('app.account_url') . '/api/user/' . $uid . '/dynamic';
$dynamic = json_decode(Http::http($url, $data_v2, 'POST'));
return true;
}
/**
* 获取公共张傲user_id
* @param int $user_id 用户id
* @return int 公共账号用户id
*/
public function getUid($user_id)
{
$user = User::with('wechat')->where('id', $user_id)->first();
if (empty($user) || empty($user->wechat)) {
return $uid = 0;
}
if ($user->uid) {
$uid = $user->uid;
} else {
$url = config('app.account_url') . '/api/user';
$data = [
'mobile' => $user->mobile,
'name' => $user->name ?: $user->nickname,
'nickname' => $user->wechat->nickname,
'gender' => $user->wechat->gender,
'city' => $user->wechat->city,
'province' => $user->wechat->province,
'country' => $user->wechat->country,
'unionid' => $user->wechat->unionid,
'avatar' => $user->wechat->avatar2 ? $user->wechat->avatar2 : $user->wechat->avatar,
];
try {
$account_user = json_decode(Http::http($url, $data, 'POST'), true);
} catch (Exception $e) {
$message = $e->getMessage();
Messenger::sendSMS('15872844805', $message);
}
if (isset($account_user['id'])) {
$uid = $account_user['id'];
$user->uid = $uid;
$user->save();
} else {
$uid = 0;
}
}
return $uid;
}
/**
* 获取公共积分
* @param int $user_id 用户id
* @return obj 积分
*/
public function getAccountScore($user_id)
{
return false;
// $uid = $this->getUid($user_id);
// if (empty($uid)) {
// $uid = $this->getUid($user_id);
// }
// $data = [];
// $url = config('app.account_url').'/api/user/'.$uid.'/score';
// try {
// $score = json_decode(Http::http($url, $data, 'GET'));
// if (empty($score)) {
// throw new \Exception("获取公共积分失败用户id:".$user_id, 1);
// }
// //同步
// // $score_arr = json_decode(Http::http($url, $data, 'GET'), true);
// // Score::where('user_id', $user_id)->update(['remain_amount'=>$score_arr['remain_amount']?:0, 'used_amount'=>$score_arr['used_amount']?:0, 'cash_amount'=>$score_arr['cash_amount']?:0]);
// } catch (\Exception $e) {
// $message = $e->getMessage();
// Messenger::sendSMS('15872844805', $message);
// }
// return $score;
}
/**
* 发消息
*/
public function sendNotice($user_id, $send_user_id, $type, $content, $message = null)
{
$notice = Notice::create([
'user_id' => $user_id,
'send_user_id' => $send_user_id,
'type' => $type,
'content' => $content,
'message' => $message,
]);
$other_user = User::findOrFail($user_id);
//触发通知查询
broadcast(new NoticeServer($other_user));
return $notice;
}
public function industryJson()
{
list($__sort, $__detail) = $this->industryJsonData();
$data = [];
foreach ($__sort as $key => $item) {
$data[] = [
'title' => $item,
'items' => $__detail[$key]
];
}
return $this->success('industry_json', $data);
}
public function industryJsonData()
{
$__sort = array(
'金融/投资',
'互联网/信息科技/高科技',
'法律/法务',
'制造/矿产/能源',
'教育',
'日常消费品',
'咨询/服务',
'医疗保健',
'媒体',
'建筑建材',
'旅游/体育/休闲娱乐',
'物流贸易/交通运输',
'非盈利/科研',
'农林牧渔',
'民生/公共服务/政府',
'宗教',
'信仰',
'其他行业'
);
$__detail =
array(
array(
'私募基金(股权)/风险投资',
'私募基金(证券)',
'私募基金(股权+证券)',
'公募基金',
'商业银行',
'证券/期货/交易所',
'信托',
'投资银行',
'保险',
'房地产',
'财富管理/理财/私人银行/',
'小额贷款/担保/典当',
'消费贷款/信用贷款',
'会计/审计/税务',
'独立财务顾问',
'财经资讯/信息/服务',
'金融租赁',
'收藏/拍卖',
'行业协会'
),
array(
'互联网',
'软件',
'信息技术与服务',
'电信与通讯',
'硬件',
'网络游戏',
'网络设备',
'网络安全',
'半导体',
'纳米/特殊材料',
'安全/监控',
'行业协会'
),
array(
'法律服务',
'法律援助',
'公证服务'
),
array(
'机械/装备',
'电子/电气',
'汽车',
'石油化工 /能源',
'纺织/皮革',
'采矿/金属/冶炼',
'水泥/混凝土/非金属',
'工业自动化',
'工业管理',
'环保/回收',
'包装/集装箱',
'造纸/木材',
'航空/宇航',
'船舶/铁路',
'玻璃/陶瓷/橡胶',
'基础材料',
'水利水电'
),
array(
'培训',
'网络教育',
'家庭/私塾教育',
'高等教育',
'职业教育',
'高中教育',
'初中教育',
'小学教育',
'学前教育',
'教育管理',
'教育研究',
'教学设施/设备',
'特殊教育'
),
array(
'服装服饰',
'家居用品',
'零售/批发',
'快速消费品',
'包装用品',
'消费电子',
'化妆品',
'超市卖场',
'家具',
'玩具礼品/工艺品',
'奢侈品与珠宝',
'食物生产',
'酒类/烟草',
'体育用品'
),
array(
'管理咨询',
'招聘/猎头',
'人力资源',
'商业培训',
'市场推广',
'市场调研',
'公共关系',
'知识产权',
'会务/活动服务',
'办公服务/公司服务',
'翻译服务',
'工程监理',
'能源管理',
'外包服务'
),
array(
'心理咨询/治疗',
'医药品',
'医疗/医院',
'医疗设备',
'中医',
'精神疾病',
'生物工程',
'生物信息',
'兽医'
),
array(
'广告',
'互联网媒体',
'文化艺术',
'杂志',
'媒体设计制作',
'电影/电视',
'印刷',
'报纸',
'写作与编辑',
'出版',
'广播'
),
array(
'建筑工程',
'建筑材料',
'装饰装潢',
'建筑设计',
'土木工程'
),
array(
'餐饮业',
'旅游/度假',
'娱乐业',
'住宿业',
'体育运动',
'设施/设备/用品',
'健身',
'食品与饮料'
),
array(
'国际贸易',
'国内贸易',
'国内/国际贸易',
'仓储/物流/供应链',
'客运/城市公共交通',
'出租车',
'邮政/包裹/快递',
'道路运输',
'铁路运输',
'航空运输',
'水上运输',
'装卸搬运',
'管道运输'
),
array(
'科学研究',
'气象/地震/测绘/勘探',
'非盈利性组织',
'智囊团',
'慈善事业',
'公益基金',
'宗教协会',
'社会团体'
),
array(
'农业/农场',
'林业',
'畜牧/屠宰',
'渔业',
'农林牧渔服务业'
),
array(
'理发美容洗浴',
'物业管理',
'环保绿化',
'家政服务',
'婚姻服务',
'保安服务',
'养老服务',
'丧事服务',
'图书馆/博物馆',
'水电燃气生',
'政府/行政部门',
'社会保障/福利',
'公共安全/司法',
'水利环境/公共设施',
'维护/维修',
'规划'
),
array(
'教堂及寺庙管理人员',
'宗教团体工作人员',
'僧尼及道士人员'
),
array(
'长老',
'执事',
'牧师',
'传道人',
'宣教士',
'同工',
'义工'
),
array(
'其他行业'
)
);
return [$__sort, $__detail];
}
/**
* 经纬度转地址
* @param [type] $local_latitude [description]
* @param [type] $local_longitude [description]
* @return [type] [description]
*/
public function getAddress($local_latitude, $local_longitude)
{
$localtion = $local_latitude . ',' . $local_longitude;
$url = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $localtion . '&key=P43BZ-QSDCP-BMHDP-V3BTR-3EL45-KOFJL';
$result = json_decode(Http::http($url, [], 'GET'), true);
if ($result['status'] == 0) {
$address_component = $result['result']['address_component'];
} else {
return false;
}
return $address_component;
}
/**
* 地址转为经纬度
* @param Request $request [description]
* @param string $address [description]
* @return [type] [description]
*/
public function getLocation(Request $request, $address = '')
{
$address = $request->input('address');
if (empty($address)) {
return $this->failure('没有地址');
}
$url = "https://apis.map.qq.com/ws/geocoder/v1/?address=" . $address . '&key=P43BZ-QSDCP-BMHDP-V3BTR-3EL45-KOFJL';
$result = json_decode(Http::http($url, [], 'GET'), true);
$location = isset($result['result']['location']) ? $result['result']['location'] : [];
return $location;
}
public function memberType($rank_id, $temp_member)
{
$rank = '普通会员';
if ($temp_member) {
$rank = '临时会员';
return $rank;
}
if ($rank_id == 3) {
$rank = '全球级会员';
} elseif ($rank_id == 2) {
$rank = '全国级会员';
} elseif ($rank_id == 1) {
$rank = '市级会员';
} elseif ($rank_id == 9) {
$rank = "超级会员";
}
return $rank;
}
/**
* 圆图
* @param string $imgpath 图片路径
* @param int $user_id 用户id
* @return string 生成图片路径
*/
public function circleImage($imgpath = null, $user_id = null)
{
if (strstr($imgpath, 'images.ufutx.com')) {
if ($user_id) {
User::where('id', $user_id)->update(['circle_avatar' => $imgpath]);
}
} else {
$filesize = @getimagesize($imgpath);
switch ($filesize['mime']) {
case 'image/jpg':
$src_img = imagecreatefromjpeg($imgpath);
break;
case 'image/jpeg':
$src_img = imagecreatefromjpeg($imgpath);
break;
case 'image/png':
$src_img = imagecreatefrompng($imgpath);
break;
}
$wh = getimagesize($imgpath);
$w = $wh[0];
$h = $wh[1];
$w = min($w, $h);
$h = $w;
$img = imagecreatetruecolor($w, $h);
//这一句一定要有
imagesavealpha($img, true);
//拾取一个完全透明的颜色,最后一个参数127为全透明
$bg = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagefill($img, 0, 0, $bg);
$r = $w / 2; //圆半径
$y_x = $r; //圆心X坐标
$y_y = $r; //圆心Y坐标
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$rgbColor = imagecolorat($src_img, $x, $y);
if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
imagesetpixel($img, $x, $y, $rgbColor);
}
}
}
$filename = date('Y-m-d-H-i-s') . '-' . uniqid() . '.png';
$file_path = storage_path('circleImg/' . $filename);
imagepng($img, $file_path);
$pic = '';
if (file_exists($file_path)) {
$pic = $this->uploadFile($file_path);
try {
unlink($file_path);
} catch (Exception $e) {
// return $this->failure($e->getMessage());
// exit();
}
}
if ($user_id) {
User::where('id', $user_id)->update(['circle_avatar' => $pic]);
}
return $pic;
}
}
/**
* 计算两点地理坐标之间的距离
* @param Decimal $longitude1 起点经度
* @param Decimal $latitude1 起点纬度
* @param Decimal $longitude2 终点经度
* @param Decimal $latitude2 终点纬度
* @param Int $unit 单位 1:米 2:公里
* @param Int $decimal 精度 保留小数位数
* @return Decimal
*/
public function getDistance($longitude1, $latitude1, $longitude2, $latitude2, $unit = 2, $decimal = 2)
{
$EARTH_RADIUS = 6370.996; // 地球半径系数
$PI = 3.1415926;
$longitude1 = round($longitude1, 7);
$latitude1 = round($latitude1, 7);
$longitude2 = round($longitude2, 7);
$latitude2 = round($latitude2, 7);
if (!is_numeric($longitude1) || !is_numeric($latitude1) || !is_numeric($longitude2) || !is_numeric($latitude2)) {
return 0;
}
$radLat1 = $latitude1 * $PI / 180.0;
$radLat2 = $latitude2 * $PI / 180.0;
$radLng1 = $longitude1 * $PI / 180.0;
$radLng2 = $longitude2 * $PI / 180.0;
$a = $radLat1 - $radLat2;
$b = $radLng1 - $radLng2;
$distance = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2)));
$distance = $distance * $EARTH_RADIUS * 1000;
if ($unit == 2) {
$distance = $distance / 1000;
}
return round($distance, $decimal);
}
public function getEvalQuestions()
{
$questions = [
['title' => '意志坚强', 'group_title' => 'D',],
['title' => '热情', 'group_title' => 'I',],
['title' => '迁就', 'group_title' => 'S',],
['title' => '容忍', 'group_title' => 'C',],
['title' => '决定性', 'group_title' => 'D',],
['title' => '表达', 'group_title' => 'I',],
['title' => '稳定', 'group_title' => 'S',],
['title' => '关键', 'group_title' => 'C',],
['title' => '好胜', 'group_title' => 'D',],
['title' => '令人信服', 'group_title' => 'I',],
['title' => '一致', 'group_title' => 'S',],
['title' => '详尽', 'group_title' => 'C',],
['title' => '独立', 'group_title' => 'D',],
['title' => '风趣', 'group_title' => 'I',],
['title' => '调解', 'group_title' => 'S',],
['title' => '遵循规则', 'group_title' => 'C',],
['title' => '顽固', 'group_title' => 'D',],
['title' => '说话温柔', 'group_title' => 'I',],
['title' => '强有力', 'group_title' => 'S',],
['title' => '控制', 'group_title' => 'C',],
['title' => '不耐烦', 'group_title' => 'D',],
['title' => '定向交往', 'group_title' => 'I',],
['title' => '委婉', 'group_title' => 'S',],
['title' => '高标准', 'group_title' => 'C',],
['title' => '雄心勃勃', 'group_title' => 'D',],
['title' => '信任他人', 'group_title' => 'I',],
['title' => '保守', 'group_title' => 'S',],
['title' => '自律', 'group_title' => 'C',],
['title' => '冒险者', 'group_title' => 'D',],
['title' => '鼓励', 'group_title' => 'I',],
['title' => '可预言', 'group_title' => 'S',],
['title' => '谨慎', 'group_title' => 'C',],
['title' => '充满信心', 'group_title' => 'D',],
['title' => '愉快', 'group_title' => 'I',],
['title' => '支持', 'group_title' => 'S',],
['title' => '尽责', 'group_title' => 'C',],
['title' => '逻辑', 'group_title' => 'D',],
['title' => '耐心', 'group_title' => 'I',],
['title' => '热情', 'group_title' => 'S',],
['title' => '强迫性', 'group_title' => 'C',],
['title' => '领导者', 'group_title' => 'D',],
['title' => '受欢迎', 'group_title' => 'I',],
['title' => '合作', 'group_title' => 'S',],
['title' => '逻辑', 'group_title' => 'C',],
['title' => '控制', 'group_title' => 'D',],
['title' => '多言多语', 'group_title' => 'I',],
['title' => '好的听众', 'group_title' => 'S',],
['title' => '分析', 'group_title' => 'C',],
['title' => '喜欢刺激', 'group_title' => 'D',],
['title' => '乐观', 'group_title' => 'I',],
['title' => '控制', 'group_title' => 'S',],
['title' => '组织', 'group_title' => 'C',],
['title' => '坦率直言', 'group_title' => 'D',],
['title' => '冲动', 'group_title' => 'I',],
['title' => '系统', 'group_title' => 'S',],
['title' => '保留', 'group_title' => 'C',],
['title' => '友善', 'group_title' => 'D',],
['title' => '愿意', 'group_title' => 'I',],
['title' => '大胆', 'group_title' => 'S',],
['title' => '愉快', 'group_title' => 'C',],
['title' => '对质', 'group_title' => 'D',],
['title' => '有魅力', 'group_title' => 'I',],
['title' => '温柔', 'group_title' => 'S',],
['title' => '保留/不敞开', 'group_title' => 'C',],
['title' => '直接', 'group_title' => 'D',],
['title' => '情绪化', 'group_title' => 'I',],
['title' => '和善', 'group_title' => 'S',],
['title' => '关心', 'group_title' => 'C',],
['title' => '拯救', 'group_title' => 'D',],
['title' => '有说服力', 'group_title' => 'I',],
['title' => '适应', 'group_title' => 'S',],
['title' => '注重质量', 'group_title' => 'C',],
['title' => '不安', 'group_title' => 'D',],
['title' => '顽皮', 'group_title' => 'I',],
['title' => '放松', 'group_title' => 'S',],
['title' => '敏感', 'group_title' => 'C',],
['title' => '随和', 'group_title' => 'D',],
['title' => '胆怯', 'group_title' => 'I',],
['title' => '友善', 'group_title' => 'S',],
['title' => '胆大/冒险', 'group_title' => 'C',],
];
return $questions;
}
public function getQuanganQuestions()
{
$questions = [
['title' => '每天看手机、电脑、电视、超过30分钟。', 'group_title' => '视觉',],
['title' => '越水沟越水沟时显得很害怕,无法跨越。', 'group_title' => '视觉',],
['title' => '不能分辨形状、大小、颜色 。', 'group_title' => '视觉',],
['title' => '眼神恍惚,不能对焦。', 'group_title' => '视觉',],
['title' => '少到户外看花草树木。', 'group_title' => '视觉',],
['title' => '不擅长玩搭积木、折纸、拼图等游戏 。', 'group_title' => '视觉',],
['title' => '不能按线条规定范围内填色。', 'group_title' => '视觉',],
['title' => '指东西给孩子看,孩子的眼睛跟不上。', 'group_title' => '视觉',],
['title' => '找不到放在指定地方的东西。', 'group_title' => '视觉',],
['title' => '不擅长玩抛接球游戏。', 'group_title' => '视觉',],
['title' => '看手机和电视很专注,做其他事情不能专注。', 'group_title' => '视觉',],
['title' => '在人多、五彩缤纷的场所显得异常兴奋。', 'group_title' => '视觉',],
['title' => '看绘本时只是看图片,对认字不感兴趣。', 'group_title' => '视觉',],
['title' => '看绘本时看过很多次的字都记不住。', 'group_title' => '视觉',],
['title' => '不能一次性专注阅读时间超过20分钟。', 'group_title' => '视觉',],
['title' => '每天听电子声音超过30分钟包括听音乐、故事等。', 'group_title' => '听觉',],
['title' => '家里环境很吵,照顾者说话声音很大。', 'group_title' => '听觉',],
['title' => '听见声音不会转头。', 'group_title' => '听觉',],
['title' => '发音不清晰、语言表达能力弱。', 'group_title' => '听觉',],
['title' => '会被太大的声音吓到。', 'group_title' => '听觉',],
['title' => '很难听指令完成简单的事情。', 'group_title' => '听觉',],
['title' => '叫他没有反应,好像没有听到似的。', 'group_title' => '听觉',],
['title' => '听觉记忆短,听过故事的容易忘。', 'group_title' => '听觉',],
['title' => '听不懂大人说话的意思,要重复很多遍。', 'group_title' => '听觉',],
['title' => '听故事不到10分钟就东张西望。', 'group_title' => '听觉',],
['title' => '听到安静的音乐不会安静下来。', 'group_title' => '听觉',],
['title' => '听不懂昨天、今天和明天是什么意思。', 'group_title' => '听觉',],
['title' => '不能说出东西的特征,比如球是圆的。', 'group_title' => '听觉',],
['title' => '不会说自己叫什么名字。', 'group_title' => '听觉',],
['title' => '不会说悄悄话 。', 'group_title' => '听觉',],
['title' => '没怎么爬就走路。', 'group_title' => '大运动',],
['title' => '身体软绵绵,没什么力气。', 'group_title' => '大运动',],
['title' => '不喜欢旋转游戏,觉得晕眩。', 'group_title' => '大运动',],
['title' => '胆小,不敢玩跨越水沟。', 'group_title' => '大运动',],
['title' => '不玩荡秋千。', 'group_title' => '大运动',],
['title' => '动作笨拙,左右不协调,走路跑步容易绊倒。', 'group_title' => '大运动',],
['title' => '不知道在高处有危险,常有危险动作。', 'group_title' => '大运动',],
['title' => '爱玩旋转的凳椅或游乐设施,怎么玩都不会晕。', 'group_title' => '大运动',],
['title' => '不玩前滚翻或者侧滚翻的游戏。', 'group_title' => '大运动',],
['title' => '俯卧在地板或者床上、头、颈、胸无法抬高。', 'group_title' => '大运动',],
['title' => '双脚跳、单脚跳等动作做不好,动作笨重。', 'group_title' => '大运动',],
['title' => '走平衡木走不稳。', 'group_title' => '大运动',],
['title' => '坐不住,动来动去。', 'group_title' => '大运动',],
['title' => '坐姿不佳,容易东倒西歪。', 'group_title' => '大运动',],
['title' => '不玩攀爬游戏。', 'group_title' => '大运动',],
['title' => '1岁前没有刻意训练孩子手抓饭菜自己进食。', 'group_title' => '精细动作',],
['title' => '1岁半还不能独立进食。', 'group_title' => '精细动作',],
['title' => '不用小刀、剪刀等工具做手工。', 'group_title' => '精细动作',],
['title' => '不会自己脱没鞋带的鞋子', 'group_title' => '精细动作',],
['title' => '不会自己剥糖果纸。', 'group_title' => '精细动作',],
['title' => '不玩折纸、搭积木、拼图等游戏。', 'group_title' => '精细动作',],
['title' => '不玩捡豆子等游戏。', 'group_title' => '精细动作',],
['title' => '手拿东西容易掉落。', 'group_title' => '精细动作',],
['title' => '不喜欢玩沙子。', 'group_title' => '精细动作',],
['title' => '拿汤匙、拿筷子拿不好。', 'group_title' => '精细动作',],
['title' => '吃手指或者咬手指甲。', 'group_title' => '精细动作',],
['title' => '不刻意训练宝贝做摘菜等家务。', 'group_title' => '精细动作',],
['title' => '画画涂颜色经常超出范围 。', 'group_title' => '精细动作',],
['title' => '不会自己拉拉链。', 'group_title' => '精细动作',],
['title' => '不刻意训练宝贝每天收拾玩过的玩具。', 'group_title' => '精细动作',],
['title' => '食物做得很精细1岁以后不能吃跟大人一样的饭菜。', 'group_title' => '嗅味觉',],
['title' => '喝流质食物。', 'group_title' => '嗅味觉',],
['title' => '不会大口啃咬和吞咽大块食物。', 'group_title' => '嗅味觉',],
['title' => '不会吐鱼刺、啃骨头、吃鸡爪。', 'group_title' => '嗅味觉',],
['title' => '不去大自然闻花草树木的味。', 'group_title' => '嗅味觉',],
['title' => '常流口水。', 'group_title' => '嗅味觉',],
['title' => '挑食偏食。', 'group_title' => '嗅味觉',],
['title' => '吃饭慢。', 'group_title' => '嗅味觉',],
['title' => '吃饭说话咬到舌头。', 'group_title' => '嗅味觉',],
['title' => '不吃带皮的水果。', 'group_title' => '嗅味觉',],
['title' => '咬字不清发音不正。', 'group_title' => '嗅味觉',],
['title' => '讲话慢。', 'group_title' => '嗅味觉',],
['title' => '只能讲简单的词,语言能力比同龄人明显慢 。', 'group_title' => '嗅味觉',],
['title' => '伤风感冒,鼻子堵。', 'group_title' => '嗅味觉',],
['title' => '吃饭时掉饭粒。', 'group_title' => '嗅味觉',],
['title' => '爱哭粘人,依赖性很强。', 'group_title' => '触觉',],
['title' => '打人,屡教不改。', 'group_title' => '触觉',],
['title' => '很固执,想要的东西一定要到。', 'group_title' => '触觉',],
['title' => '跟小伙伴或兄弟姐妹很容易有冲突。', 'group_title' => '触觉',],
['title' => '不肯承认自己错了。', 'group_title' => '触觉',],
['title' => '独占性强,别人碰他的东西会发脾气。', 'group_title' => '触觉',],
['title' => '不碰面团等黏黏糊糊的东西或者泥沙,有洁癖倾向。', 'group_title' => '触觉',],
['title' => '对疼痛反应迟钝或反应过于激烈。', 'group_title' => '触觉',],
['title' => '胆小怕黑、不敢自己睡觉。', 'group_title' => '触觉',],
['title' => '对危险反应迟钝或者反应过激。', 'group_title' => '触觉',],
['title' => '不喜欢洗脸洗头剪头发。', 'group_title' => '触觉',],
['title' => '咬手指甲或者吃手指。', 'group_title' => '触觉',],
['title' => '特别需要长时间拥抱或者不愿意拥抱。', 'group_title' => '触觉',],
['title' => '特别依恋某些玩具或者毛巾等物品。', 'group_title' => '触觉',],
['title' => '换了床、枕头或者被子睡不着。', 'group_title' => '触觉',],
];
return $questions;
}
public function getQuanganQuestions2()
{
$questions = [
['title' => '每天看手机、电脑、电视、超过30分钟。', 'group_title' => '视觉',],
['title' => '跨越水沟等有困难。', 'group_title' => '视觉',],
['title' => '不擅长玩乐高、折纸、拼图等游戏。', 'group_title' => '视觉',],
['title' => '不能辨认大小、高矮、远近等空间关系。', 'group_title' => '视觉',],
['title' => '不能辨认5种以上颜色。', 'group_title' => '视觉',],
['title' => '画直线、圆形经常歪歪斜斜。', 'group_title' => '视觉',],
['title' => '不能区分梯形和菱形的区别。', 'group_title' => '视觉',],
['title' => '幼儿园上课经常走神,跟不上老师的节奏。', 'group_title' => '视觉',],
['title' => '找不到眼前的东西。', 'group_title' => '视觉',],
['title' => '不能分清左右。', 'group_title' => '视觉',],
['title' => '找不到放在指定地方的东西。', 'group_title' => '视觉',],
['title' => '阅读绘本只看图,不喜欢认字。', 'group_title' => '视觉',],
['title' => '喜欢听父母讲故事,不喜欢眼睛跟着看绘本。', 'group_title' => '视觉',],
['title' => '认字慢,学了又忘记。', 'group_title' => '视觉',],
['title' => '不能独自阅读绘本30分钟以上。', 'group_title' => '视觉',],
['title' => '每天听电子声音超过30分钟包括听音乐、故事等。', 'group_title' => '听觉',],
['title' => '发音不清晰。', 'group_title' => '听觉',],
['title' => '不能流畅用语言表达自己的情绪和需求。', 'group_title' => '听觉',],
['title' => '不能模仿动物叫声。', 'group_title' => '听觉',],
['title' => '不擅长玩绕口令。', 'group_title' => '听觉',],
['title' => '讲话慢。', 'group_title' => '听觉',],
['title' => '幼儿园上课走神。', 'group_title' => '听觉',],
['title' => '老师提问不能正确回答。', 'group_title' => '听觉',],
['title' => '不擅长玩简单的词语接龙游戏。', 'group_title' => '听觉',],
['title' => '很难听指令完成事情。', 'group_title' => '听觉',],
['title' => '叫他没有反应,好像没有听到似的。', 'group_title' => '听觉',],
['title' => '背诵童谣或诗词很吃力,容易忘。', 'group_title' => '听觉',],
['title' => '容易被不相干的声音而分心。', 'group_title' => '听觉',],
['title' => '不理解别人说话的意思,反应慢。', 'group_title' => '听觉',],
['title' => '听故事不到10分钟就走神。', 'group_title' => '听觉',],
['title' => '7个月--2岁期间每天爬行不够2小时。', 'group_title' => '大运动',],
['title' => '不玩荡秋千等摇晃的游戏。', 'group_title' => '大运动',],
['title' => '走平衡木走不稳。', 'group_title' => '大运动',],
['title' => '坐姿不佳,容易东倒西歪,弓腰驼背。', 'group_title' => '大运动',],
['title' => '生活中不喜欢玩跳来跳去的游戏。', 'group_title' => '大运动',],
['title' => '幼儿园上课不守规则,走来走去。', 'group_title' => '大运动',],
['title' => '走路跑步容易绊倒。', 'group_title' => '大运动',],
['title' => '害怕玩旋转的运动,觉得头晕。', 'group_title' => '大运动',],
['title' => '特别喜欢玩旋转的运动,老是玩不够。', 'group_title' => '大运动',],
['title' => '恐高或者晕车。', 'group_title' => '大运动',],
['title' => '动作笨拙,常被自己绊倒,或者伤到小伙伴。', 'group_title' => '大运动',],
['title' => '分不清左右,鞋子衣服穿反。', 'group_title' => '大运动',],
['title' => '动来动去,东摸西扯,爬上爬下。', 'group_title' => '大运动',],
['title' => '经常喜欢惹人、捣蛋、恶作剧。', 'group_title' => '大运动',],
['title' => '身体软绵绵,对什么都提不起劲。', 'group_title' => '大运动',],
['title' => '不刻意训练每天收拾玩具和书包。', 'group_title' => '精细动作',],
['title' => '不用小刀、剪刀等工具玩手工。', 'group_title' => '精细动作',],
['title' => '不玩折纸、积木、乐高等游戏。', 'group_title' => '精细动作',],
['title' => '画画或写字用力过猛或者过轻,涂涂改改', 'group_title' => '精细动作',],
['title' => '画直线、圆形歪歪斜斜。', 'group_title' => '精细动作',],
['title' => '填写、涂色超出范围。', 'group_title' => '精细动作',],
['title' => '手上小动作多多,停不下来。', 'group_title' => '精细动作',],
['title' => '手容易打翻东西。', 'group_title' => '精细动作',],
['title' => '拿东西常掉落。', 'group_title' => '精细动作',],
['title' => '吃手指、咬手指甲。', 'group_title' => '精细动作',],
['title' => '不做摘菜、洗碗、洗小内裤等家务。', 'group_title' => '精细动作',],
['title' => '不会自己擦屁股。', 'group_title' => '精细动作',],
['title' => '不会自己系鞋带 。', 'group_title' => '精细动作',],
['title' => '不擅长玩石头、剪刀、布的游戏。', 'group_title' => '精细动作',],
['title' => '不会逐页翻书。', 'group_title' => '精细动作',],
['title' => '食物太精细,很少大口啃咬', 'group_title' => '嗅味觉',],
['title' => '不会吐鱼刺。', 'group_title' => '嗅味觉',],
['title' => '不会啃骨头或者吃鸡爪。', 'group_title' => '嗅味觉',],
['title' => '挑食偏食。', 'group_title' => '嗅味觉',],
['title' => '吃饭慢。', 'group_title' => '嗅味觉',],
['title' => '吃饭常咬到舌头。', 'group_title' => '嗅味觉',],
['title' => '不吃带皮的水果。', 'group_title' => '嗅味觉',],
['title' => '咬字不清,发音不正。', 'group_title' => '嗅味觉',],
['title' => '讲话慢。', 'group_title' => '嗅味觉',],
['title' => '阅读时不喜欢读出声音。', 'group_title' => '嗅味觉',],
['title' => '动不动伤风感冒。', 'group_title' => '嗅味觉',],
['title' => '有鼻炎。', 'group_title' => '嗅味觉',],
['title' => '流口水。', 'group_title' => '嗅味觉',],
['title' => '不刻意让宝贝闻尝酸甜苦辣的味道。', 'group_title' => '嗅味觉',],
['title' => '不刻意带宝贝闻花草树木的味道。', 'group_title' => '嗅味觉',],
['title' => '爱哭粘人娇气退缩。', 'group_title' => '触觉',],
['title' => '去幼儿园1个月都不能习惯。', 'group_title' => '触觉',],
['title' => '很敏感,很在乎别人的评价。', 'group_title' => '触觉',],
['title' => '常打架,承诺要改,总做不到。', 'group_title' => '触觉',],
['title' => '怕脏,有洁癖,不愿意碰黏黏糊糊的东西。', 'group_title' => '触觉',],
['title' => '胆小怕黑,不敢自己睡觉。', 'group_title' => '触觉',],
['title' => '特别依恋某些玩具或者毛巾等物品。', 'group_title' => '触觉',],
['title' => '不喜欢洗脸洗头剪头发。', 'group_title' => '触觉',],
['title' => '吃手或者咬手指甲。', 'group_title' => '触觉',],
['title' => '特别需要拥抱或者特别抗拒拥抱。', 'group_title' => '触觉',],
['title' => '对危险反应迟钝或者反应过激。', 'group_title' => '触觉',],
['title' => '对疼痛反应迟钝或者过于激烈。', 'group_title' => '触觉',],
['title' => '独占性强,别人碰他的东西会发脾气。', 'group_title' => '触觉',],
['title' => '特别在意衣服标签或者裤缝。', 'group_title' => '触觉',],
['title' => '孤僻不合群,容易跟小伙伴起冲突。', 'group_title' => '触觉',],
];
return $questions;
}
public function getNoTitleQuestion($num)
{
$title_arr = [];
for ($i = 1; $i <= $num; $i++) {
$arr = ["title" => null, 'group_title' => null];
$title_arr[] = $arr;
}
return $title_arr;
}
public function createQuanganEval($merchant_id, $title, $img, $price, $questions, $question_count, $test_item_id)
{
$desc = "<p>亲爱的家长,你是否正在为孩子的专注力欠佳而焦虑困惑?孩子聪明伶俐却磨蹭拖拉,动来动去,粗心大意,成绩还不稳定,父母使出浑身解数却效果不佳,是时候给孩子的专注力做个测评了 </p>
<p>全感专注力测评由天使日记创始人曾任华师大专业人才发展中心的资深专家依据NLP神经语言程序学和感觉统合的脑科学原理总结出全感专注力=情商专注力×动感专注力×静感专注力的公式经19年实践研发而成。</p>
<p>该测评使用线上智能技术后,更体现了方便、快捷而精准的特点。</p>";
$summary = "<p>亲爱的家长,你是否正在为孩子的专注力欠佳而焦虑困惑?孩子聪明伶俐却磨蹭拖拉,动来动去,粗心大意,成绩还不稳定,父母使出浑身解数却效果不佳,是时候给孩子的专注力做个测评了 </p>
<p>全感专注力测评由天使日记创始人曾任华师大专业人才发展中心的资深专家依据NLP神经语言程序学和感觉统合的脑科学原理总结出全感专注力=情商专注力×动感专注力×静感专注力的公式经19年实践研发而成。</p>
<p>该测评使用线上智能技术后,更体现了方便、快捷而精准的特点。</p>";
$type = 5;
$list = EvaluateList::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id], ['name' => $title, 'subtitle' => $title, 'desc' => $desc, 'test_type' => 1, 'type' => $type, 'question_number' => $question_count, 'cover' => $img, 'price' => $price, 'evaNum' => 0]);
$detail = EvaluateDetail::updateOrCreate(['test_item_id' => $test_item_id], ['title' => $title, 'subtitle' => $title, 'type' => $type, 'image' => $img, 'tabImage' => $img, 'cover' => $img, 'summary' => $summary, 'report_pages' => null, 'notes' => '本测试为虚拟服务内容,购买成功后不可退换;测试可重复购买,每次付费仅允许测试一次。', 'price' => $price, 'questions' => null, 'question_count' => $question_count, 'visitNum' => 0, 'hits' => 0]);
foreach ($questions as $question) {
$group = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => $question['group_title']]);
$group_id = $group->id;
$q = EvaluateQuestion::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_name' => $question['title']]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '从不'], ['answerNo' => 'A', 'score' => 1]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '很少即一周7天内1-2天有这个行为'], ['answerNo' => 'B', 'score' => 2]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '偶尔即一周7天内3-4天有这个行为'], ['answerNo' => 'C', 'score' => 3]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '经常即一周7天内5--6天有这个行为'], ['answerNo' => 'D', 'score' => 4]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '总是,即每天都有这个行为'], ['answerNo' => 'E', 'score' => 5]);
}
$arr = EvaluateQuestion::with('answer:id,test_item_id,group_id,question_id,content,answerNo')->where("test_item_id", $test_item_id)->select('id', 'test_item_id', 'question_name')->get()->toArray();
$detail->questions = json_encode($arr);
$detail->save();
MerchantEvaluate::updateOrCreate(['title' => $title, 'test_item_id' => $test_item_id, 'merchant_id' => $merchant_id], ['image' => $img, 'status' => 0, 'price' => $price, 'sort' => 0, 'pv' => 0, 'is_top' => 0, 'top_time' => null, 'test_item_type' => 1]);
}
public function createMerchantEval($merchant_id, $title, $img, $price, $questions, $question_count, $test_item_id)
{
$desc = null;
$summary = null;
$type = 7;
$list = EvaluateList::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id], ['name' => $title, 'subtitle' => $title, 'desc' => $desc, 'test_type' => 1, 'type' => $type, 'question_number' => $question_count, 'cover' => $img, 'price' => $price, 'evaNum' => 0]);
$detail = EvaluateDetail::updateOrCreate(['test_item_id' => $test_item_id], ['title' => $title, 'subtitle' => $title, 'type' => $type, 'image' => $img, 'tabImage' => $img, 'cover' => $img, 'summary' => $summary, 'report_pages' => null, 'notes' => '本测试为虚拟服务内容,购买成功后不可退换;测试可重复购买,每次付费仅允许测试一次。', 'price' => $price, 'questions' => null, 'question_count' => $question_count, 'visitNum' => 0, 'hits' => 0]);
foreach ($questions as $question) {
$group = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => $question['group_title']]);
$group_id = $group->id;
$q = EvaluateQuestion::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_name' => $question['title']]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '大多数描述你'], ['answerNo' => 'A', 'score' => 1]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '经常描述你'], ['answerNo' => 'B', 'score' => 2]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '很少描述你'], ['answerNo' => 'C', 'score' => 3]);
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => '最少描述你'], ['answerNo' => 'D', 'score' => 4]);
// EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id'=>$q->id, 'content' => '总是,即每天都有这个行为'], ['answerNo' => 'E', 'score' => 5]);
}
// $arr = EvaluateQuestion::/*with('answer:id,test_item_id,group_id,question_id,content,answerNo')->*/where("test_item_id", $test_item_id)->select('id', 'test_item_id', 'question_name', 'group_id')->get()->toArray();
$array = EvaluateQuestion::with('group')->where("test_item_id", $test_item_id)->select('id', 'test_item_id', 'question_name', 'group_id')->get()->toArray();
foreach ($array as &$arr) {
$arr['group_name'] = $arr['group']['title'];
unset($arr['group']);
}
$detail->questions = json_encode($array);
$detail->save();
MerchantEvaluate::updateOrCreate(['title' => $title, 'test_item_id' => $test_item_id, 'merchant_id' => $merchant_id], ['image' => $img, 'status' => 0, 'price' => $price, 'sort' => 0, 'pv' => 0, 'is_top' => 0, 'top_time' => null, 'test_item_type' => 1]);
}
public function getAnswers($merchant_id, $test_item_id)
{
$e = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "E"]);
$i = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "I"]);
$s = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "S"]);
$n = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "N"]);
$t = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "T"]);
$f = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "F"]);
$j = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "J"]);
$p = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "P"]);
$array = [
"可以容忍噪音和群众。",
"避免人群,喜欢安静。",
"从普遍一般概念学习新事物。",
"从模仿和观察中学习新事物。",
"把真理当作目标。",
"把和睦共处当作目标。",
"在自己人生经验里,尽量以顺其自然态度来应对各种境况。",
"喜爱对自己的人生作出果断抉择,用自己的意志过自己的人生。",
"多开口,少聆听。",
"多聆听,少说话。",
"聚焦于实际经验。",
"聚焦于理想的可能性。",
"多用脑来抉择。",
"多用心来抉择。",
"喜爱适应新环境。",
"宁愿认识自己正进入什么状况。",
"把火热的心局限于自己内心。",
"与人沟通时,会把热心散发出去。",
"倾向于明确和求实。",
"倾向于一般化和象征性。",
"留意人们何时需要协助。",
"明察不当的推理。",
"抉择后,放心多了。",
"喜爱豁达态度应付事物。",
"易分心。",
"能够专心。",
"运用隐喻和比拟。",
"给予详细描述。",
"选择偏重圆滑,过于偏重真相应对。",
"选择偏重真相,过于偏重圆滑应对。",
"喜爱开始事情。",
"喜爱完成事情。",
"平易近人,并参与多种社交活动。",
"交友谨慎,只参加已挑选的社交活动。",
"行为富有想象力。",
"行为脚踏实地。",
"待人富有同情心。",
"按情况需要,坚定地待人。",
"为稳定生计干活,按部就班。",
"有弹性面对人生,以致不错失良机。",
"三思而言。",
"未加思索,信口开河。",
"依赖预感。",
"依赖过去的经验。",
"期望世界按着逻辑原则运行。",
"期望世界赏识个人的差异。",
"不爱惊讶之事,需要预先提醒警戒。",
"喜爱惊讶之事,喜欢适应临时的改变。",
"喜爱宴会,因为它们会给我的人生充电。",
"喜欢独处时光,因为这可以给我充电。",
"喜欢可预料的关系。",
"重视关系的变化。",
"注意某选择的价值,以及它如何影响人。",
"注意每选择的正反面。",
"把时间视为可更新的资源,并把最终期限当作有弹性的。",
"把时间视为有限的资源,并且严肃看待最终期限。",
"需要时间来反思。",
"由于无所事事而心中不安。喜欢忙碌。",
"重视解决问题的标准方法。",
"采用崭新和不同的途径来解决问题和达成方案。",
"较易看到别人的瑕疵;喜爱采取批判态度。",
"喜欢取悦他人;喜爱表达感激。",
"喜欢核对“必做”名单。",
"就算有“必做”名单,也会把它忽略。",
"喜欢与团体一起工作或谈话。",
"比较喜欢在小组内交际,或一个人独处。",
"没头绪地兜圈子跳跃着行事。",
"有系统方式地行事。",
"容忍别人偶尔询问我人际关系的情绪状况。",
"喜欢别人时常询问我情绪的状况。",
"预先准备的行事会使我更感舒服。",
"宁愿兵来将挡,水来土掩的方式。",
"乐于靠边站的角色。",
"喜欢成为众人瞩目的焦点。",
"重视现实主义和普通常识。",
"重视想象力和创新。",
"如果感觉是合理的,它们就是正当的。",
"任何感觉都是正当的。",
"把事安顿下来、组织起来。",
"暂定性、灵活性、自发的。"
];
for ($index = 1; $index <= count($array); $index++) {
$content = $array[$index - 1];
if ($index % 2) {
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
}
switch ($index % 8) {
case 0:
$group_id = $p->id;
break;
case 1:
$group_id = $e->id;
break;
case 2:
$group_id = $i->id;
break;
case 3:
$group_id = $s->id;
break;
case 4:
$group_id = $n->id;
break;
case 5:
$group_id = $t->id;
break;
case 6:
$group_id = $f->id;
break;
case 7:
$group_id = $j->id;
break;
}
if ($index % 2) {
$no = "A";
} else {
$no = "B";
}
EvaluateAnswer::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_id, 'question_id' => $q->id, 'content' => $content], ['answerNo' => $no, 'score' => 1]);
}
}
public function getAnswers2($merchant_id, $test_item_id)
{
$e = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "E"]);
$i = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "I"]);
$s = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "S"]);
$n = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "N"]);
$t = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "T"]);
$f = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "F"]);
$j = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "J"]);
$p = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "P"]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "当你某日想去某个地方你会___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "计划好将做的事情以及何时做", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "什么都不想就去", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "如果你是一位老师你愿教___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "涉及事实的课程", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "涉及理论的课程", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你通常是___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "一个善于交际的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "安静缄默的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "事先安排好约会,聚会等", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "只要时机恰当就无拘无束地做任何有趣的事", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你通常和___相处得更好?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "现实的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "想象力丰富的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "当你和一群人在一起时你会___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "参加大家的谈话", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "只同你熟知的人单独谈话", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "往往你是___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "情感驾驭理智", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "理智驾驭情感", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你更喜欢___做多数事情?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "有计划地", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "即兴时", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你愿意自己被认为是一个___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "善于动手的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "善于创意的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "在大群体中你常更多地___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "介绍他人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "由别人来介绍你", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "按日程表办事___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "正合你意", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "束缚了你", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你更喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "务实且有丰富常识的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "头脑灵活的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你觉得通常别人要花费___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "一小段时间来了解你", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "很久来了解你", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "被称为___是更高的赞赏?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "感性的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "一贯理性的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "对于制定周末计划你觉得___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "很有必要", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "没必要", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你愿把___作为朋友?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "脚踏实地的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "常有新观点的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "多数时候你倾向于___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "同他人在一起", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "独处", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "日常工作中你喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "通常先安排好工作并加以完成,以免压力过大", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "在时间紧迫的情况下争分夺秒地工作", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "当你为了消遣而阅读时你___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "喜欢作者确切地表达其意思", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "欣赏奇特新颖的表达方式", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你能否___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "只要愿意就能轻松地同几乎任何人说个没完", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "只能在特定场合下或同特定的人才愿意讲许多话", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你更倾向于___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "感性地做事过大", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "依逻辑行事", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "当有一项特殊工作时你会___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "在开始前精心组织策划", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "在工作进行中找出必要环节", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "做很多人都会做的事情时你喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "按惯例做", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "按自己独创的方式做", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你新认识的人___说出你的兴趣所在?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "马上就能", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "只有当他们真正了解你之后才能", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "在计划一次旅行时你更喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "事先就知道在大部分日子所将做的事情", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "在多数情况下随心所欲地行事", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "多数人认为你___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "非常坦率", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "不太把自己的事情告诉别人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "事实", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "观点", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "热忱", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "坚决", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "切实", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "创新", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "有计划", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "随意", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "实在", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "抽象", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "感觉", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "思考", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "已知的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "新颖的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "感性", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "理性", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "安排好的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "不受限制的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "热情", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "安静", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "温柔", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "坚硬", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "陈述", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "观念", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "慈悲心肠", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "意志坚强", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "事实的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "理论的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "很多朋友", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "少许朋友", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "系统的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "自发的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "确定", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "推测", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "宽容", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "坚定", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "必然性", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "可能性", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "动之以情", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "晓之以理", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "健谈", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "缄默", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "温和", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "力量", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "现实", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "理想", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "好心的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "称职的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "事实", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "理论", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "系统", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "随机", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "现实的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "想象的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "易动情的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "客观的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "建造", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "发明", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "感情丰富的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "注重实际的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "有序的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "随便的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "开朗", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "文静", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "认同", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "分析", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "事实的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "想象的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "祝福", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "利益", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "详实", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "概括", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "决定", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "冲动", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "制作", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "创造", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "热情", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "客观", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "实用的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "迷人的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "体谅的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "公正的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "爱交际", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "爱文静", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "敏感", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "合理", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "制造", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "设计", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "有同情心", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "有逻辑头脑", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "公开的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "私人的", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => null]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "同情怜悯", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "深谋远虑", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "通常你更喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "提前安排好业余活动", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "即兴地做事情", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你觉得被许多人围着___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "让你感到更有精神", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "常让你精力衰竭", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "多数情况下你更喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "按日程表办事", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "顺其自然", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "在聚会中你___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "总是玩得很开心", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "有时觉得无趣", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "作决定时对于你来说更重要的是___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "考虑人们的感受和观点", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "权衡事实", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你喜欢___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "事先很早就作好准备", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "看清事态如何发展再作计划", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "别人___了解你?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "很容易", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "很难", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你喜欢的处事方式是___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "坚持那些已经有效的方法", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "分析哪些仍有错并挑战未解决的问题", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你觉得自己更偏向于是一个___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "有组织性的人", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "自发性的人", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "只要愿意,就能和几乎任何一个人谈个没完", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "只同和自己有共同兴趣的人才能长时间的交谈", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你愿在一个___老板老师手下工作学习?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $f->id, 'question_id' => $q->id, 'content' => "脾气好,但前后不一致", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $t->id, 'question_id' => $q->id, 'content' => "对人严厉,但有条理", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你更喜欢按照___做大多数事情?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "已定的日程表", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "当天的感觉", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "在聚会中你___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "自己聊得多", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "听别人聊得多", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "通常你更喜欢上涉及___的课程?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $s->id, 'question_id' => $q->id, 'content' => "具体内容", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $n->id, 'question_id' => $q->id, 'content' => "概念和原则", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "当你开始了一项必须在一周内完成的大项目时你会___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "花时间列出所要做的事情及其先后次序", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "直接开始", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "在社交场合中你通常觉得___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "很容易同大多数人长时间谈话", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "同某些人很难开展和维持长时间的谈话", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "被称为___是更高的赞赏?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "富有同情心", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "有竞争力", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你觉得按计划行事___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "多数时候是有帮助的、适宜的", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "有时必要,便令人不爽", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你通常___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $e->id, 'question_id' => $q->id, 'content' => "同大家打成一片", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $i->id, 'question_id' => $q->id, 'content' => "倾向于独处", 'answerNo' => "B", 'score' => 1]);
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => "你通常___?"]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $j->id, 'question_id' => $q->id, 'content' => "开始先确定每一个步骤", 'answerNo' => "A", 'score' => 1]);
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $p->id, 'question_id' => $q->id, 'content' => "边做边考虑必须完成的事", 'answerNo' => "B", 'score' => 1]);
}
public function getAnswers3($merchant_id, $test_item_id)
{
$taker = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "索取"]);
$giver = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "给予"]);
$matcher = EvaluateQuestionGroup::firstOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'title' => "匹配"]);
$array = [
[
"question" => "你和一个陌生人都会收到一些钱。对于你和陌生人收到的东西,你有三种选择,而且你永远不会见到或遇见陌生人。您会选择哪个选项?",
"answers" => ["我得到8美元陌生人得到4美元", "我得到5美元陌生人得到7美元", "我得到5美元陌生人得到5美元"]
],
[
"question" => "2006年卡特里娜飓风造成严重破坏后一位美国银行高管带领员工团队前往帮助重建新奥尔良。你认为他为什么这么做",
"answers" => ["他想成为一个慷慨、奉献的组织而成为头条新闻", "他对受害者感到同情,并愿意尽其所能来帮助", "他想表达对在新奥尔良有家人的银行员工的支持"]
],
[
"question" => "你正在申请经理职位,前任老板给你写了一封热情洋溢的推荐信。你最有可能做什么?",
"answers" => ["竭尽全力给我的新老板留下好印象,这样我就可以为未来提出另一个强有力的推荐", "主动为我的一位前雇员写一封推荐信,来帮助对方发展", "想办法帮助我的前老板,这样我就可以偿还"]
],
[
"question" => "您正在与两名同事一起开发一个项目,需要完成三项任务。当你们讨论如何划分任务时,很明显你们三个人都对其中两项任务非常感兴趣,但认为第三项任务相当无聊。你会怎么办?",
"answers" => ["尝试说服我的一位同事去做这项无聊的任务", "自愿从事无聊的工作而不求任何回报", "自愿完成无聊的任务,并稍后请同事帮忙"]
],
[
"question" => "几年前,你帮助一位名叫杰米的熟人找到了工作。从那以后你们就不再联系了。突然,杰米发送了一封电子邮件,向您介绍一位潜在的业务合作伙伴。杰米的电子邮件背后最可能的动机是什么?",
"answers" => ["杰米想再次寻求帮助", "杰米真诚地想帮助我", "杰米想还钱给我"]
],
[
"question" => "你经常无缘无故地送礼物给别人吗?",
"answers" => ["绝不", "经常", "有时"]
],
[
"question" => "你最喜欢和朋友谈论什么?",
"answers" => ["关于我和我的问题", "关于他们的问题,以便我可以为他们提供建议", "关于娱乐、电影、游戏"]
],
[
"question" => "度假时需要记住什么?",
"answers" => ["我什么都不用做,我想放松一下", "关于我应该给朋友买什么纪念品", "打电话给我的家人并告诉他们一切都很好"]
],
[
"question" => "你经常为别人改变你的计划吗?",
"answers" => ["不,我不会轻易被说服改变我的计划", "是的,我总是尽力帮助别人", "是的,但只有当他们真正需要我时"]
],
[
"question" => "以下哪一个特征更能描述您?",
"answers" => ["自我陶醉", "自我牺牲", "支持者"]
],
[
"question" => "您总是知道该买什么作为送给朋友或家人的礼物吗?",
"answers" => ["不,我总是在购买礼物时遇到问题", "这取决于我对他们的了解", "是的,我很了解他们,知道他们需要什么"]
],
[
"question" => "您更喜欢接受礼物还是赠送礼物?",
"answers" => ["得到", "两个都好", "赠送"]
],
[
"question" => "如果你买彩票中了很多钱你会做什么?",
"answers" => ["我会给自己买一些我一直梦想的东西", "我会与所爱的人分享奖金", "我会把钱存起来做重要的事情"]
],
[
"question" => "如果你买彩票中了很多钱你会做什么?",
"answers" => ["我会给自己买一些我一直梦想的东西", "我会与所爱的人分享奖金", "我会把钱存起来做重要的事情"]
],
[
"question" => "在你们的关系中,你最常如何解决问题?",
"answers" => ["我坚持直到伴侣承认我是对的", "我做伴侣想做的事以避免冲突", "我制定了一个妥协方案"]
],
[
"question" => "当有人向你求助时,你会如何反应?",
"answers" => ["我很快想出了一个借口", "我立即提供帮助", "我想知道我是否能做到"]
],
[
"question" => "当你需要帮助时你会做什么?",
"answers" => ["我立即向某人寻求帮助", "首先,我尝试自己弄清楚,然后我问别人可以吗?", "我尽可能不向任何人寻求帮助"]
],
[
"question" => "你的人生目标是什么?",
"answers" => ["以我想要的方式生活", "让世界变得更美好", "实现互惠互利"]
],
[
"question" => "你借的东西总是归还吗?",
"answers" => ["不,我很少归还它们", "总是", "有时我会忘记它"]
],
[
"question" => "当你看到你的伴侣或朋友不高兴时你会怎么做?",
"answers" => ["不关我的事", "立即尝试安慰他或她", "我问他/她为什么不高兴"]
],
[
"question" => "以下哪一个特征更能描述您?",
"answers" => ["懒惰的", "勤劳的人", "独立的"]
],
[
"question" => "谁做的家务更多——你还是你的伴侣/室友?",
"answers" => ["他们做更多的家务", "我做更多的家务事", "我没有伴侣或室友"]
],
[
"question" => "朋友问你生日想要什么。你知道该怎么回答他吗?",
"answers" => ["是的,我最清楚自己想要什么", "不,我永远无法决定我真正想要什么", "有时我知道,有时我不知道"]
],
[
"question" => "您有多关心让您所爱的人幸福?",
"answers" => ["他们应该照顾自己的幸福,我不在乎", "他们的幸福比我的幸福更重要", "我关心他们的幸福,但我必须照顾好自己"]
],
[
"question" => "哪个职业最适合您?",
"answers" => ["音乐家", "医生", "商人"]
],
[
"question" => "你是个好孩子吗?",
"answers" => ["不,我没有听我父母的话", "是的,我从来没有给我的父母带来任何麻烦", "我不记得了"]
],
[
"question" => "3.你到现在成全过几个人,让他们人生变得更好,或者有更好的幸福感呢?",
"answers" => ["0", "3-7个或以上", "1-3个"]
],
];
$group_ids = [$taker->id, $giver->id, $matcher->id];
$nos = ["A", "B", "C"];
foreach ($array as $arr) {
$q = EvaluateQuestion::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => null, 'question_name' => $arr["question"]]);
$index = 0;
foreach ($arr['answers'] as $answer) {
EvaluateAnswer::create(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id, 'group_id' => $group_ids[$index], 'question_id' => $q->id, 'content' => $answer, 'answerNo' => $nos[$index], 'score' => 1]);
$index++;
}
}
}
public function createMBTIEval($merchant_id, $title, $img, $price, $questions, $question_count)
{
$test_item_id = 10009;
$question_count = 93;
$desc = "<p>每一组中都有两选项a 或 b挑选最适合你的答案。作答所有的问题包括从两相似的答案中挑选其</p>";
$summary = "<p>每一组中都有两选项a 或 b挑选最适合你的答案。作答所有的问题包括从两相似的答案中挑选其</p>";
$type = 8;
$list = EvaluateList::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id], ['name' => $title, 'subtitle' => $title, 'desc' => $desc, 'test_type' => 1, 'type' => $type, 'question_number' => $question_count, 'cover' => $img, 'price' => $price, 'evaNum' => 0]);
$detail = EvaluateDetail::updateOrCreate(['test_item_id' => $test_item_id], ['title' => $title, 'subtitle' => $title, 'type' => $type, 'image' => $img, 'tabImage' => $img, 'cover' => $img, 'summary' => $summary, 'report_pages' => null, 'notes' => '本测试为虚拟服务内容,购买成功后不可退换;测试可重复购买,每次付费仅允许测试一次。', 'price' => $price, 'questions' => null, 'question_count' => $question_count, 'visitNum' => 0, 'hits' => 0]);
$this->getAnswers($merchant_id, $test_item_id);
$arr = EvaluateQuestion::with('answer:id,test_item_id,group_id,question_id,content,answerNo')->where("test_item_id", $test_item_id)->select('id', 'test_item_id', 'question_name')->get()->toArray();
$detail->questions = json_encode($arr);
$detail->save();
MerchantEvaluate::updateOrCreate(['title' => $title, 'test_item_id' => $test_item_id, 'merchant_id' => $merchant_id], ['image' => $img, 'status' => 0, 'price' => $price, 'sort' => 0, 'pv' => 0, 'is_top' => 0, 'top_time' => null, 'test_item_type' => 1]);
}
public function createMBTIEval2($merchant_id, $title, $img, $price, $questions, $question_count, $test_item_id)
{
$desc = "<p>该问卷用于揭示你是如何看待事物、如何做决定,答案无好坏之分。
问卷结果有助于了解自己的职业倾向、个性特征、人际相处的特征。
请仔细阅读每一个问题,答案直接写在题目上面。
不必对问题想的太多,根据第一感觉回答即可。</p>";
$summary = $desc;
$type = 9;
$list = EvaluateList::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id], ['name' => $title, 'subtitle' => $title, 'desc' => $desc, 'test_type' => 1, 'type' => $type, 'question_number' => $question_count, 'cover' => $img, 'price' => $price, 'evaNum' => 0]);
$detail = EvaluateDetail::updateOrCreate(['test_item_id' => $test_item_id], ['title' => $title, 'subtitle' => $title, 'type' => $type, 'image' => $img, 'tabImage' => $img, 'cover' => $img, 'summary' => $summary, 'report_pages' => null, 'notes' => '本测试为虚拟服务内容,购买成功后不可退换;测试可重复购买,每次付费仅允许测试一次。', 'price' => $price, 'questions' => null, 'question_count' => $question_count, 'visitNum' => 0, 'hits' => 0]);
$this->getAnswers2($merchant_id, $test_item_id);
$arr = EvaluateQuestion::with('answer:id,test_item_id,group_id,question_id,content,answerNo')->where("test_item_id", $test_item_id)->select('id', 'test_item_id', 'question_name')->get()->toArray();
$detail->questions = json_encode($arr);
$detail->save();
MerchantEvaluate::updateOrCreate(['title' => $title, 'test_item_id' => $test_item_id, 'merchant_id' => $merchant_id], ['image' => $img, 'status' => 0, 'price' => $price, 'sort' => 0, 'pv' => 0, 'is_top' => 0, 'top_time' => null, 'test_item_type' => 1]);
}
public function createGMT()
{
$merchant_id = 69;
$test_item_id = 10010;
$question_count = 26;
$title = '给予者、匹配者、拿取者测试';
$img = 'https://image.fulllinkai.com/202207/26/b6c31d01d41c9e1714958f9c56d01d8f.png';
$price = 0;
$desc = "<p>这些类型的测试是最好的。那么你就能更好地了解自己。了解你自己和你的需求是很有用的。今天我们来看看——你是给予者还是索取者</p>";
$summary = $desc;
$type = 10;
$list = EvaluateList::updateOrCreate(['merchant_id' => $merchant_id, 'test_item_id' => $test_item_id], ['name' => $title, 'subtitle' => $title, 'desc' => $desc, 'test_type' => 1, 'type' => $type, 'question_number' => $question_count, 'cover' => $img, 'price' => $price, 'evaNum' => 0]);
$detail = EvaluateDetail::updateOrCreate(['test_item_id' => $test_item_id], ['title' => $title, 'subtitle' => $title, 'type' => $type, 'image' => $img, 'tabImage' => $img, 'cover' => $img, 'summary' => $summary, 'report_pages' => null, 'notes' => '本测试为虚拟服务内容,购买成功后不可退换;测试可重复购买,每次付费仅允许测试一次。', 'price' => $price, 'questions' => null, 'question_count' => $question_count, 'visitNum' => 0, 'hits' => 0]);
$this->getAnswers3($merchant_id, $test_item_id);
$arr = EvaluateQuestion::with('answer:id,test_item_id,group_id,question_id,content,answerNo')->where("test_item_id", $test_item_id)->select('id', 'test_item_id', 'question_name')->get()->toArray();
$detail->questions = json_encode($arr);
$detail->save();
MerchantEvaluate::updateOrCreate(['title' => $title, 'test_item_id' => $test_item_id, 'merchant_id' => $merchant_id], ['image' => $img, 'status' => 0, 'price' => $price, 'sort' => 0, 'pv' => 0, 'is_top' => 0, 'top_time' => null, 'test_item_type' => 1]);
}
public function createEval()
{
DB::beginTransaction();
try {
// $questions = $this->getNoTitleQuestion(40);
// $title = 'MBTI测试1';
// $img = 'https://image.fulllinkai.com/202207/26/b6c31d01d41c9e1714958f9c56d01d8f.png';
// $price = 0;
// $merchant_id = 69;
// $this->createMBTIEval2($merchant_id, $title, $img, $price, $questions=null);
$this->createGMT();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->getError($e);
}
}
public function test(Request $request)
{
$order = TouristOrder::find($request->order_id);
$orderService = new OrderService();
$res = $orderService->storeUftxCustomer($order);
dd($res);
}
public function postIndex()
{
return $this->success('ok');
}
public function getUserToken(User $user)
{
if (request()->token != "fulliank")
return $this->failure("请输入秘钥");
$token = $user->createToken($user->id)->accessToken;
return $this->success('ok', $token);
}
public function getSaasAdminToken(Request $request, MerchantAccount $account)
{
$admin_id = $request->admin_id ?? 0;
if (request()->token != "fulliank")
return $this->failure("请输入秘钥");
$token = MerchantAccount::where('id', $account->id)->value('api_token');
if ($token) {
$result = decrypt($token);
//$time = explode('-', $result)[2];
//if(time()-$time>604800){
if ($admin_id) {
$token = encrypt($account->id . '-' . $account->mobile . '-' . time() . '-' . $account->email . "-" . $admin_id);
} else {
$token = encrypt($account->id . '-' . $account->mobile . '-' . time() . '-' . $account->email);
}
MerchantAccount::where('id', $account->id)->update(['api_token' => $token]);
//}
} else {
if ($admin_id) {
$token = encrypt($account->id . '-' . $account->mobile . '-' . time() . '-' . $account->email . "-" . $admin_id);
} else {
$token = encrypt($account->id . '-' . $account->mobile . '-' . time() . '-' . $account->email);
}
MerchantAccount::where('id', $account->id)->update(['api_token' => $token]);
}
return $this->success('ok', $token);
}
public function dailyComments()
{
$today = date('Y-m-1');
$yestoday = date('Y-m-1', strtotime('-1 month'));
$comments = DB::table('client_comments')->whereBetween('created_at', [$yestoday, $today])->groupBy("maker_user_id")->selectRaw('count(*) as comment_count, maker_user_id');
$users = DB::table('users')->rightJoinSub($comments, 'ufutx_client_comments', function ($join) {
$join->on('users.id', 'client_comments.maker_user_id');
})->select('users.id', 'users.nickname', 'client_comments.comment_count')->orderBy('client_comments.comment_count', 'desc')->get();
return view('daily_comments', compact('users'));
}
public function dailyPreviewRanks()
{
$yestoday = date('Y-m-d', strtotime('-30 day'));
$logs = RankHistory::withTrashed()->where('type', 'preview')->where('created_at', '>', $yestoday)->get();
return view('daily_preview_ranks', compact('logs'));
}
public function getHeader()
{
$header = array(
"type" => "JWT",
"ALG" => "HS256"
);
$header = base64_encode(json_encode($header));
return $header;
}
public function testV2(Request $request)
{
dd(session("abc"));
}
public function urlLink(Request $request, $code)
{
$url = \CommonUtilsService::longUrl($code);
if (empty($url['url']))
return;
$url = $url['url'];
if ($code == 'NO') {
$key = 'vip_to_sms';
Cache::increment($key);
}
Log::info($url);
return redirect()->away($url);
}
public function shorUrl(Request $request)
{
if (empty($request->url))
return $this->failure('请输入链接');
$url = \CommonUtilsService::shortUrl($request->url);
return $this->success('ok', $url);
}
public function testV4()
{
// $result = \DB::table('users')->whereNotNull('location_longitude')->whereNotNull('location_latitude')->select('id', 'nickname', 'mobile', 'location_longitude', 'location_latitude')->orderByRaw('ACOS(SIN((22.576932 * 3.1415) / 180 ) *SIN((location_latitude * 3.1415) / 180 ) +COS((22.576932 * 3.1415) / 180 ) * COS((location_latitude * 3.1415) / 180 ) *COS((113.965004 * 3.1415) / 180 - (location_longitude * 3.1415) / 180 ) ) * 6380 asc')->limit(10)->get();
// $result = \DB::table('users')->selectRaw('ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-latitude*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(latitude*PI()/180)*POW(SIN(($longitude*PI()/180-longitude*PI()/180)/2),2)))*1000) AS distance FROM shop having distance <= 5000 order by distance asc');
// foreach ($result as $re) {
// $s = $this->_distance(113.965004, 22.576932, $re->location_longitude, $re->location_latitude);
// $re->s = $s;
// }
}
private function _distance($lng1, $lat1, $lng2, $lat2)//根据经纬度计算距离
{
//将角度转为弧度
$radLat1 = deg2rad($lat1);
$radLat2 = deg2rad($lat2);
$radLng1 = deg2rad($lng1);
$radLng2 = deg2rad($lng2);
$a = $radLat1 - $radLat2;//两纬度之差,纬度<90
$b = $radLng1 - $radLng2;//两经度之差纬度<180
$s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137;
return $s;
}
public function makerCoinLogs()
{
return \Excel::download(new \App\Exports\LiveMakerCoinLog(), '直播结算记录.xlsx');
}
public function userApprovedExport()
{
return \Excel::download(new \App\Exports\UserApprovedExport(), 'approved.xlsx');
}
public function testV3()
{
$start_time = "2020-09-20 13:30:00";
$end_time = "2020-09-20 19:00:00";
//观看人员
$user_ids = InteractLiveMember::where(function ($sql) use ($start_time, $end_time) {
$sql->where('created_at', '>', $start_time)->where('created_at', '<', $end_time);
})->orWhere(function ($sql) use ($start_time, $end_time) {
$sql->where('updated_at', '>', $start_time)->where('updated_at', '<', $end_time);
})->distinct('user_id')->pluck('user_id')->toArray();
$user_ids = array_unique($user_ids);
if (empty(count($user_ids)))
return $this->success('ok');
$array = $this->exportUserData($user_ids);
return \Excel::download(new \App\Exports\UserDataExport($array), '观看直播记录.xlsx');
// $array = [
// 'user_ids'=>$user_ids,
// 'type'=>'join_live',
// 'month'=>1,
// 'message'=>"感谢您在2020年9月20号13点30分至19点之间观看福恋app直播相亲特赠送1个月超级会员以表感谢!【福恋】"
// ];
// \App\Jobs\AddLiveGuestRank::dispatch($array)->onQueue('love');
return $this->success('ok');
}
public function exportUserData($user_ids)
{
$users = User::whereIn('id', $user_ids)->with('profileCourtship:user_id,wechat_id,province,city,resident_province,resident_city')->get();
$array = [];
foreach ($users as $user) {
$arr = [];
$arr['id'] = $user->id;
$arr['nickname'] = $user->nickname;
$arr['name'] = $user->name;
$arr['sex'] = $user->sex == 1 ? '男' : '女';
$arr['mobile'] = $user->mobile;
$arr['type'] = $user->type == 'single' ? '单身' : '介绍人';
$arr['wechat_id'] = $user->profileCourtship ? $user->profileCourtship->wechat_id : '';
$arr['province'] = $user->profileCourtship ? $user->profileCourtship->province : '';
$arr['city'] = $user->profileCourtship ? $user->profileCourtship->city : '';
$arr['resident_province'] = $user->profileCourtship ? $user->profileCourtship->resident_province : '';
$arr['resident_city'] = $user->profileCourtship ? $user->profileCourtship->resident_city : '';
$array[] = $arr;
}
return $array;
}
public function matchMakerLineExport()
{
$start_time = "2020-09-20 13:30:00";
$end_time = "2020-09-20 19:00:00";
$live_ids = InteractLiveLog::where('created_at', '>', $start_time)->where('created_at', '<', $end_time)->distinct('live_id')->pluck('live_id');
$array = [];
foreach ($live_ids as $live_id) {
$nickname = InteractLive::find($live_id)->matchMaker->nickname;
$num_arr = InteractLiveLog::where('live_id', $live_id)->where('created_at', '>', $start_time)->where('created_at', '<', $end_time)->distinct('num')->pluck('num');
//开播次数
$in_live_num = count($num_arr);
$log_arr = [];
$total_duraction = 0;
foreach ($num_arr as $num) {
//开始时间
$log_start_time = InteractLiveLog::where('live_id', $live_id)->where('num', $num)->where('created_at', '>', $start_time)->where('created_at', '<', $end_time)->orderBy('id', 'asc')->value('created_at');
$log_start_time = $log_start_time ? $log_start_time->toDateTimeString() : null;
//结束时间
$log_end_time = InteractLiveLog::where('live_id', $live_id)->where('num', $num)->where('created_at', '>', $start_time)->where('created_at', '<', $end_time)->orderBy('id', 'desc')->value('updated_at');
$log_end_time = $log_end_time ? $log_end_time->toDateTimeString() : null;
$arr = [];
//第几次直播
$arr['live_id'] = $live_id;
$arr['name'] = $nickname;
$arr['num'] = $num;
//直播开始时间
$arr['log_start_time'] = $log_start_time;
//直播结束时间
$arr['log_end_time'] = $log_end_time;
//直播时长秒
$arr['duraction'] = strtotime($log_end_time) - strtotime($log_start_time);
$log_arr[] = $arr;
$total_duraction += $arr['duraction'];
}
$arr = [];
$arr['live_id'] = $live_id;
$arr['nickname'] = $nickname;
$arr['log_arr'] = $log_arr;
$arr['total_duraction'] = $total_duraction;
$array[] = $arr;
}
return \Excel::download(new \App\Exports\LiveLogData($array), '红娘直播记录.xlsx');
return $this->success('ok', $array);
}
public function liveMemberLineExport()
{
$start_time = "2020-09-20 13:30:00";
$end_time = "2020-09-20 19:00:00";
$live_ids = InteractLiveLog::where('created_at', '>', $start_time)->where('created_at', '<', $end_time)->distinct('live_id')->pluck('live_id');
$array = [];
foreach ($live_ids as $live_id) {
$logs = InteractLiveLog::where('created_at', '>', $start_time)->where('created_at', '<', $end_time)->where('live_id', $live_id)->where(function ($sql) {
$sql->whereNotNull('female_user_id')->orWhereNotNull('male_user_id');
})->get();
$arr = [];
foreach ($logs as $log) {
$data['make_user_id'] = $log->mk_user_id;
$data['make_nickname'] = User::find($log->mk_user_id)->nickname;
$data['female_user_id'] = $log->female_user_id;
$data['female_nickname'] = $log->female_user_id ? User::find($log->female_user_id)->nickname : null;
$data['male_user_id'] = $log->male_user_id;
$data['male_nickname'] = $log->male_user_id ? User::find($log->male_user_id)->nickname : null;
$arr[] = $data;
}
$array[] = $arr;
}
return \Excel::download(new \App\Exports\LiveLogDataV4($array), '红娘直播名单记录.xlsx');
return $this->success('ok', $arr);
}
public function tongMessengerDataExport(Request $request)
{
$start_date = $request->input('start_date');
$end_date = $request->input('end_date');
if (empty($start_date) || empty($end_date)) {
return $this->failure('请输入日期');
}
$data = ShareRoleViewer::with('messenger')->whereHas('messenger', function ($sql) use ($start_date, $end_date) {
$sql->where('is_audit', 1);
})->where('share_role_id', '>=', 2)->whereBetween('updated_at', [$start_date, $end_date])->get();
$arr = [];
foreach ($data as $da) {
$array = [];
$array['role_id'] = $da->share_role_id;
$array['viewer_id'] = $da->viewer_id;
$array['role_name'] = ShareRole::where('id', $da->share_role_id)->value('name');
$array['nickname'] = $da->messenger->name;
$array['mobile'] = $da->messenger->mobile;
$array['sex'] = $da->messenger->sex == 1 ? '男' : ($da->messenger->sex == 2 ? '女' : '未知');
$array['age'] = $da->messenger->age ? $da->messenger->age . '后' : '';
$array['marital_status'] = $da->messenger->marital_status == 2 ? '恋爱中' : ($da->messenger->marital_status == 1 ? '已婚' : '单身');
$array['belief'] = $da->messenger->belief ? '其他' : '基督教';
$array['degree'] = $da->messenger->degree;
$array['resident_province'] = $da->messenger->resident_province;
$array['resident_city'] = $da->messenger->resident_city;
$array['work_province'] = $da->messenger->work_province;
$array['work_city'] = $da->messenger->work_city;
$array['check_date'] = $da->updated_at;
$arr[] = $array;
}
if (count($data) == 0) {
return $this->failure('暂时没有数据');
}
// return \Excel::download(new DailyMessengerData($data), $date.'分享婚恋使者.xlsx');
return \Excel::download(new TongMessengerData($arr), '铜牌以上婚姻使者.xlsx');
}
public function messengerDataExport(Request $request)
{
$date = $request->input('date');
if (empty($date)) {
return $this->failure('请输入日期');
}
$end_date = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($date)));
$data = \DB::table('messengers as m')->whereNotNull('m.share_viewer_id')->where('m.share_viewer_id', '<>', 0)->whereBetween('m.created_at', [$date, $end_date])->groupBy('share_viewer_id')->leftJoin('viewers as v', 'v.id', '=', 'm.share_viewer_id')->select(\DB::raw('share_viewer_id, nickname, actual_name, count(*) as count'))->orderBy('count', 'desc')->get();
foreach ($data as $da) {
//新用户
$da->new_count = Viewer::where('viewer_id', $da->share_viewer_id)->whereBetween('created_at', [$date, $end_date])->count();
//总分享婚恋使者人数
// $da->messenger_count = LiveMessenger::where('share_viewer_id', $da->share_viewer_id)->whereBetween('created_at', [$date, $end_date])->count();
}
if (count($data) == 0) {
return $this->failure('暂时没有数据');
}
return \Excel::download(new DailyMessengerData($data), $date . '分享婚恋使者.xlsx');
}
public function viwerDateExport(Request $request)
{
$date = $request->input('date');
if (empty($date)) {
return $this->failure('请输入日期');
}
$end_date = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($date)));
$data = \DB::table('viewers as m')->whereBetween('m.created_at', [$date, $end_date])->groupBy('m.viewer_id')->leftJoin('viewers as v', 'v.id', '=', 'm.viewer_id')->whereNotNull('v.id')->where('v.viewer_id', '<>', 0)->select(\DB::raw('ufutx_v.id, ufutx_v.nickname, ufutx_v.actual_name, count(*) as count'))->orderBy('count', 'desc')->get();
// return view('welcome');
if (count($data) == 0) {
return $this->failure('暂时没有数据');
}
return \Excel::download(new DailyViewerData($data), $date . '分享新用户.xlsx');
}
public function likersTest(Request $request)
{
$userCon = new UserService();
$user = User::where('mobile', $request->input('mobile'))->first();
if (empty($user)) {
return $this->failure("用户不存在");
}
$likers = $userCon->largeDataSingleLikers($user, $paas = '');
// return view('welcome');
return $this->success('ok', $likers);
}
public function testOfficialNotice(Request $request)
{
$mobile = $request->input('mobile');
if (empty($mobile)) {
return $this->failure('请输入查询手机号');
}
$user = User::with('wechat')->where('mobile', $mobile)->first();
$count = RecommendLinkingNew::where('id_users_left', $user->id)->where('score', '>', 0.8)->count();
if (empty($count)) {
return $this->failure('大数据没有匹配');
}
$result = $user->hasSubscribeOfficial();
if (empty($result)) {
return $this->failure('没有关注公众号');
}
$official_openid = $user->wechat ? $user->wechat->official_openid : '';
if (empty($official_openid)) {
$official_openid = SingleProfile::where('user_id', $user->id)->value('openid');
if (empty($official_openid)) {
return $this->failure('没有openid');
}
}
return $this->success('ok');
}
public function qrcode(Request $request)
{
// $app_id = config('wechat.mini_program.app_id');
// $secret = config('wechat.mini_program.secret');
// $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$app_id.'&secret='.$secret;
// $access_token = Http::get($url);
// dd($access_token);
$path = $request->input('path');
$width = $request->input('width', 200);
$type = $request->input('type');
$pic = $this->getQrcode($path, $width, $type);
return $pic;
}
public function getQrcode($path, $width, $type = 'mp')
{
$data = [];
$data['is_hyaline'] = true;
$data['width'] = $width;
if ($type == 'mp') {
$app = \WechatService::app();
$response = $app->app_code->get($path, $data);
$time = time();
$path = $time . 'qrcode.png';
$filename = $response->save(storage_path('qrcode'), $path);
$qrcode_path = storage_path("qrcode/" . $time . "qrcode.png");
} elseif ($type == 'h5') {
$app = \WechatService::officialApp();
$response = $app->qrcode->forever($path);
if ($response && $response['ticket']) {
$url = $app->qrcode->url($response['ticket']);
return $url;
} else {
return null;
}
}
if (file_exists($qrcode_path)) {
$pic = $this->uploadFile($qrcode_path);
try {
unlink($qrcode_path);
} catch (Exception $e) {
return $this->failure($e->getMessage());
exit();
}
return $pic;
}
}
public function getWechatMiniQrcode($page, $scene)
{
$app = \WechatService::app();
$response = $app->app_code->getUnlimit($scene, [
'page' => $page
]);
$name = uniqid() . '.png';
$response->save(storage_path('qrcode'), $name);
$qrcode_path = storage_path("qrcode/" . $name);
$qrcode = $this->uploadFile($qrcode_path);
unlink($qrcode_path);
return $qrcode;
}
public function getSubscribeStatus($openid)
{
$app = \WechatService::officialApp('new');
$wechat_user = $app->user->get($openid);
$result = !empty($wechat_user) && count($wechat_user) && isset($wechat_user['subscribe']);
$is_subscribe = $result ? $wechat_user['subscribe'] : 0;
return $is_subscribe;
}
public function getUrlqrcode($url, $size = 300)
{
// $name = mb_substr($url, stripos($url, 'community'));
// $name = str_replace('/', '-', $name);
// if (strpos($name, 'https') !== false) {
// $name = base64_encode($name);
// }
// $path = "../storage/qrcode/$name.png";
$name = time() . uniqid() . 'qrcode';
$path = storage_path("qrcode/$name.png");
QrCode::format('png')->margin(1)->size($size)->generate($url, $path);
$pic = $this->uploadFile($path);
return $pic;
}
/**
* 赠送会员
* @param [type] $user_id [description]
* @param [type] $rank_id [description]
* @param [type] $month [description]
* @return [type] [description]
*/
public function addUserRank($user_id, $rank_id, $month)
{
//子等级
$rank = Rank::find($rank_id);
//当前等级
$user = User::where('id', $user_id)->first();
//当前会员记录
$rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', $user->rank_id)->orderBy('id', 'desc')->first();
if (empty($rank_history)) {
$user->rank_id = 0;
$user->save();
}
//购买月数
$rank_month = $month;
if ($user->rank_id == 0) {//当前没有会员
RankHistory::create([
'user_id' => $user_id,
'rank_id' => $rank_id,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month')),
]);
$user->rank_id = $rank_id;
$user->save();
} elseif ($user->rank_id == 1) {//当前市级
if ($rank_history && empty($rank_history->deadline)) {//当前市级(未激活)
$rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month'));
$rank_history->rank_id = $rank_id;
$rank_history->save();
$user->rank_id = $rank_id;
$user->save();
} elseif ($rank_history && $rank_history->deadline) {//市级(已激活)
//更新市级
$rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline)));
$rank_history->save();
if ($rank_id != 1) {
//生成黄金/钻石
RankHistory::create([
'user_id' => $user_id,
'rank_id' => $rank_id,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month')),
]);
$user->rank_id = $rank_id;
$user->save();
}
}
} elseif ($user->rank_id == 2) {//当前黄金
if ($rank_id == 1) {
//市级会员
$city_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 1)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if ($city_rank_history) {//市级会员存在
$city_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($city_rank_history->deadline)));
$city_rank_history->save();
} else {//市级会员不存在
//时间 = 当前会员时间 + 所购买的时间
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 1,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline))),
]);
}
} elseif ($rank_id == 2) {//赠送的黄金会员
//市级会员
$city_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 1)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if ($city_rank_history) {//市级会员存在
$city_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($city_rank_history->deadline)));
$city_rank_history->save();
}
//更新黄金会员
if ($rank_history) {
$rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline)));
$rank_history->save();
} else {
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 2,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month')),
]);
}
} elseif ($rank_id == 3) {//赠送的钻石会员
//市级会员
$city_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 1)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if ($city_rank_history) {//市级会员存在
$city_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($city_rank_history->deadline)));
$city_rank_history->save();
}
//黄金会员记录
if ($rank_history) {
$rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline)));
$rank_history->save();
}
//生成钻石会员
RankHistory::create([
'user_id' => $user_id,
'rank_id' => $rank_id,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month')),
]);
$user->rank_id = $rank_id;
$user->save();
}
} elseif ($user->rank_id == 3) {//当前钻石
if ($rank_id == 1) {//赠送的市级会员
//市级会员
$city_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 1)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if ($city_rank_history) {//市级会员存在
$city_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($city_rank_history->deadline)));
$city_rank_history->save();
} else {
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 1,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline))),
]);
}
} elseif ($rank_id == 2) {//赠送的黄金会员
//市级会员
$city_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 1)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if ($city_rank_history) {//市级会员存在
$city_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($city_rank_history->deadline)));
$city_rank_history->save();
}
//更新黄金会员
$gold_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 2)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if (!empty($gold_rank_history)) {//黄金会员在期限内
//更新市级会员
$gold_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($gold_rank_history->deadline)));
$gold_rank_history->save();
} else {
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 2,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline))),
]);
}
} elseif ($rank_id == 3) {
//市级会员
$city_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 1)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if ($city_rank_history) {
$city_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($city_rank_history->deadline)));
$city_rank_history->save();
}
//黄金会员记录
$gold_rank_history = RankHistory::where('user_id', $user_id)->where('rank_id', 2)->whereNotNull('deadline')->orderBy('id', 'desc')->first();
if (!empty($gold_rank_history)) {//黄金会员在期限内
//更新市级会员
$gold_rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($gold_rank_history->deadline)));
$gold_rank_history->save();
}
//更新钻石会员
if ($rank_history) {
$rank_history->deadline = date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($rank_history->deadline)));
$rank_history->save();
} else {
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 3,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month')),
]);
}
}
} elseif ($rank_id == 9) {
//是否在会员期内
$history = RankHistory::where('user_id', $user_id)->where('deadline', '>', date('Y-m-d H:i:s'))->orderBy('deadline', 'desc')->first();
if ($history) {
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 9,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month', strtotime($history->deadline))),
]);
} else {
RankHistory::create([
'user_id' => $user_id,
'rank_id' => 9,
'deadline' => date('Y-m-d H:i:s', strtotime('+' . $rank_month . ' month')),
]);
}
}
return;
}
public function activityMemberExport($activity_id)
{
$data = [];
$members = ActivityMember::where('activity_id', $activity_id)->with('user.profileCourtship', 'user.profileMarriage')->whereHas('user', function ($sql) {
$sql->where('id', '>', 0);
})->get();
foreach ($members as $member) {
$new_data['name'] = $member->user->name;
$new_data['mobile'] = $member->user->mobile;
switch ($member->user->sex) {
case 1:
$sex = '男';
break;
case 2:
$sex = '女';
default:
$sex = '未知';
}
$new_data['sex'] = $sex;
if ($member->user->profileCourtship || $member->user->profileMarriage) {
$new_data['birthday'] = $member->user->type == 'single' ? $member->user->profileCourtship->birthday : $member->user->profileMarriage->birthday;
} else {
$new_data['birthday'] = '无';
}
$new_data['type'] = $member->user->type == 'single' ? '单身' : '介绍人';
$new_data['card_num'] = '-' . $member->user->card_num . '-';
$new_data['is_approved'] = $member->user->is_approved ? '已认证' : '未认证';
if (empty($member->user->profileCourtship)) {
$new_data['province'] = '';
$new_data['city'] = '';
$new_data['resident_province'] = '';
$new_data['resident_city'] = '';
$new_data['wechat_id'] = '';
} else {
$new_data['province'] = $member->user->profileCourtship->province;
$new_data['city'] = $member->user->profileCourtship->city;
$new_data['resident_province'] = $member->user->profileCourtship->resident_province;
$new_data['resident_city'] = $member->user->profileCourtship->resident_city;
$new_data['wechat_id'] = $member->user->profileCourtship->wechat_id;
}
$data[] = $new_data;
}
return \Excel::download(new ActivityMemberExport($data), 'activity_member.xlsx');
}
/**
* 根据订单信息获取用户数据
* @param TouristOrder $order
*/
public function getOrderUserInfo(TouristOrder $order)
{
$user = null;
if ($order->account_id) {
$merchnat_user = MerchantUser::where('id', $order->account_id)
->select('openid', 'mobile', 'user_id')
->first();
if ($merchnat_user) {
if (!empty($merchnat_user->user_id)) {
$user = User::with('profileCourtship', 'profilePhoto')->where('id', $merchnat_user->user_id)
->select('*')
->first();
if ($user) {
return $user;
}
}
if (!empty($merchnat_user->mobile)) {
$user = User::with('profileCourtship', 'profilePhoto')->where('mobile', $merchnat_user->mobile)
->select('*')
->first();
if ($user) {
return $user;
}
}
if (!empty($merchnat_user->openid)) {
if ($order->channel == 3) { //小程序
$user_id = Wechat::where('openid', $order->open_id)
->value('user_id');
} elseif ($order->channel == 0 || $order->channel == 1) { //公众号
$user_id = Wechat::where('official_openid', $order->open_id)
->value('user_id');
}
if ($user_id) {
$user = User::with('profileCourtship', 'profilePhoto')->where('id', $user_id)
->select('*')
->first();
}
if ($user) {
return $user;
}
}
}
}
if ($order->mobile && $order->mobile != '未获取') {
$user = User::with('profileCourtship', 'profilePhoto')->where('mobile', $order->mobile)
->select('*')
->first();
if ($user) {
return $user;
}
}
if ($order->open_id) {
switch ($order->channel) {
case 0:
case 1:
$user_id = Wechat::where('official_openid', $order->open_id)
->value('user_id');
break;
case 2:
$user_id = Wechat::where('app_openid', $order->open_id)
->value('user_id');
case 3:
$user_id = Wechat::where('openid', $order->open_id)
->value('user_id');
break;
default:
break;
}
if ($user_id) {
$user = User::with('profileCourtship', 'profilePhoto')->where('id', $user_id)
->select('*')
->first();
}
if ($user) {
return $user;
}
}
if ($order->linkmen) {
$linkmen = json_decode($order->linkmen, true);
if (!empty($linkmen)) {
if (!empty($linkmen[0]) && !empty($linkmen[0]['mobile'])) {
$user = User::with('profileCourtship', 'profilePhoto')->where('mobile', $linkmen[0]['mobile'])
->select('*')
->first();
if ($user) {
return $user;
}
} elseif (!empty($linkmen['mobile'])) {
$user = User::with('profileCourtship', 'profilePhoto')->where('mobile', $linkmen['mobile'])
->select('*')
->first();
if ($user) {
return $user;
}
}
}
}
return $user;
}
/**
* 导出商户订单
*/
public function touristOrdersExport($orders)
{
$data = [];
// $orders = TouristOrder::whereIn('id',$orders)
// ->select('id','type','type_id','num','pay_status','trade_no','name','mobile','channel','goods','desc',
// 'created_at','account_id','linkmen','open_id','remark','from_openid','price','merchant_id')
// ->get();
$man_key = 0;
$women_key = 0;
foreach ($orders as $key => $order) {
// $remark = $this->numMember($order);
// if(!$order->remark){
// $order->remark = $remark;
// $order->save();
// }
$new_data['订单ID'] = $order->id;
$new_data['订单金额'] = $order->price;
$new_data['商家用户ID'] = $order->account_id;
$new_data['订单号'] = $order->trade_no;
switch ($order->type) {
case 'course'://课程
$new_data['订单类型'] = '课程';
break;
case 'shop'://商城
$new_data['订单类型'] = '商城';
break;
case 'community'://活动服务
$new_data['订单类型'] = '活动服务';
break;
case 'consult'://咨询
$new_data['订单类型'] = '咨询';
break;
default:
break;
}
$new_data['类型ID'] = $order->type_id;
switch ($order->pay_status) {
case 0:
$new_data['支付状态'] = '未支付';
break;
case 1:
$new_data['支付状态'] = '已支付';
break;
case 3:
$new_data['支付状态'] = '已退款';
break;
case 4:
$new_data['支付状态'] = '已完成分成';
break;
default:
$new_data['支付状态'] = '异常状态';
break;
}
if ($order->created_at < '2022-3-21 18:00') {
$temp_sku = explode('-', $order->desc);
if (!empty($temp_sku[1])) {
$new_data['品名'] = $temp_sku[0];
$new_data['规格'] = $temp_sku[1];
}
} else {
$new_data['品名'] = $order->desc;
$new_data['规格'] = $order->goods;
}
$new_data['份数'] = $order->num;
$new_data['订单姓名'] = $order->name;
$new_data['订单手机号'] = $order->mobile;
$new_data['下单日期'] = $order->created_at->toDateTimeString();
if ($order->linkmen) {
$linkmen = json_decode($order->linkmen, true);
$new_data['报名联系人'] = $linkmen[0]['name'] ?? '未设置';
$new_data['联系手机号'] = $linkmen[0]['mobile'] ?? '未设置';
$new_data['机构'] = $linkmen[0]['institution'] ?? '未设置';
} else {
$new_data['报名联系人'] = '未提供';
$new_data['联系手机号'] = '未提供';
$new_data['机构'] = '未提供';
}
$new_data['嘉宾编号'] = null;
if ($order->fromUsers) {
$new_data['分享人昵称'] = $order->fromUsers->nickname;
} else {
$new_data['分享人昵称'] = '无分享人';
}
if (!($order->merchant_id == 491 || $order->merchant_id == 974)) {
$data[] = $new_data;
continue;
}
$user = null;
// $user = $this->getOrderUserInfo($order);
$user_id = MerchantUser::where('id', $order->account_id)->value('user_id');
if ($user_id) {
$user = User::with('profileCourtship')->find($user_id);
}
if ($user) {
// $profile = ProfileCourtship::where('user_id',$user->id)
// ->first();
$profile = $user->profileCourtship;
$new_data['用户ID'] = $user->id;
$new_data['真实姓名'] = $user->name ?? '未设置';
$new_data['实名认证'] = $user->is_approved ? '已认证' : '未认证';
$new_data['真人认证'] = $user->is_real_approved ? '已认证' : '未认证';
$new_data['头像认证'] = $user->is_photo_audited ? '已认证' : '未认证';
$new_data['学历认证'] = $user->is_educate_approved ? '已认证' : '未认证';
$new_data['昵称'] = $user->nickname;
$new_data['性别'] = $user->sex ? ($user->sex == 1 ? '男' : '女') : '未设置';
$new_data['手机号'] = $user->mobile ?? '未设置';
$new_data['行业'] = $user->industry ?? '未设置';
$new_data['二维码'] = $user->my_qrcode_rect ?? '未设置';
if ($user->hidden_profile) {
switch ($user->hidden_profile) {
case 'ALLSEX':
$new_data['资料状态'] = '关闭资料';
break;
default:
$new_data['资料状态'] = '开放资料';
break;
}
}
switch ($user->sex) {
case 1:
$man_key += 1;
$new_data['嘉宾编号'] = $man_key . '男';
break;
case 2:
$women_key += 1;
$new_data['嘉宾编号'] = $women_key . '女';
break;
}
$extend = json_decode($order->extend, true);
if (!isset($extend['is_update_remark'])) {
$order->remark = $new_data['嘉宾编号'];
$order->save();
} else {
$new_data['嘉宾编号'] = $order->remark;
}
if ($profile) {
$new_data['年龄'] = $this->getAge($profile->birthday);
$new_data['信仰'] = $profile->belief ?? '未设置';
$new_data['生日'] = $profile->birthday ?? '未设置';
$new_data['常居地'] = ($profile->province ?? '未设置') . '-' . ($profile->city ?? '未设置');
$new_data['成长地'] = ($profile->resident_province ?? '未设置') . '-' . ($profile->resident_city ?? '未设置');
$new_data['身高'] = $profile->stature ?? '未设置';
$new_data['学历'] = $profile->degree ?? '未设置';
;
$new_data['年收入'] = $profile->income ?? '未设置';
$new_data['婚姻状态'] = $profile->state ?? '未设置';
}
} else {
$new_data['用户ID'] = '未提供';
$new_data['真实姓名'] = '未提供';
$new_data['实名认证'] = '未提供';
$new_data['真人认证'] = '未提供';
$new_data['头像认证'] = '未提供';
$new_data['学历认证'] = '未提供';
$new_data['昵称'] = '未提供';
$new_data['性别'] = '未提供';
$new_data['手机号'] = '未提供';
$new_data['行业'] = '未提供';
$new_data['二维码'] = '未提供';
$new_data['资料状态'] = '未提供';
$new_data['年龄'] = '未提供';
$new_data['年龄'] = '未提供';
$new_data['信仰'] = '未提供';
$new_data['生日'] = '未提供';
$new_data['常居地'] = '未提供';
$new_data['成长地'] = '未提供';
$new_data['身高'] = '未提供';
$new_data['学历'] = '未提供';
$new_data['年收入'] = '未提供';
$new_data['婚姻状态'] = '未提供';
}
$data[] = $new_data;
}
return $data;
}
/**
* 导出介绍人
* @return [type] [description]
*/
public function marriageExport(Request $request, User $user)
{
$new_data = [];
$users = $user->where('type', 'marriage')->whereNotNull('location_longitude')->with('profileMarriage');
$start_time = $request->input('start_time');
$end_time = $request->input('end_time');
if ($start_time && $end_time) {
$users = $users->whereHas('profileMarriage', function ($sql) use ($start_time, $end_time) {
$sql->where('created_at', '>', $start_time)->where('created_at', '<', $end_time);
});
}
$province = $request->input('province');
if ($province) {
$users = $users->whereHas('profileMarriage', function ($sql) use ($province) {
$sql->where('province', $province);
});
}
$users = $users->get();
foreach ($users as $user) {
//姓名
$data['id'] = $user->id;
$data['is_approved'] = $user->is_approved ? '已认证' : '未认证';
$data['name'] = '湖北介绍人_' . $user->name;
$data['mobile'] = $user->mobile;
$data['sex'] = $user->sex == 1 ? '男' : '女';
$data['card_num'] = '-' . $user->card_num . '-';
$profile = $user->profileMarriage;
if ($profile) {
$data['belief'] = $profile->belief;
$data['birthday'] = $profile->birthday;
$data['company'] = $profile->company;
$data['province'] = $profile->province;
$data['city'] = $profile->city;
$data['slogan'] = $profile->slogan;
}
$new_data[] = $data;
}
return \Excel::download(new MarriageExport($new_data), 'marriage.xlsx');
}
/**
* 导出单身
*/
public function singleExport(Request $request, User $user)
{
$new_data = [];
$users = $user->where('type', 'single')->with('profileCourtship');
$start_time = $request->input('start_time');
$end_time = $request->input('end_time');
if ($start_time && $end_time) {
$users = $users->whereHas('profileCourtship', function ($sql) use ($start_time, $end_time) {
$sql->where('created_at', '>', $start_time)->where('created_at', '<', $end_time);
});
}
$province = $request->input('province');
if ($province) {
$users = $users->whereHas('profileCourtship', function ($sql) use ($province) {
$sql->where('province', $province)->orWhere('resident_province', $province);
});
}
$users = $users->get();
foreach ($users as $user) {
//姓名
$data['id'] = $user->id;
$data['is_approved'] = $user->is_approved ? '已认证' : '未认证';
$data['name'] = '湖北单身_' . $user->name;
$data['mobile'] = $user->mobile;
$data['sex'] = $user->sex == 1 ? '男' : '女';
$data['card_num'] = '-' . $user->card_num . '-';
$profile = $user->profileCourtship;
if ($profile) {
$data['belief'] = $profile->belief;
$data['birthday'] = $profile->birthday;
$data['company'] = $profile->company;
$data['province'] = $profile->province;
$data['city'] = $profile->city;
$data['resident_province'] = $profile->resident_province;
$data['resident_city'] = $profile->resident_city;
}
$new_data[] = $data;
}
return \Excel::download(new SingleExport($new_data), 'single.xlsx');
}
public function redPacketExport(Request $request, RedPacketOrder $order)
{
set_time_limit(0);
$min = $request->input('min', 0);
$max = $request->input('max', 0);
$new_data = [];
$orders = $order->with('user')->orderBy('id', 'desc')->where('id', '>', $min)->where('id', '<=', $max)->get();
foreach ($orders as $order) {
$data['id'] = $order->id;
$data['user_id'] = $order->user_id;
$data['type'] = $order->type == 'SHARE' ? '分享' : '注册';
$data['official_openid'] = $order->official_openid;
$data['amount'] = $order->amount;
$data['is_hooked'] = $order->is_hooked ? '已发放' : '未发放';
if ($order->user) {
$data['mobile'] = $order->user->mobile;
$data['name'] = $order->user->name;
} else {
$data['mobile'] = '';
$data['name'] = '';
}
$new_data[] = $data;
}
return \Excel::download(new RedPacketExport($new_data), 'red_packet.xlsx');
}
public function matchmakerExport(Request $request, Matchmaker $matchmaker, UserProfile $user_profile)
{
$new_data = [];
$user_ids = $matchmaker->distinct('user_id')->pluck('user_id');
$users = $user_profile->whereIn('id', $user_ids)->get();
foreach ($users as $user) {
$data['name'] = $user->name;
$data['mobile'] = $user->mobile;
$data['province'] = $user->province;
$data['city'] = $user->city;
$new_data[] = $data;
}
return \Excel::download(new MatchmakerExport($new_data), 'matchmaker.xlsx');
}
/**
* 导出用户订单
*/
public function ordersExport(Request $request, Order $order)
{
$orders = $order->with('user')->orderBy('id', 'desc');
$type = $request->input('type');
$type_name = '';
if ($type && $type == 'passive') {//约见
$type_ids = [3, 4];
$orders = $orders->where('type', 'meet')->whereIn('type_id', $type_ids);
$type_name = '约见服务';
} elseif ($type && $type == 'active') {
$type_ids = [1, 2];
$orders = $orders->where('type', 'meet')->whereIn('type_id', $type_ids);
$type_name = '牵线服务';
}
$orders = $orders->get();
$new_data = [];
foreach ($orders as $order) {
$user = $order->user;
$data['name'] = '';
$data['birthday'] = '';
$data['mobile'] = '';
$data['province'] = '';
$data['city'] = '';
$data['is_approved'] = '';
if (!empty($user)) {
$data['name'] = $order->user->name;
$data['birthday'] = $order->user->profileCourtship->birthday;
$data['mobile'] = $order->user->mobile;
$data['province'] = $order->user->profileCourtship->province;
$data['city'] = $order->user->profileCourtship->city;
$data['is_approved'] = $order->user->is_approved ? '已认证' : '未认证';
$data['age'] = $this->getAge($order->user->profileCourtship->birthday);
$data['state'] = $order->user->profileCourtship->state;
;
}
$data['goods'] = $order->goods;
$data['type'] = $type_name;
$data['created_at'] = $order->created_at->toDateTimeString();
$new_data[] = $data;
}
return \Excel::download(new OrdersExport($new_data), 'orders.xlsx');
}
public function otherWechatBind(Request $request)
{
$paas_wechat_user = session('wechat.oauth_user')['znsj'];
$openid = $paas_wechat_user['id'];
$app = \EasyWeChat::officialAccount('znsj');
$user = $app->user->get($openid);
// $wechat_user = session('wechat.oauth_user')['other'];
// dd($wechat_user);
$user = $app->oauth->user();
dd($user);
$wechat_user = session('wechat.oauth_user');
}
public function app_config()
{
$config = [
// 'app_id' => 'wx0745fa0688992c01', // AppID
// 'secret' => 'af3366efe18b1149da9567ec1414d9af', // AppSecret
'app_id' => 'wx7e80298ed20df081',
'secret' => 'e118a5ec4974068a75846517f8baf9e3',
'response_type' => 'array',
'oauth' => [
//'scopes' => array_map('trim', explode(',', env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_SCOPES', 'snsapi_userinfo'))),
'scopes' => 'snsapi_userinfo',
//'callback' => env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_CALLBACK', '/oauth_callback'),
// 'callback' => '/oauth_callback/'.$account,
],
'log' => [
'level' => 'debug',
'file' => storage_path('logs/wechat.log'), //这个必须要有,要不调试有问题,你都会找不到原因
],
];
return $config;
}
public function updateAddressCache()
{
$cache_name = 'love_address';
$addresses = Address::where('name', '<>', '不限')->orderBy('codeId', 'asc')->get()->toArray();
$data = $this->addressSort($addresses);
Cache::forever($cache_name, $data);
return $this->success('ok');
}
/**
* 地址分类
* @param [type] $data [description]
* @param integer $pId [description]
* @return [type] [description]
*/
public function addressSort($data, $pId = 0)
{
$tree = [];
foreach ($data as $k => $v) {
if ($v['parentId'] == $pId) { //父亲找到儿子
if (count($this->addressSort($data, $v['codeId']))) {
$v['son'] = $this->addressSort($data, $v['codeId']);
}
$tree[] = $v;
unset($data[$k]);
}
}
return $tree;
}
public function getMyShare(Request $request, $user_id)
{
// $openid = $this->getOpenid();
// $wechat = Wechat::where('openid', $openid)->first();
// $name = '';
// if ($wechat->user_id) {
// $name = User::where('id', $wechat->user_id)->value('name');
// }else{
// $name = $wechat->nickname;
// }
$user = User::findOrFail($user_id);
$openid = $user->wechat->openid;
$name = $user->name;
// $avatar = $user->wechat->avatar2?$user->wechat->avatar2:$user->wechat->avatar2;
$avatar = $user->circle_avatar ?: $user->wechat->avatar2;
if ($user->my_share) {
$pic = $user->my_share;
$qrcode = $user->my_qrcode;
return $this->success('ok', compact('pic', 'qrcode', 'name', 'avatar'));
}
$time = time();
if (empty($user->my_qrcode)) {
$app = EasyWechat::miniProgram();
$data = [];
$data['is_hyaline'] = true;
$response = $app->app_code->get('/pages/tabBar/welcome?from_openid=' . $openid, $data);
// $response = $app->app_code->getUnlimit('from_openid='.$openid, [
// 'page' => 'pages/tabBar/welcome',
// ]);
$path = $time . 'home_qrcode.png';
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$filename = $response->saveAs(storage_path('qrcode'), $path);
}
// $filename = $response->saveAs(storage_path('qrcode'), $path);
$qrcode_path = storage_path() . "/qrcode/" . $time . "home_qrcode.png";
if (file_exists($qrcode_path)) {
$qrcode = $this->uploadFile($qrcode_path);
try {
unlink($qrcode_path);
} catch (Exception $e) {
return $this->failure($e->getMessage());
exit();
}
$user->my_qrcode = $qrcode;
}
$image2 = $user->my_qrcode;
} else {
$image2 = $user->my_qrcode;
}
//http://images.ufutx.com/201808/17/dd7540992e1e124a0947aa2422bf711c.jpeg
// $image1 = "http://images.ufutx.com/201808/17/dd7540992e1e124a0947aa2422bf711c.jpeg";
$image1 = "https://images.ufutx.com/201909/02/56f3f8255dc326ebd4b4a7f39b0ae76f.jpeg";
$new_image = $this->imageAddImage($image1, $image2, 297, 297, 218, 156, 'bottom-left');
if ($avatar) {
$new_image = $this->imageAddImage($new_image, $avatar, 163, 163, 300, 60, 'top-left');
}
$new_image = $this->textAddImage($new_image, 'Hi,我是' . $name, 30, 375, 243, '#001100', 'center');
if ($user->type == 'single') {
$slogan = '我在福恋,找对象!';
} else {
$slogan = '我在福恋为你找对象!';
}
$new_image = $this->textAddImage($new_image, $slogan, 42, 375, 309, '#d92553', 'center');
$file_path = storage_path() . "/qrcode/" . $time . "invite_qrcode.png";
$new_image->save($file_path);
$qrcode = $user->my_qrcode;
if (file_exists($file_path)) {
$pic = $this->uploadFile($file_path);
try {
unlink($file_path);
} catch (Exception $e) {
return $this->failure($e->getMessage());
exit();
}
}
$user->my_share = $pic;
$user->save();
$name = User::where('id', auth()->id())->value('name');
return $this->success('ok', compact('qrcode', 'name', 'avatar', 'pic'));
}
public function zhengxin(Request $request)
{
//接口地址
$url = 'test.pycredit.com:6001/rest/query/report/unzip';
// $url = "https://test.pycredit.com:6443/rest/query/report/unzip";
//用户名
$params['userID'] = 'testflwsquery';
//密码
$params['password'] = 'D9iaSF9eV8DBYv0PWymFcA==';
//查询条件
$params['queryCondition'] = $this->GETQUERYCONDITION();
//请求格式(默认json)
// $params['format'] = 'json';
// dd($params);
//发送远程请求;
$result = $this->APIREQUEST($url, $params);
//返回结果
//var_dump($result);
if ($result['status'] == '1') {
var_dump($result['returnValue']);
} else {
echo "errorCode: <" . $result['errorCode'] . ">\n";
echo "errorMessage: <" . $result['errorMessage'] . ">\n";
}
}
/**
* GETQUERYCONDITION 构造查询条件
* @return json
*/
public function GETQUERYCONDITION()
{
$arr = array();
$arr['conditions'][0]['queryType'] = "25160";
$arr['conditions'][0]['items'][0]['name'] = "name";
$arr['conditions'][0]['items'][0]['value'] = "测试一";
$arr['conditions'][0]['items'][1]['name'] = "documentNo";
$arr['conditions'][0]['items'][1]['value'] = "110000199001011112";
$arr['conditions'][0]['items'][2]['name'] = "subreportIDs";
$arr['conditions'][0]['items'][2]['value'] = "10602";
$arr['conditions'][0]['items'][3]['name'] = "queryReasonID";
$arr['conditions'][0]['items'][3]['value'] = "901";
$jsonobj = json_encode($arr);
return $jsonobj;
}
/**
* APIREQUEST 获取数据
* @param $url 请求地址
* @param array $params 请求的数据
* @return array|mixed
*/
public function APIREQUEST($url, $params = array())
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
//如果是https协议
if (stripos($url, "https://") !== FALSE) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // 信任任何证书
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); // 不检查证书中域名
//CURL_SSLVERSION_TLSv1
curl_setopt($curl, CURLOPT_SSLVERSION, 1);
// curl_setopt($curl, CURLOPT_VERBOSE, '1'); //开发模式,会把通信时的信息显示出来
curl_setopt($curl, CURLOPT_SSLCERT, dirname(__FILE__) . '/xxx.pem'); //pem
curl_setopt($curl, CURLOPT_SSLCERTPASSWD, '******');
curl_setopt($curl, CURLOPT_SSLKEY, dirname(__FILE__) . '/xxx.pem'); //pem
curl_setopt($curl, CURLOPT_SSLKEYPASSWD, '******'); //pem
}
//超时时间
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//通过POST方式提交
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
//返回内容
$callbcak = curl_exec($curl);
//http status
$CURLINFO_HTTP_CODE = curl_getinfo($curl, CURLINFO_HTTP_CODE);
//关闭,释放资源
curl_close($curl);
if ($CURLINFO_HTTP_CODE == 200)
return json_decode($callbcak, true);
}
/**
* @param $userId
* @param $from_openid
* @param $fromUserId
*
*/
public function referreAward($userId, $from_openid, $fromUserId, $num, $type = 'score')
{
}
//判断用户是否关注
public function subscribe($openid)
{
$config = config('wechat.official_account.new');
$app = Factory::officialAccount($config);
$wechatUser = $app->user->get($openid);
$result = !empty($wechatUser) && isset($wechatUser['subscribe']);
$is_subscribe = $result ? $wechatUser['subscribe'] : 0;
return $is_subscribe;
}
//生成用户随机字符串
public function randString($len)
{
$arr = array(
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
);
$arrlength = count($arr) - 1;
$str = "";
for ($i = 0; $i < $len; $i++) {
$str .= $arr[mt_rand(0, $arrlength)];
}
return $str;
}
//检查手机号
public function checkMobile($mobile)
{
$result = CheckMobile::where('mobile', $mobile)->first();
$mothtime = date("Y-m-d H:i:s", strtotime("-1 month"));
if (empty($result) || (!empty($result) && $result->updated_at < $mothtime)) {
$host = "http://ali.market.alicloudapi.com";
$path = "/open/unn/batch-ucheck";
$method = "POST";
$appcode = config("aliyun.appcode");
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "mobiles=" . $mobile;
$bodys = "";
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
if (1 == strpos("$" . $host, "https://")) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$curl_result = curl_exec($curl);
$new_result = json_decode($curl_result);
if (!empty($new_result) && $new_result->code == 200000) {
if (empty($result)) {
$result = new CheckMobile();
$result->mobile = $mobile;
$result->status = $new_result->data[0]->status;
$result->result = $curl_result;
$result->save();
} else {
$result->status = $new_result->data[0]->status;
$result->save();
}
}
}
if (empty($result)) {
return false;
}
$code = in_array($result->status, [1, 2, 4]) ?: false;
return $code;
}
public function changeTime($date)
{
$now_time = time();
$date = strtotime($date);
$diff = $now_time - $date;
if ($diff < 60) {
return '刚刚';
}
if (60 < $diff && 3600 > $diff) {
$min = intval($diff / 60);
return $min . '分钟前';
}
if (3600 < $diff && 24 * 3600 > $diff) {
$hour = intval($diff / 3600);
return $hour . '小时前';
}
if (24 * 3600 < $diff && 30 * 24 * 3600 > $diff) {
$day = intval($diff / 86400);
return $day . '天前';
}
if (30 * 24 * 3600 < $diff) {
$month = intval($diff / 2592000);
return $month . '月前';
}
}
//获取阿里云点播视频信息
public function getVodInfo($video_id)
{
$access_key_id = config('aliyun.aliyun_vod_access_key_id');
$access_key_secret = config('aliyun.aliyun_vod_access_key_secret');
AlibabaCloud::accessKeyClient($access_key_id, $access_key_secret)
->regionId('cn-shanghai')
->asDefaultClient();
try {
$result = AlibabaCloud::rpc()
->product('vod')
// ->scheme('https') // https | http
->version('2017-03-21')
->action('GetMezzanineInfo')
->method('POST')
->host('vod.cn-shanghai.aliyuncs.com')
->options([
'query' => [
'RegionId' => "cn-shanghai",
'VideoId' => $video_id,
'AdditionType' => "video",
],
])
->request();
return $result->toArray();
} catch (ClientException $e) {
$this->getError($e);
return false;
} catch (ServerException $e) {
$this->getError($e);
return false;
}
}
public function createNewUserBigData($user_id)
{
\App\Jobs\NewUserLinkData::dispatch($user_id)->onQueue("love");
return $this->success('ok');
}
//生成带参二维码
public function qrcodeWithScene($scene_str)
{
$config = [
'app_id' => config('wechat.official_account.new.app_id'),
'secret' => config('wechat.official_account.new.secret'),
];
$app = Factory::officialAccount($config);
$result = $app->qrcode->forever($scene_str);
// return $result;
if ($result) {
$url = $app->qrcode->url($result['ticket']);
$content = file_get_contents($url); // 得到二进制图片内容
$ticket = $result['ticket'];
$path = storage_path('/qrcode/' . $ticket . ".png");
file_put_contents($path, $content);
$pic = $this->uploadFile($path);
unlink($path);
}
return $pic;
}
public function getPreviewQrcode($scene_str)
{
$pic_path = storage_path('qrcode/' . time() . $this->randString(6) . 'preview.png');
//二维码图片
QrCode::format('png')->margin(1)->size(600)->generate($scene_str, $pic_path);
$pic = $this->uploadFile($pic_path);
try {
if ($pic_path) {
unlink($pic_path);
}
} catch (\Exception $e) {
return $this->failure($e->getMessage());
}
return $pic;
}
//计算订单总收益
public function totalIncome($community_ids, $course_ids, $activity_ids, $consult_ids, $shop_ids, $account_id, $type = 'user')
{
$can_cashout_total = 0;
//计算已经卖出去的收益
//服务收益
$community_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'community')->whereIn('type_id', $community_ids)->get();
foreach ($community_orders as $community_order) {
$can_cashout = ($community_order->price) * ($community_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//课程收益
$course_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'course')->whereIn('type_id', $course_ids)->get();
foreach ($course_orders as $course_order) {
$can_cashout = ($course_order->price) * ($course_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//活动收益
$activity_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'community')->whereIn('type_id', $activity_ids)->get();
foreach ($activity_orders as $key => $activity_order) {
$can_cashout = ($activity_order->price) * ($activity_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//咨询服务收益
$consult_orders = TouristOrder::where('merchant_id', $account_id)->whereIn('type_id', $consult_ids)->whereIn('pay_status', [1, 4])->get();
foreach ($consult_orders as $key => $consult_order) {
$can_cashout = ($consult_order->price) * ($consult_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//商品收益
$shop_orders = TouristOrder::where('merchant_id', $account_id)->whereIn('type_id', $shop_ids)->whereIn('pay_status', [1, 4])->get();
foreach ($shop_orders as $key => $shop_order) {
$can_cashout = ($shop_order->price) * ($shop_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
$system_orders = TouristOrder::where('merchant_id', $account_id)->where('type', 'system')->wherewhereIn('pay_status', [1, 4])->get();
foreach ($system_orders as $key => $system_orders) {
$can_cashout = ($system_orders->price) * ($system_orders->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
return $can_cashout_total;
}
//计算我的可提现额度
public function canCashoutMoney($community_ids, $course_ids, $activity_ids, $consult_ids, $shop_ids, $account_id)
{
$can_cashout_total = 0;
//计算已经卖出去的收益
//服务收益
$community_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'community')->whereIn('type_id', $community_ids)->get();
foreach ($community_orders as $community_order) {
$can_cashout = ($community_order->price) * ($community_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//课程收益
$course_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'course')->whereIn('type_id', $course_ids)->get();
foreach ($course_orders as $course_order) {
$can_cashout = ($course_order->price) * ($course_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//活动收益
$activity_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'community')->whereIn('type_id', $activity_ids)->get();
foreach ($activity_orders as $key => $activity_order) {
$can_cashout = ($activity_order->price) * ($activity_order->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//系统赠送
$system_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'system')->where('merchant_id', $account_id)->get();
foreach ($system_orders as $key => $system_orders) {
$can_cashout = ($system_orders->price) * ($system_orders->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//商品收益
$shop_orders = TouristOrder::whereIn('pay_status', [1, 4])->where('type', 'shop')->whereIn('type_id', $shop_ids)->get();
foreach ($shop_orders as $key => $shop_orders) {
$can_cashout = ($shop_orders->price) * ($shop_orders->withdrawal_radio / 100);
$can_cashout_total += $can_cashout;
}
//咨询服务收益
$consult_order_price = ConsultationRecords::whereIn('consulation_id', $consult_ids)->where('pay_status', 1)->sum('price');
//系统打款收益
// $system_order_price = TouristOrder::where('')
$can_cashout_total = $can_cashout_total + $consult_order_price;
//总的可提现:$can_cashout_total
$wechat_cash_out_amount = 0;
// if($openid&&$openid!='business')
$wechat_cash_out_amount = CashoutLog::where('status', 2)->where('type', 'wechat')->where('merchant_id', $account_id)->sum('amount'); //微信提现
$ali_cash_out_amount = CashoutLog::where('status', 2)->where('type', 'alipay')->where('merchant_id', $account_id)->sum('amount'); //支付宝提现
//计算已提现金额 has_cash_out_amount
$has_cash_out_amount = $wechat_cash_out_amount + $ali_cash_out_amount;
//剩余可提现金额
$can_cash_out_amount = $can_cashout_total - $has_cash_out_amount;
if ($can_cash_out_amount <= 0)
return 0;
return $can_cash_out_amount;
}
//判断是否入驻
public function is_recruit($openid)
{
//账号
$mobile = Anchor::where('openid', $openid)->value('mobile');
//密码
$merchant = MerchantAccount::where('mobile', $mobile)->whereNotNull('mobile')->first();
if (!$merchant)
return 0;
return 1;
}
public function subOperatV2($app, $openid)
{
try {
//账号
$mobile = Anchor::where('openid', $openid)->value('mobile');
//密码
$merchant = MerchantAccount::where('mobile', $mobile)->first();
$password = decrypt($merchant->password);
$msg = env('APP_URL') . '/pu_m/#/';
//客服消息
$text = "您好您已成功入驻福恋平台SaaS系统
账号:$mobile
密码:$password
<a href='love.ufutx.com/pu_m'>进入SaaS后台</a>管理你的相关服务";
$text_info = $text . $openid;
return $text;
} catch (\Exception $e) {
$this->getError($e);
return false;
}
}
//判断当前版本是否大于线上版本
public function isCurrentVersion($request, $c_ios_version, $c_and_version)
{
$ios_version = $request->header('app-version', '1.0.0');
$and_version = $request->header('version-name', '1.0.0');
if ($this->contrastVersion($ios_version, $c_ios_version) || $this->contrastVersion($and_version, $c_and_version)) {
return true;
} else {
return false;
}
}
//比较版本号
public function contrastVersion($version, $other_version)
{
$version = explode('.', $version);
$other_version = explode('.', $other_version);
if ($version[0] > $other_version[0]) {
return true;
}
if ($version[0] < $other_version[0]) {
return false;
}
if ($version[0] == $other_version[0]) {
if ($version[1] > $other_version[1]) {
return true;
}
if ($version[1] < $other_version[1]) {
return false;
}
if ($version[1] == $other_version[1]) {
if ($version[2] > $other_version[2]) {
return true;
} else {
return false;
}
}
}
}
public function showTextStripTag(Request $request)
{
return view('stripTag', ['content' => '', 'old_content' => '']);
}
public function textStripTag(Request $request)
{
$old_content = $request->input('old_content');
$content = strip_tags($old_content);
return view('stripTag', ['content' => $content ?: '', 'old_content' => $old_content ?: '']);
}
// 删除指定前缀下redis 缓存
public function forgetBykey($key)
{
$result = app('redis')->keys($key . '*');
app('redis')->del($result);
}
public function http_get_data($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
ob_start();
curl_exec($ch);
$return_content = ob_get_contents();
ob_end_clean();
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return $return_content;
}
public function dealWechat()
{
// $count = \DB::table('wechats')->whereNotNUll('openid')->groupby('openid')->selectRaw('count(*) as count, openid')->orderBy('count', 'desc')->chunk(100, function ($wechats) {
// foreach ($wechats as $wechat) {
// if ($wechat->count == 1) continue;
// $first_wechat = Wechat::where('openid', $wechat->openid)->whereNotNull('user_id')->orderBy('id', 'asc')->first();
// if (empty($first_wechat)) {
// $first_wechat = Wechat::where('openid', $wechat->openid)->orderBy('id', 'desc')->first();
// }
// Wechat::where('openid', $wechat->openid)->where('id', '<>', $first_wechat->id)->delete();
// }
// });
\DB::table('wechats')->whereNotNull('unionid')->groupby('unionid')->selectRaw('count(*) as count, unionid')->orderBy('count', 'desc')->chunk(100, function ($wechats) {
foreach ($wechats as $wechat) {
if ($wechat->count <= 1)
continue;
// $first_wechat = Wechat::where('unionid', $wechat->unionid)->whereNotNull('user_id')->orderBy('id', 'asc')->first();
// if (empty($first_wechat)) {
// $first_wechat = Wechat::where('unionid', $wechat->unionid)->orderBy('id', 'desc')->first();
// }
Wechat::where('unionid', $wechat->unionid)->whereNull('user_id')->delete();
}
});
}
//根据福恋用户id 匹配saas用户id
public function matchMerchantUser($user_id)
{
$m_user = MerchantUser::where('user_id', $user_id)->first();
if ($m_user) {
return $m_user->id;
}
$openid = Wechat::where('user_id', $user_id)->value('official_openid');
if ($openid) {
$m_user = MerchantUser::where('openid', $openid)->first();
if ($m_user) {
return $m_user->id;
}
}
$openid = Viewer::where('user_id', $user_id)->value('openid');
if ($openid) {
$m_user = MerchantUser::where('openid', $openid)->first();
if ($m_user) {
return $m_user->id;
}
}
$user = User::find($user_id);
if (empty($user))
return 0;
$m_user = MerchantUser::where('uuid', $user->uuid)->first();
if ($m_user) {
return $m_user->id;
}
$unionid = Wechat::where('user_id', $user_id)->value('unionid');
if ($unionid) {
$m_user = MerchantUser::where('unionid', $unionid)->first();
if ($m_user) {
return $m_user->id;
}
}
return 0;
}
//根据saas用户id 匹配福恋用户id
public function matchFulinkUser($m_user_id)
{
$m_user = MerchantUser::where('id', $m_user_id)->first();
if (empty($m_user))
return 0;
$wechat_user_id = Wechat::where('unionid', $m_user->unionid)->value('user_id');
if ($wechat_user_id) {
return $wechat_user_id;
}
if ($m_user && $m_user->user_id) {
return $m_user->user_id;
}
$wechat_user_id = Wechat::where('official_openid', $m_user->openid)->value('user_id');
if ($wechat_user_id) {
return $wechat_user_id;
}
// $viewer_user_id = Viewer::where('openid',$m_user->openid)->value('user_id');
// if($viewer_user_id){
// return $viewer_user_id;
// }
$user_id = User::where('mobile', $m_user->mobile)->whereNotNull('mobile')->value('id');
if ($user_id) {
return $user_id;
}
return 0;
}
//根据openid 获取用户id
//channel 0 saasH5 1福恋h5 2小程序
public function getUseridByOpenid($openid, $channel = 0)
{
if (empty($openid) || $openid == 'null')
return 0;
if ($channel == 2) {
$wechat = Wechat::where('openid', $openid)->first();
if ($wechat && $wechat->user_id) {
$user_id = $wechat->user_id;
return $user_id;
}
return 0;
} else {
$merchant_user = MerchantUser::where('openid', $openid)->first();
if ($merchant_user && $merchant_user->user_id) {
$user_id = $merchant_user->user_id;
return $user_id;
}
if (!isset($user_id)) {
$wechat = Wechat::where('official_openid', $openid)->first();
if ($wechat && $wechat->user_id) {
$user_id = $wechat->user_id;
return $user_id;
}
}
if (!isset($user_id)) {
$viewer = Viewer::where('openid', $openid)->first();
if ($viewer && $viewer->user_id) {
$user_id = $viewer->user_id;
return $user_id;
}
}
if (!isset($user_id) && $merchant_user && $merchant_user->unionid) {
$wechat = Wechat::where('unionid', $merchant_user->unionid)->first();
if ($wechat) {
$user_id = $wechat->user_id;
return $user_id;
}
}
return 0;
}
}
public function getMakerUserId($admin_id = 0, $mch_id)
{
if ($admin_id) {
$admin = MerchantAdmins::find($admin_id);
$user_id = User::where('mobile', $admin->mobile)->value('id');
return !empty($user_id) ? $user_id : 0;
} else {
$m = MerchantAccount::find($mch_id);
$user_id = User::withTrashed()->where('mobile', $m->mobile)->value('id');
return !empty($user_id) ? $user_id : 0;
}
}
//根据openid获取用户性别
public function getUserSexByOpenid($openid, $channel = 0)
{
$m_user = MerchantUser::where('openid', $openid)->first();
if ($m_user && $m_user->sex && $m_user->sex != 0) {
return $m_user->sex;
}
$viewer = Viewer::where('openid', $openid)->first();
if ($viewer && $viewer->sex && $viewer->sex != 0) {
return $viewer->sex;
}
$user_id = $this->getUseridByOpenid($openid, $channel);
if ($user_id) {
$user = User::withTrashed()->find($user_id);
if ($user && $user->sex) {
return $user->sex;
}
$wechat = Wechat::where('user_id', $user_id)->first();
if ($wechat && $wechat->gender) {
return $wechat->gender;
}
}
return 0;
}
//给嘉宾编号
public function numMember($tourist_order)
{
if ($tourist_order->channel == '福恋小程序' || $tourist_order->channel == 3) {
$buy_channel = 2;
} else {
$buy_channel = 0;
}
//获取当前报名用户的性别
if ($tourist_order->open_id) {
$openid = $tourist_order->open_id;
} else {
$openid = MerchantUser::where('id', $tourist_order->account_id)->value('openid');
}
$sex = $this->getUserSexByOpenid($openid, $buy_channel);
if ($sex == 0) {
$sex = User::where('mobile', $tourist_order->mobile)->value('sex');
}
if ($sex && $sex == 1) {
//当前男嘉宾数量
$male_count = TouristOrder::where('type', 'community')->where('type_id', $tourist_order->type_id)->where('remark', 'like', "%男%")->count();
//当前男嘉宾数量加1
$male_count = $male_count + 1;
$remark = $male_count . '男';
} elseif ($sex && $sex == 2) {
//当前女嘉宾数量
$female_count = TouristOrder::where('type', 'community')->where('type_id', $tourist_order->type_id)->where('remark', 'like', "%女%")->count();
//当前女嘉宾数量加1
$female_count = $female_count + 1;
$remark = $female_count . '女';
} else {
$remark = null;
}
return $remark;
}
//给嘉宾数量v2
public function numMemberV2($tourist_order, $sex)
{
if ($sex == 1) {
//当前男嘉宾数量
$male_count = TouristOrder::where('type', 'community')->where('type_id', $tourist_order->type_id)->where('remark', 'like', "%男%")->count();
//当前男嘉宾数量加1
$male_count = $male_count + 1;
$remark = $male_count . '男';
} elseif ($sex == 2) {
//当前女嘉宾数量
$female_count = TouristOrder::where('type', 'community')->where('type_id', $tourist_order->type_id)->where('remark', 'like', "%女%")->count();
//当前女嘉宾数量加1
$female_count = $female_count + 1;
$remark = $female_count . '女';
} else {
$remark = '';
}
return $remark;
}
public function errorMessage($id)
{
$err_log = ErrorLog::find($id);
$err_msg = $err_log->message;
return view('errorMessage', compact('err_msg'));
}
public function degreeSortV2($min_degree = 0, $max_degree = 4)
{
$degree_arr = ['未认证', '大专', '本科', '硕士', '博士'];//0 1 2 3 4
$need_arr = [];
if (empty($min_degree) && empty($max_degree)) {
return $need_arr;
} elseif (empty($min_degree) && !empty($max_degree)) {
foreach ($degree_arr as $key => $value) {
$need_arr[] = $value;
if ($max_degree == $key)
return $need_arr;
}
} elseif (!empty($min_degree) && !empty($max_degree) && $min_degree != $max_degree) {
foreach ($degree_arr as $key => $value) {
if ($min_degree > ($key))
continue;
$need_arr[] = $value;
if ($max_degree == $key)
return $need_arr;
}
} elseif (!empty($min_degree) && !empty($max_degree) && $min_degree == $max_degree) {
$need_arr[] = $degree_arr[$min_degree];
return $need_arr;
}
return $need_arr;
}
// 提取富文本中的纯文字
public function getHtmlText($string, $num = 50)
{
$html_string = htmlspecialchars_decode($string);
$content = str_replace(" ", "", $html_string);
$contents = strip_tags($content);
$contents = mb_strlen($contents, 'utf-8') > $num ? mb_substr($contents, 0, $num, "utf-8") . '...' : mb_substr($contents, 0, $num, "utf-8");
$contents = str_replace(array("\n", "\t", ' ', ' '), array('<br />', '&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $contents);
return $contents;
}
}