12, 'name' => '平台充值'], ['id' => 13, 'name' => '平台扣除'], ['id' => 0, 'name' => '其他'], ]; private static $stateMap = [ ['id' => 1, 'name' => '增加'], ['id' => 2, 'name' => '减少'] ]; /** * @return array[] */ public static function getStateMap(): array { return self::$stateMap; } /** * @return array[] */ public static function getTypeMap(): array { return self::$typeMap; } /** * 绿色积分记录 * @param $page * @param $limit * @param $where * @param array $sort * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function scoreLog($page, $limit, $where, $sort) { $model = new GreenScoreLogModel(); $count = $model ->where($where) ->count(); $type_conf = config('type.green_score'); $list = $model ->where($where) ->withAttr('type', function ($value, $data) use ($type_conf) { if (array_key_exists($value, $type_conf)) { return $type_conf[$value]; } return ''; }) ->withAttr('score', function ($value, $data) { if ($data['state'] == 2) $value = '-' . $value; return $value; }) ->page($page, $limit) ->order($sort) ->select(); return [$count, $list]; } }