Index.php 47 KB

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