Index.php 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use Think\Cache;
  5. use think\Db;
  6. use wxpay;
  7. use Qcloud\Cos\Client;
  8. use Qcloud\Cos\Exception\ServiceResponseException;
  9. /**
  10. * 首页接口
  11. */
  12. class Index extends Api
  13. {
  14. protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection', 'activeinfo'];
  15. protected $noNeedRight = ['*'];
  16. /**
  17. * 首页
  18. *
  19. */
  20. public function index()
  21. {
  22. $this->success('请求成功');
  23. }
  24. //轮播图
  25. public function banner()
  26. {
  27. $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 0])->order('weigh', 'desc')->select();
  28. $list = list_domain_image($list, ['image']);
  29. $this->success('轮播图', $list);
  30. }
  31. //活动列表
  32. public function activelist() {
  33. $type = input('type', 0, 'intval'); //分类:1=休闲,2=中度
  34. $keyword = input('keyword', '', 'trim'); //关键字
  35. // $where['signupendtime'] = ['gt', time()];
  36. $where['status'] = ['neq', 3];
  37. $where['showstatus'] = 1;
  38. if ($type) {
  39. $where['type'] = $type;
  40. }
  41. if ($keyword !== '') {
  42. $where['title|desc|remark|collectionplace|leader'] = ['like', '%'.$keyword.'%'];
  43. }
  44. $list = Db::name('active')->field('id, type, title, desc, remark, image, price, maxperson, currentperson, status')
  45. ->where($where)->page($this->page, $this->pagenum)->order('weigh, createtime desc')->select();
  46. $list = list_domain_image($list, ['image']);
  47. foreach ($list as &$v) {
  48. if ($v['maxperson'] <= $v['currentperson']) {
  49. $v['is_full'] = 1;
  50. } else {
  51. $v['is_full'] = 0;
  52. }
  53. $v['surplusperson'] = $v['maxperson'] - $v['currentperson'];
  54. }
  55. $this->success('活动列表', $list);
  56. }
  57. //活动详情
  58. public function activeinfo() {
  59. $id = input('id', 0, 'intval');
  60. if (!$id) {
  61. $this->error('参数缺失');
  62. }
  63. $info = Db::name('active')->find($id);
  64. if (!$info) {
  65. $this->error('数据不存在');
  66. }
  67. $info = info_domain_image($info, ['image']);
  68. $info['starttime'] = date('Y-m-d H:i', $info['starttime']);
  69. $info['endtime'] = date('Y-m-d H:i', $info['endtime']);
  70. $info['collectiontime'] = date('Y-m-d H:i', $info['collectiontime']);
  71. $info['signupendtime'] = date('Y-m-d H:i', $info['signupendtime']);
  72. $info['refundendtime'] = date('Y-m-d H:i', $info['refundendtime']);
  73. //查询已报名列表
  74. $active_people = Db::name('active_people')->where(['active_id' => $id, 'status' => ['neq', 3]])->field('user_id, name, createtime')->select();
  75. $user = Db::name('user');
  76. foreach ($active_people as &$v) {
  77. $user_info = $user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
  78. $v['name'] = $user_info['nickname'];
  79. $v['avatar'] = $user_info['avatar'];
  80. $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
  81. }
  82. $info['active_people'] = $active_people;
  83. $info['customer_service'] = config('site.customer_service') ? config('site.customer_service') : ''; //客服电话
  84. $this->success('活动详情', $info);
  85. }
  86. //报名活动之前检查
  87. public function beforesignup() {
  88. $id = input('id', 0, 'intval'); //活动id
  89. if (!$id) {
  90. $this->error('请选择要报名的活动');
  91. }
  92. $info = Db::name('active')->find($id);
  93. if (!$info) {
  94. $this->error('活动不存在');
  95. }
  96. if ($info['status'] == 2) {
  97. $this->error('活动已经结束');
  98. }
  99. if ($info['status'] == 3) {
  100. $this->error('活动已经取消');
  101. }
  102. if ($info['showstatus'] != 1) {
  103. $this->error('活动暂时不能报名');
  104. }
  105. if ($info['signupendtime'] < time()) {
  106. $this->error('活动报名已经截止');
  107. }
  108. if ($info['currentperson'] >= $info['maxperson']) {
  109. $this->error('活动名额已满');
  110. }
  111. //检查自己信息是否完善
  112. if (!$this->auth->realname) {
  113. $this->success('请在个人资料中完善真实姓名', ['code' => 3]);
  114. }
  115. if (!$this->auth->idcard) {
  116. $this->success('请在个人资料中完善身份证号', ['code' => 3]);
  117. }
  118. if (!$this->auth->emergencycontact) {
  119. $this->success('请在个人资料中完善紧急联系人', ['code' => 3]);
  120. }
  121. if (!$this->auth->contactmobile) {
  122. $this->success('请在个人资料中完善紧急联系方式', ['code' => 3]);
  123. }
  124. $this->success('检查通过');
  125. }
  126. //查询可用优惠券
  127. public function canusercoupon() {
  128. $price = input('price', '', 'trim'); //价格
  129. if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $price) || $price < 0) {
  130. $this->error('价格错误');
  131. }
  132. $where['user_id'] = $this->auth->id;
  133. $where['endtime'] = ['egt', time()];
  134. $where['status'] = 0;
  135. $map = 'type = 1 or (type = 2 and minmoney <= '.$price.')';
  136. $list = Db::name('user_coupon')->field('id, title, desc, type, money, minmoney')->where($where)->where($map)->select();
  137. // p(\db()->getLastSql());
  138. $this->success('查询可用优惠券', $list);
  139. }
  140. //报名活动
  141. public function signupactive() {
  142. //检查自己信息是否完善
  143. if (!$this->auth->realname || !$this->auth->idcard || !$this->auth->emergencycontact || !$this->auth->contactmobile) {
  144. $this->success('请在个人资料中完善资料', ['code' => 3]);
  145. }
  146. $id = input('id', 0, 'intval'); //活动id
  147. // $collectionplace = input('collectionplace', '', 'trim'); //集合地点
  148. //人员信息json串:
  149. // name姓名 credtype证件类型 idcard身份证号 mobile手机号 emergencycontact紧急联系人 contactmobile紧急联系方式
  150. // insurance保险 originalprice原价 vipprice会员价 coupon_id用户优惠券ID is_free是否使用免费次数:0=否,1=是
  151. // price小计 is_self是否本人:0=否,1=是 collectionplace集合地点
  152. $active_people = input('active_people', '', 'trim');
  153. $paytype = input('paytype', 0, 'intval'); //支付方式:0=余额,1=微信
  154. $total_price = input('total_price', 0, 'trim'); //总价格
  155. // if ($collectionplace === '' || iconv_strlen($collectionplace, 'utf-8') > 255) {
  156. // $this->error('请选择集合地点');
  157. // }
  158. if (!preg_match('/^[0-9]+(.[0-9]{1,2})?$/', $total_price) || $total_price < 0) {
  159. $this->error('合计价格错误');
  160. }
  161. if (!in_array($paytype, [0, 1])) {
  162. $this->error('支付错误');
  163. }
  164. if ($total_price == 0 && $paytype != 0) {
  165. $this->error('请选择余额支付');
  166. }
  167. //检查活动信息
  168. if (!$id) {
  169. $this->error('请选择要报名的活动');
  170. }
  171. $info = Db::name('active')->find($id);
  172. if (!$info) {
  173. $this->error('活动不存在');
  174. }
  175. if ($info['status'] == 2) {
  176. $this->error('活动已经结束');
  177. }
  178. if ($info['status'] == 3) {
  179. $this->error('活动已经取消');
  180. }
  181. if ($info['showstatus'] != 1) {
  182. $this->error('活动暂时不能报名');
  183. }
  184. if ($info['signupendtime'] < time()) {
  185. $this->error('活动报名已经截止');
  186. }
  187. if ($info['currentperson'] >= $info['maxperson']) {
  188. $this->error('活动名额已满');
  189. }
  190. //检查人员信息
  191. if (!$active_people) {
  192. $this->error('请添加报名人员信息');
  193. }
  194. $active_people_arr = json_decode($active_people, true);
  195. if (!$active_people_arr) {
  196. $this->error('请添加报名人员信息');
  197. }
  198. if ($info['currentperson'] + count($active_people_arr) > $info['maxperson']) {
  199. $this->error('活动名额不足');
  200. }
  201. //会员信息
  202. $vip_info = Db::name('vip')->find($this->auth->maxlevel);
  203. if (!$vip_info) {
  204. $this->error('会员信息缺失,请联系管理员');
  205. }
  206. $_data = [];
  207. $total_amount = 0; //总价格验证
  208. $active_people = Db::name('active_people'); //报名人员表
  209. $active_people_modify = Db::name('active_people_modify'); //报名修改信息表
  210. $user_coupon = Db::name('user_coupon');
  211. foreach ($active_people_arr as $k => &$v) {
  212. $data = [];
  213. //检查信息
  214. if (!$v['name'] || iconv_strlen($v['name'], 'utf-8') > 50) {
  215. $this->error('请输入正确姓名');
  216. break;
  217. }
  218. if (iconv_strlen($v['idcard'], 'utf-8') != 18) {
  219. $this->error('请输入正确身份证号');
  220. break;
  221. }
  222. if (!is_mobile($v['mobile'])) {
  223. $this->error('请输入正确手机号');
  224. break;
  225. }
  226. if (!$v['emergencycontact'] || iconv_strlen($v['emergencycontact'], 'utf-8') > 50) {
  227. $this->error('请输入紧急联系人');
  228. break;
  229. }
  230. if (!is_mobile($v['contactmobile'])) {
  231. $this->error('请输入正确紧急联系人方式');
  232. break;
  233. }
  234. //判断是否报名过
  235. $count = $active_people->where(['active_id' => $id, 'idcard' => $v['idcard'], 'status' => ['neq', 3]])->count('id');
  236. if ($count) {
  237. $this->error($v['name'] . $v['idcard'] . '已报名过该活动');
  238. break;
  239. }
  240. $count2 = $active_people_modify->where(['active_id' => $id, 'idcard' => $v['idcard'], 'status' => 0])->count('id');
  241. if ($count2) {
  242. $this->error($v['name'] . $v['idcard'] . '已提交过修改,请等待审核');
  243. break;
  244. }
  245. //判断证件类型和保险
  246. if (!$v['credtype'] || iconv_strlen($v['credtype'], 'utf-8') > 50) {
  247. $this->error('证件类型错误');
  248. break;
  249. }
  250. if (!$v['insurance'] || iconv_strlen($v['insurance'], 'utf-8') > 50) {
  251. $this->error('保险信息错误');
  252. break;
  253. }
  254. //判断集合地点
  255. if ($v['collectionplace'] === '' || iconv_strlen($v['collectionplace'] , 'utf-8') > 255) {
  256. $this->error($v['name'] . '请选择集合地点');
  257. break;
  258. }
  259. //判断用户信息
  260. if ($v['is_self'] && $k == 0) {
  261. //判断用户信息
  262. 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) {
  263. $this->error('本人信息错误');
  264. break;
  265. }
  266. //本人判断年龄 价格
  267. if ($info['maxage'] > 0) {
  268. $age = $this->idcardage($this->auth->idcard);
  269. if ($age < $info['minage'] || $age > $info['maxage']) {
  270. $this->error('活动年龄限制为' . $info['minage'] . '-' . $info['maxage']);
  271. break;
  272. }
  273. }
  274. if ($v['is_free'] == 1) { //使用免费次数
  275. if ($info['is_free'] != 1) {
  276. $this->error('活动暂不支持免费体验');
  277. break;
  278. }
  279. if ($this->auth->freenumber <= 0) {
  280. $this->error('您的免费次数不足');
  281. break;
  282. }
  283. //检查当月是否用过免费次数
  284. $month_time = strtotime(date('Y-m-1', time()));
  285. $count = $active_people->where(['user_id' => $this->auth->id, 'is_free' => 1, 'createtime' => ['egt', $month_time]])->count('id');
  286. if ($count) {
  287. $this->error('您当月已使用过免费次数');
  288. break;
  289. }
  290. if ($v['vipprice'] != 0 || $v['price'] != 0) {
  291. $this->error($this->auth->realname . '价格错误');
  292. break;
  293. }
  294. if ($v['coupon_id']) {
  295. $this->error('使用免费体验,无法使用优惠券');
  296. break;
  297. }
  298. } else { //不使用免费次数
  299. //会员价和优惠券是否可以叠加使用:0=否,1=是
  300. if ($info['is_overlying'] == 0 && $v['vipprice'] != $info['price'] && $v['coupon_id']) {
  301. $this->error('该活动不支持会员价和优惠券同时使用');
  302. break;
  303. }
  304. //计算会员价, 会员价优先顺序: 生日 > 女生特权日 > 会员价格
  305. $birthday = date('md', strtotime($this->auth->birthday));
  306. $now_day = date('md', $info['starttime']); //活动当天生日
  307. if ($birthday == $now_day) {
  308. //生日折扣
  309. if ($vip_info['birthdiscount'] > 100 || $vip_info['birthdiscount'] < 0) {
  310. $this->error('会员生日折扣错误,请联系管理员');
  311. break;
  312. }
  313. $discount = $vip_info['birthdiscount'];
  314. } elseif ($info['girldiscount'] < 100 && $info['girldiscount'] > 0 && $this->auth->gender == 2) {
  315. //女生特权日折扣
  316. $discount = $info['girldiscount'];
  317. } else {
  318. //会员折扣
  319. if ($vip_info['vipdiscount'] > 100 || $vip_info['vipdiscount'] < 0) {
  320. $this->error('会员折扣错误,请联系管理员');
  321. break;
  322. }
  323. $discount = $vip_info['vipdiscount'];
  324. }
  325. $vipprice = number_format($info['price'] * $discount / 100, 2, '.', ''); //会员价
  326. //查询优惠券
  327. if ($v['coupon_id']) {
  328. $user_coupon_info = $user_coupon->where(['id' => $v['coupon_id'], 'user_id' => $this->auth->id])->find();
  329. if (!$user_coupon_info) {
  330. $this->error('优惠券不存在');
  331. }
  332. if ($user_coupon_info['status'] != 0) {
  333. $this->error('优惠券已使用');
  334. }
  335. if ($user_coupon_info['endtime'] < time()) {
  336. $this->error('优惠券已过期');
  337. }
  338. if ($user_coupon_info['type'] == 1) {
  339. //打折券
  340. if ($user_coupon_info['money'] < 0 || $user_coupon_info['money'] > 100) {
  341. $this->error('优惠券折扣错误,请联系管理员');
  342. break;
  343. }
  344. } else {
  345. //抵扣券
  346. //会员价和优惠券是否可以叠加使用:0=否,1=是
  347. if ($info['is_overlying'] == 0) {
  348. if ($info['price'] < $user_coupon_info['minmoney']) {
  349. $this->error('优惠券使用条件不满足');
  350. break;
  351. }
  352. } else {
  353. if ($vipprice < $user_coupon_info['minmoney']) {
  354. $this->error('优惠券使用条件不满足');
  355. break;
  356. }
  357. }
  358. }
  359. }
  360. //判断价格
  361. //会员价和优惠券是否可以叠加使用:0=否,1=是
  362. if ($info['is_overlying'] == 0) {
  363. if ($v['coupon_id']) { //使用优惠券
  364. if ($v['vipprice'] != $info['price']) {
  365. $this->error('会员价显示错误');
  366. break;
  367. }
  368. if ($user_coupon_info['type'] == 1) {
  369. //打折券
  370. $coupon_price = number_format($info['price'] * (100 - $user_coupon_info['money']) / 100, 2, '.', '');
  371. $price = number_format($info['price'] - $coupon_price, 2, '.', '');
  372. } else {
  373. //抵扣券
  374. $price = number_format($info['price'] - $user_coupon_info['money'], 2, '.', '');
  375. }
  376. } else {
  377. $price = $vipprice;
  378. }
  379. } else {
  380. if ($vipprice != $v['vipprice']) {
  381. $this->error('会员价显示错误');
  382. break;
  383. }
  384. if ($v['coupon_id']) { //使用优惠券
  385. if ($user_coupon_info['type'] == 1) {
  386. //打折券
  387. $coupon_price = number_format($vipprice * (100 - $user_coupon_info['money']) / 100, 2, '.', '');
  388. $price = number_format($vipprice - $coupon_price, 2, '.', '');
  389. } else {
  390. //抵扣券
  391. $price = number_format($vipprice - $user_coupon_info['money'], 2, '.', '');
  392. }
  393. } else {
  394. $price = $vipprice;
  395. }
  396. }
  397. //判断小计
  398. if ($price != $v['price']) {
  399. $this->error('小计显示错误');
  400. break;
  401. }
  402. $data['vipprice'] = $v['vipprice']; //会员价
  403. $data['coupon_id'] = $v['coupon_id']; //优惠券id
  404. if ($v['coupon_id']) {
  405. $data['coupontype'] = $user_coupon_info['type'];
  406. $data['couponprice'] = $user_coupon_info['money'];
  407. }
  408. }
  409. $data['name'] = $this->auth->realname;
  410. $data['idcard'] = $this->auth->idcard;
  411. $data['mobile'] = $this->auth->mobile;
  412. $data['emergencycontact'] = $this->auth->emergencycontact;
  413. $data['contactmobile'] = $this->auth->contactmobile;
  414. } else {
  415. //帮人报名判断年龄 报名信息
  416. if ($info['maxage'] > 0) {
  417. $age = $this->idcardage($v['idcard']);
  418. if ($age < $info['minage'] || $age > $info['maxage']) {
  419. $this->error('活动年龄限制为' . $info['minage'] . '-' . $info['maxage']);
  420. break;
  421. }
  422. }
  423. //判断是否符合满几人减免一人费用
  424. //会员权限
  425. if ($vip_info['manypeople'] > 1 && $k == $vip_info['manypeople'] - 1) {
  426. if ($v['price'] != 0) {
  427. $this->error('小计显示错误');
  428. break;
  429. }
  430. } else {
  431. if ($v['price'] != $info['price']) {
  432. $this->error('小计显示错误');
  433. break;
  434. }
  435. }
  436. $data['name'] = $v['name'];
  437. $data['idcard'] = $v['idcard'];
  438. $data['mobile'] = $v['mobile'];
  439. $data['emergencycontact'] = $v['emergencycontact'];
  440. $data['contactmobile'] = $v['contactmobile'];
  441. $data['vipprice'] = $v['price']; //会员价
  442. }
  443. $data['active_id'] = $id;
  444. $data['user_id'] = $this->auth->id;
  445. $data['collectionplace'] = $v['collectionplace'];
  446. $data['credtype'] = $v['credtype'];
  447. $data['insurance'] = $v['insurance'];
  448. $data['originalprice'] = $info['price'];
  449. $data['is_free'] = $v['is_free'];
  450. $data['price'] = $v['price']; //小计
  451. $data['is_self'] = $v['is_self'];
  452. $data['createtime'] = time();
  453. array_push($_data, $data);
  454. $total_amount += $v['price'];
  455. }
  456. if ($total_amount != $total_price) {
  457. $this->error('合计价格错误');
  458. }
  459. if ($paytype == 0) { //余额支付
  460. if ($this->auth->money < $total_amount) {
  461. $this->success('您的余额不足,请先去充值', ['code' => 2]);
  462. }
  463. }
  464. //构建订单信息
  465. $order_data['order_sn'] = date('YmdHis', time()) . rand(10000000, 99999999);
  466. $order_data['active_id'] = $id;
  467. $order_data['user_id'] = $this->auth->id;
  468. // $order_data['collectionplace'] = $collectionplace;
  469. $order_data['paytype'] = $paytype;
  470. $order_data['price'] = $total_amount;
  471. $order_data['number'] = count($active_people_arr);
  472. $order_data['status'] = $paytype == 1 ? 0 : 1;
  473. $order_data['createtime'] = time();
  474. //构建活动信息
  475. $active_data['currentperson'] = $info['currentperson'] + count($active_people_arr);
  476. if ($info['currentperson'] + count($active_people_arr) >= $info['minperson'] && $info['status'] == 0) {
  477. $active_data['status'] = 1;
  478. }
  479. //开始事务
  480. Db::startTrans();
  481. //修改活动表数据
  482. $active_rs = Db::name('active')->where(['id' => $id, 'status' => $info['status'],'currentperson' => $info['currentperson']])->setField($active_data);
  483. if (!$active_rs) {
  484. Db::rollback();
  485. $this->error('网络延迟,请稍后再试');
  486. }
  487. //添加订单
  488. $rs = Db::name('active_order')->insertGetId($order_data);
  489. if (!$rs) {
  490. Db::rollback();
  491. $this->error('网络延迟,请稍后再试');
  492. }
  493. //添加人员信息
  494. foreach ($_data as &$v) {
  495. $v['order_id'] = $rs;
  496. $v['status'] = $order_data['status'];
  497. $rt = $active_people->insertGetId($v);
  498. if (!$rt) {
  499. Db::rollback();
  500. $this->error('网络延迟,请稍后再试');
  501. }
  502. }
  503. //扣除免费次数
  504. if ($info['is_free'] == 1 && $active_people_arr[0]['is_self'] == 1 && $active_people_arr[0]['is_free'] == 1) {
  505. $freenumber = $this->auth->freenumber - 1;
  506. $user_rs = Db::name('user')->where(['id' => $this->auth->id, 'freenumber' => $this->auth->freenumber])->setField('freenumber', $freenumber);
  507. if (!$user_rs) {
  508. Db::rollback();
  509. $this->error('网络延迟,请稍后再试');
  510. }
  511. }
  512. //扣除优惠券
  513. if ($active_people_arr[0]['is_self'] == 1 && $active_people_arr[0]['coupon_id']) {
  514. $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]);
  515. if (!$user_coupon_rs) {
  516. Db::rollback();
  517. $this->error('网络延迟,请稍后再试');
  518. }
  519. }
  520. //扣款 支付方式:0=余额,1=微信
  521. if ($paytype == 0) {
  522. $res = create_log(-$total_amount, '支付活动订单', $this->auth->id, 2, $rs);
  523. if ($res != 1) {
  524. Db::rollback();
  525. $this->error('余额资金异常,请联系管理员');
  526. }
  527. //给上级发送优惠券
  528. if ($this->auth->pre_user_id) {
  529. //查询报名活动优惠券
  530. $invite_coupon = Db::name('coupon')->where(['purpose' => 5, 'status' => 1])->order('weigh desc, id desc')->find();
  531. if ($invite_coupon) {
  532. $invite_coupon_data = [
  533. 'user_id' => $this->auth->pre_user_id,
  534. 'coupon_id' => $invite_coupon['id'],
  535. 'title' => $invite_coupon['title'],
  536. 'desc' => $invite_coupon['desc'],
  537. 'type' => $invite_coupon['type'],
  538. 'money' => $invite_coupon['money'],
  539. 'minmoney' => $invite_coupon['minmoney'],
  540. 'purpose' => $invite_coupon['purpose'],
  541. 'starttime' => time(),
  542. 'endtime' => time() + $invite_coupon['effectiveday'] * 86400,
  543. 'active_id' => $id,
  544. 'order_id' => $rs,
  545. 'createtime' => time()
  546. ];
  547. $invite_coupon_rs = Db::name('user_coupon')->insertGetId($invite_coupon_data);
  548. if (!$invite_coupon_rs) {
  549. Db::rollback();
  550. $this->error('发放优惠券失败');
  551. }
  552. }
  553. }
  554. //发送消息
  555. $data = [
  556. 'user_id' => $this->auth->id,
  557. 'type' => 1,
  558. 'title' => '活动通知',
  559. 'content' => '您已成功报名' . $info['title'] . '活动',
  560. 'createtime' => time()
  561. ];
  562. $sys_rs = Db::name('sys_msg')->insertGetId($data);
  563. if (!$sys_rs) {
  564. Db::rollback();
  565. $this->error('网络延迟,请稍后再试');
  566. }
  567. Db::commit();
  568. $this->success('报名成功');
  569. } else {
  570. //生成支付订单记录
  571. $rechar_order['user_id'] = $this->auth->id;
  572. $rechar_order['order_no'] = date('YmdHis', time()) . rand(10000000, 99999999); //微信订单编号
  573. $rechar_order['money'] = $total_amount;
  574. $rechar_order['purpose'] = 1; //充值用途:1=支付订单,2=充值,3=开通会员
  575. $rechar_order['pay_type'] = 'wechat';
  576. $rechar_order['relation_id'] = $rs;
  577. $rechar_order['createtime'] = time();
  578. $result = Db::name('rechar_order')->insertGetId($rechar_order);
  579. if (!$result) {
  580. Db::rollback();
  581. $this->error('网络延迟,请稍后再试');
  582. }
  583. Db::commit();
  584. //构建支付链接数据
  585. $wxData['body'] = '报名活动支付';
  586. $wxData['out_trade_no'] = $rechar_order['order_no'];
  587. $wxData['total_fee'] = $total_amount;
  588. // $wxData['total_fee'] = 0.01;
  589. $wxData['openid'] = $this->auth->openid;
  590. // require_once($_SERVER['DOCUMENT_ROOT'] . '/Plugins/Weixin/WxPay/WxPay.php');
  591. $wxPay = new wxpay\WxPay(config('wxchatpay'));
  592. $doResult = $wxPay->WxPayJs($wxData);
  593. $this->success('微信支付参数返回成功', $doResult);
  594. }
  595. }
  596. //根据身份证号获取年龄
  597. public function idcardage($idcard = '') {
  598. //截取身份证里的出生日期
  599. $year = substr($idcard, 6, 4);
  600. $month = substr($idcard, 10, 2);
  601. $day = substr($idcard, 12, 2);
  602. //获取当前日期
  603. $current_year = date('Y');
  604. $current_month = date('m');
  605. $current_day = date('d');
  606. //计算年龄
  607. $age = $current_year - $year;//今年减去生日年
  608. if ($month > $current_month || ($month == $current_month && $day > $current_day)) {
  609. //如果出生月大于当前月或出生月等于当前月但出生日大于当前日则减一岁
  610. $age--;
  611. }
  612. return $age;
  613. }
  614. //私人订制类型
  615. public function personaltype() {
  616. $list = Db::name('personal_type')->field('id, name')->order('weigh', 'desc')->select();
  617. $this->success('私人订制类型', $list);
  618. }
  619. //私人订制活动类型
  620. public function personalactivetype() {
  621. $list = Db::name('personal_active_type')->field('id, name')->where(['pid' => 0])->order('weigh', 'desc')->select();
  622. $list = $this->getchildtype($list);
  623. $this->success('私人订制活动类型', $list);
  624. }
  625. //无限级私人订制活动类型
  626. public function getchildtype($list = [])
  627. {
  628. $complaint_type = Db::name('personal_active_type');
  629. foreach ($list as &$v) {
  630. $child = $complaint_type->field('id, name')->where(['pid' => $v['id']])->order('weigh', 'desc')->select();
  631. if ($child) {
  632. $child = $this->getchildtype($child);
  633. }
  634. $v['child'] = $child;
  635. }
  636. return $list;
  637. }
  638. //车辆类型
  639. public function car() {
  640. $list = Db::name('car')->field('id, name, desc')->order('weigh', 'desc')->select();
  641. $this->success('车辆类型', $list);
  642. }
  643. //领队
  644. public function leader() {
  645. $list = Db::name('leader')->field('id, name')->order('weigh', 'desc')->select();
  646. $this->success('领队', $list);
  647. }
  648. //私人订制出行方向
  649. public function personaldirection() {
  650. $list = Db::name('personal_direction')->field('id, name')->order('weigh', 'desc')->select();
  651. $this->success('私人订制出行方向', $list);
  652. }
  653. //私人订制
  654. public function personalactive() {
  655. $type = input('type', '', 'trim'); //类型
  656. $number = input('number', 0, 'intval'); //出行人数
  657. $traveltime = input('traveltime', '', 'strtotime'); //出行时间
  658. $traveday = input('traveday', 0, 'intval'); //出行天数
  659. $activetype = input('activetype', '', 'trim'); //活动类型
  660. $car = input('car', '', 'trim'); //车辆
  661. $leader = input('leader', '', 'trim'); //领队
  662. $travedirection = input('travedirection', '', 'trim'); //出行方向
  663. $freerange = input('freerange', '', 'trim'); //空闲时段
  664. $remark = input('remark', '', 'trim'); //留言
  665. if (!$type || iconv_strlen($type, 'utf-8') > 50) {
  666. $this->error('请选择类型');
  667. }
  668. if ($number <= 0) {
  669. $this->error('请填写出行人数');
  670. }
  671. if ($traveltime < time()) {
  672. $this->error('请选择正确出行时间');
  673. }
  674. if ($traveday <= 0) {
  675. $this->error('请填写正确出行天数');
  676. }
  677. if (!$activetype || iconv_strlen($activetype, 'utf-8') > 50) {
  678. $this->error('请选择活动类型');
  679. }
  680. if ($car && iconv_strlen($car, 'utf-8') > 50) {
  681. $this->error('请选择车辆');
  682. }
  683. if ($leader && iconv_strlen($leader, 'utf-8') > 50) {
  684. $this->error('请选择领队');
  685. }
  686. if (!$travedirection || iconv_strlen($travedirection, 'utf-8') > 50) {
  687. $this->error('请选择出行方向');
  688. }
  689. if (!$freerange || iconv_strlen($freerange, 'utf-8') > 50) {
  690. $this->error('请选择空闲时段');
  691. }
  692. if (iconv_strlen($remark, 'utf-8') > 500) {
  693. $this->error('留言最多500字');
  694. }
  695. $data['user_id'] = $this->auth->id;
  696. $data['type'] = $type;
  697. $data['number'] = $number;
  698. $data['traveltime'] = $traveltime;
  699. $data['traveday'] = $traveday;
  700. $data['activetype'] = $activetype;
  701. $data['car'] = $car;
  702. $data['leader'] = $leader;
  703. $data['travedirection'] = $travedirection;
  704. $data['freerange'] = $freerange;
  705. $data['remark'] = $remark;
  706. $data['createtime'] = time();
  707. $rs = Db::name('personal_order')->insertGetId($data);
  708. if (!$rs) {
  709. $this->error('提交失败');
  710. }
  711. $this->success('提交成功');
  712. }
  713. //查询轮播图优惠券列表
  714. public function bannercoupon() {
  715. $list = Db::name('coupon')->field('id, title, desc, type, money')
  716. ->where(['purpose' => 4, 'status' => 1])->page($this->page, $this->pagenum)->order('weigh desc, id desc')->select();
  717. $user_coupon = Db::name('user_coupon');
  718. foreach ($list as &$v) {
  719. $v['is_receive'] = $user_coupon->where(['user_id' => $this->auth->id, 'coupon_id' => $v['id']])->count('id');
  720. }
  721. $this->success('查询轮播图优惠券列表', $list);
  722. }
  723. //领取轮播图优惠券
  724. public function receivebannercoupon() {
  725. $id = input('id', 0, 'intval'); //优惠券id
  726. if (!$id) {
  727. $this->error('参数缺失');
  728. }
  729. $info = Db::name('coupon')->where(['id' => $id, 'purpose' => 4])->find();
  730. if (!$info) {
  731. $this->error('优惠券不存在');
  732. }
  733. if ($info['status'] != 1) {
  734. $this->error('优惠券已下架');
  735. }
  736. //查询是否已领取
  737. $count = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'coupon_id' => $id])->count('id');
  738. if ($count) {
  739. $this->error('您已经领取过了');
  740. }
  741. $data['user_id'] = $this->auth->id;
  742. $data['coupon_id'] = $id;
  743. $data['title'] = $info['title'];
  744. $data['desc'] = $info['desc'];
  745. $data['type'] = $info['type'];
  746. $data['money'] = $info['money'];
  747. $data['minmoney'] = $info['minmoney'];
  748. $data['purpose'] = $info['purpose'];
  749. $data['starttime'] = time();
  750. $data['endtime'] = time() + $info['effectiveday'] * 86400;
  751. $data['createtime'] = time();
  752. //开启事务
  753. Db::startTrans();
  754. //添加领取记录
  755. $rs = Db::name('user_coupon')->insertGetId($data);
  756. if (!$rs) {
  757. Db::rollback();
  758. $this->error('领取失败');
  759. }
  760. $rt = Db::name('user_coupon')->where(['user_id' => $this->auth->id, 'coupon_id' => $id])->count('id');
  761. if ($rt != 1) {
  762. Db::rollback();
  763. $this->error('领取失败');
  764. }
  765. Db::commit();
  766. $this->success('领取成功');
  767. }
  768. //体验会员列表
  769. public function experiencevip() {
  770. $where = [];
  771. if ($this->auth->maxlevel != 5) {
  772. $where['id'] = ['neq', 5];
  773. }
  774. $list = Db::name('vip')->where(['id' => ['gt', $this->auth->maxlevel], 'status' => 1])->where($where)->select();
  775. $vip_privilege = Db::name('vip_privilege');
  776. foreach ($list as &$v) {
  777. $v['vip_privilege'] = $vip_privilege->field('id, title, desc')
  778. ->where(['vip_id' => $v['id']])->order('weigh desc')->select();
  779. }
  780. $this->success('体验会员列表', $list);
  781. }
  782. //购买体验会员
  783. public function buyexperiencevip() {
  784. //检查是否已经开通体验会员
  785. if ($this->auth->experiencetime >= time()) {
  786. $this->error('您已开通体验会员,不能重复开通');
  787. }
  788. $id = input('id', 0, 'intval');
  789. if (!$id) {
  790. $this->error('参数缺失');
  791. }
  792. $info = Db::name('vip')->where(['id' => $id])->find();
  793. if (!$info) {
  794. $this->error('会员不存在');
  795. }
  796. if ($info['status'] != 1) {
  797. $this->error('体验会员已下架');
  798. }
  799. if ($info['price'] <= 0) {
  800. $this->error('会员价格异常');
  801. }
  802. //体验会员等级必须大于成长值会员
  803. if ($id <= $this->auth->maxlevel) {
  804. $this->error('请开通更高等级体验会员');
  805. }
  806. //判断余额
  807. if ($this->auth->money < $info['price']) {
  808. $this->success('您的余额不足,请先去充值', ['code' => 2]);
  809. }
  810. $data['user_id'] = $this->auth->id;
  811. $data['vip_id'] = $id;
  812. $data['title'] = $info['title'];
  813. $data['level'] = $info['level'];
  814. $data['growthvalue'] = $info['growthvalue'];
  815. $data['free'] = $info['free'];
  816. $data['price'] = $info['price'];
  817. $data['endtime'] = time() + $info['day'] * 86400;
  818. $data['vipdiscount'] = $info['vipdiscount'];
  819. $data['birthdiscount'] = $info['birthdiscount'];
  820. $data['manypeople'] = $info['manypeople'];
  821. $data['createtime'] = time();
  822. //开启事务
  823. Db::startTrans();
  824. //添加开通记录
  825. $rs = Db::name('vip_log')->insertGetId($data);
  826. if (!$rs) {
  827. Db::rollback();
  828. $this->error('开通失败');
  829. }
  830. //扣除余额
  831. $result = create_log(-$info['price'], '开通会员', $this->auth->id, 4, $rs);
  832. if ($result != 1) {
  833. Db::rollback();
  834. $this->error('资金异常,请联系管理员');
  835. }
  836. //成长值会员信息
  837. $growth_vip_info = Db::name('vip')->find($this->auth->growthlevel);
  838. //修改用户表信息
  839. $user_data['experiencelevel'] = $id;
  840. $user_data['experiencetime'] = $data['endtime'];
  841. $user_data['maxlevel'] = $id;
  842. $freenumber = $this->auth->freenumber + $info['free'] - $growth_vip_info['free'];
  843. $user_data['freenumber'] = $freenumber > 0 ? $freenumber : 0;
  844. $rt = Db::name('user')->where([
  845. 'id' => $this->auth->id,
  846. 'experiencelevel' => $this->auth->experiencelevel,
  847. 'maxlevel' => $this->auth->maxlevel,
  848. 'freenumber' => $this->auth->freenumber])->setField($user_data);
  849. if (!$rt) {
  850. Db::rollback();
  851. $this->error('开通失败');
  852. }
  853. Db::commit();
  854. $this->success('开通成功');
  855. }
  856. //获取活动分享链接
  857. public function activelink() {
  858. $id = input('id', 0, 'intval'); //活动id
  859. if (!$id) {
  860. $this->error('参数缺失');
  861. }
  862. $info = Db::name('active')->find($id);
  863. if (!$info) {
  864. $this->error('活动不存在');
  865. }
  866. if ($info['status'] == 2) {
  867. $this->error('活动已结束');
  868. }
  869. if ($info['status'] == 3) {
  870. $this->error('活动已取消');
  871. }
  872. if ($info['showstatus'] != 1) {
  873. $this->error('活动暂时不能报名');
  874. }
  875. $access_token = Cache::get('access_token');
  876. if (!$access_token) {
  877. //获取$access_token
  878. $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.config('wxchatpay.app_id').'&secret='.config('wxchatpay.app_secret');
  879. $result = file_get_contents($url);
  880. $result = json_decode($result, true);
  881. $access_token = $result['access_token'];
  882. //缓存
  883. Cache::set('access_token', $access_token, 7000);
  884. }
  885. if (!$access_token) {
  886. $this->error('参数缺失');
  887. }
  888. $data['page_url'] = 'pages/home/detail?id='.$id.'&code='.$this->auth->invite_no;
  889. $data['page_title'] = $info['title'];
  890. $data = json_encode($data, 320);
  891. $url = 'https://api.weixin.qq.com/wxa/genwxashortlink?access_token='.$access_token;
  892. $rs = httpRequest($url, 'POST', $data);
  893. $rs = json_decode($rs, true);
  894. if ($rs['errcode'] != 0) {
  895. $this->error('网络延迟');
  896. }
  897. $this->success('分享链接', $rs['link']);
  898. }
  899. //生成小程序邀请二维码
  900. public function getqrcode($id = 0) {
  901. $access_token = Cache::get('access_token');
  902. // $access_token = '';
  903. if (!$access_token) {
  904. //获取$access_token
  905. $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.config('wxchatpay.app_id').'&secret='.config('wxchatpay.app_secret');
  906. // $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx326ed0bf442d2773&secret=33609a3bc45bb407f0b26816158405b8';
  907. $result = file_get_contents($url);
  908. $result = json_decode($result, true);
  909. $access_token = $result['access_token'];
  910. //缓存
  911. Cache::set('access_token', $access_token, 7000);
  912. }
  913. if (!$access_token) {
  914. $this->error('参数缺失');
  915. }
  916. $data['scene'] = 'id='.$id.'&code='.$this->auth->invite_no;
  917. // $data['scene'] = 'id=AVwvR&code='.$this->auth->invite_no;
  918. $data['page'] = 'pages/home/detail';
  919. // $data['page'] = 'pages/product/product';
  920. $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" . $access_token;
  921. $ch = curl_init($url);
  922. $timeout = 6000;
  923. curl_setopt($ch, CURLOPT_POST, 1);
  924. curl_setopt($ch, CURLOPT_HEADER, 0);
  925. curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
  926. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  927. curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
  928. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  929. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
  930. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  931. $ret = curl_exec($ch);
  932. curl_close($ch);
  933. if (is_array($ret)) {
  934. return '';
  935. }
  936. if (json_decode($ret)) {
  937. $this->error('生成失败');
  938. }
  939. $secretId = "AKIDhDTSBdoTs0rS4bx3rQijSu61f3B2cv3y"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
  940. $secretKey = "f3A1btufAOL2SbT4ORDiwtZy7yYooY1D"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
  941. $region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
  942. $cosClient = new Client(
  943. array(
  944. 'region' => $region,
  945. 'schema' => 'https', //协议头部,默认为http
  946. 'credentials'=> array(
  947. 'secretId' => $secretId ,
  948. 'secretKey' => $secretKey)));
  949. // $local_path = "/Users/xxx/Desktop/exampleobject.txt"; //保存到用户本地路径
  950. $path = "qrcode/"; // 二维码文件流存放位置
  951. $fileName = time() . rand(10000,99999) . ".png";
  952. $result = $cosClient->putObject(array(
  953. 'Bucket' => 'fireflytra-1309974405', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  954. 'Key' => $path . $fileName,//'exampleobject',
  955. 'Body' => $ret,//fopen($local_path, 'rb'),
  956. ));
  957. // 请求成功
  958. return 'https://' . $result['Location'];
  959. // //上传到阿里云oss
  960. // require_once './Plugins/Aliyun/aliyun-oss-php-sdk-2.3.0/autoload.php';
  961. // require_once './Plugins/Aliyun/aliyun-oss-php-sdk-2.3.0/src/OSS/OssClient.php';
  962. // $config = C('ALIOSS_CONFIG');
  963. //
  964. // $oss = new \OSS\OssClient($config['KEY_ID'], $config['KEY_SECRET'], $config['END_POINT']);
  965. //
  966. // $path = "shopqrcode/"; // 二维码文件流存放位置
  967. // $fileName = time() . rand(10000,99999) . ".png";
  968. //
  969. // // 上传到oss
  970. // $result = $oss->putObject($config['BUCKET'], $path . $fileName, $ret);
  971. //
  972. // // 获取图片url地址
  973. // $oss_url = json_decode(json_encode($result), true);
  974. //
  975. // return $oss_url['oss-request-url'];
  976. }
  977. //生成活动海报
  978. public function activeposter() {
  979. // $poster = Db::name('poster')->find(1);
  980. // p($poster);die;
  981. $id = input('id', 0, 'intval'); //活动id
  982. if (!$id) {
  983. $this->error('参数缺失');
  984. }
  985. $info = Db::name('active')->find($id);
  986. if (!$info) {
  987. $this->error('活动不存在');
  988. }
  989. if ($info['status'] == 2) {
  990. $this->error('活动已结束');
  991. }
  992. if ($info['status'] == 3) {
  993. $this->error('活动已取消');
  994. }
  995. if ($info['showstatus'] != 1) {
  996. $this->error('活动暂时不能报名');
  997. }
  998. $data = [
  999. [
  1000. "left" => "4px",
  1001. "top" => "4px",
  1002. "type" => "img",
  1003. "width" => "310px",
  1004. "height" => "235px",
  1005. "src" => one_domain_image($info['image']) //主图
  1006. ],
  1007. [
  1008. "left" => "100px",
  1009. "top" => "347px",
  1010. "type" => "img",
  1011. "width" => "115px",
  1012. "height" => "115px",
  1013. "src" => $this->getqrcode($id) //小程序二维码'https://fireflytra-1309974405.cos.ap-beijing.myqcloud.com/qrcode/165405491386733.png'
  1014. ]
  1015. ];
  1016. //处理标题字符
  1017. $child = [
  1018. "left" => "11px",
  1019. "top" => "253px",
  1020. "type" => "nickname",
  1021. "width" => "296px",
  1022. "height" => "50px",
  1023. "size" => "16px",
  1024. "color" => "#000",
  1025. "content" => mb_substr($info['title'], 0, 14)
  1026. ];
  1027. array_push($data, $child);
  1028. if (iconv_strlen($info['title'], 'utf-8') > 14) {
  1029. $child = [
  1030. "left" => "11px",
  1031. "top" => "285px",
  1032. "type" => "nickname",
  1033. "width" => "296px",
  1034. "height" => "50px",
  1035. "size" => "16px",
  1036. "color" => "#000",
  1037. "content" => mb_substr($info['title'], 14, 14)
  1038. ];
  1039. if (iconv_strlen($info['title'], 'utf-8') <= 28) {
  1040. $child['content'] = mb_substr($info['title'], 14, 14);
  1041. } else {
  1042. $child['content'] = mb_substr($info['title'], 14, 11) . '...';
  1043. }
  1044. array_push($data, $child);
  1045. }
  1046. //添加价格
  1047. $child = [
  1048. "left" => "11px",
  1049. "top" => "318px",
  1050. "type" => "nickname",
  1051. "width" => "296px",
  1052. "height" => "50px",
  1053. "size" => "16px",
  1054. "color" => "#FF0000",
  1055. "content" => $info['price'] . '元'
  1056. ];
  1057. array_push($data, $child);
  1058. $data = json_encode($data, 320);
  1059. $poster = [
  1060. 'id' => 1,
  1061. 'title' => '测试',
  1062. 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
  1063. 'bg_image' => '/assets/img/bg.png',
  1064. 'data' => $data,
  1065. 'status' => 'normal',
  1066. 'weigh' => 0,
  1067. 'createtime' => 1653993709,
  1068. 'updatetime' => 1653994259,
  1069. ];
  1070. $image = new \addons\poster\library\Image();
  1071. $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
  1072. if (!$imgurl) {
  1073. $this->error('生成海报出错');
  1074. }
  1075. $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
  1076. $this->success('', $imgurl);
  1077. }
  1078. //查询帮报名过的人员信息
  1079. public function getpeopleinfo() {
  1080. $name = input('name', '', 'trim'); //名称
  1081. if (!$name) {
  1082. $this->success('信息', (object)[]);
  1083. }
  1084. $info = Db::name('active_people')->field('name, idcard, mobile, emergencycontact, contactmobile')->where(['user_id' => $this->auth->id, 'name' => $name])->find();
  1085. if (!$info) {
  1086. $info = (object)[];
  1087. }
  1088. $this->success('信息', $info);
  1089. }
  1090. }