|
|
@@ -24,7 +24,6 @@ import com.ytpm.app.param.AppUserQueryParam;
|
|
|
import com.ytpm.app.param.AppUserTodayBannedParam;
|
|
|
import com.ytpm.app.param.YtAppUserListParam;
|
|
|
import com.ytpm.app.view.HourCountView;
|
|
|
-import com.ytpm.app.view.WxDefaultConfig;
|
|
|
import com.ytpm.app.view.YtAppUserListView;
|
|
|
import com.ytpm.feign.RiskFeign;
|
|
|
import com.ytpm.general.RepMessage;
|
|
|
@@ -39,12 +38,10 @@ import com.ytpm.question.redis.RedisService;
|
|
|
import com.ytpm.risk.enums.BannedTypeEnum;
|
|
|
import com.ytpm.risk.view.RiskConfigView;
|
|
|
import com.ytpm.risk.view.RiskTemplateView;
|
|
|
-import com.ytpm.util.NumberUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
@@ -57,7 +54,6 @@ import javax.imageio.ImageIO;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
@@ -90,9 +86,6 @@ public class UserController {
|
|
|
@Resource
|
|
|
private RiskFeign riskFeign;
|
|
|
|
|
|
- @Value("${yt.revenue.scale:3}")
|
|
|
- private Integer revenueScale;
|
|
|
-
|
|
|
@Value("${spring.application.name:}")
|
|
|
private String applicationName;
|
|
|
|
|
|
@@ -182,23 +175,6 @@ public class UserController {
|
|
|
user.setHistoryAnswerCount(questionMapper.getAnswerCount(userId, 2));
|
|
|
// 答题记录列表
|
|
|
user.setAnswerRecordList(questionMapper.getAnswerRecords(userId));
|
|
|
- WxDefaultConfig defaultConfig = appUserMapper.getDefaultConfigByAppId(user.getAppId());
|
|
|
- // 分层系数
|
|
|
- String revenueDisplayRate = defaultConfig == null ? "" : defaultConfig.getRevenueDisplayRate();
|
|
|
- BigDecimal todayRevenue = adRecordMapper.getToTalRevenue(userId, 1);
|
|
|
- BigDecimal totalRevenue = user.getTotalIncome() == null ? adRecordMapper.getToTalRevenue(userId, 2) : user.getTotalIncome();
|
|
|
- if (StrUtil.isNotEmpty(revenueDisplayRate)) {
|
|
|
- BigDecimal rate = NumberUtils.rateToBigDecimal(revenueDisplayRate);
|
|
|
- todayRevenue = todayRevenue.multiply(rate).setScale(revenueScale, RoundingMode.HALF_UP);
|
|
|
- totalRevenue = totalRevenue.multiply(rate).setScale(revenueScale, RoundingMode.HALF_UP);
|
|
|
- }
|
|
|
- // 今日收益
|
|
|
- user.setTodayIncome(todayRevenue);
|
|
|
- // 历史收益
|
|
|
- user.setTotalIncome(totalRevenue);
|
|
|
- if (user.getNearlyIncome() != null) {
|
|
|
- user.setNearlyIncome(user.getNearlyIncome().setScale(revenueScale, RoundingMode.HALF_UP));
|
|
|
- }
|
|
|
// 是否体力已达上限
|
|
|
boolean ifPowerLimit = false;
|
|
|
Result<?> result = riskFeign.checkAdRisk(user);
|
|
|
@@ -208,31 +184,31 @@ public class UserController {
|
|
|
}
|
|
|
user.setIfPowerLimit(ifPowerLimit);
|
|
|
}
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("serverName", applicationName);
|
|
|
- jsonObject.put("appId", user.getAppId());
|
|
|
- jsonObject.put("userId", userId);
|
|
|
- jsonObject.put("deviceId", user.getDeviceId());
|
|
|
- String content = new Base64().encodeToString(JSONObject.toJSONString(jsonObject).getBytes());
|
|
|
- BufferedImage qrCode = QrCodeUtil.generate(content, 50, 50);
|
|
|
- user.setQrCode(bufferedImageToBase64(qrCode));
|
|
|
return Result.resultObjOk(user);
|
|
|
}
|
|
|
|
|
|
- public String bufferedImageToBase64(BufferedImage bufferedImage) {
|
|
|
+ /**
|
|
|
+ * 生成用户信息二维码
|
|
|
+ */
|
|
|
+ private void setQrCode(YtDyzUser user) {
|
|
|
try {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("serverName", applicationName);
|
|
|
+ jsonObject.put("appId", user.getAppId());
|
|
|
+ jsonObject.put("userId", user.getUserId());
|
|
|
+ jsonObject.put("deviceId", user.getDeviceId());
|
|
|
+ String content = new Base64().encodeToString(JSONObject.toJSONString(jsonObject).getBytes());
|
|
|
+ BufferedImage qrCode = QrCodeUtil.generate(content, 50, 50);
|
|
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
|
- ImageIO.write(bufferedImage, "png", stream);
|
|
|
+ ImageIO.write(qrCode, "png", stream);
|
|
|
Base64 base64 = new Base64();
|
|
|
String base64String = base64.encodeToString(stream.toByteArray());
|
|
|
- return "data:image/png;base64," + base64String;
|
|
|
+ user.setQrCode("data:image/png;base64," + base64String);
|
|
|
} catch (Exception e) {
|
|
|
log.error("生成qrCode失败", e);
|
|
|
- return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询用户信息
|
|
|
*/
|