123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use Think\Cache;
- use think\Db;
- use wxpay;
- use Qcloud\Cos\Client;
- use Qcloud\Cos\Exception\ServiceResponseException;
- class Index extends Api
- {
- protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection', 'activeinfo', 'position', 'gamelist'];
- protected $noNeedRight = ['*'];
-
- public function index()
- {
- $this->success('请求成功');
- }
-
- public function banner()
- {
- $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 0])->order('weigh', 'desc')->select();
- $list = list_domain_image($list, ['image']);
- $this->success('轮播图', $list);
- }
-
- public function activelist() {
- $type = input('type', 0, 'intval');
- $keyword = input('keyword', '', 'trim');
- $where['status'] = ['neq', 3];
- $where['showstatus'] = 1;
- if ($type) {
- $where['type'] = $type;
- }
- if ($keyword !== '') {
- $where['title|desc|remark|collectionplace|leader'] = ['like', '%'.$keyword.'%'];
- }
- $list = Db::name('active')->field('id, type, title, desc, remark, image, price, maxperson, currentperson, status')
- ->where($where)->page($this->page, $this->pagenum)->order('weigh, createtime desc')->select();
- $list = list_domain_image($list, ['image']);
- foreach ($list as &$v) {
- if ($v['maxperson'] <= $v['currentperson']) {
- $v['is_full'] = 1;
- } else {
- $v['is_full'] = 0;
- }
- $v['surplusperson'] = $v['maxperson'] - $v['currentperson'];
- }
- $this->success('活动列表', $list);
- }
-
- public function activeinfo() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('参数缺失');
- }
- $info = Db::name('active')->find($id);
- if (!$info) {
- $this->error('数据不存在');
- }
- $info = info_domain_image($info, ['image']);
- $info['starttime'] = date('Y-m-d H:i', $info['starttime']);
- $info['endtime'] = date('Y-m-d H:i', $info['endtime']);
- $info['collectiontime'] = date('Y-m-d H:i', $info['collectiontime']);
- $info['signupendtime'] = date('Y-m-d H:i', $info['signupendtime']);
- $info['refundendtime'] = date('Y-m-d H:i', $info['refundendtime']);
-
- $active_people = Db::name('active_people')->where(['active_id' => $id, 'status' => ['neq', 3]])->field('user_id, name, createtime')->select();
- $user = Db::name('user');
- foreach ($active_people as &$v) {
- $user_info = $user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
- $v['name'] = $user_info['nickname'];
- $v['avatar'] = $user_info['avatar'];
- $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
- }
- $info['active_people'] = $active_people;
- $info['customer_service'] = config('site.customer_service') ? config('site.customer_service') : '';
- $this->success('活动详情', $info);
- }
-
- public function beforesignup() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('请选择要报名的活动');
- }
- $info = Db::name('active')->find($id);
- if (!$info) {
- $this->error('活动不存在');
- }
- if ($info['status'] == 2) {
- $this->error('活动已经结束');
- }
- if ($info['status'] == 3) {
- $this->error('活动已经取消');
- }
- if ($info['showstatus'] != 1) {
- $this->error('活动暂时不能报名');
- }
- if ($info['signupendtime'] < time()) {
- $this->error('活动报名已经截止');
- }
- if ($info['currentperson'] >= $info['maxperson']) {
- $this->error('活动名额已满');
- }
-
- if (!$this->auth->realname) {
- $this->success('请在个人资料中完善真实姓名', ['code' => 3]);
- }
- if (!$this->auth->idcard) {
- $this->success('请在个人资料中完善身份证号', ['code' => 3]);
- }
- if (!$this->auth->emergencycontact) {
- $this->success('请在个人资料中完善紧急联系人', ['code' => 3]);
- }
- if (!$this->auth->contactmobile) {
- $this->success('请在个人资料中完善紧急联系方式', ['code' => 3]);
- }
- $this->success('检查通过');
- }
-
- public function canusercoupon() {
- $price = input('price', '', 'trim');
- if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $price) || $price < 0) {
- $this->error('价格错误');
- }
- $where['user_id'] = $this->auth->id;
- $where['endtime'] = ['egt', time()];
- $where['status'] = 0;
- $map = 'type = 1 or (type = 2 and minmoney <= '.$price.')';
- $list = Db::name('user_coupon')->field('id, title, desc, type, money, minmoney')->where($where)->where($map)->select();
- $this->success('查询可用优惠券', $list);
- }
-
-
- public function signupactive() {
-
- if (!$this->auth->realname || !$this->auth->idcard || !$this->auth->emergencycontact || !$this->auth->contactmobile) {
- $this->success('请在个人资料中完善资料', ['code' => 3]);
- }
- $id = input('id', 0, 'intval');
-
-
-
-
- $active_people = input('active_people', '', 'trim');
- $paytype = input('paytype', 0, 'intval');
- $total_price = input('total_price', 0, 'trim');
- if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $total_price) || $total_price < 0) {
- $this->error('合计价格错误');
- }
- if (!in_array($paytype, [0, 1])) {
- $this->error('支付错误');
- }
- if ($total_price == 0 && $paytype != 0) {
- $this->error('请选择余额支付');
- }
-
- if (!$id) {
- $this->error('请选择要报名的活动');
- }
- $info = Db::name('active')->find($id);
- if (!$info) {
- $this->error('活动不存在');
- }
- if ($info['status'] == 2) {
- $this->error('活动已经结束');
- }
- if ($info['status'] == 3) {
- $this->error('活动已经取消');
- }
- if ($info['showstatus'] != 1) {
- $this->error('活动暂时不能报名');
- }
- if ($info['signupendtime'] < time()) {
- $this->error('活动报名已经截止');
- }
- if ($info['currentperson'] >= $info['maxperson']) {
- $this->error('活动名额已满');
- }
-
- if (!$active_people) {
- $this->error('请添加报名人员信息');
- }
- $active_people_arr = json_decode($active_people, true);
- if (!$active_people_arr) {
- $this->error('请添加报名人员信息');
- }
- if ($info['currentperson'] + count($active_people_arr) > $info['maxperson']) {
- $this->error('活动名额不足');
- }
-
- $vip_info = Db::name('vip')->find($this->auth->maxlevel);
- if (!$vip_info) {
- $this->error('会员信息缺失,请联系管理员');
- }
- $_data = [];
- $total_amount = 0;
- $active_people = Db::name('active_people');
- $active_people_modify = Db::name('active_people_modify');
- $user_coupon = Db::name('user_coupon');
- foreach ($active_people_arr as $k => &$v) {
- $data = [];
-
- if (!$v['name'] || iconv_strlen($v['name'], 'utf-8') > 50) {
- $this->error('请输入正确姓名');
- break;
- }
- if (iconv_strlen($v['idcard'], 'utf-8') != 18) {
- $this->error('请输入正确身份证号');
- break;
- }
- if (!is_mobile($v['mobile'])) {
- $this->error('请输入正确手机号');
- break;
- }
- if (!$v['emergencycontact'] || iconv_strlen($v['emergencycontact'], 'utf-8') > 50) {
- $this->error('请输入紧急联系人');
- break;
- }
- if (!is_mobile($v['contactmobile'])) {
- $this->error('请输入正确紧急联系人方式');
- break;
- }
-
- $count = $active_people->where(['active_id' => $id, 'idcard' => $v['idcard'], 'status' => ['neq', 3]])->count('id');
- if ($count) {
- $this->error($v['name'] . $v['idcard'] . '已报名过该活动');
- break;
- }
- $count2 = $active_people_modify->where(['active_id' => $id, 'idcard' => $v['idcard'], 'status' => 0])->count('id');
- if ($count2) {
- $this->error($v['name'] . $v['idcard'] . '已提交过修改,请等待审核');
- break;
- }
-
- if (!$v['credtype'] || iconv_strlen($v['credtype'], 'utf-8') > 50) {
- $this->error('证件类型错误');
- break;
- }
- if (!$v['insurance'] || iconv_strlen($v['insurance'], 'utf-8') > 50) {
- $this->error('保险信息错误');
- break;
- }
-
- if ($v['collectionplace'] === '' || iconv_strlen($v['collectionplace'] , 'utf-8') > 255) {
- $this->error($v['name'] . '请选择集合地点');
- break;
- }
-
- if ($v['is_self'] && $k == 0) {
-
- if ($v['name'] != $this->auth->realname || $v['idcard'] != $this->auth->idcard || $v['mobile'] != $this->auth->mobile || $v['emergencycontact'] != $this->auth->emergencycontact || $v['contactmobile'] != $this->auth->contactmobile) {
- $this->error('本人信息错误');
- break;
- }
-
- if ($info['maxage'] > 0) {
- $age = $this->idcardage($this->auth->idcard);
- if ($age < $info['minage'] || $age > $info['maxage']) {
- $this->error('活动年龄限制为' . $info['minage'] . '-' . $info['maxage']);
- break;
- }
- }
- if ($v['is_free'] == 1) {
- if ($info['is_free'] != 1) {
- $this->error('活动暂不支持免费体验');
- break;
- }
- if ($this->auth->freenumber <= 0) {
- $this->error('您的免费次数不足');
- break;
- }
-
- $month_time = strtotime(date('Y-m-1', time()));
- $count = $active_people->where(['user_id' => $this->auth->id, 'is_free' => 1, 'createtime' => ['egt', $month_time]])->count('id');
- if ($count) {
- $this->error('您当月已使用过免费次数');
- break;
- }
- if ($v['vipprice'] != 0 || $v['price'] != 0) {
- $this->error($this->auth->realname . '价格错误');
- break;
- }
- if ($v['coupon_id']) {
- $this->error('使用免费体验,无法使用优惠券');
- break;
- }
- } else {
-
- if ($info['is_overlying'] == 0 && $v['vipprice'] != $info['price'] && $v['coupon_id']) {
- $this->error('该活动不支持会员价和优惠券同时使用');
- break;
- }
-
- $birthday = date('md', strtotime($this->auth->birthday));
- $now_day = date('md', $info['starttime']);
- if ($birthday == $now_day) {
-
- if ($vip_info['birthdiscount'] > 100 || $vip_info['birthdiscount'] < 0) {
- $this->error('会员生日折扣错误,请联系管理员');
- break;
- }
- $discount = $vip_info['birthdiscount'];
- } elseif ($info['girldiscount'] < 100 && $info['girldiscount'] > 0 && $this->auth->gender == 2) {
-
- $discount = $info['girldiscount'];
- } else {
-
- if ($vip_info['vipdiscount'] > 100 || $vip_info['vipdiscount'] < 0) {
- $this->error('会员折扣错误,请联系管理员');
- break;
- }
- $discount = $vip_info['vipdiscount'];
- }
- $vipprice = number_format($info['price'] * $discount / 100, 2, '.', '');
-
- if ($v['coupon_id']) {
- $user_coupon_info = $user_coupon->where(['id' => $v['coupon_id'], 'user_id' => $this->auth->id])->find();
- if (!$user_coupon_info) {
- $this->error('优惠券不存在');
- }
- if ($user_coupon_info['status'] != 0) {
- $this->error('优惠券已使用');
- }
- if ($user_coupon_info['endtime'] < time()) {
- $this->error('优惠券已过期');
- }
- if ($user_coupon_info['type'] == 1) {
-
- if ($user_coupon_info['money'] < 0 || $user_coupon_info['money'] > 100) {
- $this->error('优惠券折扣错误,请联系管理员');
- break;
- }
- } else {
-
-
- if ($info['is_overlying'] == 0) {
- if ($info['price'] < $user_coupon_info['minmoney']) {
- $this->error('优惠券使用条件不满足');
- break;
- }
- } else {
- if ($vipprice < $user_coupon_info['minmoney']) {
- $this->error('优惠券使用条件不满足');
- break;
- }
- }
- }
- }
-
-
- if ($info['is_overlying'] == 0) {
- if ($v['coupon_id']) {
- if ($v['vipprice'] != $info['price']) {
- $this->error('会员价显示错误');
- break;
- }
- if ($user_coupon_info['type'] == 1) {
-
- $coupon_price = number_format($info['price'] * (100 - $user_coupon_info['money']) / 100, 2, '.', '');
- $price = number_format($info['price'] - $coupon_price, 2, '.', '');
- } else {
-
- $price = number_format($info['price'] - $user_coupon_info['money'], 2, '.', '');
- }
- } else {
- $price = $vipprice;
- }
- } else {
- if ($vipprice != $v['vipprice']) {
- $this->error('会员价显示错误');
- break;
- }
- if ($v['coupon_id']) {
- if ($user_coupon_info['type'] == 1) {
-
- $coupon_price = number_format($vipprice * (100 - $user_coupon_info['money']) / 100, 2, '.', '');
- $price = number_format($vipprice - $coupon_price, 2, '.', '');
- } else {
-
- $price = number_format($vipprice - $user_coupon_info['money'], 2, '.', '');
- }
- } else {
- $price = $vipprice;
- }
- }
-
- if ($price != $v['price']) {
- $this->error('小计显示错误');
- break;
- }
- $data['vipprice'] = $v['vipprice'];
- $data['coupon_id'] = $v['coupon_id'];
- if ($v['coupon_id']) {
- $data['coupontype'] = $user_coupon_info['type'];
- $data['couponprice'] = $user_coupon_info['money'];
- }
- }
- $data['name'] = $this->auth->realname;
- $data['idcard'] = $this->auth->idcard;
- $data['mobile'] = $this->auth->mobile;
- $data['emergencycontact'] = $this->auth->emergencycontact;
- $data['contactmobile'] = $this->auth->contactmobile;
- } else {
-
- if ($info['maxage'] > 0) {
- $age = $this->idcardage($v['idcard']);
- if ($age < $info['minage'] || $age > $info['maxage']) {
- $this->error('活动年龄限制为' . $info['minage'] . '-' . $info['maxage']);
- break;
- }
- }
-
-
- if ($vip_info['manypeople'] > 1 && $k == $vip_info['manypeople'] - 1) {
- if ($v['price'] != 0) {
- $this->error('小计显示错误');
- break;
- }
- } else {
- if ($v['price'] != $info['price']) {
- $this->error('小计显示错误');
- break;
- }
- }
- $data['name'] = $v['name'];
- $data['idcard'] = $v['idcard'];
- $data['mobile'] = $v['mobile'];
- $data['emergencycontact'] = $v['emergencycontact'];
- $data['contactmobile'] = $v['contactmobile'];
- $data['vipprice'] = $v['price'];
- }
- $data['active_id'] = $id;
- $data['user_id'] = $this->auth->id;
- $data['collectionplace'] = $v['collectionplace'];
- $data['credtype'] = $v['credtype'];
- $data['insurance'] = $v['insurance'];
- $data['originalprice'] = $info['price'];
- $data['is_free'] = $v['is_free'];
- $data['price'] = $v['price'];
- $data['is_self'] = $v['is_self'];
- $data['createtime'] = time();
- array_push($_data, $data);
- $total_amount += $v['price'];
- }
- if ($total_amount != $total_price) {
- $this->error('合计价格错误');
- }
- if ($paytype == 0) {
- if ($this->auth->money < $total_amount) {
- $this->success('您的余额不足,请先去充值', ['code' => 2]);
- }
- }
-
- $order_data['order_sn'] = date('YmdHis', time()) . rand(10000000, 99999999);
- $order_data['active_id'] = $id;
- $order_data['user_id'] = $this->auth->id;
- $order_data['paytype'] = $paytype;
- $order_data['price'] = $total_amount;
- $order_data['number'] = count($active_people_arr);
- $order_data['status'] = $paytype == 1 ? 0 : 1;
- $order_data['createtime'] = time();
-
- $active_data['currentperson'] = $info['currentperson'] + count($active_people_arr);
- if ($info['currentperson'] + count($active_people_arr) >= $info['minperson'] && $info['status'] == 0) {
- $active_data['status'] = 1;
- }
-
- Db::startTrans();
-
- $active_rs = Db::name('active')->where(['id' => $id, 'status' => $info['status'],'currentperson' => $info['currentperson']])->setField($active_data);
- if (!$active_rs) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
-
- $rs = Db::name('active_order')->insertGetId($order_data);
- if (!$rs) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
-
- foreach ($_data as &$v) {
- $v['order_id'] = $rs;
- $v['status'] = $order_data['status'];
- $rt = $active_people->insertGetId($v);
- if (!$rt) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
- }
-
- if ($info['is_free'] == 1 && $active_people_arr[0]['is_self'] == 1 && $active_people_arr[0]['is_free'] == 1) {
- $freenumber = $this->auth->freenumber - 1;
- $user_rs = Db::name('user')->where(['id' => $this->auth->id, 'freenumber' => $this->auth->freenumber])->setField('freenumber', $freenumber);
- if (!$user_rs) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
- }
-
- if ($active_people_arr[0]['is_self'] == 1 && $active_people_arr[0]['coupon_id']) {
- $user_coupon_rs = Db::name('user_coupon')->where(['id' => $active_people_arr[0]['coupon_id'], 'user_id' => $this->auth->id, 'status' => 0])->setField(['active_id' => $id, 'order_id' => $rs, 'status' => 1]);
- if (!$user_coupon_rs) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
- }
-
- if ($paytype == 0) {
- $res = create_log(-$total_amount, '支付活动订单', $this->auth->id, 2, $rs);
- if ($res != 1) {
- Db::rollback();
- $this->error('余额资金异常,请联系管理员');
- }
-
- if ($this->auth->pre_user_id) {
-
- $invite_coupon = Db::name('coupon')->where(['purpose' => 5, 'status' => 1])->order('weigh desc, id desc')->find();
- if ($invite_coupon) {
- $invite_coupon_data = [
- 'user_id' => $this->auth->pre_user_id,
- 'coupon_id' => $invite_coupon['id'],
- 'title' => $invite_coupon['title'],
- 'desc' => $invite_coupon['desc'],
- 'type' => $invite_coupon['type'],
- 'money' => $invite_coupon['money'],
- 'minmoney' => $invite_coupon['minmoney'],
- 'purpose' => $invite_coupon['purpose'],
- 'starttime' => time(),
- 'endtime' => time() + $invite_coupon['effectiveday'] * 86400,
- 'active_id' => $id,
- 'order_id' => $rs,
- 'createtime' => time()
- ];
- $invite_coupon_rs = Db::name('user_coupon')->insertGetId($invite_coupon_data);
- if (!$invite_coupon_rs) {
- Db::rollback();
- $this->error('发放优惠券失败');
- }
- }
- }
-
- $data = [
- 'user_id' => $this->auth->id,
- 'type' => 1,
- 'title' => '活动通知',
- 'content' => '您已成功报名' . $info['title'] . '活动',
- 'createtime' => time()
- ];
- $sys_rs = Db::name('sys_msg')->insertGetId($data);
- if (!$sys_rs) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
- Db::commit();
- $this->success('报名成功');
- } else {
-
- $rechar_order['user_id'] = $this->auth->id;
- $rechar_order['order_no'] = date('YmdHis', time()) . rand(10000000, 99999999);
- $rechar_order['money'] = $total_amount;
- $rechar_order['purpose'] = 1;
- $rechar_order['pay_type'] = 'wechat';
- $rechar_order['relation_id'] = $rs;
- $rechar_order['createtime'] = time();
- $result = Db::name('rechar_order')->insertGetId($rechar_order);
- if (!$result) {
- Db::rollback();
- $this->error('网络延迟,请稍后再试');
- }
- Db::commit();
-
- $wxData['body'] = '报名活动支付';
- $wxData['out_trade_no'] = $rechar_order['order_no'];
- $wxData['total_fee'] = $total_amount;
- $wxData['openid'] = $this->auth->openid;
- $wxPay = new wxpay\WxPay(config('wxchatpay'));
- $doResult = $wxPay->WxPayJs($wxData);
- $this->success('微信支付参数返回成功', $doResult);
- }
- }
-
- public function idcardage($idcard = '') {
-
- $year = substr($idcard, 6, 4);
- $month = substr($idcard, 10, 2);
- $day = substr($idcard, 12, 2);
-
- $current_year = date('Y');
- $current_month = date('m');
- $current_day = date('d');
-
- $age = $current_year - $year;
- if ($month > $current_month || ($month == $current_month && $day > $current_day)) {
-
- $age--;
- }
- return $age;
- }
-
- public function personaltype() {
- $list = Db::name('personal_type')->field('id, name')->order('weigh', 'desc')->select();
- $this->success('私人订制类型', $list);
- }
-
- public function personalactivetype() {
- $list = Db::name('personal_active_type')->field('id, name')->where(['pid' => 0])->order('weigh', 'desc')->select();
- $list = $this->getchildtype($list);
- $this->success('私人订制活动类型', $list);
- }
-
- public function getchildtype($list = [])
- {
- $complaint_type = Db::name('personal_active_type');
- foreach ($list as &$v) {
- $child = $complaint_type->field('id, name')->where(['pid' => $v['id']])->order('weigh', 'desc')->select();
- if ($child) {
- $child = $this->getchildtype($child);
- }
- $v['child'] = $child;
- }
- return $list;
- }
-
- public function car() {
- $list = Db::name('car')->field('id, name, desc')->order('weigh', 'desc')->select();
- $this->success('车辆类型', $list);
- }
-
- public function leader() {
- $list = Db::name('leader')->field('id, name')->order('weigh', 'desc')->select();
- $this->success('领队', $list);
- }
-
-
- public function personaldirection() {
- $list = Db::name('personal_direction')->field('id, name')->order('weigh', 'desc')->select();
- $this->success('私人订制出行方向', $list);
- }
-
- public function personalactive() {
- $type = input('type', '', 'trim');
- $number = input('number', 0, 'intval');
- $traveltime = input('traveltime', '', 'strtotime');
- $traveday = input('traveday', 0, 'intval');
- $activetype = input('activetype', '', 'trim');
- $car = input('car', '', 'trim');
- $leader = input('leader', '', 'trim');
- $travedirection = input('travedirection', '', 'trim');
- $freerange = input('freerange', '', 'trim');
- $remark = input('remark', '', 'trim');
- if (!$type || iconv_strlen($type, 'utf-8') > 50) {
- $this->error('请选择类型');
- }
- if ($number <= 0) {
- $this->error('请填写出行人数');
- }
- if ($traveltime < time()) {
- $this->error('请选择正确出行时间');
- }
- if ($traveday <= 0) {
- $this->error('请填写正确出行天数');
- }
- if (!$activetype || iconv_strlen($activetype, 'utf-8') > 50) {
- $this->error('请选择活动类型');
- }
- if ($car && iconv_strlen($car, 'utf-8') > 50) {
- $this->error('请选择车辆');
- }
- if ($leader && iconv_strlen($leader, 'utf-8') > 50) {
- $this->error('请选择领队');
- }
- if (!$travedirection || iconv_strlen($travedirection, 'utf-8') > 50) {
- $this->error('请选择出行方向');
- }
- if (!$freerange || iconv_strlen($freerange, 'utf-8') > 50) {
- $this->error('请选择空闲时段');
- }
- if (iconv_strlen($remark, 'utf-8') > 500) {
- $this->error('留言最多500字');
- }
- $data['user_id'] = $this->auth->id;
- $data['type'] = $type;
- $data['number'] = $number;
- $data['traveltime'] = $traveltime;
- $data['traveday'] = $traveday;
- $data['activetype'] = $activetype;
- $data['car'] = $car;
- $data['leader'] = $leader;
- $data['travedirection'] = $travedirection;
- $data['freerange'] = $freerange;
- $data['remark'] = $remark;
- $data['createtime'] = time();
- $rs = Db::name('personal_order')->insertGetId($data);
- if (!$rs) {
- $this->error('提交失败');
- }
- $this->success('提交成功');
- }
-
- public function bannercoupon() {
- $list = Db::name('coupon')->field('id, title, desc, type, money')
- ->where(['purpose' => 4, 'status' => 1])->page($this->page, $this->pagenum)->order('weigh desc, id desc')->select();
- $user_coupon = Db::name('user_coupon');
- foreach ($list as &$v) {
- $v['is_receive'] = $user_coupon->where(['user_id' => $this->auth->id, 'coupon_id' => $v['id']])->count('id');
- }
- $this->success('查询轮播图优惠券列表', $list);
- }
-
- public function receivebannercoupon() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('参数缺失');
- }
- $info = Db::name('coupon')->where(['id' => $id, 'purpose' => 4])->find();
- if (!$info) {
- $this->error('优惠券不存在');
- }
- if ($info['status'] != 1) {
- $this->error('优惠券已下架');
- }
-
- $count = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'coupon_id' => $id])->count('id');
- if ($count) {
- $this->error('您已经领取过了');
- }
- $data['user_id'] = $this->auth->id;
- $data['coupon_id'] = $id;
- $data['title'] = $info['title'];
- $data['desc'] = $info['desc'];
- $data['type'] = $info['type'];
- $data['money'] = $info['money'];
- $data['minmoney'] = $info['minmoney'];
- $data['purpose'] = $info['purpose'];
- $data['starttime'] = time();
- $data['endtime'] = time() + $info['effectiveday'] * 86400;
- $data['createtime'] = time();
-
- Db::startTrans();
-
- $rs = Db::name('user_coupon')->insertGetId($data);
- if (!$rs) {
- Db::rollback();
- $this->error('领取失败');
- }
- $rt = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'coupon_id' => $id])->count('id');
- if ($rt != 1) {
- Db::rollback();
- $this->error('领取失败');
- }
- Db::commit();
- $this->success('领取成功');
- }
-
-
- public function experiencevip() {
- $where = [];
- if ($this->auth->maxlevel != 5) {
- $where['id'] = ['neq', 5];
- }
- $list = Db::name('vip')->where(['id' => ['gt', $this->auth->maxlevel], 'status' => 1])->where($where)->select();
- $vip_privilege = Db::name('vip_privilege');
- foreach ($list as &$v) {
- $v['vip_privilege'] = $vip_privilege->field('id, title, desc')
- ->where(['vip_id' => $v['id']])->order('weigh desc')->select();
- }
- $this->success('体验会员列表', $list);
- }
-
- public function buyexperiencevip() {
-
- if ($this->auth->experiencetime >= time()) {
- $this->error('您已开通体验会员,不能重复开通');
- }
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('参数缺失');
- }
- $info = Db::name('vip')->where(['id' => $id])->find();
- if (!$info) {
- $this->error('会员不存在');
- }
- if ($info['status'] != 1) {
- $this->error('体验会员已下架');
- }
- if ($info['price'] <= 0) {
- $this->error('会员价格异常');
- }
-
- if ($id <= $this->auth->maxlevel) {
- $this->error('请开通更高等级体验会员');
- }
-
- if ($this->auth->money < $info['price']) {
- $this->success('您的余额不足,请先去充值', ['code' => 2]);
- }
- $data['user_id'] = $this->auth->id;
- $data['vip_id'] = $id;
- $data['title'] = $info['title'];
- $data['level'] = $info['level'];
- $data['growthvalue'] = $info['growthvalue'];
- $data['free'] = $info['free'];
- $data['price'] = $info['price'];
- $data['endtime'] = time() + $info['day'] * 86400;
- $data['vipdiscount'] = $info['vipdiscount'];
- $data['birthdiscount'] = $info['birthdiscount'];
- $data['manypeople'] = $info['manypeople'];
- $data['createtime'] = time();
-
- Db::startTrans();
-
- $rs = Db::name('vip_log')->insertGetId($data);
- if (!$rs) {
- Db::rollback();
- $this->error('开通失败');
- }
-
- $result = create_log(-$info['price'], '开通会员', $this->auth->id, 4, $rs);
- if ($result != 1) {
- Db::rollback();
- $this->error('资金异常,请联系管理员');
- }
-
- $growth_vip_info = Db::name('vip')->find($this->auth->growthlevel);
-
- $user_data['experiencelevel'] = $id;
- $user_data['experiencetime'] = $data['endtime'];
- $user_data['maxlevel'] = $id;
- $freenumber = $this->auth->freenumber + $info['free'] - $growth_vip_info['free'];
- $user_data['freenumber'] = $freenumber > 0 ? $freenumber : 0;
- $rt = Db::name('user')->where([
- 'id' => $this->auth->id,
- 'experiencelevel' => $this->auth->experiencelevel,
- 'maxlevel' => $this->auth->maxlevel,
- 'freenumber' => $this->auth->freenumber])->setField($user_data);
- if (!$rt) {
- Db::rollback();
- $this->error('开通失败');
- }
- Db::commit();
- $this->success('开通成功');
- }
-
- public function activelink() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('参数缺失');
- }
- $info = Db::name('active')->find($id);
- if (!$info) {
- $this->error('活动不存在');
- }
- if ($info['status'] == 2) {
- $this->error('活动已结束');
- }
- if ($info['status'] == 3) {
- $this->error('活动已取消');
- }
- if ($info['showstatus'] != 1) {
- $this->error('活动暂时不能报名');
- }
- $access_token = Cache::get('access_token');
- if (!$access_token) {
-
- $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.config('wxchatpay.app_id').'&secret='.config('wxchatpay.app_secret');
- $result = file_get_contents($url);
- $result = json_decode($result, true);
- $access_token = $result['access_token'];
-
- Cache::set('access_token', $access_token, 7000);
- }
- if (!$access_token) {
- $this->error('参数缺失');
- }
- $data['page_url'] = 'pages/home/detail?id='.$id.'&code='.$this->auth->invite_no;
- $data['page_title'] = $info['title'];
- $data = json_encode($data, 320);
- $url = 'https://api.weixin.qq.com/wxa/genwxashortlink?access_token='.$access_token;
- $rs = httpRequest($url, 'POST', $data);
- $rs = json_decode($rs, true);
- if ($rs['errcode'] != 0) {
- $this->error('网络延迟');
- }
- $this->success('分享链接', $rs['link']);
- }
-
- public function getqrcode($id = 0) {
- $access_token = Cache::get('access_token');
- if (!$access_token) {
-
- $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.config('wxchatpay.app_id').'&secret='.config('wxchatpay.app_secret');
- $result = file_get_contents($url);
- $result = json_decode($result, true);
- $access_token = $result['access_token'];
-
- Cache::set('access_token', $access_token, 7000);
- }
- if (!$access_token) {
- $this->error('参数缺失');
- }
- $data['scene'] = 'id='.$id.'&code='.$this->auth->invite_no;
- $data['page'] = 'pages/home/detail';
- $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" . $access_token;
- $ch = curl_init($url);
- $timeout = 6000;
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
- $ret = curl_exec($ch);
- curl_close($ch);
- if (is_array($ret)) {
- return '';
- }
- if (json_decode($ret)) {
- $this->error('生成失败');
- }
- $secretId = "AKIDhDTSBdoTs0rS4bx3rQijSu61f3B2cv3y";
- $secretKey = "f3A1btufAOL2SbT4ORDiwtZy7yYooY1D";
- $region = "ap-beijing";
- $cosClient = new Client(
- array(
- 'region' => $region,
- 'schema' => 'https',
- 'credentials'=> array(
- 'secretId' => $secretId ,
- 'secretKey' => $secretKey)));
- $path = "qrcode/";
- $fileName = time() . rand(10000,99999) . ".png";
- $result = $cosClient->putObject(array(
- 'Bucket' => 'fireflytra-1309974405',
- 'Key' => $path . $fileName,
- 'Body' => $ret,
- ));
-
- return 'https://' . $result['Location'];
- }
-
- public function activeposter() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('参数缺失');
- }
- $info = Db::name('active')->find($id);
- if (!$info) {
- $this->error('活动不存在');
- }
- if ($info['status'] == 2) {
- $this->error('活动已结束');
- }
- if ($info['status'] == 3) {
- $this->error('活动已取消');
- }
- if ($info['showstatus'] != 1) {
- $this->error('活动暂时不能报名');
- }
- $data = [
- [
- "left" => "4px",
- "top" => "4px",
- "type" => "img",
- "width" => "310px",
- "height" => "235px",
- "src" => one_domain_image($info['image'])
- ],
- [
- "left" => "100px",
- "top" => "347px",
- "type" => "img",
- "width" => "115px",
- "height" => "115px",
- "src" => $this->getqrcode($id)
- ]
- ];
-
- $child = [
- "left" => "11px",
- "top" => "253px",
- "type" => "nickname",
- "width" => "296px",
- "height" => "50px",
- "size" => "16px",
- "color" => "#000",
- "content" => mb_substr($info['title'], 0, 14)
- ];
- array_push($data, $child);
- if (iconv_strlen($info['title'], 'utf-8') > 14) {
- $child = [
- "left" => "11px",
- "top" => "285px",
- "type" => "nickname",
- "width" => "296px",
- "height" => "50px",
- "size" => "16px",
- "color" => "#000",
- "content" => mb_substr($info['title'], 14, 14)
- ];
- if (iconv_strlen($info['title'], 'utf-8') <= 28) {
- $child['content'] = mb_substr($info['title'], 14, 14);
- } else {
- $child['content'] = mb_substr($info['title'], 14, 11) . '...';
- }
- array_push($data, $child);
- }
-
- $child = [
- "left" => "11px",
- "top" => "318px",
- "type" => "nickname",
- "width" => "296px",
- "height" => "50px",
- "size" => "16px",
- "color" => "#FF0000",
- "content" => $info['price'] . '元'
- ];
- array_push($data, $child);
- $data = json_encode($data, 320);
- $poster = [
- 'id' => 1,
- 'title' => '测试',
- 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
- 'bg_image' => '/assets/img/bg.png',
- 'data' => $data,
- 'status' => 'normal',
- 'weigh' => 0,
- 'createtime' => 1653993709,
- 'updatetime' => 1653994259,
- ];
- $image = new \addons\poster\library\Image();
- $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
- if (!$imgurl) {
- $this->error('生成海报出错');
- }
- $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
- $this->success('', $imgurl);
- }
-
-
- public function getpeopleinfo() {
- $name = input('name', '', 'trim');
- if (!$name) {
- $this->success('信息', (object)[]);
- }
- $info = Db::name('active_people')->field('name, idcard, mobile, emergencycontact, contactmobile')->where(['user_id' => $this->auth->id, 'name' => $name])->find();
- if (!$info) {
- $info = (object)[];
- }
- $this->success('信息', $info);
- }
-
- public function videotype() {
- $type = input('type', 0, 'intval');
- if (!in_array($type, [0, 1])) {
- $this->error('参数错误');
- }
- $list = Db::name('video_type')->field('id, name, image')->where(['type' => $type])
- ->page($this->page, $this->pagenum)->order('weigh, id')->select();
- $list = list_domain_image($list, ['image']);
- $this->success('分类', $list);
- }
-
- public function video() {
- $type_id = input('type_id', 0, 'intval');
- if (!$type_id) {
- $this->error('您的网络开小差了~');
- }
- $list = Db::name('video')->field('id, title, image, is_pay')->where(['video_type_id' => $type_id, 'status' => 1, 'inject_status' => 2])->page($this->page, $this->pagenum)->order('weigh, id desc')->select();
- $list = list_domain_image($list, ['image']);
- $this->success('视频', $list);
- }
-
- public function videoinfo() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('您的网络开小差了');
- }
- $info = Db::name('video')->field('id, title, image, desc, is_pay, status, inject_status, seriesid, programid, movieid')
- ->where(['id' => $id])->find();
- if (!$info) {
- $this->error('数据不存在');
- }
- if ($info['status'] != 1) {
- $this->error('视频丢失');
- }
- if ($info['inject_status'] != 2) {
- $this->error('视频丢失');
- }
- $info['image'] = one_domain_image($info['image']);
- $info['is_collection'] = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
- $this->success('详情', $info);
- }
-
- public function encrypt($string, $key) {
- $data = openssl_encrypt($string, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
- $data = bin2hex($data);
- return $data;
- }
-
- public function decrypt($string, $key) {
- $decrypted = openssl_decrypt(hex2bin($string), 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
- return $decrypted;
- }
-
- public function playrecord() {
- $id = input('id', 0, 'intval');
- $total_time = input('total_time', 0, 'intval');
- $start_time = input('start_time', 0, 'intval');
- $end_time = input('end_time', 0, 'intval');
- $log_type = input('log_type', 'watching', 'trim');
- if (!$id) {
- $this->error('您的网络开小差了');
- }
- $info = Db::name('video')->where(['id' => $id])->find();
- if (!$info) {
- $this->error('数据不存在');
- }
- if ($info['inject_status'] != 2) {
- $this->error('视频丢失');
- }
- $info['image'] = one_domain_image($info['image']);
- $url = 'http://jscp.agency.gitv.tv/OTT/jscmcc/addThirdPartyHistoryRecord';
- $content = [
- 'cpPrvdName' => '健康e家',
- 'cpPrvCode' => '41000144',
- 'cpPrvType' => '1006',
- 'contentName' => $info['title'],
- 'ChnName' => '健康',
- 'ChnCode' => '1000020',
- 'contentId' => (string)$info['id'],
- 'extraContentID' => '',
- 'isEffective' => $info['status'],
- 'isPaid' => $info['is_pay'],
- 'contentTotalTime' => $total_time,
- 'startWatchTime' => $start_time,
- 'endWatchTime' => $end_time,
- 'playTime' => $end_time - $start_time,
- 'logType' => $log_type,
- 'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
- 'cpPermission' => 'GITV',
- 'intent' => [
- 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
- 'package' => 'com.huxiu.heh.tv',
- 'component' => [
- 'pkg' => 'com.huxiu.heh.tv',
- 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
- ],
- 'extras' => [
-
- 'type_id' => $info['video_type_id'],
- 'id' => $info['id']
- ]
- ],
- 'imageURL' => $info['image']
- ];
- $content = json_encode($content, 320);
- $rt = httpRequest($url, 'POST', $content);
- if (!$rt) {
- $this->error('同步失败');
- }
- $rt = json_decode($rt, true);
- if ($rt['code'] != 0) {
- $this->error('同步失败');
- }
- $this->success('同步成功');
- }
-
- public function collectionrecord() {
- $id = input('id', 0, 'intval');
- if (!$id) {
- $this->error('您的网络开小差了');
- }
- $info = Db::name('video')->where(['id' => $id])->find();
- if (!$info) {
- $this->error('数据不存在');
- }
- $info['image'] = one_domain_image($info['image']);
-
- $count = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->count('id');
-
- if ($count) {
- $result = Db::name('video_collection')->where(['user_id' => $this->auth->id, 'video_id' => $id])->delete();
- } else {
- $result = Db::name('video_collection')->insertGetId(['user_id' => $this->auth->id, 'video_id' => $id, 'createtime' => time()]);
- }
- if (!$result) {
- Db::rollback();
- $this->error('操作失败');
- }
- $url = 'http://jscp.agency.gitv.tv/OTT/jscmcc/addThirdPartyCollectionRecord';
- $content = [
- 'cpPrvdName' => '健康e家',
- 'cpPrvCode' => '41000144',
- 'cpPrvType' => '1006',
- 'content' => $info['title'],
- 'ChnCode' => '1000020',
- 'contentId' => (string)$info['id'],
- 'extraContentID' => '',
- 'isEffective' => $info['status'],
- 'isPaid' => $info['is_pay'],
- 'collectionFlag' => $count ? 0 : 1,
- 'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
- 'cpPermission' => 'GITV',
- 'intent' => [
- 'action' => 'com.huxiu.heh.tv.ui.splash.SplashActivity',
- 'package' => 'com.huxiu.heh.tv',
- 'component' => [
- 'pkg' => 'com.huxiu.heh.tv',
- 'cls' => 'com.huxiu.heh.tv.ui.splash.SplashActivity'
- ],
- 'extras' => [
-
- 'type_id' => $info['video_type_id'],
- 'id' => $info['id']
- ]
- ],
- 'imageURL' => $info['image']
- ];
- $content = json_encode($content, 320);
- $rt = httpRequest($url, 'POST', $content);
- if (!$rt) {
- Db::rollback();
- $this->error('操作失败');
- }
- $rt = json_decode($rt, true);
- if ($rt['code'] != 0) {
- Db::rollback();
- $this->error('操作失败');
- }
-
- $data = [
- 'favid' => (string)(config('cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
- 'UserID' => $this->auth->mobile,
- 'time' => date('Y-m-d H:i:s'),
- 'type' => $count ? 0 : 1,
- 'cpid' => config('cp_id'),
- 'albumid' => $id,
- 'albumname' => $info['title']
- ];
- $data = json_encode($data, 320);
- $filename = date('Ymd').'_'.config('cp_id').'_userfavdata_1.dat';
- $check_filename = date('Ymd').'_'.config('cp_id').'_userfavdata_1.chk';
- error_log(print_r($data, 1) . PHP_EOL, 3, './jiankang/' . $filename);
- error_log('', 3, './jiankang/' . $check_filename);
- $finish_filename = date('Ymd') . '_' . config('cp_id') . '_userfavdata.finish';
- error_log('', 3, './jiankang/' . $finish_filename);
- Db::commit();
- $this->success('操作成功');
- }
-
- public function userplay() {
- $id = input('id', 0, 'intval');
- $sn = input('sn', '', 'trim');
- $start_time = input('start_time', '', 'trim');
- $end_time = input('end_time', '', 'trim');
- $csource = input('csource', 0, '');
- $trace_id = input('trace_id', '', 'trim');
- if (!$id) {
- $this->error('您的网络开小差了');
- }
- $info = Db::name('video')->where(['id' => $id])->find();
- if (!$info) {
- $this->error('数据不存在');
- }
- $content = [
- 'playid' => (string)(config('cp_id') . date('Ymd') . getMillisecond() . mt_rand(10000000, 99999999)),
- 'UserID' => $this->auth->mobile,
- 'SN' => $sn,
- 'start_time' => $start_time,
- 'end_time' => $end_time,
- 'service_type' => 1,
- 'cpid' => config('cp_id'),
- 'albumid' => $id,
- 'albumname' => $info['title'],
- 'videoid' => $id,
- 'videoname' => $info['title'],
- 'csource' => $csource,
- 'fee_type' => $info['is_pay'] == 1 ? 1 : 4
- ];
- if ($content['csource'] == 5) {
- $content['trace_id'] = $trace_id;
- }
- $content = json_encode($content, 320);
- $filename = date('Ymd').'_'.config('cp_id').'_userplaydata_1.dat';
- $check_filename = date('Ymd').'_'.config('cp_id').'_userplaydata_1.chk';
- error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
- error_log('', 3, './jiankang/' . $check_filename);
- $finish_filename = date('Ymd') . '_' . config('cp_id') . '_userplaydata.finish';
- error_log('', 3, './jiankang/' . $finish_filename);
- }
-
- public function userfeedback() {
- $type = input('type', '', 'trim');
- $itemid = input('itemid', '', 'trim');
- $otherid = input('otherid', '', 'trim');
- $prodid = input('prodid', '', 'trim');
- $trace_id = input('trace_id', '', 'trim');
- $signal = input('signal', '', 'trim');
- $pos = input('pos', '', 'trim');
- $play_duration = input('play_duration', 0, 'trim');
- $url = 'http://jscp.agency.gitv.tv/v2/feedback';
- $content['userid'] = $this->auth->mobile;
- $content['type'] = $type;
- if ($itemid) {
- $content['itemid'] = config('cp_id') . '|' . $itemid;
- }
- if ($otherid) {
- $content['otherid'] = config('cp_id') . '|' . $otherid;
- }
- if ($prodid) {
- $content['prodid'] = $prodid;
- }
- if ($trace_id) {
- $content['trace_id'] = 'v2_1_2_1000035_' . $this->auth->mobile . '_153672384859_123456_01';
- } else {
- $content['trace_id'] = '';
- }
- if ($signal) {
- $content['signal'] = $signal;
- } else {
- $content['signal'] = '';
- }
- if ($pos) {
- $content['pos'] = $pos;
- } else {
- $content['pos'] = '';
- }
- if ($play_duration) {
- $content['play_duration'] = $play_duration;
- } else {
- $content['play_duration'] = '';
- }
- $content['operate_time'] = getMillisecond();
- $content = http_build_query($content);
- $url = $url . '?' . $content;
- $rt = file_get_contents($url);
- if (!$rt) {
- $this->error('上报失败');
- }
- $this->success('上报成功');
- }
- }
|