Usercenter.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 会员中心
  7. */
  8. class Usercenter extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. //我的配套
  13. public function my_package(){
  14. $user_status = input('user_status',1); //默认已启用
  15. $map = [
  16. 'order.user_id' => $this->auth->id,
  17. 'order.order_status' => 1,
  18. //'order.remain' => ['gt',0],
  19. 'order.is_gift' => 0,
  20. 'order.use_status' => $user_status,
  21. ];
  22. $list = Db::name('package_order')->alias('order')
  23. ->field('order.id,order.starttime,order.endtime,order.days,order.is_gift,order.remain,order.price,p.name,p.name_en,p.image')
  24. ->join('lesson_package p','order.package_id = p.id','LEFT')
  25. ->where($map)->order('order.remain desc,order.endtime asc')
  26. ->autopage()->select();
  27. $list = $this->list_lang($list,['name']);
  28. $list = list_domain_image($list,['image']);
  29. if(!empty($list)){
  30. foreach($list as $key => &$val){
  31. //转换remain
  32. $val['remain'] = floatval($val['remain']);
  33. //日期
  34. $val['time_text'] = $this->date_lang($val['starttime']).'-'.$this->date_lang($val['endtime']);
  35. //是否有延期按钮
  36. $val['expired'] = 0;
  37. if($val['endtime'] < time()){
  38. $val['expired'] = 1;
  39. }
  40. }
  41. }
  42. $this->success(1,$list);
  43. }
  44. //赠课记录
  45. public function package_gift(){
  46. $map = [
  47. 'order.user_id' => $this->auth->id,
  48. 'order.order_status' => 1,
  49. //'order.remain' => ['gt',0],
  50. 'order.is_gift' => 1,
  51. ];
  52. $list = Db::name('package_order')->alias('order')
  53. ->field('order.id,order.order_no,order.starttime,order.endtime,order.days,order.is_gift,order.sessions,order.remain,order.use_status,
  54. p.name as package_name,p.name_en as package_name_en')
  55. ->join('lesson_package p','order.package_id = p.id','LEFT')
  56. ->where($map)->order('order.remain desc,order.endtime asc')
  57. ->autopage()->select();
  58. $list = $this->list_lang($list,['package_name']);
  59. foreach($list as $key => &$order){
  60. //转换remain
  61. $order['remain'] = floatval($order['remain']);
  62. //日期
  63. $order['showtime_text'] = $this->date_lang($order['starttime']).'-'.$this->date_lang($order['endtime']);
  64. $order['remark'] = __('购买套餐赠送');
  65. }
  66. $this->success(1,$list);
  67. }
  68. //上课记录,预约点了名的
  69. public function lesson_order_finish(){
  70. $map = [
  71. 'order.user_id' => $this->auth->id,
  72. 'order.order_status' => 20,//已点名
  73. 'order.usernumber_sign' => ['gt',0],
  74. ];
  75. $list = Db::name('lesson_order')->alias('order')
  76. ->field('order.id,order.order_amount,order.paytype,order.package_order_id,order.package_remark,order.trylesson_order_id,
  77. lesson.name,lesson.name_en,
  78. slot.starttime,slot.hours,slot.address,slot.coach_ids')
  79. ->join('lesson_slot slot','order.slot_id = slot.id','LEFt')
  80. ->join('lesson','order.lesson_id = lesson.id','LEFT')
  81. ->where($map)->order('slot.starttime desc')
  82. ->autopage()->select();
  83. $list = $this->list_lang($list,['name']);
  84. //准备教练数据
  85. $coach_list = Db::name('coach')->column('id,nickname');
  86. foreach($list as $key => &$order){
  87. //hours转换
  88. $order['hours'] = floatval($order['hours']);
  89. //放入教练
  90. $coach_text = '';
  91. $coach_ids = explode(',',$order['coach_ids']);
  92. foreach($coach_ids as $coach_id){
  93. if(isset($coach_list[$coach_id])){
  94. $coach_text .= $coach_list[$coach_id].',';
  95. }
  96. }
  97. $order['coach_text'] = substr($coach_text,0,-1);
  98. //放入支付套餐
  99. if($order['paytype'] == 1){
  100. $package_order = Db::name('package_order')->alias('order')
  101. ->field('p.name,p.name_en,order.starttime,order.endtime')
  102. ->join('lesson_package p','order.package_id = p.id','LEFT')
  103. ->where('order.id',$order['package_order_id'])->find();
  104. $order['package_name'] = $package_order['name'];
  105. $order['package_name_en'] = $package_order['name_en'];
  106. $order['package_starttime'] = $package_order['starttime'];
  107. $order['package_endtime'] = $package_order['endtime'];
  108. $order['package_showtime_text'] = $this->date_lang($package_order['starttime']).'-'.$this->date_lang($package_order['endtime']);
  109. }
  110. if($order['paytype'] == 4){
  111. $trylesson_order = Db::name('trylesson_order')->alias('order')
  112. ->field('t.name,t.name_en,order.starttime,order.endtime')
  113. ->join('trylesson t','order.trylesson_id = t.id','LEFT')
  114. ->where('order.id',$order['trylesson_order_id'])->find();
  115. $order['package_name'] = $trylesson_order['name'];
  116. $order['package_name_en'] = $trylesson_order['name_en'];
  117. $order['package_starttime'] = $trylesson_order['starttime'];
  118. $order['package_endtime'] = $trylesson_order['endtime'];
  119. $order['package_showtime_text'] = $this->date_lang($trylesson_order['starttime']).'-'.$this->date_lang($trylesson_order['endtime']);
  120. }
  121. //显示时间
  122. $order['showtime_text'] = $this->weektime_lang($order['starttime']);
  123. }
  124. $list = $this->list_lang($list,['package_name']);
  125. $this->success(1,$list);
  126. }
  127. //取消记录
  128. public function lesson_order_cancel(){
  129. $map = [
  130. 'order.user_id' => $this->auth->id,
  131. 'order.order_status' => ['IN',[30,40]],//已取消
  132. ];
  133. $list = Db::name('lesson_order')->alias('order')
  134. ->field('order.id,order.order_amount,order.paytype,order.package_order_id,order.package_remark,order.cancel_reason,
  135. lesson.name,lesson.name_en,
  136. slot.starttime,slot.hours,slot.address,slot.coach_ids')
  137. ->join('lesson_slot slot','order.slot_id = slot.id','LEFt')
  138. ->join('lesson','order.lesson_id = lesson.id','LEFT')
  139. ->where($map)->order('slot.starttime desc')
  140. ->autopage()->select();
  141. $list = $this->list_lang($list,['name']);
  142. //准备教练数据
  143. $coach_list = Db::name('coach')->column('id,nickname');
  144. foreach($list as $key => &$order){
  145. //hours转换
  146. $order['hours'] = floatval($order['hours']);
  147. //放入教练
  148. $coach_text = '';
  149. $coach_ids = explode(',',$order['coach_ids']);
  150. foreach($coach_ids as $coach_id){
  151. if(isset($coach_list[$coach_id])){
  152. $coach_text .= $coach_list[$coach_id].',';
  153. }
  154. }
  155. $order['coach_text'] = substr($coach_text,0,-1);
  156. //显示时间
  157. $order['showtime_text'] = $this->weektime_lang($order['starttime']);
  158. //放入支付套餐
  159. /*if($order['paytype'] == 1){
  160. $package_order = Db::name('package_order')->alias('order')
  161. ->field('p.name,p.name_en,order.starttime,order.endtime')
  162. ->join('lesson_package p','order.package_id = p.id','LEFT')
  163. ->where('order.id',$order['package_order_id'])->find();
  164. $order['package_name'] = $package_order['name'];
  165. $order['package_name_en'] = $package_order['name_en'];
  166. $order['package_starttime'] = $package_order['starttime'];
  167. $order['package_endtime'] = $package_order['endtime'];
  168. }*/
  169. }
  170. //$list = $this->list_lang($list,['package_name']);
  171. $this->success(1,$list);
  172. }
  173. //取消售课预约单
  174. public function cancel_lesson_order(){
  175. $order_id = input('order_id',0);
  176. $map = [
  177. 'id' => $order_id,
  178. 'user_id' => $this->auth->id,
  179. ];
  180. $lesson_order = Db::name('lesson_order')->where($map)->find();
  181. if($lesson_order['order_status'] != 10){
  182. $this->error('此订单已无法取消');
  183. }
  184. //还有24小时上课,不能取消
  185. $slot = Db::name('lesson_slot')->where('id',$lesson_order['slot_id'])->find();
  186. if($slot['starttime'] - time() <= 86400){
  187. $this->error('距离上课时间不足24小时,不能取消');
  188. }
  189. Db::startTrans();
  190. //套餐给加回去
  191. if($lesson_order['paytype'] == 1){
  192. $package_order = Db::name('package_order')->where('id',$lesson_order['package_order_id'])->lock(true)->find();
  193. $update = [
  194. 'remain' => bcadd($package_order['remain'],$lesson_order['usernumber_hours'],1),
  195. 'updatetime' => time(),
  196. ];
  197. $rs_remain = Db::name('package_order')->where('id',$lesson_order['package_order_id'])->update($update);
  198. if($rs_remain === false){
  199. Db::rollback();
  200. $this->error('取消失败');
  201. }
  202. }
  203. //试课给改回去
  204. if($lesson_order['paytype'] == 4){
  205. $update = [
  206. 'order_status' => 10,
  207. 'updatetime' => time(),
  208. 'lesson_order_id' => 0,
  209. ];
  210. $rs_remain = Db::name('trylesson_order')->where('id',$lesson_order['trylesson_order_id'])->update($update);
  211. if($rs_remain === false){
  212. Db::rollback();
  213. $this->error('取消失败');
  214. }
  215. }
  216. //现金支付不给退,线下处理
  217. //取消预约单
  218. $update = [
  219. 'order_status' => 30,
  220. 'cancel_time' => time(),
  221. 'cancel_reason' => __('用户主动取消'),
  222. ];
  223. if($lesson_order['paytype'] == 1 || $lesson_order['paytype'] == 4){
  224. $update['order_status'] = 40;
  225. }
  226. $rs = Db::name('lesson_order')->where($map)->update($update);
  227. if($rs === false){
  228. Db::rollback();
  229. $this->error('取消失败');
  230. }
  231. Db::commit();
  232. $this->success('取消完成');
  233. }
  234. //过期课程。就是过了上课时间,没签到的
  235. public function lesson_order_signout(){
  236. $map = [
  237. 'order.user_id' => $this->auth->id,
  238. 'order.order_status' => 20,//已点名
  239. 'order.usernumber_sign' => 0,//没签到的
  240. ];
  241. $list = Db::name('lesson_order')->alias('order')
  242. ->field('order.id,order.order_amount,order.paytype,order.package_order_id,order.package_remark,
  243. lesson.name,lesson.name_en,
  244. slot.starttime,slot.hours,slot.address,slot.coach_ids')
  245. ->join('lesson_slot slot','order.slot_id = slot.id','LEFt')
  246. ->join('lesson','order.lesson_id = lesson.id','LEFT')
  247. ->where($map)->order('slot.starttime desc')
  248. ->autopage()->select();
  249. $list = $this->list_lang($list,['name']);
  250. //准备教练数据
  251. $coach_list = Db::name('coach')->column('id,nickname');
  252. foreach($list as $key => &$order){
  253. //hours转换
  254. $order['hours'] = floatval($order['hours']);
  255. //放入教练
  256. $coach_text = '';
  257. $coach_ids = explode(',',$order['coach_ids']);
  258. foreach($coach_ids as $coach_id){
  259. if(isset($coach_list[$coach_id])){
  260. $coach_text .= $coach_list[$coach_id].',';
  261. }
  262. }
  263. $order['coach_text'] = substr($coach_text,0,-1);
  264. //时间
  265. $order['showtime_text'] = $this->weektime_lang($order['starttime']);
  266. //放入支付套餐
  267. /*if($order['paytype'] == 1){
  268. $package_order = Db::name('package_order')->alias('order')
  269. ->field('p.name,p.name_en,order.starttime,order.endtime')
  270. ->join('lesson_package p','order.package_id = p.id','LEFT')
  271. ->where('order.id',$order['package_order_id'])->find();
  272. $order['package_name'] = $package_order['name'];
  273. $order['package_name_en'] = $package_order['name_en'];
  274. $order['package_starttime'] = $package_order['starttime'];
  275. $order['package_endtime'] = $package_order['endtime'];
  276. }*/
  277. }
  278. // $list = $this->list_lang($list,['package_name']);
  279. $this->success(1,$list);
  280. }
  281. //课程预约,即将到来3天,售课
  282. public function lesson_order_near(){
  283. $starttime = strtotime(date('Y-m-d')); //今天早上
  284. $todaytime = strtotime(date('Y-m-d')) + 86400*3 - 1; //后天晚上
  285. $map = [
  286. 'order.user_id' => $this->auth->id,
  287. 'order.order_status' => 10,
  288. 'slot.starttime' => ['BETWEEN',[$starttime,$todaytime]],
  289. ];
  290. $list = Db::name('lesson_order')->alias('order')
  291. ->field('order.id,order.order_amount,order.paytype,order.package_order_id,order.package_remark,
  292. lesson.name,lesson.name_en,
  293. slot.starttime,slot.hours,slot.address,slot.coach_ids')
  294. ->join('lesson_slot slot','order.slot_id = slot.id','LEFt')
  295. ->join('lesson','order.lesson_id = lesson.id','LEFT')
  296. ->where($map)->order('slot.starttime desc')
  297. ->autopage()->select();
  298. $list = $this->list_lang($list,['name']);
  299. //准备教练数据
  300. $coach_list = Db::name('coach')->column('id,nickname');
  301. foreach($list as $key => &$order){
  302. //hours转换
  303. $order['hours'] = floatval($order['hours']);
  304. //放入教练
  305. $coach_text = '';
  306. $coach_ids = explode(',',$order['coach_ids']);
  307. foreach($coach_ids as $coach_id){
  308. if(isset($coach_list[$coach_id])){
  309. $coach_text .= $coach_list[$coach_id].',';
  310. }
  311. }
  312. $order['coach_text'] = substr($coach_text,0,-1);
  313. //24小时内可以申请取消
  314. if($order['starttime'] - time() > 86400){
  315. $order['can_cancel'] = 1;
  316. }else{
  317. $order['can_cancel'] = 0;
  318. }
  319. //显示时间
  320. $order['showtime_text'] = $this->weektime_lang($order['starttime']);
  321. //放入支付套餐
  322. /*if($order['paytype'] == 1){
  323. $package_order = Db::name('package_order')->alias('order')
  324. ->field('p.name,p.name_en,order.starttime,order.endtime')
  325. ->join('lesson_package p','order.package_id = p.id','LEFT')
  326. ->where('order.id',$order['package_order_id'])->find();
  327. $order['package_name'] = $package_order['name'];
  328. $order['package_name_en'] = $package_order['name_en'];
  329. $order['package_starttime'] = $package_order['starttime'];
  330. $order['package_endtime'] = $package_order['endtime'];
  331. }*/
  332. }
  333. //$list = $this->list_lang($list,['package_name']);
  334. $this->success(1,$list);
  335. }
  336. //课程预约,预约记录,售课
  337. public function lesson_order(){
  338. $map = [
  339. 'order.user_id' => $this->auth->id,
  340. 'order.order_status' => 10
  341. ];
  342. $list = Db::name('lesson_order')->alias('order')
  343. ->field('order.id,order.order_amount,order.paytype,order.package_order_id,order.package_remark,
  344. lesson.name,lesson.name_en,
  345. slot.starttime,slot.hours,slot.address,slot.coach_ids')
  346. ->join('lesson_slot slot','order.slot_id = slot.id','LEFt')
  347. ->join('lesson','order.lesson_id = lesson.id','LEFT')
  348. ->where($map)->order('slot.starttime desc')
  349. ->autopage()->select();
  350. $list = $this->list_lang($list,['name']);
  351. //准备教练数据
  352. $coach_list = Db::name('coach')->column('id,nickname');
  353. foreach($list as $key => &$order){
  354. //hours转换
  355. $order['hours'] = floatval($order['hours']);
  356. //放入教练
  357. $coach_text = '';
  358. $coach_ids = explode(',',$order['coach_ids']);
  359. foreach($coach_ids as $coach_id){
  360. if(isset($coach_list[$coach_id])){
  361. $coach_text .= $coach_list[$coach_id].',';
  362. }
  363. }
  364. $order['coach_text'] = substr($coach_text,0,-1);
  365. //显示时间
  366. $order['showtime_text'] = $this->weektime_lang($order['starttime']);
  367. //放入支付套餐
  368. /*if($order['paytype'] == 1){
  369. $package_order = Db::name('package_order')->alias('order')
  370. ->field('p.name,p.name_en,order.starttime,order.endtime')
  371. ->join('lesson_package p','order.package_id = p.id','LEFT')
  372. ->where('order.id',$order['package_order_id'])->find();
  373. $order['package_name'] = $package_order['name'];
  374. $order['package_name_en'] = $package_order['name_en'];
  375. $order['package_starttime'] = $package_order['starttime'];
  376. $order['package_endtime'] = $package_order['endtime'];
  377. }*/
  378. }
  379. //$list = $this->list_lang($list,['package_name']);
  380. $this->success(1,$list);
  381. }
  382. //我的试课订单
  383. public function trylesson_order(){
  384. $map = [
  385. 'order.user_id' => $this->auth->id,
  386. 'order.order_status' => ['in',[10,20]],
  387. ];
  388. $list = Db::name('trylesson_order')->alias('order')
  389. ->field('order.id,order.order_amount,order.paytime,order.order_status,order.starttime,order.endtime,
  390. trylesson.name,trylesson.name_en')
  391. ->join('trylesson','order.trylesson_id = trylesson.id','LEFT')
  392. ->where($map)->order('order.order_status asc,order.endtime asc')
  393. ->autopage()->select();
  394. $list = $this->list_lang($list,['name']);
  395. foreach($list as $key => &$order){
  396. //显示时间
  397. $order['showtime_text'] = $this->date_lang($order['starttime']).'-'.$this->date_lang($order['endtime']);
  398. }
  399. $this->success(1,$list);
  400. }
  401. //设置通知方式
  402. //可以转让的、延期的配套
  403. public function package_list(){
  404. $map = [
  405. 'order.user_id' => $this->auth->id,
  406. 'order.order_status' => 1,
  407. 'order.remain' => ['gt',0],
  408. ];
  409. $list = Db::name('package_order')->alias('order')
  410. ->field('order.id,order.starttime,order.endtime,order.is_gift,order.remain,
  411. p.name,p.name_en')
  412. ->join('lesson_package p','order.package_id = p.id','LEFT')
  413. ->where($map)->order('order.remain desc,order.endtime asc')
  414. ->select();
  415. $list = $this->list_lang($list,['name']);
  416. if(!empty($list)){
  417. foreach($list as $key => &$val){
  418. //转换remain
  419. $val['remain'] = floatval($val['remain']);
  420. $val['time_text'] = $this->date_lang($val['starttime']).'-'.$this->date_lang($val['endtime']);
  421. //是否有延期按钮
  422. $val['expired'] = 0;
  423. if($val['endtime'] < time()){
  424. $val['expired'] = 1;
  425. }
  426. }
  427. }
  428. $this->success(1,$list);
  429. }
  430. //配套转让申请
  431. public function package_move(){
  432. $field = ['name','mobile','email','reason','reason_files','package_order_id','sessions','to_name','to_mobile','to_email','remark'];
  433. $data = request_post_hub($field);
  434. //检查被装让套餐
  435. $package = Db::name('package_order')->where('order_status',1)->where('user_id',$this->auth->id)->where('id',$data['package_order_id'])->find();
  436. if(empty($package)){
  437. $this->error('不存在的套餐订单');
  438. }
  439. if($package['remain'] < $data['sessions']){
  440. $this->error('套餐剩余课时不足');
  441. }
  442. if($package['endtime'] < time()){
  443. //$this->error('套餐已过期');
  444. }
  445. //检查被转让人
  446. $to_user = Db::name('user')->where('email',$data['to_email'])->find();
  447. if(empty($to_user)){
  448. $this->error('被转让人的邮箱没找到对应用户');
  449. }
  450. if($to_user['id'] == $this->auth->id){
  451. $this->error('不能转让给自己');
  452. }
  453. $data['to_user_id'] = $to_user['id'];
  454. //入库
  455. $data['user_id'] = $this->auth->id;
  456. $data['createtime'] = time();
  457. Db::name('package_move')->insertGetId($data);
  458. $this->success('申请成功,请等待审核');
  459. }
  460. //配套延期申请
  461. public function package_delay(){
  462. $field = ['name','mobile','email','package_order_id','delay_week','reason','remark','reason_files'];
  463. $data = request_post_hub($field);
  464. //检查被装让套餐
  465. $package = Db::name('package_order')->where('order_status',1)->where('user_id',$this->auth->id)->where('id',$data['package_order_id'])->find();
  466. if(empty($package)){
  467. $this->error('不存在的套餐订单');
  468. }
  469. if($package['use_status'] != 1){
  470. $this->error('该配套还没有激活');
  471. }
  472. $data['user_id'] = $this->auth->id;
  473. $data['createtime'] = time();
  474. Db::name('package_delay')->insertGetId($data);
  475. $this->success('申请成功,请等待审核');
  476. }
  477. //可以申请退课的
  478. public function refund_lesson_order(){
  479. //试课单
  480. /*$map = [
  481. 'order.user_id' => $this->auth->id,
  482. 'order.order_status' => 10
  483. ];
  484. $list = Db::name('trylesson_order')->alias('order')
  485. ->field('order.id,order.order_amount,order.paytime,
  486. trylesson.name,trylesson.name_en')
  487. ->join('trylesson','order.trylesson_id = trylesson.id','LEFT')
  488. ->where($map)->order('order.paytime desc')
  489. ->select();
  490. $trylist = $this->list_lang($list,['name']);*/
  491. /*if(!empty($trylist)){
  492. foreach($trylist as $key2 => $val2){
  493. //日期
  494. $trylist[$key2]['showtime_text'] = date('Y-m-d H:i',$val2['paytime']);
  495. }
  496. }*/
  497. //售课单(已支付开课24小时内不能取消的,已点名实到人不足的),已取消只是个暂时状态,后台处理完会改成已退课
  498. $map = [
  499. 'order.user_id' => $this->auth->id,
  500. ];
  501. $map2 = '( (order.order_status = 10 ) or (order.order_status = 20 and order.usernumber_sign != order.usernumber) )';
  502. $list = Db::name('lesson_order')->alias('order')
  503. ->field('order.id,order.order_amount,
  504. lesson.name,lesson.name_en,
  505. slot.starttime,slot.hours,slot.endtime')
  506. ->join('lesson_slot slot','order.slot_id = slot.id','LEFt')
  507. ->join('lesson','order.lesson_id = lesson.id','LEFT')
  508. ->where($map)
  509. ->where($map2)
  510. ->order('order.createtime desc')
  511. ->select();
  512. $lesson = $this->list_lang($list,['name']);
  513. if(!empty($list)){
  514. foreach($lesson as $key => &$val){
  515. //hours转换
  516. $val['hours'] = floatval($val['hours']);
  517. //日期
  518. $val['showtime_text'] = $this->weektime_lang($val['starttime']);
  519. }
  520. }
  521. //
  522. $result = [
  523. 'trylesson' => [],
  524. 'lesson' => $lesson,
  525. ];
  526. $this->success(1,$result);
  527. }
  528. //课时退课申请
  529. public function order_refund(){
  530. $field = ['name','mobile','email','order_table','order_id','remark','reason_files'];
  531. $require = ['order_table','order_id'];
  532. $data = request_post_hub($field,$require);
  533. $data['user_id'] = $this->auth->id;
  534. $data['createtime'] = time();
  535. //冗余订单号,售课=1,试课=2
  536. if($data['order_table'] == 1){
  537. $data['order_no'] = Db::name('lesson_order')->where('id',$data['order_id'])->value('order_no');
  538. }else{
  539. $data['order_no'] = Db::name('trylesson_order')->where('id',$data['order_id'])->value('order_no');
  540. }
  541. Db::name('order_refund')->insertGetId($data);
  542. $this->success('申请成功,请等待审核');
  543. }
  544. //公司团建活动信息
  545. public function company_apply(){
  546. $field = ['name','mobile','email','company_name','company_type','remark'];
  547. $data = request_post_hub($field);
  548. $data['user_id'] = $this->auth->id;
  549. $data['createtime'] = time();
  550. Db::name('company_apply')->insertGetId($data);
  551. $this->success('申请成功,请等待审核');
  552. }
  553. }