Browse Source

分销

master
nili 7 months ago
parent
commit
103c16217a
  1. 1
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java
  2. 4
      game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixUserMapper.java
  3. 35
      game-service/src/main/java/awesome/group/game/service/bo/citrus/TeamBo.java
  4. 12
      game-service/src/main/java/awesome/group/game/service/citrus/AdvRecordService.java
  5. 18
      game-service/src/main/java/awesome/group/game/service/citrus/UserService.java
  6. 8
      game-web/src/main/java/awesome/group/game/web/rest/citrus/UserController.java

1
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java

@ -23,5 +23,6 @@ public class MatrixUser {
private String inviteCode;
private Integer upUid;
private Long income;//分,累计收益
private Long contributeIncome;//贡献给上级的收益,分,ecpm
private Timestamp createdAt;
}

4
game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixUserMapper.java

@ -19,8 +19,8 @@ public interface MatrixUserMapper extends BaseMapper<MatrixUser> {
@Update("update matrix_user set real_money = real_money + #{cent} where id = #{userId}")
int incRealMoney(int userId, int cent);
@Update("update matrix_user set income = income + #{ecpmReal} where id = #{userId}")
int incIncome(int userId, long ecpmReal);
@Update("update matrix_user set income = income + #{ecpmReal}, contribute_income = contribute_income + #{contribute} where id = #{userId}")
int incIncome(int userId, long ecpmReal, long contribute);
@Update("update matrix_user set ali_pay_account = #{aliPayAccount}, name = #{name} where id = #{userId}")
int updateAliPayAccount(int userId, String aliPayAccount, String name);

35
game-service/src/main/java/awesome/group/game/service/bo/citrus/TeamBo.java

@ -0,0 +1,35 @@
package awesome.group.game.service.bo.citrus;
import awesome.group.game.dao.bean.MatrixUser;
import org.springframework.util.StringUtils;
import java.util.List;
public class TeamBo {
public List<Member> memberList;
public TeamBo() {
}
public TeamBo(List<MatrixUser> list) {
this.memberList = list.stream().map(Member::new).toList();
}
public static class Member {
public String nickname;
public String avatar;
public Long contributeGoldCoin;
public Member() {
}
public Member(MatrixUser u) {
this.nickname = u.getNickname();
this.avatar = u.getAvatar();
this.contributeGoldCoin = u.getContributeIncome();
if (!StringUtils.hasText(this.nickname)) {
this.nickname = UserBo.replaceWithX(u.getMobile());
}
}
}
}

12
game-service/src/main/java/awesome/group/game/service/citrus/AdvRecordService.java

@ -47,9 +47,14 @@ public class AdvRecordService {
Assert.isTrue(u.getAppId().equals(app.getId()), "非法请求");
long ecpmReal = ecpm * config.getRate(u) / 100;
ecpmReal = Math.min(config.maxIncomeEachVideo * 1000L, ecpmReal);
long contribute = 0;
if (bo.advType != 3) {
ecpmReal = 0; //只有激励视频算钱
}
if (u.getUpUid() != null) {
contribute = ecpmReal / 10;
ecpmReal = ecpmReal - contribute;
}
MatrixAdvRecord record = new MatrixAdvRecord();
record.setDeviceId(bo.deviceId);
@ -65,7 +70,12 @@ public class AdvRecordService {
record.setAdvId(bo.advId);
mapper.insert(record);
userMapper.incIncome(uid, ecpmReal);
if (ecpmReal > 0) {
userMapper.incIncome(uid, ecpmReal, contribute);
}
if (contribute > 0) {
userMapper.incIncome(u.getUpUid(), contribute, 0);
}
MatrixUser user = userMapper.selectById(uid);
return new AdvResponse(ecpmReal, user);
}

18
game-service/src/main/java/awesome/group/game/service/citrus/UserService.java

@ -8,15 +8,14 @@ import awesome.group.game.dao.mapper.MatrixMoneyRecordMapper;
import awesome.group.game.dao.mapper.MatrixUserMapper;
import awesome.group.game.service.SmsService;
import awesome.group.game.service.UMengService;
import awesome.group.game.service.bo.citrus.AppCashConfig;
import awesome.group.game.service.bo.citrus.CashRecord;
import awesome.group.game.service.bo.citrus.LoginReq;
import awesome.group.game.service.bo.citrus.UserBo;
import awesome.group.game.service.bo.citrus.*;
import awesome.group.game.service.bo.matrix.UmengConfigBo;
import awesome.group.game.service.common.exception.PaganiException;
import awesome.group.game.service.common.exception.PaganiExceptionCode;
import awesome.group.game.service.util.DateUtil;
import awesome.group.game.service.util.EncryptUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.gson.Gson;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,6 +23,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.sql.Timestamp;
@ -130,6 +130,16 @@ public class UserService {
return res;
}
public TeamBo myTeam(Integer uid) {
LambdaQueryWrapper<MatrixUser> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(MatrixUser::getUpUid, uid);
List<MatrixUser> members = userMapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(members)) {
return null;
}
return new TeamBo(members);
}
public void bindAliPay(Integer uid, String aliPayAccount, String name) {
Assert.isTrue(StringUtils.hasText(aliPayAccount), "支付宝账号不能为空");
Assert.isTrue(StringUtils.hasText(name), "支付宝账号姓名不能为空");

8
game-web/src/main/java/awesome/group/game/web/rest/citrus/UserController.java

@ -3,6 +3,7 @@ package awesome.group.game.web.rest.citrus;
import awesome.group.game.service.bo.MatrixAdvRecordEditBo;
import awesome.group.game.service.bo.citrus.AdvResponse;
import awesome.group.game.service.bo.citrus.CashRecord;
import awesome.group.game.service.bo.citrus.TeamBo;
import awesome.group.game.service.bo.citrus.UserBo;
import awesome.group.game.service.citrus.AdvRecordService;
import awesome.group.game.service.citrus.UserService;
@ -31,7 +32,6 @@ public class UserController {
private WeiXinService weiXinService;
@GetMapping("/current")
@RestApi
public R<UserBo> currentUser() {
@ -71,4 +71,10 @@ public class UserController {
weiXinService.bindWx(RequestContext.getCitrusUid(), accessToken, openId);
return new R<>(null);
}
@GetMapping("/myTeam")
@RestApi
public R<TeamBo> myTeam() {
return new R<>(userService.myTeam(RequestContext.getCitrusUid()));
}
}

Loading…
Cancel
Save