|  |  |  | 
|---|
|  |  |  | package cc.mrbird.febs; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AgentLevelUpdateDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.AgentInfo; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.quartz.ProfitJob; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.IAgentService; | 
|---|
|  |  |  | import cc.mrbird.febs.rabbit.producter.AgentProducer; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.IApiMallMemberService; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.IMemberProfitService; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.aspectj.weaver.loadtime.Agent; | 
|---|
|  |  |  | import org.junit.jupiter.api.Test; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.boot.test.context.SpringBootTest; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.math.RoundingMode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author wzy | 
|---|
|  |  |  | * @date 2021-09-25 | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @SpringBootTest | 
|---|
|  |  |  | public class AgentTest { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private AgentProducer agentProducer; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private IMemberProfitService memberProfitService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DataDictionaryCustomMapper dataDictionaryCustomMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IAgentService agentService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private IApiMallMemberService apiMallMemberService; | 
|---|
|  |  |  | //    @Test | 
|---|
|  |  |  | //    public void getCouponAmountMap(){ | 
|---|
|  |  |  | //        for(int i = 0;i<10;i++){ | 
|---|
|  |  |  | //            RegisterDto registerDto = new RegisterDto(); | 
|---|
|  |  |  | //            registerDto.setAccount("1910000044"+i); | 
|---|
|  |  |  | //            registerDto.setRegistType("admin"); | 
|---|
|  |  |  | //            registerDto.setPassword("a123456"); | 
|---|
|  |  |  | //            registerDto.setPasswordAgain("a123456"); | 
|---|
|  |  |  | //            registerDto.setInviteId("36940411"); | 
|---|
|  |  |  | //            apiMallMemberService.register(registerDto); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void agentTest() { | 
|---|
|  |  |  | //        agentProducer.sendDelayMsg(1L, 10000L); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void insertAgentTest() { | 
|---|
|  |  |  | AgentInfo agentInfo = new AgentInfo(); | 
|---|
|  |  |  | agentInfo.setOrderType(2); | 
|---|
|  |  |  | agentInfo.setOrderCnt(2000); | 
|---|
|  |  |  | agentInfo.setLastCnt(3); | 
|---|
|  |  |  | agentInfo.setDirectIncome(BigDecimal.valueOf(50)); | 
|---|
|  |  |  | agentInfo.setTeamIncome(BigDecimal.valueOf(15)); | 
|---|
|  |  |  | agentInfo.setTeamIncomeType(2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DataDictionaryCustom data = new DataDictionaryCustom(); | 
|---|
|  |  |  | data.setType("AGENT_LEVEL_REQUIRE"); | 
|---|
|  |  |  | data.setCode(AgentLevelEnum.FOUR_LEVEL.name()); | 
|---|
|  |  |  | data.setValue(JSONObject.toJSONString(agentInfo)); | 
|---|
|  |  |  | dataDictionaryCustomMapper.insert(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void insertData() { | 
|---|
|  |  |  | int i = 1; | 
|---|
|  |  |  | for (AgentLevelEnum value : AgentLevelEnum.values()) { | 
|---|
|  |  |  | DataDictionaryCustom data = new DataDictionaryCustom(); | 
|---|
|  |  |  | data.setType("AGENT_LEVEL"); | 
|---|
|  |  |  | data.setDescription(value.getName()); | 
|---|
|  |  |  | data.setCode(value.name()); | 
|---|
|  |  |  | data.setValue(String.valueOf(i)); | 
|---|
|  |  |  | dataDictionaryCustomMapper.insert(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | getJson(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void getJson(){ | 
|---|
|  |  |  | AgentLevelUpdateDto adminAgentLevelUpdateInfoVo = new AgentLevelUpdateDto(); | 
|---|
|  |  |  | String jsonStr = "{\"directIncome\":50,\"lastCnt\":3,\"orderCnt\":2000,\"orderType\":2,\"teamIncome\":15,\"teamIncomeType\":2}"; | 
|---|
|  |  |  | JSONObject jsonObject = JSONObject.parseObject(jsonStr); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setDirectIncome(new BigDecimal((jsonObject.get("directIncome")==null?0:jsonObject.get("directIncome")).toString())); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setLastCnt(Integer.parseInt((jsonObject.get("lastCnt")==null?0:jsonObject.get("lastCnt")).toString())); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setOrderCnt(Integer.parseInt((jsonObject.get("orderCnt")==null?0:jsonObject.get("orderCnt")).toString())); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setOrderType(Integer.parseInt(jsonObject.get("orderType").toString())); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setTeamIncome(new BigDecimal((jsonObject.get("teamIncome")==null?0:jsonObject.get("teamIncome")).toString())); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setTeamIncomeType(Integer.parseInt(jsonObject.get("orderType").toString())); | 
|---|
|  |  |  | adminAgentLevelUpdateInfoVo.setId(14L); | 
|---|
|  |  |  | AgentLevelUpdateDto agentLevelUpdateDtoJson = new AgentLevelUpdateDto(); | 
|---|
|  |  |  | agentLevelUpdateDtoJson.setDirectIncome(adminAgentLevelUpdateInfoVo.getDirectIncome()); | 
|---|
|  |  |  | agentLevelUpdateDtoJson.setLastCnt(adminAgentLevelUpdateInfoVo.getLastCnt()); | 
|---|
|  |  |  | agentLevelUpdateDtoJson.setOrderCnt(adminAgentLevelUpdateInfoVo.getOrderCnt()); | 
|---|
|  |  |  | agentLevelUpdateDtoJson.setTeamIncome(adminAgentLevelUpdateInfoVo.getTeamIncome()); | 
|---|
|  |  |  | agentLevelUpdateDtoJson.setOrderType(adminAgentLevelUpdateInfoVo.getOrderType()); | 
|---|
|  |  |  | agentLevelUpdateDtoJson.setTeamIncomeType(adminAgentLevelUpdateInfoVo.getTeamIncomeType()); | 
|---|
|  |  |  | JSONObject jsonObjectA = (JSONObject)JSONObject.toJSON(agentLevelUpdateDtoJson); | 
|---|
|  |  |  | System.out.println(jsonObjectA.toJSONString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void autoLevelUp() { | 
|---|
|  |  |  | // agentService.autoUpAgentLevel(3L); | 
|---|
|  |  |  | //        agentProducer.sendAutoLevelUpMsg(5L); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | agentProducer.sendReturnMoneyMsg(2L); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void returnMoney() { | 
|---|
|  |  |  | // agentService.autoUpAgentLevel(3L); | 
|---|
|  |  |  | //        agentProducer.sendAutoLevelUpMsg(5L); | 
|---|
|  |  |  | //        agentProducer.sendReturnMoneyMsg(52L); | 
|---|
|  |  |  | agentService.returnMoneyToAgent(52L); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void bigdecimalTest() { | 
|---|
|  |  |  | BigDecimal aa = new BigDecimal("1.345"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | System.out.println(aa.setScale(2, RoundingMode.DOWN)); | 
|---|
|  |  |  | System.out.println(aa.setScale(2, RoundingMode.UP)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ProfitJob profitJob; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Test | 
|---|
|  |  |  | public void profitJobTest() { | 
|---|
|  |  |  | profitJob.profitJob(); | 
|---|
|  |  |  | public void getCouponAmountMapV2(){ | 
|---|
|  |  |  | memberProfitService.updateMemberCoin(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|