RechargeController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\controller;
  20. use app\adminapi\logic\gift_card\GiftCardLogic;
  21. use app\shopapi\validate\GiftCardValidate;
  22. use app\shopapi\lists\RechargeTemplateLists;
  23. use app\shopapi\logic\RechargeLogic;
  24. /**
  25. * 充值控制器
  26. * Class RechargeController
  27. * @package app\shopapi\controller
  28. */
  29. class RechargeController extends BaseShopController
  30. {
  31. /**
  32. * @notes 查看充值模板列表
  33. * @return \think\response\Json
  34. * @author Tab
  35. * @date 2021/8/11 10:02
  36. */
  37. public function rechargeTemplateLists()
  38. {
  39. return $this->dataLists(new RechargeTemplateLists());
  40. }
  41. /**
  42. * @notes 充值
  43. * @return \think\response\Json
  44. * @author Tab
  45. * @date 2021/8/11 10:44
  46. */
  47. public function recharge()
  48. {
  49. $params = $this->request->post();
  50. $params['user_id'] = $this->userId;
  51. $params['terminal'] = $this->userInfo['terminal'];
  52. $result = RechargeLogic::recharge($params);
  53. if($result) {
  54. return $this->data($result);
  55. }
  56. return $this->fail(RechargeLogic::getError());
  57. }
  58. /**
  59. * @notes 查看充值记录列表
  60. * @return \think\response\Json
  61. * @author Tab
  62. * @date 2021/8/11 14:58
  63. */
  64. public function lists()
  65. {
  66. return $this->dataLists();
  67. }
  68. public function giftCardExchange(){
  69. if($this->request->isPost()) {
  70. $params = (new GiftCardValidate())->post()->goCheck('exchange');
  71. $params['user_id'] = $this->userId;
  72. $result = (new RechargeLogic())->exchange($params);
  73. if($result == 'true'){
  74. return $this->success('礼品卡兑换成功');
  75. }else{
  76. return $this->fail(RechargeLogic::getError());
  77. }
  78. }else{
  79. return $this->fail('请求方式错误');
  80. }
  81. }
  82. }