| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | <?phpnamespace app\api\controller;use app\common\controller\Api;use think\Db;use think\Exception;class UserMoneyLog extends Api{    protected $noNeedLogin = [];    protected $noNeedRight = '*';    protected $model = null;    public function _initialize()    {        parent::_initialize();        $this->model = Db::name('user_money_log');    }    /**     * 列表     * @return void     */    public function getList()    {        try {            $userId = $this->auth->id;            $companyId = $this->auth->company_id;            $field = 'id,before,change_value,remain,remark,createtime';            $where['user_id'] = $userId;            $where['company_id'] = $companyId;            $result = $this->model->field($field)->where($where)->order('createtime desc')->autopage()->select();            if (!empty($result)) {                foreach ($result as $key => &$value) {                    $symbol = $value['remain'] > $value['before'] ? '+' : '-';                    $value['symbol'] = $value['remain'] > $value['before'] ? 2 : 1;                    $value['change_value_text'] = $symbol.$value['change_value'];                    !empty($value['createtime']) && $value['createtime'] = date('Y.m.d H:i:s',$value['createtime']);                }            }            $this->success('获取成功',$result);        } catch (Exception $e) {            $this->error($e->getMessage());        }    }}
 |