1, 'name' => '预约福袋'], // ['id' => 2, 'name' => '预约福袋空盒退回'], // ['id' => 3, 'name' => '买商品送积分'], // ['id' => 4, 'name' => '提现多次返回'], // ['id' => 6, 'name' => '兑换商品'], ['id' => 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 ScoreLogModel(); $count = $model ->where($where) ->count(); $type_conf = config('type.scoreAll'); $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]; } }