Recharge.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Exception;
  6. class Recharge extends Api
  7. {
  8. protected $noNeedLogin = [];
  9. protected $noNeedRight = '*';
  10. //首页
  11. public function getList(){
  12. $where = [
  13. 'company_id' => $this->auth->company_id,
  14. 'status' => 1,
  15. ];
  16. $field = 'id,price,giftprice';
  17. $list = Db::name('recharge_config')->field($field)->where($where)->order('id desc')->select();
  18. //追加赠送
  19. /*if(!empty($list)){
  20. $config_ids = array_column($list,'id');
  21. $gift = Db::name('recharge_gift')->alias('gift')
  22. ->field('gift.*,coupons.name,coupons.info,coupons.days')
  23. ->join('coupons','gift.coupon_id = coupons.id','LEFT')
  24. ->where('gift.config_id','IN',$config_ids)
  25. ->where('coupons.status',1)
  26. ->select();
  27. foreach($list as $key => &$val){
  28. $val['gift'] = [];
  29. foreach($gift as $k => $v){
  30. if($val['id'] == $v['config_id']){
  31. $val['gift'][] = $v;
  32. }
  33. }
  34. }
  35. }*/
  36. $this->success(1,$list);
  37. }
  38. /**
  39. * 充值
  40. * @return void
  41. */
  42. /*public function add()
  43. {
  44. Db::startTrans();
  45. try {
  46. //验证参数
  47. $id = $this->request->param('id',0);
  48. $amounts = $this->request->param('amounts',0.00);
  49. if (empty($id) && empty($amounts)) {
  50. throw new Exception('参数错误');
  51. }
  52. if (!empty($id)) {
  53. } else {
  54. $isInt = is_int($amounts);
  55. if (!$isInt) {
  56. throw new Exception('请输入整数');
  57. }
  58. if ($amounts < 1) {
  59. throw new Exception('充值金额有误');
  60. }
  61. }
  62. $userId = $this->auth->id;
  63. $time = time();
  64. $data = [
  65. 'car_number' => $this->request->param('car_number', ''),
  66. 'car_model' => $this->request->param('car_model', ''),
  67. ];
  68. $data['user_id'] = $userId;
  69. $data['createtime'] = $time;
  70. $res = $this->model->insertGetId($data);
  71. if (!$res) {
  72. throw new Exception('操作失败');
  73. }
  74. Db::commit();
  75. $this->success('操作成功');
  76. } catch (Exception $e) {
  77. Db::rollback();
  78. $this->error($e->getMessage());
  79. }
  80. }*/
  81. }