Browse Source

刷数据v2

master
nili 6 months ago
parent
commit
0aedaa1461
  1. 17
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixInnerUser.java
  2. 20
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixMockScheduleV2.java
  3. 10
      game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixInnerUserMapper.java
  4. 22
      game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixMockScheduleV2Mapper.java
  5. 10
      game-service/src/main/java/awesome/group/game/service/bo/matrix/WhiteUserBo.java
  6. 79
      game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java
  7. 17
      game-service/src/test/java/awesome/group/game/service/citrus/UserServiceTest.java
  8. 32
      game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java

17
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixInnerUser.java

@ -0,0 +1,17 @@
package awesome.group.game.dao.bean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class MatrixInnerUser {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Integer userId;
private Integer appId;
private Timestamp createdAt;
private Timestamp updatedAt;
}

20
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixMockScheduleV2.java

@ -0,0 +1,20 @@
package awesome.group.game.dao.bean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class MatrixMockScheduleV2 {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Integer appId;
private Integer incomeYuan;
private Long mockIncome;//ecpm累计,分
private Integer status;
private Timestamp scheduleTime;
private Timestamp createdAt;
private Timestamp updatedAt;
}

10
game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixInnerUserMapper.java

@ -0,0 +1,10 @@
package awesome.group.game.dao.mapper;
import awesome.group.game.dao.bean.MatrixInnerUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
public interface MatrixInnerUserMapper extends BaseMapper<MatrixInnerUser> {
@Select("select * from matrix_inner_user where user_id = #{userId}")
MatrixInnerUser queryByUserId(Integer userId);
}

22
game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixMockScheduleV2Mapper.java

@ -0,0 +1,22 @@
package awesome.group.game.dao.mapper;
import awesome.group.game.dao.bean.MatrixMockScheduleV2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import java.util.List;
public interface MatrixMockScheduleV2Mapper extends BaseMapper<MatrixMockScheduleV2> {
@Update("update matrix_mock_schedule_v2 set status=#{status} where id = #{id}")
int updateStatus(int status, int id);
@Update("update matrix_mock_schedule_v2 set mock_income = mock_income + #{incrMockIncome} where id = #{id}")
int updateMockIncome(long incrMockIncome, int id);
@Insert("<script>insert into matrix_mock_schedule_v2 (app_id, income_yuan, schedule_time) values " +
"<foreach collection='scheduleList' item='item' index='index' separator=','>" +
"(#{item.appId}, #{item.incomeYuan}, #{item.scheduleTime})" +
"</foreach></script>")
int insertBatch(List<MatrixMockScheduleV2> scheduleList);
}

10
game-service/src/main/java/awesome/group/game/service/bo/matrix/WhiteUserBo.java

@ -1,6 +1,7 @@
package awesome.group.game.service.bo.matrix; package awesome.group.game.service.bo.matrix;
import awesome.group.game.dao.bean.MatrixApp; import awesome.group.game.dao.bean.MatrixApp;
import awesome.group.game.dao.bean.MatrixInnerUser;
import awesome.group.game.dao.bean.MatrixUser; import awesome.group.game.dao.bean.MatrixUser;
import awesome.group.game.dao.bean.MatrixWhiteUser; import awesome.group.game.dao.bean.MatrixWhiteUser;
import awesome.group.game.service.bo.citrus.UserBo; import awesome.group.game.service.bo.citrus.UserBo;
@ -27,4 +28,13 @@ public class WhiteUserBo {
this.updatedAt = w.getUpdatedAt().getTime(); this.updatedAt = w.getUpdatedAt().getTime();
} }
public WhiteUserBo(MatrixInnerUser w, MatrixUser u, MatrixApp a) {
this.id = w.getId();
this.appId = u.getAppId();
this.appName = a.getName();
this.user = new UserBo(u, true);
this.createdAt = w.getCreatedAt().getTime();
this.updatedAt = w.getUpdatedAt().getTime();
}
} }

79
game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java

@ -1,25 +1,25 @@
package awesome.group.game.service.matrix; package awesome.group.game.service.matrix;
import awesome.group.game.dao.bean.MatrixApp; import awesome.group.game.dao.bean.*;
import awesome.group.game.dao.bean.MatrixEvilApp; import awesome.group.game.dao.mapper.*;
import awesome.group.game.dao.bean.MatrixUser; import awesome.group.game.service.bo.AddMockScheduleReq;
import awesome.group.game.dao.bean.MatrixWhiteUser;
import awesome.group.game.dao.mapper.MatrixAppMapper;
import awesome.group.game.dao.mapper.MatrixEvilAppMapper;
import awesome.group.game.dao.mapper.MatrixUserMapper;
import awesome.group.game.dao.mapper.MatrixWhiteUserMapper;
import awesome.group.game.service.bo.matrix.WhiteUserBo; import awesome.group.game.service.bo.matrix.WhiteUserBo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static awesome.group.game.service.util.Constants.SUPER_ADMIN;
@Service @Service
public class SuperAdminService { public class SuperAdminService {
@ -29,12 +29,21 @@ public class SuperAdminService {
@Autowired @Autowired
private MatrixWhiteUserMapper whiteUserMapper; private MatrixWhiteUserMapper whiteUserMapper;
@Autowired
private MatrixInnerUserMapper innerUserMapper;
@Autowired @Autowired
private MatrixUserMapper userMapper; private MatrixUserMapper userMapper;
@Autowired @Autowired
private MatrixAppMapper appMapper; private MatrixAppMapper appMapper;
@Autowired
private MatrixAdminMapper adminMapper;
@Autowired
private MatrixMockScheduleV2Mapper mockScheduleV2Mapper;
public List<MatrixEvilApp> evilAppList() { public List<MatrixEvilApp> evilAppList() {
List<MatrixEvilApp> app = evilAppMapper.selectList(null); List<MatrixEvilApp> app = evilAppMapper.selectList(null);
Collections.reverse(app); Collections.reverse(app);
@ -68,6 +77,26 @@ public class SuperAdminService {
return Lists.reverse(res); return Lists.reverse(res);
} }
public List<WhiteUserBo> innerUserList() {
List<MatrixInnerUser> list = innerUserMapper.selectList(null);
if (CollectionUtils.isEmpty(list)) {
return null;
}
List<Integer> userIds = list.stream().map(MatrixInnerUser::getUserId).toList();
List<MatrixUser> users = userMapper.selectBatchIds(userIds);
List<Integer> appIds = users.stream().map(MatrixUser::getAppId).toList();
List<MatrixApp> apps = appMapper.selectBatchIds(appIds);
Map<Integer, MatrixUser> uMap = users.stream().collect(Collectors.toMap(MatrixUser::getId, x -> x));
Map<Integer, MatrixApp> aMap = apps.stream().collect(Collectors.toMap(MatrixApp::getId, x -> x));
List<WhiteUserBo> res = new ArrayList<>();
for (MatrixInnerUser r : list) {
MatrixUser u = uMap.get(r.getUserId());
res.add(new WhiteUserBo(r, u, aMap.get(u.getAppId())));
}
return Lists.reverse(res);
}
public void saveWhiteUser(Integer userId, Integer status) { public void saveWhiteUser(Integer userId, Integer status) {
MatrixWhiteUser r = whiteUserMapper.queryByUserId(userId); MatrixWhiteUser r = whiteUserMapper.queryByUserId(userId);
MatrixWhiteUser update = new MatrixWhiteUser(); MatrixWhiteUser update = new MatrixWhiteUser();
@ -81,5 +110,39 @@ public class SuperAdminService {
} }
} }
public void saveInnerUser(Integer userId) {
if (innerUserMapper.queryByUserId(userId) != null) {
return;
}
MatrixUser u = userMapper.selectById(userId);
MatrixInnerUser innerUser = new MatrixInnerUser();
innerUser.setAppId(u.getAppId());
innerUser.setUserId(userId);
innerUserMapper.insert(innerUser);
}
public List<MatrixMockScheduleV2> mockScheduleList() {
return mockScheduleV2Mapper.selectList(new QueryWrapper<MatrixMockScheduleV2>().last("order by id desc limit 200"));
}
public void addMockSchedule(AddMockScheduleReq bo, Integer adminId) {
MatrixAdmin admin = adminMapper.selectById(adminId);
Assert.isTrue(admin != null && admin.getRole() == SUPER_ADMIN, "非法请求");
Assert.isTrue(!CollectionUtils.isEmpty(bo.scheduleTime), "时间不能为空");
Assert.isTrue(!CollectionUtils.isEmpty(bo.appId), "应用不能为空");
List<MatrixMockScheduleV2> list = new ArrayList<>();
for (Integer appId : bo.appId) {
bo.scheduleTime.forEach(x -> {
MatrixMockScheduleV2 schedule = new MatrixMockScheduleV2();
schedule.setAppId(appId);
schedule.setScheduleTime(new Timestamp(x));
schedule.setIncomeYuan(bo.incomeYuan);
list.add(schedule);
});
}
mockScheduleV2Mapper.insertBatch(list);
}
} }

17
game-service/src/test/java/awesome/group/game/service/citrus/UserServiceTest.java

@ -0,0 +1,17 @@
package awesome.group.game.service.citrus;
import awesome.group.game.service.BaseTest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static org.junit.jupiter.api.Assertions.*;
class UserServiceTest extends BaseTest {
@Autowired
private UserService userService;
@Test
void getAdvList() {
userService.getAdvList(1000003, 159567);
}
}

32
game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java

@ -1,10 +1,14 @@
package awesome.group.game.web.rest.matrix; package awesome.group.game.web.rest.matrix;
import awesome.group.game.dao.bean.MatrixEvilApp; import awesome.group.game.dao.bean.MatrixEvilApp;
import awesome.group.game.dao.bean.MatrixMockSchedule;
import awesome.group.game.dao.bean.MatrixMockScheduleV2;
import awesome.group.game.service.bo.AddMockScheduleReq;
import awesome.group.game.service.bo.matrix.WhiteUserBo; import awesome.group.game.service.bo.matrix.WhiteUserBo;
import awesome.group.game.service.common.response.R; import awesome.group.game.service.common.response.R;
import awesome.group.game.service.matrix.SuperAdminService; import awesome.group.game.service.matrix.SuperAdminService;
import awesome.group.game.service.pay.AlipayFundTransUniTransfer; import awesome.group.game.service.pay.AlipayFundTransUniTransfer;
import awesome.group.game.web.RequestContext;
import awesome.group.game.web.aop.RestApi; import awesome.group.game.web.aop.RestApi;
import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -14,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("/api/superAdmin") @RequestMapping("/api/admin/superAdmin")
@Tag(name = "superAdmin") @Tag(name = "superAdmin")
//@Hidden //@Hidden
public class SuperAdminController { public class SuperAdminController {
@ -51,10 +55,36 @@ public class SuperAdminController {
return new R<>(superAdminService.whiteUserList()); return new R<>(superAdminService.whiteUserList());
} }
@GetMapping("/innerUserList")
@RestApi
public R<List<WhiteUserBo>> innerUserList() {
return new R<>(superAdminService.innerUserList());
}
@PostMapping("/saveInnerUser")
@RestApi
public R<Void> saveInnerUser(@RequestParam Integer userId) {
superAdminService.saveInnerUser(userId);
return new R<>(null);
}
@PostMapping("/transfer") @PostMapping("/transfer")
@RestApi @RestApi
public R<Void> transfer(@RequestParam String name, @RequestParam String aliAccount, @RequestParam String appCode) { public R<Void> transfer(@RequestParam String name, @RequestParam String aliAccount, @RequestParam String appCode) {
alipayFundTransUniTransfer.transfer(appCode, name, aliAccount); alipayFundTransUniTransfer.transfer(appCode, name, aliAccount);
return new R<>(null); return new R<>(null);
} }
@GetMapping("/scheduleList")
@RestApi
public R<List<MatrixMockScheduleV2>> scheduleListV2() {
return new R<>(R.CODE_SUCCESS, "ok", superAdminService.mockScheduleList());
}
@PostMapping("/addSchedule")
@RestApi
public R<Void> addScheduleV2(@RequestBody AddMockScheduleReq bo) {
superAdminService.addMockSchedule(bo, RequestContext.getAdminID());
return new R<>(R.CODE_SUCCESS, "ok", null);
}
} }

Loading…
Cancel
Save