Index.php 47 KB

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