guildUsd
This commit is contained in:
@@ -11,4 +11,6 @@ public class UsersVo extends Users {
|
||||
private double radishNum;
|
||||
|
||||
private double diamondsNum;
|
||||
|
||||
private double guildUsdNum;
|
||||
}
|
||||
|
@@ -11,9 +11,13 @@ import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.admin.vo.OfficialGoldAllRecordVo;
|
||||
import com.accompany.admin.vo.OfficialGoldRecordVo;
|
||||
import com.accompany.business.constant.OfficalSendTypeEnum;
|
||||
import com.accompany.business.constant.guild.GuildUsdOperateTypeEnum;
|
||||
import com.accompany.business.model.OfficialGoldBusType;
|
||||
import com.accompany.business.model.UserPurse;
|
||||
import com.accompany.business.model.guild.GuildMember;
|
||||
import com.accompany.business.service.WebConfigService;
|
||||
import com.accompany.business.service.guild.GuildMemberService;
|
||||
import com.accompany.business.service.guild.GuildUsdBillRecordService;
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
@@ -55,6 +59,8 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.accompany.common.status.BusiStatus.NOT_ENOUGH_GUILD_USD;
|
||||
|
||||
@Service
|
||||
public class OfficialGoldRecordService extends BaseService {
|
||||
|
||||
@@ -86,6 +92,10 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private OfficialGoldRoleLimitService officialGoldRoleLimitService;
|
||||
@Autowired
|
||||
private GuildMemberService guildMemberService;
|
||||
@Autowired
|
||||
private GuildUsdBillRecordService guildUsdBillRecordService;
|
||||
|
||||
public List<Map<String, Object>> listType(int adminId){
|
||||
boolean hasLimit = officialGoldRoleLimitService.hasLimit(adminId);
|
||||
@@ -140,6 +150,12 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
case OFFICAL_REDUCE_DIAMONDS:
|
||||
reduceDiamondNum(ernos, type.getValue(), num, adminId, remark, busType);
|
||||
break;
|
||||
case OFFICAL_MINUS_GUILD_USD:
|
||||
adjustUsd(ernos, type.getValue(), num, adminId, remark, busType, Boolean.FALSE);
|
||||
break;
|
||||
case OFFICAL_PLUS_GUILD_USD:
|
||||
adjustUsd(ernos, type.getValue(), num, adminId, remark, busType, Boolean.TRUE);
|
||||
break;
|
||||
default:
|
||||
throw new AdminServiceException(BusiStatus.REQUEST_PARAM_ERROR);
|
||||
}
|
||||
@@ -169,7 +185,6 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
(userPurse)-> billRecordService.insertGeneralBillRecord(user.getUid(), recordIdStr, BillObjTypeEnum.OFFICIAL_GOLD_REDUCE, num.doubleValue(), userPurse));
|
||||
addGoldRecord(recordId, user, type, Constant.WalletCurrencyType.diamonds, num, optId, remark, busType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠送钻石
|
||||
*
|
||||
@@ -231,13 +246,13 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
|
||||
addGoldRecord(recordId, users, type, Constant.WalletCurrencyType.diamonds, num, adminId, remark, busType, actualAmount);
|
||||
|
||||
BillObjTypeEnum billObjTypeEnum = Constant.BillType.chargeByCompanyAccount.byteValue() == type? BillObjTypeEnum.CHARGE_BY_COMPANY_ACCOUNT: BillObjTypeEnum.OFFICIAL_GOLD_ADD;
|
||||
BillObjTypeEnum billObjTypeEnum = Constant.OfficialType.chargeByCompanyAccount.byteValue() == type? BillObjTypeEnum.CHARGE_BY_COMPANY_ACCOUNT: BillObjTypeEnum.OFFICIAL_GOLD_ADD;
|
||||
|
||||
UserPurse after = userPurseService.addDiamond(users.getUid(), num.doubleValue(), billObjTypeEnum,
|
||||
(userPurse)-> billRecordService.insertGeneralBillRecord(users.getUid(), recordIdStr, billObjTypeEnum, num.doubleValue(), userPurse));
|
||||
|
||||
// 增加充值记录
|
||||
if (Constant.BillType.chargeByCompanyAccount.byteValue() == type) {
|
||||
if (Constant.OfficialType.chargeByCompanyAccount.byteValue() == type) {
|
||||
BigDecimal amount = actualAmount.multiply(Constant.HUNDRED);
|
||||
String chargeRecordId = UUIDUtil.get();
|
||||
addChargeRecord(chargeRecordId, users.getUid(), num.longValue(), amount.longValue());
|
||||
@@ -316,13 +331,88 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 官方调整薪资(增加或减少)
|
||||
* @param ernos 用户耳伴号列表,多个用换行分隔
|
||||
* @param type 操作类型
|
||||
* @param num 调整数量
|
||||
* @param optId 操作人ID
|
||||
* @param remark 备注
|
||||
* @param busType 业务类型
|
||||
* @param isPlus 是否为增加操作 true:增加 false:减少
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void adjustUsd(String ernos, byte type, BigDecimal num, int optId, String remark, Integer busType, boolean isPlus) {
|
||||
|
||||
String lockval = null;
|
||||
try {
|
||||
lockval = this.jedisLockService.lock(RedisKey.lock_official_gold_send.getKey(), 3000);
|
||||
if (StringUtils.isEmpty(lockval)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
List<String> erbanNos = Arrays.asList(ernos.trim().split("\n"));
|
||||
Map<Long, GuildMember> guildMemberMap = new HashMap<>();
|
||||
Map<Long, Users> usersMap = new HashMap<>();
|
||||
for (String erbanNoStr : erbanNos) {
|
||||
Long erbanNo = Long.parseLong(erbanNoStr.trim());
|
||||
if (usersMap.containsKey(erbanNo)) {
|
||||
continue;
|
||||
}
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (u == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
Long uid = u.getUid();
|
||||
GuildMember guildMemberByUid = guildMemberService.getVaildGuildMemberByUid(uid);
|
||||
if (guildMemberByUid == null) {
|
||||
throw new AdminServiceException("ID:" + erbanNoStr + " but not in guild, not allow operate");
|
||||
}
|
||||
guildMemberMap.put(uid, guildMemberByUid);
|
||||
usersMap.put(uid, u);
|
||||
}
|
||||
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
Long uid = users.getUid();
|
||||
GuildMember guildMember = guildMemberMap.get(uid);
|
||||
|
||||
// 增加官方赠送活动记录
|
||||
addGoldRecord(recordId, users, type, Constant.WalletCurrencyType.usd, num, optId, remark, busType, null);
|
||||
|
||||
if (isPlus) {
|
||||
// 增加账户usd数量
|
||||
UserPurse userPurse = userPurseService.addGuildUsd(uid, num.doubleValue(), BillObjTypeEnum.PLUS_GUILD_USD,
|
||||
(up) -> billRecordService.insertGeneralBillRecord(uid, uid, BillObjTypeEnum.PLUS_GUILD_USD, num.doubleValue(), up));
|
||||
guildUsdBillRecordService.insert(UUIDUtil.get(), guildMember.getPartitionId(), guildMember.getId(), guildMember.getGuildId(), uid,
|
||||
guildMember.getId(), uid, GuildUsdOperateTypeEnum.SYSTEM_PLUS_USD, userPurse, null, num, null, recordId);
|
||||
logger.info("plusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type, num, recordId);
|
||||
} else {
|
||||
// 减少账户usd数量
|
||||
UserPurse userPurse = userPurseService.subGuildUsd(uid, num, BillObjTypeEnum.MIUNS_GUILD_USD, NOT_ENOUGH_GUILD_USD,
|
||||
(up)-> billRecordService.insertGeneralBillRecord(uid, uid, BillObjTypeEnum.MIUNS_GUILD_USD, num.doubleValue(), up));
|
||||
guildUsdBillRecordService.insert(UUIDUtil.get(), guildMember.getPartitionId(), guildMember.getId(), guildMember.getGuildId(), uid,
|
||||
guildMember.getId(), uid, GuildUsdOperateTypeEnum.SYSTEM_MIUNS_USD, userPurse, null, num, null, null);
|
||||
logger.info("minusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type, num, recordId);
|
||||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
this.jedisLockService.unlock(RedisKey.lock_official_gold_send.getKey(), lockval);
|
||||
}
|
||||
}
|
||||
|
||||
public long addGoldRecord(Long recordId, Users user, byte type, byte currencyType, BigDecimal num, int optId, String remark, Integer busType, BigDecimal actualAmount) {
|
||||
Long uid = user.getUid();
|
||||
BigDecimal diamondNum = null;
|
||||
BigDecimal goldNum = null;
|
||||
BigDecimal currentGoldNum = null;
|
||||
if (Constant.BillType.interSendGold.byteValue() == type
|
||||
|| Constant.BillType.clearUserGold.byteValue() == type) {
|
||||
if (Constant.OfficialType.interSendGold.byteValue() == type
|
||||
|| Constant.OfficialType.clearUserGold.byteValue() == type
|
||||
|| Constant.OfficialType.plusGuildUsd == type
|
||||
||Constant.OfficialType.miunsGuildUsd == type) {
|
||||
diamondNum = num;
|
||||
} else {
|
||||
goldNum = num;
|
||||
@@ -334,6 +424,8 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
currentGoldNum = BigDecimal.valueOf(userPurse.getCrystals()).add(num);
|
||||
} else if (currencyType == Constant.WalletCurrencyType.diamonds){
|
||||
currentGoldNum = BigDecimal.valueOf(userPurse.getDiamonds()).add(num);
|
||||
} else if (currencyType == Constant.WalletCurrencyType.usd){
|
||||
currentGoldNum = BigDecimal.valueOf(userPurse.getGuildUsd()).add(num);
|
||||
}
|
||||
}
|
||||
return addOfficialGoldRecord(recordId, uid, diamondNum, goldNum, currentGoldNum, type, currencyType, busType, optId, remark, actualAmount);
|
||||
|
@@ -41,11 +41,12 @@
|
||||
<result column="gold_num" property="goldNum" jdbcType="DOUBLE"/>
|
||||
<result column="radish_num" property="radishNum" jdbcType="BIGINT"/>
|
||||
<result column="diamonds_num" property="diamondsNum" jdbcType="DOUBLE"/>
|
||||
<result column="guild_usd" property="guildUsdNum" jdbcType="DOUBLE"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectUserWithGold" parameterType="java.util.Map" resultMap="BaseResultMap">
|
||||
/* SHARDINGSPHERE_HINT: WRITE_ROUTE_ONLY=true */
|
||||
select b.erban_no,b.nick,b.avatar,golds as gold_num, diamonds as diamonds_num, crystals as radish_num from
|
||||
select b.erban_no,b.nick,b.avatar,golds as gold_num, diamonds as diamonds_num, crystals as radish_num, guild_usd from
|
||||
user_purse as a
|
||||
join users as b on a.uid=b.uid
|
||||
where b.erban_no in
|
||||
|
@@ -34,86 +34,18 @@ public class Constant {
|
||||
public static Byte B = 2;// B面用户
|
||||
}
|
||||
|
||||
public static class BillType {
|
||||
// 账单类型:1充值2提现3消费订单支出4服务订单收入5刷礼物消费6收礼物收入7发个人红包消费8收到个人红包收入9房主佣金收入10注册送金币11分享送金币12官方送金币13关注公众号送金币
|
||||
public static Integer charge = 1; // 充值
|
||||
public static Integer getCash = 2; // 提现
|
||||
public static Integer orderPay = 3; // 消费订单支出
|
||||
public static Integer orderIncome = 4;// 服务订单收入
|
||||
public static Integer giftPay = 5; // 送礼物支出
|
||||
public static Integer giftIncome = 6; // 收礼物收入
|
||||
public static Integer redPackPay = 7; // 发个人红包消费
|
||||
public static Integer redPackIncome = 8; // 收到个人红包收入
|
||||
public static Integer roomOwnerIncome = 9; // 房主佣金收入
|
||||
public static Integer registSendGift = 10; // 注册送金币
|
||||
public static Integer shareGold = 11; // 分享送金币
|
||||
public static Integer interSendDiamond = 12; // 官方直接送钻石
|
||||
public static Integer followSendGold = 13; // 关注公众号送金币
|
||||
public static Integer exchangeDimondToGoldPay = 14; // 兑换钻石支出
|
||||
public static Integer exchangeDimondToGoldIncome = 15;// 兑换钻石收入
|
||||
|
||||
public static Integer hallowActRewardGold = 16; // 万圣节金币奖励
|
||||
public static Integer actReward = 17; // 活动奖励
|
||||
public static Integer chargeByCompanyAccount = 20; // 打款至公账充值金币
|
||||
|
||||
public static Integer redeemCode = 21; //兑换码兑换金币
|
||||
public static Integer draw = 23; //促销活动得金币
|
||||
public static Integer bonusPerDaySend = 24; //发送的
|
||||
public static Integer bonusPerDayRecv = 25; //钻石回馈账单
|
||||
public static Integer openNoble = 26; //开通贵族
|
||||
public static Integer renewNoble = 27; //续费贵族
|
||||
public static Integer roomNoble = 28; //房间内开通贵族分成
|
||||
public static Integer openNobleReturn = 29; //开通贵族
|
||||
public static Integer renewNobleReturn = 30; //续费贵族
|
||||
public static Integer purchaseCarGoods = 31; //购买座驾
|
||||
|
||||
public static Integer renewCarGoods = 32; //续费座驾
|
||||
public static Integer duibaDraw = 33; // 兑吧促销活动支出
|
||||
public static Integer duibaDrawReward = 34; // 兑吧促销活动奖励
|
||||
public static Integer giftMagicPay = 35; // 发送魔法支出
|
||||
public static Integer giftMagicIncome = 36; // 接收魔法收入
|
||||
|
||||
public static Integer monsterDrawReward = 37; // 打怪夺宝奖励
|
||||
|
||||
public static Integer giveCarGoods = 38; //座驾赠送
|
||||
|
||||
public static Integer purchaseHeadwear = 39; // 购买头饰
|
||||
public static Integer renewHeadwear = 40; // 续费头饰
|
||||
public static Integer donateHeadwear = 41; // 赠送头饰
|
||||
|
||||
public static Integer packetGetCash = 42; //红包提现
|
||||
|
||||
public static Integer buyOpenBoxKey = 45; //购买开箱子钥匙
|
||||
|
||||
public static Integer eggPrizeGold = 46; // 砸金蛋得金币
|
||||
|
||||
public static Integer roomFlowExtract = 47; //公会房间流水提成
|
||||
|
||||
public static Integer buyActivityPack = 48; //购买礼包
|
||||
|
||||
public static Integer drawGold = 49; //瓜分金币
|
||||
|
||||
public static Integer eternalHeartBuy = 50; //购买永恒之心
|
||||
|
||||
public static Integer officalDiamondReduce = 51; // 官方钻石支出
|
||||
|
||||
public static Integer nationalBuyFirework = 52; // 国庆活动购买礼花
|
||||
|
||||
public static Integer doubleElevenBuyGift = 53; // 双十一购买礼物
|
||||
|
||||
public static Integer sendGold = 54; // 主播赠送金币
|
||||
|
||||
public static Integer receiveGold = 55; // 受赠金币
|
||||
|
||||
public static Integer releaseGold = 56; // 流水发放
|
||||
|
||||
public static Integer activityBuyPack = 59; // 活动购买礼包
|
||||
|
||||
public static Integer interSendCrystal = 60; // 官方直接送水晶
|
||||
|
||||
public static Integer clearUserGold = 61; //用户金币清除
|
||||
|
||||
public static Integer interSendGold = 62; // 官方直接送金币
|
||||
/**
|
||||
*(对不上了,重新定义)该类转用官方金币操作类型
|
||||
*/
|
||||
public static class OfficialType {
|
||||
public static Byte interSendDiamond = 12; // 官方直接送钻石
|
||||
public static Byte actReward = 17; // 活动奖励
|
||||
public static Byte chargeByCompanyAccount = 20; // 打款至公账充值金币
|
||||
public static Byte officalDiamondReduce = 51; // 官方钻石支出
|
||||
public static Byte clearUserGold = 61; //用户金币清除
|
||||
public static Byte interSendGold = 62; // 官方直接送钻石
|
||||
public static Byte miunsGuildUsd = 63; // 官方直接消除薪资
|
||||
public static Byte plusGuildUsd = 64; // 官方直接赠送薪资
|
||||
}
|
||||
|
||||
public static class AppVersion {
|
||||
@@ -2599,6 +2531,7 @@ public class Constant {
|
||||
public static final Byte gold = 0; // 金币
|
||||
public static final Byte radish = 1; // 水晶
|
||||
public static final Byte diamonds = 2; //钻石
|
||||
public static final Byte usd = 4;
|
||||
}
|
||||
|
||||
public static class PrizePoolType {
|
||||
|
@@ -244,6 +244,9 @@ public enum BillObjTypeEnum {
|
||||
USER_EVENT_REFUND_BANNER(163, "用户活动审核失败退款", BillTypeEnum.OUT, CurrencyEnum.DIAMOND, BillDomainTypeEnum.USER_EVENT),
|
||||
|
||||
FIRST_CHARGE_REWARD_BILL(164, "首充奖励", BillTypeEnum.IN, CurrencyEnum.DIAMOND, BillDomainTypeEnum.FIRST_CHARGE),
|
||||
PLUS_GUILD_USD( 165, "官方增加薪资", BillTypeEnum.IN, CurrencyEnum.GUILD_USD, BillDomainTypeEnum.GUILD_USD),
|
||||
|
||||
MIUNS_GUILD_USD( 166, "官方扣除薪资", BillTypeEnum.OUT, CurrencyEnum.GUILD_USD, BillDomainTypeEnum.GUILD_USD),
|
||||
;
|
||||
|
||||
BillObjTypeEnum(int value, String desc, BillTypeEnum type, CurrencyEnum currency, BillDomainTypeEnum domain) {
|
||||
|
@@ -2,26 +2,30 @@ package com.accompany.business.constant;
|
||||
|
||||
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.core.enumeration.CurrencyEnum;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* 后台管理赠送类型
|
||||
*/
|
||||
public enum OfficalSendTypeEnum {
|
||||
|
||||
OFFICAL_GOLD(Constant.BillType.interSendGold.byteValue(), "官方赠送钻石", (byte)0),
|
||||
OFFICAL_DIAMOND(Constant.BillType.interSendDiamond.byteValue(), "官方赠送金币", (byte)2),
|
||||
OFFICAL_GOLD(Constant.OfficialType.interSendGold, "官方赠送钻石", (byte)0),
|
||||
OFFICAL_DIAMOND(Constant.OfficialType.interSendDiamond, "官方赠送金币", (byte)2),
|
||||
|
||||
ACTIVITY_GOLD(Constant.BillType.actReward.byteValue(), "活动奖励钻石", (byte)0),
|
||||
ACTIVITY_GOLD(Constant.OfficialType.actReward, "活动奖励钻石", (byte)0),
|
||||
|
||||
COMPANY_ACCOUNT_DIAMOND(Constant.BillType.chargeByCompanyAccount.byteValue(), "公款充值金币", (byte)2),
|
||||
COMPANY_ACCOUNT_DIAMOND(Constant.OfficialType.chargeByCompanyAccount, "公款充值金币", (byte)2),
|
||||
|
||||
CLEAR_USER_GOLD(Constant.BillType.clearUserGold.byteValue(), "后台清除钻石", (byte)0),
|
||||
CLEAR_USER_GOLD(Constant.OfficialType.clearUserGold, "后台清除钻石", (byte)0),
|
||||
|
||||
OFFICAL_REDUCE_DIAMONDS(Constant.BillType.officalDiamondReduce.byteValue(),"官方金币消除", (byte)2)
|
||||
OFFICAL_REDUCE_DIAMONDS(Constant.OfficialType.officalDiamondReduce,"官方金币消除", (byte)2),
|
||||
|
||||
OFFICAL_MINUS_GUILD_USD(Constant.OfficialType.miunsGuildUsd, "官方消除薪资", CurrencyEnum.GUILD_USD.getValue()),
|
||||
|
||||
OFFICAL_PLUS_GUILD_USD(Constant.OfficialType.plusGuildUsd,"官方赠送薪资", CurrencyEnum.GUILD_USD.getValue()),
|
||||
;
|
||||
|
||||
private byte value;
|
||||
|
@@ -50,6 +50,14 @@ public enum GuildUsdOperateTypeEnum {
|
||||
false, CurrencyEnum.GUILD_USD, null, null,
|
||||
BillObjTypeEnum.GUILD_USD_TO_PLATFORM_OUT, null),
|
||||
|
||||
SYSTEM_PLUS_USD(9, null, null, null,
|
||||
false, CurrencyEnum.GUILD_USD, null, null,
|
||||
BillObjTypeEnum.PLUS_GUILD_USD, null),
|
||||
|
||||
SYSTEM_MIUNS_USD(10, null, null, null,
|
||||
false, CurrencyEnum.GUILD_USD, null, null,
|
||||
null, BillObjTypeEnum.MIUNS_GUILD_USD),
|
||||
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
Reference in New Issue
Block a user