cxfoot/modules/api/controllers/IntegralController.php
2023-10-27 14:25:12 +08:00

101 lines
3.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @author Any
* @description KISS
* @date 2021年10月4日
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\api\controllers;
use app\modules\api\behaviors\LoginBehavior;
use app\components\SiteHelper;
use app\components\SysConst;
use app\models\common\integral\CommonIntegralLogListForm;
use app\models\integral\Integral;
class IntegralController extends Controller
{
public function behaviors() {
return array_merge(parent::behaviors(),[
'login' => [
'class' => LoginBehavior::className(),
'ignore' => [
]
]
]);
}
/**
* hidedoc
* @catalog 用户信息/积分
* @title 积分明细列表
* @description 本接口提供积分明细
* @method get
* @url /api/integral/log
* @param keywords 非必选 string 关键词
* @param page 必选 int 页码
* @param limit 非必选 int 每页记录数
* @param start_time 非必选 string 开始时间
* @param end_time 非必选 string 结束时间
* @param year 非必选 string 年份格式YYYY
* @param month 非必选 string 月份格式MM
* @return {"code":0,"msg":"ok","data":[{"nickname":"admin","avatar_url":"http://app.tpl.dev.1nww.com/statics/images/avatar.jpg","real_name":"","id":"3","cx_mch_id":"0","user_id":"1","type":"1","scene":"0","money":"10.10","before_account_integral":"20.20","after_account_integral":"30.30","desc":"新用户注册","order_type":"0","order_no":"111111111","ext":"","created_at":"1623146573","created_at_cn":"2021-06-08 18:02:53"}],"count":"3","page_size":20,"page_count":1,"page_no":1,"end_flag":false}
* @return_param count int 记录条数
* @return_param page_size int 每页记录数
* @return_param page_count int 总页数
* @return_param page_no int 当前页码
* @return_param end_flag bool 是否加载结束
* @remark
*/
public function actionLog()
{
$form = new CommonIntegralLogListForm();
$form->scenario = 'user';
$form->attributes = \Yii::$app->request->get();
$form->scene = Integral::$cxIntegralSceneUserIntegralWallet;
$form->cx_mch_id = $this->cx_mch_id;
$form->user_id = \Yii::$app->user->identity->id;
$data = $form->search();
return $this->responseHandler($data);
}
/**
* hidedoc
* @catalog 用户信息/积分
* @title 积分明细详情
* @description 本接口提供积分明细详情
* @method get
* @url /api/integral/log-detail
* @param integral_id 必选 int 钱包明细ID
* @return {"code":0,"msg":"ok","data":{}}
* @return_param after_account_integral number 变化后账户余额
* @remark
*/
public function actionLogDetail()
{
$form = new CommonIntegralLogListForm();
$form->scenario = 'detail';
$form->attributes = \Yii::$app->request->get();
$form->scene = Integral::$cxIntegralSceneUserIntegralWallet;
$form->cx_mch_id = $this->cx_mch_id;
$form->user_id = \Yii::$app->user->identity->id;
$res = $form->search();
if($res['code'] != 0)
return $this->responseHandler($res);
if(count($res['data']) == 0)
return $this->responseHandler(['code' => 1, 'msg' => '钱包明细详情不存在']);
$data = [
'code' => 0,
'msg' => 'ok',
'data' => $res['data'][0]
];
return $this->responseHandler($data);
}
}