12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php namespace App\Http\Controllers\Api;
- use App\Models\CustomAmountRecord as CustomAmountRecord;
- use App\Models\CustomAmount as Model;
- /**
- * 用户余额接口
- *
- * @author jun
- *
- * */
- class CustomAmount extends Api{
-
-
- /**
- * 获取余额记录 /api/custom_amount/get_record_list
- *
- * @param string $code 授权码
- *
- * */
- public function get_record_list(Model $Model,CustomAmountRecord $CustomAmountRecord){
- // 接口验签
- // $this->verify_sign();
- // 检查登录
- $uid = $this->checkLogin();
- // 接收参数
- $limit = request('limit',15);
- // 查询条件
- $map = [['custom_uid','=',$uid]];
- // 查询数据
- $Paginator = $CustomAmountRecord->query()->where($map)->orderByDesc('id')
- ->paginate($limit,['id','buy_type','pay_type','prefix','description','insert_time','pay_time','status','transfer_bill_no','balance','amount']);
- // 重置数据
- $list = [];
- // 获取数据
- $list['total'] = $Paginator->total();
- $list['current_page'] = $Paginator->currentPage();
- $list['per_page'] = $Paginator->perPage();
- $list['last_page'] = $Paginator->lastPage();
- $list['data'] = $Paginator->items();
- // 循环数据
- foreach ($list['data'] as $key => $value) {
- // 处理时间
- $value['pay_time'] = $value['pay_time'] ? date('Y-m-d H:i:s',$value['pay_time']) : '';
- $value['insert_time'] = date('Y-m-d H:i:s',$value['insert_time']);
- // 获取子列表
- $value['type_state'] = (string) $CustomAmountRecord->getPayType($value['buy_type'],$value['pay_type'],'name');
- if ($value['buy_type'] == 2){
- $value['state'] = $CustomAmountRecord->getState($value['status'],'state');
- }
- // 重组
- $list['data'][$key] = $value;
- }
- // 返回结果
- return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
- }
- /**
- * 获取余额详情 /api/custom_amount/get_record_info
- *
- * @param string record_id 记录ID
- *
- * */
- public function get_record_info(Model $Model,CustomAmountRecord $CustomAmountRecord){
- // 检查登录
- $uid = $this->checkLogin();
- // 接收参数
- $recordId = request('record_id',0);
- $info = $CustomAmountRecord::query()->where(['custom_uid'=>$uid,'id'=>$recordId])->first(['id','buy_type','pay_type','prefix','description','insert_time','pay_time','status','transfer_bill_no','balance','amount']);
- if($info){
- $info['id_code'] = $CustomAmountRecord->idToCode($info['id']);
- }
- return json_send(['code'=>'success','msg'=>'获取成功','data'=>$info]);
- }
- }
|