<?php
namespace app\shared\logic\user;
use app\shared\model\Recharge;
use app\shared\model\StoreRecharge;
use app\shared\model\Coupon;
use app\shared\model\Card;
use think\exception\ValidateException;
use app\BaseController;
class RechargeForm extends  UserForm
{
   //充值列表
	public function index(){
         $query=Recharge::where(['acid'=>$this->acid,'is_delete'=>0,'status'=>1]);
         $list=$query->order('price ASC')->field('id,price,give_price,coupon_ids,card_ids')
         ->select()
         ->toArray();
         foreach ($list as $key => &$value) {
             $value['give_text']='买'.$value['price'].'元送'.$value['give_price'].'元';
             $value['card_list']=Card::where(['acid'=>$this->acid])->where('id','in',$value['card_ids'])->column('id,title,discount,cover');
             $value['coupon_list']=Coupon::where(['acid'=>$this->acid,'is_delete'=>0,'status'=>1])->where('id','in',$value['coupon_ids'])->column('id,name,price,full_price');
         }
         return fetchJson($list);
    }
    
}