后台-赠送钻石水晶-提取公共方法并实现对应的机器人推送
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
package com.accompany.admin.service.push;
|
||||
|
||||
import com.accompany.admin.model.AdminUser;
|
||||
import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.common.config.WebSecurityConfig;
|
||||
import com.accompany.common.constant.AppEnum;
|
||||
import com.accompany.common.push.MarkdownMessage;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.message.MessageRobotPushService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class EnterpriseWeChatPushAdminService extends MessageRobotPushService {
|
||||
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired
|
||||
private WebSecurityConfig webSecurityConfig;
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
|
||||
public void pushMessage(Map<Long, Users> usersMap, Integer partitionId, String title, int adminId, BigDecimal amount, String remark) {
|
||||
if (envComponent.getDevOrNativeEnv()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String userDescList = usersMap.values().stream().map(u-> String.format("%s(%d)", u.getNick(), u.getErbanNo())).collect(Collectors.joining(","));
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
|
||||
AdminUser adminUser = adminUserService.getAdminUserById(adminId);
|
||||
MarkdownMessage msg = new MarkdownMessage();
|
||||
msg.addTitle(MarkdownMessage.getHeaderText(3, adminUser.getUsername() + title));
|
||||
msg.add(MarkdownMessage.getReferenceText(title));
|
||||
msg.add(MarkdownMessage.getReferenceText("APP应用: ") + AppEnum.getCurApp().getValue());
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送数量: " + amount.toPlainString()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送分区: " + partitionEnum.getDesc()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送人数: " + usersMap.size()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送用户: " + userDescList));
|
||||
msg.add(MarkdownMessage.getReferenceText("操作者: " + adminUser.getUsername()));
|
||||
msg.add(MarkdownMessage.getReferenceText("备注: " + remark));
|
||||
// 发送消息
|
||||
this.pushMessageByKey(webSecurityConfig.getOfficialDingPushKey(), msg, false);
|
||||
}
|
||||
|
||||
}
|
@@ -1,12 +1,10 @@
|
||||
package com.accompany.admin.service.record;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.admin.common.AdminConstants;
|
||||
import com.accompany.admin.mapper.OfficialGoldRecordMapper;
|
||||
import com.accompany.admin.mapper.OfficialGoldRecordMapperExpand;
|
||||
import com.accompany.admin.model.AdminUser;
|
||||
import com.accompany.admin.model.OfficialGoldRecord;
|
||||
import com.accompany.admin.service.push.EnterpriseWeChatPushAdminService;
|
||||
import com.accompany.admin.model.AdminUser;
|
||||
import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.admin.vo.OfficialGoldAllRecordVo;
|
||||
import com.accompany.admin.vo.OfficialGoldRecordVo;
|
||||
@@ -15,20 +13,22 @@ 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;
|
||||
import com.accompany.business.vo.charge.CommonRecharge4ActVo;
|
||||
import com.accompany.common.config.WebSecurityConfig;
|
||||
import com.accompany.common.constant.AppEnum;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.push.MarkdownMessage;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.common.utils.UUIDUtil;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
@@ -37,7 +37,7 @@ import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.base.BaseService;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.service.message.MessageRobotPushService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.payment.event.ChargeSuccessEvent;
|
||||
import com.accompany.payment.event.CommonRecharge4ActEvent;
|
||||
@@ -53,14 +53,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
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 {
|
||||
|
||||
@@ -79,16 +77,8 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
@Autowired
|
||||
private OfficialGoldRecordMapperExpand officialGoldRecordMapperExpand;
|
||||
@Autowired
|
||||
private WebConfigService webConfigService;
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private OfficialGoldBusTypeAdminService officialGoldBusTypeAdminService;
|
||||
@Autowired
|
||||
private EnterpriseWeChatPushAdminService enterpriseWeChatPushAdminService;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private OfficialGoldRoleLimitService officialGoldRoleLimitService;
|
||||
@@ -96,6 +86,14 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
private GuildMemberService guildMemberService;
|
||||
@Autowired
|
||||
private GuildUsdBillRecordService guildUsdBillRecordService;
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired
|
||||
private WebSecurityConfig webSecurityConfig;
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
@Autowired
|
||||
private MessageRobotPushService messageRobotPushService;
|
||||
|
||||
public List<Map<String, Object>> listType(int adminId){
|
||||
boolean hasLimit = officialGoldRoleLimitService.hasLimit(adminId);
|
||||
@@ -117,60 +115,179 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
* 后台赠送金币、萝卜
|
||||
*
|
||||
* @param ernos
|
||||
* @param type
|
||||
* @param typeEnum
|
||||
* @param num
|
||||
* @param adminId
|
||||
* @param actualAmount
|
||||
* @param remark
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handle(String ernos, OfficalSendTypeEnum type, BigDecimal num, int adminId,
|
||||
BigDecimal actualAmount, String remark, Integer busType) throws Exception {
|
||||
if (type == null) {
|
||||
public void handle(String ernos, OfficalSendTypeEnum typeEnum, BigDecimal num, int adminId,
|
||||
String remark, Integer busType) {
|
||||
if (typeEnum == null) {
|
||||
throw new AdminServiceException(BusiStatus.REQUEST_PARAM_ERROR);
|
||||
}
|
||||
|
||||
if (!OfficalSendTypeEnum.OFFICAL_DIAMOND.equals(type) && officialGoldRoleLimitService.hasLimit(adminId)) {
|
||||
if (!OfficalSendTypeEnum.OFFICAL_DIAMOND.equals(typeEnum) && officialGoldRoleLimitService.hasLimit(adminId)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
switch (type){
|
||||
case OFFICAL_GOLD:
|
||||
giveGold(ernos, type.getValue(), num, adminId, remark, busType);
|
||||
break;
|
||||
case OFFICAL_DIAMOND:
|
||||
case COMPANY_ACCOUNT_DIAMOND:
|
||||
giveDiamond(ernos, type.getValue(), num, adminId, actualAmount, remark, busType);
|
||||
break;
|
||||
//case OFFICAL_RADISH:
|
||||
// giveCrystal(ernos, type.getValue(), num, adminId, remark, busType);
|
||||
// return BusiResult.success();
|
||||
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;
|
||||
case OFFICAL_PLUS_GUILD_CRYSTAL:
|
||||
adjustGuildCrystal(ernos, type.getValue(), num, adminId, remark, busType, Boolean.TRUE);
|
||||
break;
|
||||
case OFFICAL_MINUS_GUILD_CRYSTAL:
|
||||
adjustGuildCrystal(ernos, type.getValue(), num, adminId, remark, busType, Boolean.FALSE);
|
||||
break;
|
||||
default:
|
||||
throw new AdminServiceException(BusiStatus.REQUEST_PARAM_ERROR);
|
||||
if (OfficalSendTypeEnum.OFFICAL_DIAMOND.equals(typeEnum)
|
||||
&& officialGoldRoleLimitService.overLimit(adminId, num)){
|
||||
throw new AdminServiceException("本月的金币打款已经封顶");
|
||||
}
|
||||
|
||||
// 提取用户查询和分区检查逻辑到统一位置
|
||||
List<String> erbanNos = Arrays.asList(ernos.trim().split("\n"));
|
||||
Map<Long, Users> usersMap = erbanNos.parallelStream().map(Long::parseLong).distinct()
|
||||
.map(erbanNo->{
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (u == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
return u;
|
||||
})
|
||||
.collect(Collectors.toMap(Users::getErbanNo, u->u));
|
||||
List<Integer> partitionIds = usersMap.values().stream().map(Users::getPartitionId).distinct().toList();
|
||||
if (partitionIds.size() > 1){
|
||||
throw new ServiceException(BusiStatus.PARTITION_ERROR, "分区不一致");
|
||||
}
|
||||
Integer partitionId = partitionIds.get(0);
|
||||
|
||||
BigDecimal actualAmount = num.divide(typeEnum.getCurrencyType().getExchangeRate(), 2 , RoundingMode.HALF_UP);
|
||||
|
||||
// 统一获取锁
|
||||
String lockval = null;
|
||||
try {
|
||||
lockval = this.jedisLockService.lock(RedisKey.lock_official_gold_send.getKey(), 3000);
|
||||
if (StringUtils.isEmpty(lockval)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
// 统一发送微信提示消息
|
||||
pushEnterpriseWeChatMessage(usersMap, partitionId, typeEnum.getDesc(), adminId, num, remark);
|
||||
|
||||
switch (typeEnum){
|
||||
case OFFICAL_GOLD:
|
||||
giveGold(usersMap, typeEnum, num, adminId, remark, busType, actualAmount);
|
||||
break;
|
||||
case OFFICAL_DIAMOND:
|
||||
case COMPANY_ACCOUNT_DIAMOND:
|
||||
giveDiamond(usersMap, typeEnum, num, adminId, remark, busType, actualAmount);
|
||||
break;
|
||||
case OFFICAL_REDUCE_DIAMONDS:
|
||||
reduceDiamondNum(usersMap, typeEnum, num, adminId, remark, busType, actualAmount);
|
||||
break;
|
||||
case OFFICAL_MINUS_GUILD_USD:
|
||||
adjustUsd(usersMap, typeEnum, num, adminId, remark, busType, Boolean.FALSE, actualAmount);
|
||||
break;
|
||||
case OFFICAL_PLUS_GUILD_USD:
|
||||
adjustUsd(usersMap, typeEnum, num, adminId, remark, busType, Boolean.TRUE, actualAmount);
|
||||
break;
|
||||
case OFFICAL_PLUS_GUILD_CRYSTAL:
|
||||
adjustGuildCrystal(usersMap, typeEnum, num, adminId, remark, busType, Boolean.TRUE, actualAmount);
|
||||
break;
|
||||
case OFFICAL_MINUS_GUILD_CRYSTAL:
|
||||
adjustGuildCrystal(usersMap, typeEnum, num, adminId, remark, busType, Boolean.FALSE, actualAmount);
|
||||
break;
|
||||
case CLEAR_USER_GOLD:
|
||||
clearUserGold(usersMap, num, adminId, actualAmount);
|
||||
break;
|
||||
default:
|
||||
throw new AdminServiceException(BusiStatus.REQUEST_PARAM_ERROR);
|
||||
}
|
||||
} finally {
|
||||
// 统一释放锁
|
||||
if (StringUtils.isNotEmpty(lockval)) {
|
||||
this.jedisLockService.unlock(RedisKey.lock_official_gold_send.getKey(), lockval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠送钻石
|
||||
*
|
||||
* @param usersMap 用户映射
|
||||
* @param type 赠送类型
|
||||
* @param num 赠送数量
|
||||
* @return
|
||||
*/
|
||||
public void giveDiamond(Map<Long, Users> usersMap, OfficalSendTypeEnum type, BigDecimal num, int adminId, String remark, Integer busType,
|
||||
BigDecimal actualAmount) {
|
||||
|
||||
// AdminDict adminDict = adminDictService.getOneAdminDict("official_gold_limit_" + type, "limit_time");
|
||||
// AdminDict adminDict2 = adminDictService.getOneAdminDict("official_gold_limit_" + type, "limit_count");
|
||||
// int limitTime = Integer.valueOf(adminDict.getDictval());
|
||||
// int limitCount = Integer.valueOf(adminDict2.getDictval());
|
||||
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
// if (!isCanGiveGold(users, type, num, limitTime, limitCount)) {
|
||||
// busiResult.setCode(-1);
|
||||
// busiResult.setMessage("兔兔号为" + erNo + "的用户被赠送的次数大于" + limitTime + "或者金币余额大于" + limitCount);
|
||||
// return busiResult;
|
||||
// }
|
||||
// 增加官方赠送活动记录
|
||||
long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
String recordIdStr = String.valueOf(recordId);
|
||||
|
||||
addGoldRecord(recordId, users, type.getValue(), Constant.WalletCurrencyType.diamonds, num, adminId, remark, busType, actualAmount);
|
||||
|
||||
BillObjTypeEnum billObjTypeEnum = Constant.OfficialType.chargeByCompanyAccount.byteValue() == type.getValue()? 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.OfficialType.chargeByCompanyAccount.byteValue() == type.getValue()) {
|
||||
BigDecimal amount = actualAmount.multiply(Constant.HUNDRED);
|
||||
String chargeRecordId = UUIDUtil.get();
|
||||
addChargeRecord(chargeRecordId, users.getUid(), num.longValue(), amount.longValue());
|
||||
this.applicationContext.publishEvent(new CommonRecharge4ActEvent(
|
||||
CommonRecharge4ActVo.builder()
|
||||
.uid(users.getUid())
|
||||
.channel(Constant.ChargeChannel.company)
|
||||
.chargeStatus(Constant.ChargeRecordStatus.finish)
|
||||
.totalGoldNum(num.longValue())
|
||||
.createTime(new Date()).build()));
|
||||
}
|
||||
try {
|
||||
userPurseService.sendSysMsgByModifyGold(after);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("sendSysMsgByModifyGold error, uid:" + users.getUid(), e);
|
||||
}
|
||||
logger.info("giveGold success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type.getValue(), num, recordId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠送金币
|
||||
*
|
||||
* @param usersMap 用户映射
|
||||
* @param num 赠送数量
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void giveGold(Map<Long, Users> usersMap, OfficalSendTypeEnum typeEnum, BigDecimal num, int optId, String remark, Integer busType,
|
||||
BigDecimal actualAmount) {
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
// 增加官方赠送活动记录
|
||||
addGoldRecord(recordId, users, typeEnum.getValue(), Constant.WalletCurrencyType.gold, num, optId, remark, busType, actualAmount);
|
||||
// 更新账户钻石数量
|
||||
userPurseService.addGold(users.getUid(), num.doubleValue(), BillObjTypeEnum.INTER_SEND_DIAMOND);
|
||||
|
||||
logger.info("giveGold success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), typeEnum.getValue(), num, recordId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 官方消钻
|
||||
*
|
||||
* @param ernos
|
||||
* @param usersMap 用户映射
|
||||
* @param type
|
||||
* @param num
|
||||
* @param optId
|
||||
@@ -180,166 +297,19 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void reduceDiamondNum(String ernos, byte type, BigDecimal num, int optId, String remark, Integer busType) {
|
||||
Users user = usersBaseService.getUsersByErBanNo(Long.valueOf(ernos.trim()));
|
||||
if (user == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
public void reduceDiamondNum(Map<Long, Users> usersMap, OfficalSendTypeEnum type, BigDecimal num, int optId, String remark, Integer busType, BigDecimal actualAmount) {
|
||||
for (Users user : usersMap.values()) {
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
String recordIdStr = String.valueOf(recordId);
|
||||
userPurseService.subDiamond(user.getUid(), num.doubleValue(), BillObjTypeEnum.OFFICIAL_GOLD_REDUCE,
|
||||
(userPurse)-> billRecordService.insertGeneralBillRecord(user.getUid(), recordIdStr, BillObjTypeEnum.OFFICIAL_GOLD_REDUCE, num.doubleValue(), userPurse));
|
||||
addGoldRecord(recordId, user, type.getValue(), Constant.WalletCurrencyType.diamonds, num, optId, remark, busType, actualAmount);
|
||||
}
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
String recordIdStr = String.valueOf(recordId);
|
||||
userPurseService.subDiamond(user.getUid(), num.doubleValue(), BillObjTypeEnum.OFFICIAL_GOLD_REDUCE,
|
||||
(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);
|
||||
}
|
||||
/**
|
||||
* 赠送钻石
|
||||
*
|
||||
* @param ernos 耳伴号,多个耳伴号用换行符分隔
|
||||
* @param type 赠送类型
|
||||
* @param num 赠送数量
|
||||
* @return
|
||||
*/
|
||||
public void giveDiamond(String ernos, byte type, BigDecimal num, int adminId, BigDecimal actualAmount, String remark, Integer busType) {
|
||||
String lockval = null;
|
||||
try {
|
||||
lockval = this.jedisLockService.lock(RedisKey.lock_official_gold_send.getKey(), 3000);
|
||||
if (StringUtils.isEmpty(lockval)) {
|
||||
throw new AdminServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
OfficalSendTypeEnum typeEnum = OfficalSendTypeEnum.get(type);
|
||||
|
||||
if (OfficalSendTypeEnum.OFFICAL_DIAMOND.equals(typeEnum)
|
||||
&& officialGoldRoleLimitService.overLimit(adminId, num)){
|
||||
throw new AdminServiceException("本月的金币打款已经封顶");
|
||||
}
|
||||
|
||||
// 根据配置,发送微信提示消息
|
||||
List<String> erbanNos = Arrays.asList(ernos.trim().split("\n"));
|
||||
Map<Long, Users> usersMap = erbanNos.parallelStream().map(Long::parseLong).distinct()
|
||||
.map(erbanNo->{
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (u == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
return u;
|
||||
})
|
||||
.collect(Collectors.toMap(Users::getErbanNo, u->u));
|
||||
List<Integer> partitionIds = usersMap.values().stream().map(Users::getPartitionId).distinct().toList();
|
||||
if (partitionIds.size() > 1){
|
||||
throw new ServiceException(BusiStatus.PARTITION_ERROR, "分区不一致");
|
||||
}
|
||||
Integer partitionId = partitionIds.get(0);
|
||||
|
||||
enterpriseWeChatPushAdminService.pushMessage(usersMap, partitionId, typeEnum.getDesc(), adminId, num, remark);
|
||||
// officialGoldSendMsg(ernos,num,optId,remark);
|
||||
|
||||
// AdminDict adminDict = adminDictService.getOneAdminDict("official_gold_limit_" + type, "limit_time");
|
||||
// AdminDict adminDict2 = adminDictService.getOneAdminDict("official_gold_limit_" + type, "limit_count");
|
||||
// int limitTime = Integer.valueOf(adminDict.getDictval());
|
||||
// int limitCount = Integer.valueOf(adminDict2.getDictval());
|
||||
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
// if (!isCanGiveGold(users, type, num, limitTime, limitCount)) {
|
||||
// busiResult.setCode(-1);
|
||||
// busiResult.setMessage("兔兔号为" + erNo + "的用户被赠送的次数大于" + limitTime + "或者金币余额大于" + limitCount);
|
||||
// return busiResult;
|
||||
// }
|
||||
// 增加官方赠送活动记录
|
||||
long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
String recordIdStr = String.valueOf(recordId);
|
||||
|
||||
addGoldRecord(recordId, users, type, Constant.WalletCurrencyType.diamonds, num, adminId, remark, busType, actualAmount);
|
||||
|
||||
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.OfficialType.chargeByCompanyAccount.byteValue() == type) {
|
||||
BigDecimal amount = actualAmount.multiply(Constant.HUNDRED);
|
||||
String chargeRecordId = UUIDUtil.get();
|
||||
addChargeRecord(chargeRecordId, users.getUid(), num.longValue(), amount.longValue());
|
||||
this.applicationContext.publishEvent(new CommonRecharge4ActEvent(
|
||||
CommonRecharge4ActVo.builder()
|
||||
.uid(users.getUid())
|
||||
.channel(Constant.ChargeChannel.company)
|
||||
.chargeStatus(Constant.ChargeRecordStatus.finish)
|
||||
.totalGoldNum(num.longValue())
|
||||
.createTime(new Date()).build()));
|
||||
}
|
||||
try {
|
||||
userPurseService.sendSysMsgByModifyGold(after);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("sendSysMsgByModifyGold error, uid:" + users.getUid(), e);
|
||||
}
|
||||
logger.info("giveGold success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type, num, recordId);
|
||||
}
|
||||
} finally {
|
||||
this.jedisLockService.unlock(RedisKey.lock_official_gold_send.getKey(), lockval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠送钻石
|
||||
*
|
||||
* @param ernos 耳伴号,多个耳伴号用换行符分隔
|
||||
* @param type 赠送类型
|
||||
* @param num 赠送数量
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void giveGold(String ernos, byte type, BigDecimal num, int optId, String remark, Integer busType) {
|
||||
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, Users> usersMap = erbanNos.parallelStream().map(Long::parseLong).distinct()
|
||||
.map(erbanNo->{
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (u == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
return u;
|
||||
})
|
||||
.collect(Collectors.toMap(Users::getErbanNo, u->u));
|
||||
List<Integer> partitionIds = usersMap.values().stream().map(Users::getPartitionId).distinct().collect(Collectors.toList());
|
||||
if (partitionIds.size() > 1){
|
||||
throw new ServiceException(BusiStatus.PARTITION_ERROR, "分区不一致");
|
||||
}
|
||||
Integer partitionId = partitionIds.get(0);
|
||||
|
||||
enterpriseWeChatPushAdminService.pushMessage(usersMap, partitionId, "后台赠送金币", optId, num, remark);
|
||||
// officialGoldSendMsg(ernos,num,optId,remark);
|
||||
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
// 增加官方赠送活动记录
|
||||
addGoldRecord(recordId, users, type, Constant.WalletCurrencyType.gold, num, optId, remark, busType, null);
|
||||
// 更新账户钻石数量
|
||||
userPurseService.addGold(users.getUid(), num.doubleValue(), BillObjTypeEnum.INTER_SEND_DIAMOND);
|
||||
|
||||
logger.info("giveGold success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type, num, recordId);
|
||||
}
|
||||
} finally {
|
||||
this.jedisLockService.unlock(RedisKey.lock_official_gold_send.getKey(), lockval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 官方调整薪资(增加或减少)
|
||||
* @param ernos 用户耳伴号列表,多个用换行分隔
|
||||
* @param usersMap 用户映射
|
||||
* @param type 操作类型
|
||||
* @param num 调整数量
|
||||
* @param optId 操作人ID
|
||||
@@ -349,70 +319,47 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
* @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);
|
||||
public void adjustUsd(Map<Long, Users> usersMap, OfficalSendTypeEnum type, BigDecimal num, int optId, String remark, Integer busType, boolean isPlus, BigDecimal actualAmount) {
|
||||
Map<Long, GuildMember> guildMemberMap = new HashMap<>();
|
||||
for (Users u : usersMap.values()) {
|
||||
Long uid = u.getUid();
|
||||
GuildMember guildMemberByUid = guildMemberService.getVaildGuildMemberByUid(uid);
|
||||
if (guildMemberByUid == null) {
|
||||
throw new AdminServiceException("ID:" + u.getErbanNo() + " but not in guild, not allow operate");
|
||||
}
|
||||
guildMemberMap.put(uid, guildMemberByUid);
|
||||
}
|
||||
|
||||
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.getValue(), Constant.WalletCurrencyType.guildUsd, num, optId, remark, busType, actualAmount);
|
||||
|
||||
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, null, userPurse, num, null, recordId, remark);
|
||||
logger.info("plusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type.getValue(), num, recordId);
|
||||
} else {
|
||||
// 减少账户usd数量
|
||||
UserPurse userPurse = userPurseService.subGuildUsd(uid, num, BillObjTypeEnum.MIUNS_GUILD_USD, BusiStatus.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, recordId, remark);
|
||||
logger.info("minusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type.getValue(), num, recordId);
|
||||
}
|
||||
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
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.guildUsd, 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, null, userPurse, num, null, recordId, remark);
|
||||
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, recordId, remark);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 官方调整薪资(增加或减少)
|
||||
* @param ernos 用户耳伴号列表,多个用换行分隔
|
||||
* 官方调整水晶(增加或减少)
|
||||
* @param usersMap 用户映射
|
||||
* @param type 操作类型
|
||||
* @param num 调整数量
|
||||
* @param optId 操作人ID
|
||||
@@ -422,53 +369,46 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void adjustGuildCrystal(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);
|
||||
public void adjustGuildCrystal(Map<Long, Users> usersMap, OfficalSendTypeEnum type, BigDecimal num, int optId, String remark, Integer busType, boolean isPlus, BigDecimal actualAmount) {
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
Long uid = users.getUid();
|
||||
|
||||
// 增加官方赠送活动记录
|
||||
addGoldRecord(recordId, users, type.getValue(), Constant.WalletCurrencyType.guildCrystal, num, optId, remark, busType, actualAmount);
|
||||
|
||||
if (isPlus) {
|
||||
// 增加账户usd数量
|
||||
userPurseService.addGuildCrystal(uid, num.doubleValue(), BillObjTypeEnum.OFFICIAL_PLUS_GUILD_CRYSTAL);
|
||||
logger.info("plusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type.getValue(), num, recordId);
|
||||
} else {
|
||||
// 减少账户usd数量
|
||||
userPurseService.subGuildCrystal(uid, num.doubleValue(), BillObjTypeEnum.OFFICIAL_MIUNS_GUILD_CRYSTAL);
|
||||
logger.info("minusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type.getValue(), num, recordId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> erbanNos = Arrays.asList(ernos.trim().split("\n"));
|
||||
|
||||
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();
|
||||
|
||||
usersMap.put(uid, u);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void clearUserGold(Map<Long, Users> usersMap, BigDecimal num, Integer adminId, BigDecimal actualAmount) {
|
||||
for (Users users: usersMap.values()) {
|
||||
Long uid = users.getUid();
|
||||
UserPurse userPurse = userPurseService.queryUserPurse(uid);
|
||||
BigDecimal golds = BigDecimal.valueOf(userPurse.getGolds());
|
||||
if (golds.compareTo(num) < 0) {
|
||||
throw new AdminServiceException("[" + users.getErbanNo() + "]的用户金币金额低于" + num);
|
||||
}
|
||||
|
||||
// 分隔耳伴号,多个耳伴号用换行分隔
|
||||
for (Users users : usersMap.values()) {
|
||||
Long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
Long uid = users.getUid();
|
||||
|
||||
// 增加官方赠送活动记录
|
||||
addGoldRecord(recordId, users, type, Constant.WalletCurrencyType.guildCrystal, num, optId, remark, busType, null);
|
||||
|
||||
if (isPlus) {
|
||||
// 增加账户usd数量
|
||||
userPurseService.addGuildCrystal(uid, num.doubleValue(), BillObjTypeEnum.OFFICIAL_PLUS_GUILD_CRYSTAL);
|
||||
logger.info("plusUsd success, erpan_no: {}, type: {}, num: {}, recordId: {}", users.getErbanNo(), type, num, recordId);
|
||||
} else {
|
||||
// 减少账户usd数量
|
||||
userPurseService.subGuildCrystal(uid, num.doubleValue(), BillObjTypeEnum.OFFICIAL_MIUNS_GUILD_CRYSTAL);
|
||||
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);
|
||||
long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
String recordIdStr = String.valueOf(recordId);
|
||||
//扣减金币
|
||||
userPurse = userPurseService.subGold(uid, num.doubleValue(), BillObjTypeEnum.CLEAR_USER_GOLD,
|
||||
(up)-> billRecordService.insertGeneralBillRecord(uid, recordIdStr, BillObjTypeEnum.CLEAR_USER_GOLD, num.doubleValue(), up));
|
||||
//获取更新后的金额
|
||||
BigDecimal currentGoldNum = BigDecimal.valueOf(userPurse.getGolds());
|
||||
//增加官方操作记录
|
||||
addOfficialGoldRecord(recordId, uid, null, num, currentGoldNum, OfficalSendTypeEnum.CLEAR_USER_GOLD.getValue(),
|
||||
Constant.WalletCurrencyType.gold, BillObjTypeEnum.CLEAR_USER_GOLD.getValue(), adminId, BillObjTypeEnum.CLEAR_USER_GOLD.getDesc(), actualAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,110 +592,6 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台金币充值根据配置,发送微信消息
|
||||
*
|
||||
* @param ernos
|
||||
* @param num
|
||||
* @param optId
|
||||
* @param remark
|
||||
*/
|
||||
public void officialGoldSendMsg(String ernos, long num, int optId, String remark) {
|
||||
boolean flag = true;//true为金额提示消息,false为笔数提示消息
|
||||
String cusDate = DateTimeUtil.getTodayStr();
|
||||
Integer limitTime = Integer.valueOf(webConfigService.getSingleConf(AdminConstants.OFFICIAL_GOLD_LIMIT_TIME));
|
||||
Integer limitGold = Integer.valueOf(webConfigService.getSingleConf(AdminConstants.OFFICIAL_GOLD_LIMIT_GOLD));
|
||||
String openIds = webConfigService.getSingleConf(AdminConstants.OFFICIAL_GOLD_NOTIFY_MEMBER);
|
||||
Assert.notNull(openIds, "通知的openIds不能为空");
|
||||
List<String> openIdList = Arrays.asList(openIds.split(","));
|
||||
|
||||
//获取操作人名字
|
||||
AdminUser user = adminUserService.getAdminUserById(optId);
|
||||
Assert.notNull(user, "该操作人不存在!");
|
||||
//当日累计一次
|
||||
Double rechargeTime = jedisService.zincrby(RedisKey.official_gold_limit_time.getKey(), 1.0, cusDate);
|
||||
//判断后台充值金额是否需要发送消息
|
||||
if (rechargeTime >= limitTime) {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
//根据openId发送微信消息
|
||||
boolean finalFlag = flag;
|
||||
if (rechargeTime >= limitTime || num >= limitGold) {
|
||||
openIdList.forEach((openID) -> {
|
||||
sendMsg(ernos, num, user.getUsername(), remark, rechargeTime.intValue(), finalFlag, openID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送微信消息
|
||||
*
|
||||
* @param ernos
|
||||
* @param num
|
||||
* @param optName
|
||||
* @param remark
|
||||
* @param countTime
|
||||
* @param flag
|
||||
* @param openId
|
||||
*/
|
||||
public void sendMsg(String ernos, long num, String optName, String remark, int countTime, boolean flag, String openId) {
|
||||
String first = "耳伴管理系统";
|
||||
String keyword1 = "后台管理系统金币充值提醒";
|
||||
String keyword2 = "充值人:" + optName + ",充值:" + num + "元,被充值人:" + ernos + ",原因:" + remark + ",当日累计笔数:" + countTime;
|
||||
String keyword3 = "提醒类型:";
|
||||
if (flag) {
|
||||
keyword3 += "金额";
|
||||
} else {
|
||||
keyword3 += "笔数";
|
||||
}
|
||||
String keyword4 = "充值时间:" + DateTimeUtil.convertDate(new Date(), "yyyy-MM-dd hh:mm");
|
||||
//wxPubService.sendAlertMsg(openId,first,keyword1,keyword2,keyword3,keyword4,"");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void clearUserGold(String erBanNos, BigDecimal num, Integer adminId) {
|
||||
if (StrUtil.isEmpty(erBanNos)) {
|
||||
throw new AdminServiceException("ID不能为空");
|
||||
}
|
||||
|
||||
// 根据配置,发送微信提示消息
|
||||
List<String> erbanNos = Arrays.asList(erBanNos.trim().split("\n"));
|
||||
Map<Long, Users> usersMap = erbanNos.parallelStream().map(Long::parseLong).distinct()
|
||||
.map(erbanNo->{
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (u == null) {
|
||||
throw new AdminServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
return u;
|
||||
})
|
||||
.collect(Collectors.toMap(Users::getErbanNo, u->u));
|
||||
List<Integer> partitionIds = usersMap.values().stream().map(Users::getPartitionId).distinct().collect(Collectors.toList());
|
||||
if (partitionIds.size() > 1){
|
||||
throw new ServiceException(BusiStatus.PARTITION_ERROR, "分区不一致");
|
||||
}
|
||||
|
||||
for (Users users: usersMap.values()) {
|
||||
Long uid = users.getUid();
|
||||
UserPurse userPurse = userPurseService.queryUserPurse(uid);
|
||||
BigDecimal golds = BigDecimal.valueOf(userPurse.getGolds());
|
||||
if (golds.compareTo(num) < 0) {
|
||||
throw new AdminServiceException("[" + users.getErbanNo() + "]的用户金币金额低于" + num);
|
||||
}
|
||||
long recordId = DefaultIdentifierGenerator.getInstance().nextId(null);
|
||||
String recordIdStr = String.valueOf(recordId);
|
||||
//扣减金币
|
||||
userPurse = userPurseService.subGold(uid, num.doubleValue(), BillObjTypeEnum.CLEAR_USER_GOLD,
|
||||
(up)-> billRecordService.insertGeneralBillRecord(uid, recordIdStr, BillObjTypeEnum.CLEAR_USER_GOLD, num.doubleValue(), up));
|
||||
//获取更新后的金额
|
||||
BigDecimal currentGoldNum = BigDecimal.valueOf(userPurse.getGolds());
|
||||
//增加官方操作记录
|
||||
addOfficialGoldRecord(recordId, uid, null, num, currentGoldNum, OfficalSendTypeEnum.CLEAR_USER_GOLD.getValue(),
|
||||
Constant.WalletCurrencyType.gold, BillObjTypeEnum.CLEAR_USER_GOLD.getValue(), adminId, BillObjTypeEnum.CLEAR_USER_GOLD.getDesc(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BusiResult<PageResult<OfficialGoldAllRecordVo>> allRecord(Integer partitionId, Long erbanNo, OfficalSendTypeEnum type,
|
||||
Date beginDate, Date endDate, Integer pageNo, Integer pageSize) {
|
||||
Page<OfficialGoldRecordVo> p = new Page<>(pageNo, pageSize);
|
||||
@@ -820,4 +656,36 @@ public class OfficialGoldRecordService extends BaseService {
|
||||
|
||||
return BusiResult.success(pageResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送企业微信消息
|
||||
* @param usersMap 用户映射
|
||||
* @param partitionId 分区ID
|
||||
* @param title 标题
|
||||
* @param adminId 管理员ID
|
||||
* @param amount 数量
|
||||
* @param remark 备注
|
||||
*/
|
||||
private void pushEnterpriseWeChatMessage(Map<Long, Users> usersMap, Integer partitionId, String title, int adminId, BigDecimal amount, String remark) {
|
||||
if (envComponent.getDevOrNativeEnv()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String userDescList = usersMap.values().stream().map(u-> String.format("%s(%d)", u.getNick(), u.getErbanNo())).collect(Collectors.joining(","));
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
|
||||
AdminUser adminUser = adminUserService.getAdminUserById(adminId);
|
||||
MarkdownMessage msg = new MarkdownMessage();
|
||||
msg.addTitle(MarkdownMessage.getHeaderText(3, adminUser.getUsername() + title));
|
||||
msg.add(MarkdownMessage.getReferenceText(title));
|
||||
msg.add(MarkdownMessage.getReferenceText("APP应用: ") + AppEnum.getCurApp().getValue());
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送数量: " + amount.toPlainString()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送分区: " + partitionEnum.getDesc()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送人数: " + usersMap.size()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送用户: " + userDescList));
|
||||
msg.add(MarkdownMessage.getReferenceText("操作者: " + adminUser.getUsername()));
|
||||
msg.add(MarkdownMessage.getReferenceText("备注: " + remark));
|
||||
// 发送消息
|
||||
messageRobotPushService.pushMessageByKey(webSecurityConfig.getOfficialDingPushKey(), msg, false);
|
||||
}
|
||||
}
|
@@ -6,8 +6,8 @@ import com.accompany.admin.common.Combobox;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.params.RoomFreeGiftConfigParams;
|
||||
import com.accompany.admin.service.gift.GiftAdminService;
|
||||
import com.accompany.admin.service.push.EnterpriseWeChatPushAdminService;
|
||||
import com.accompany.admin.service.system.AdminLogService;
|
||||
import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.business.dto.room.RoomFreeGiftConfigDto;
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.service.gift.GiftSendRecordService;
|
||||
@@ -15,16 +15,22 @@ import com.accompany.business.service.gift.GiftService;
|
||||
import com.accompany.business.service.gift.RoomExclusiveGiftService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.room.RoomExclusiveGiftVo;
|
||||
import com.accompany.common.config.WebSecurityConfig;
|
||||
import com.accompany.common.constant.AppEnum;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.push.MarkdownMessage;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.tencent.cos.TencentCosUploadService;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.common.utils.PinYin4JUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.message.MessageRobotPushService;
|
||||
import com.accompany.sharding.vo.GiftSendRecordStatistics;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -65,11 +71,17 @@ public class GiftAdminController extends BaseController {
|
||||
@Autowired
|
||||
private AdminLogService adminLogService;
|
||||
@Autowired
|
||||
private EnterpriseWeChatPushAdminService enterpriseWeChatPushAdminService;
|
||||
@Autowired
|
||||
private GiftService giftService;
|
||||
@Autowired
|
||||
private RoomExclusiveGiftService roomExclusiveGiftService;
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired
|
||||
private WebSecurityConfig webSecurityConfig;
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
@Autowired
|
||||
private MessageRobotPushService messageRobotPushService;
|
||||
|
||||
@GetMapping("/listLuckyBagGift")
|
||||
public BusiResult<List<Gift>> listLuckyBagLinearGift() {
|
||||
@@ -344,7 +356,7 @@ public class GiftAdminController extends BaseController {
|
||||
Integer partitionId = partitionIds.get(0);
|
||||
|
||||
String title = "后台赠送礼物(" + gift.getGiftName() + ") x " + giftNum + "个";
|
||||
enterpriseWeChatPushAdminService.pushMessage(usersMap, partitionId, title, getAdminId(), totalGoldNum, null);
|
||||
pushEnterpriseWeChatMessage(usersMap, partitionId, title, getAdminId(), totalGoldNum, null);
|
||||
|
||||
//赠送失败的平台号
|
||||
List<Long> failErban = new ArrayList<>();
|
||||
@@ -460,6 +472,36 @@ public class GiftAdminController extends BaseController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送企业微信消息
|
||||
* @param usersMap 用户映射
|
||||
* @param partitionId 分区ID
|
||||
* @param title 标题
|
||||
* @param adminId 管理员ID
|
||||
* @param amount 数量
|
||||
* @param remark 备注
|
||||
*/
|
||||
private void pushEnterpriseWeChatMessage(Map<Long, Users> usersMap, Integer partitionId, String title, int adminId, BigDecimal amount, String remark) {
|
||||
if (envComponent.getDevOrNativeEnv()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String userDescList = usersMap.values().stream().map(u-> String.format("%s(%d)", u.getNick(), u.getErbanNo())).collect(Collectors.joining(","));
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
|
||||
com.accompany.admin.model.AdminUser adminUser = adminUserService.getAdminUserById(adminId);
|
||||
MarkdownMessage msg = new MarkdownMessage();
|
||||
msg.addTitle(MarkdownMessage.getHeaderText(3, adminUser.getUsername() + title));
|
||||
msg.add(MarkdownMessage.getReferenceText(title));
|
||||
msg.add(MarkdownMessage.getReferenceText("APP应用: ") + AppEnum.getCurApp().getValue());
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送数量: " + amount.toPlainString()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送分区: " + partitionEnum.getDesc()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送人数: " + usersMap.size()));
|
||||
msg.add(MarkdownMessage.getReferenceText("赠送用户: " + userDescList));
|
||||
msg.add(MarkdownMessage.getReferenceText("操作者: " + adminUser.getUsername()));
|
||||
msg.add(MarkdownMessage.getReferenceText("备注: " + remark));
|
||||
// 发送消息
|
||||
messageRobotPushService.pushMessageByKey(webSecurityConfig.getOfficialDingPushKey(), msg, false);
|
||||
}
|
||||
}
|
@@ -8,13 +8,11 @@ import com.accompany.admin.vo.OfficialGoldAllRecordVo;
|
||||
import com.accompany.admin.vo.OfficialGoldRecordVo;
|
||||
import com.accompany.admin.vo.UsersVo;
|
||||
import com.accompany.business.constant.OfficalSendTypeEnum;
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.result.PageResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
@@ -51,8 +49,6 @@ public class GoldCoinController extends BaseController {
|
||||
private OfficialGoldRecordService officialGoldRecordService;
|
||||
@Autowired
|
||||
private AdminLogService adminLogService;
|
||||
@Autowired
|
||||
private UserPurseService userPurseService;
|
||||
|
||||
@RequestMapping("/listType")
|
||||
@ResponseBody
|
||||
@@ -70,17 +66,16 @@ public class GoldCoinController extends BaseController {
|
||||
* @param num 赠送数量
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/give")
|
||||
@RequestMapping("/operate")
|
||||
@ResponseBody
|
||||
public BusiResult<Void> giveGoldCoin(String ernos, OfficalSendTypeEnum type, BigDecimal num, BigDecimal actualAmount, String remark, Integer busType) throws Exception {
|
||||
public BusiResult<Void> operate(String ernos, OfficalSendTypeEnum type, Integer busType, BigDecimal num, String remark) {
|
||||
if (BlankUtil.isBlank(ernos) || num.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
int adminId = getAdminId();
|
||||
officialGoldRecordService.handle(ernos, type, num, adminId, actualAmount, remark, busType);
|
||||
adminLogService.insertLog(adminId, getClass().getCanonicalName(), "giveGoldCoin"
|
||||
, "params===>>ernos:" + ernos + ", type:" + type + ", num:" + num + ", actualAmount:" + actualAmount
|
||||
+ ", remark:" + remark);
|
||||
officialGoldRecordService.handle(ernos, type, num, adminId, remark, busType);
|
||||
adminLogService.insertLog(adminId, getClass().getCanonicalName(), "operateGoldCoin"
|
||||
, "params===>>ernos:" + ernos + ", type:" + type + ", num:" + num + ", remark:" + remark);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@@ -176,48 +171,6 @@ public class GoldCoinController extends BaseController {
|
||||
return workbook;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/return", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public BusiResult returnGoldNum(String uids, String golds, String diamonds) {
|
||||
try {
|
||||
String[] uid = uids.trim().split(",");
|
||||
String[] gold = golds.trim().split(",");
|
||||
String[] diamond = diamonds.trim().split(",");
|
||||
String errorUids = "";
|
||||
if (uid.length != gold.length || uid.length != diamond.length || gold.length != diamond.length) {
|
||||
return new BusiResult(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
for (int i = 0; i < uid.length; i++) {
|
||||
try {
|
||||
userPurseService.addDiamond(Long.parseLong(uid[i]), Double.parseDouble(gold[i]), BillObjTypeEnum.OFFICIAL_GOLD_ADD);
|
||||
} catch (Exception e) {
|
||||
errorUids = errorUids + ",";
|
||||
}
|
||||
}
|
||||
return new BusiResult(BusiStatus.SUCCESS, errorUids);
|
||||
} catch (Exception e) {
|
||||
logger.error("赠送失败");
|
||||
return new BusiResult(BusiStatus.BUSIERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户金币清除
|
||||
*
|
||||
* @param erBanNos
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("用户金币清除")
|
||||
@PostMapping("clearUserGold")
|
||||
@ResponseBody
|
||||
public BusiResult<Void> clearUserGold(String erBanNos, BigDecimal num) {
|
||||
int adminId = getAdminId();
|
||||
officialGoldRecordService.clearUserGold(erBanNos, num, adminId);
|
||||
adminLogService.insertLog(adminId, getClass().getCanonicalName(), "clearUserGold", "params===>>erBanNos:" + erBanNos + ",num:" + num);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "转赠记录-全平台", httpMethod = "GET")
|
||||
@RequestMapping("/recordAll")
|
||||
|
@@ -39,7 +39,6 @@ public class Constant {
|
||||
*/
|
||||
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; //用户金币清除
|
||||
|
@@ -1,5 +1,9 @@
|
||||
package com.accompany.core.enumeration;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -9,37 +13,21 @@ import java.util.Optional;
|
||||
* @author xiaoyuyou
|
||||
* @date 2019/6/11 18:32
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CurrencyEnum {
|
||||
|
||||
DIAMOND((byte)1, "金币", 0.0000625),
|
||||
CRYSTAL((byte)2, "水晶", 0.0001),
|
||||
GOLD((byte)3, "钻石", 0.0001),
|
||||
GUILD_USD((byte)4, "公会薪资", 1),
|
||||
GAME_USD((byte)5, "游戏薪资", 1),
|
||||
GUILD_CRYSTAL((byte)6, "公会紫晶", 0.0000625),
|
||||
DIAMOND((byte)1, "金币", BigDecimal.valueOf(7000L)),
|
||||
CRYSTAL((byte)2, "水晶", BigDecimal.valueOf(11200L)),
|
||||
GOLD((byte)3, "钻石", BigDecimal.valueOf(11200L)),
|
||||
GUILD_USD((byte)4, "公会薪资", BigDecimal.ONE),
|
||||
GAME_USD((byte)5, "游戏薪资", BigDecimal.ONE),
|
||||
GUILD_CRYSTAL((byte)6, "公会紫晶", BigDecimal.valueOf(7000L)),
|
||||
;
|
||||
|
||||
CurrencyEnum(byte value, String desc, double exchangeRate) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
this.exchangeRate = exchangeRate;
|
||||
}
|
||||
|
||||
private byte value;
|
||||
private String desc;
|
||||
private double exchangeRate;
|
||||
|
||||
public byte getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public double getExchangeRate() {
|
||||
return exchangeRate;
|
||||
}
|
||||
private BigDecimal exchangeRate;
|
||||
|
||||
public static CurrencyEnum get(byte value) {
|
||||
Optional<CurrencyEnum> result = Arrays.stream(CurrencyEnum.values()).filter(currencyEnum ->
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.accompany.business.constant;
|
||||
|
||||
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.core.enumeration.CurrencyEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
@@ -9,65 +11,34 @@ import java.util.Optional;
|
||||
/**
|
||||
* 后台管理赠送类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum OfficalSendTypeEnum {
|
||||
|
||||
OFFICAL_GOLD(Constant.OfficialType.interSendGold, "官方赠送钻石", (byte)0),
|
||||
OFFICAL_DIAMOND(Constant.OfficialType.interSendDiamond, "官方赠送金币", (byte)2),
|
||||
OFFICAL_GOLD(Constant.OfficialType.interSendGold, "官方赠送钻石", CurrencyEnum.GOLD),
|
||||
OFFICAL_DIAMOND(Constant.OfficialType.interSendDiamond, "官方赠送金币", CurrencyEnum.DIAMOND),
|
||||
|
||||
ACTIVITY_GOLD(Constant.OfficialType.actReward, "活动奖励钻石", (byte)0),
|
||||
COMPANY_ACCOUNT_DIAMOND(Constant.OfficialType.chargeByCompanyAccount, "公款充值金币", CurrencyEnum.DIAMOND),
|
||||
|
||||
COMPANY_ACCOUNT_DIAMOND(Constant.OfficialType.chargeByCompanyAccount, "公款充值金币", (byte)2),
|
||||
OFFICAL_REDUCE_DIAMONDS(Constant.OfficialType.officalDiamondReduce,"官方金币消除", CurrencyEnum.DIAMOND),
|
||||
CLEAR_USER_GOLD(Constant.OfficialType.clearUserGold, "官方清除钻石", CurrencyEnum.GOLD),
|
||||
|
||||
CLEAR_USER_GOLD(Constant.OfficialType.clearUserGold, "后台清除钻石", (byte)0),
|
||||
OFFICAL_MINUS_GUILD_USD(Constant.OfficialType.miunsGuildUsd, "消除公会薪资", CurrencyEnum.GUILD_USD),
|
||||
OFFICAL_PLUS_GUILD_USD(Constant.OfficialType.plusGuildUsd,"赠送公会薪资", CurrencyEnum.GUILD_USD),
|
||||
|
||||
OFFICAL_REDUCE_DIAMONDS(Constant.OfficialType.officalDiamondReduce,"官方金币消除", (byte)2),
|
||||
|
||||
OFFICAL_MINUS_GUILD_USD(Constant.OfficialType.miunsGuildUsd, "消除薪资", Constant.WalletCurrencyType.guildUsd),
|
||||
OFFICAL_PLUS_GUILD_USD(Constant.OfficialType.plusGuildUsd,"赠送薪资", Constant.WalletCurrencyType.guildUsd),
|
||||
|
||||
OFFICAL_MINUS_GUILD_CRYSTAL(Constant.OfficialType.miunsGuildCrystal, "消除公会紫晶", Constant.WalletCurrencyType.guildCrystal),
|
||||
OFFICAL_PLUS_GUILD_CRYSTAL(Constant.OfficialType.plusGuildCrystal,"赠送公会紫晶", Constant.WalletCurrencyType.guildCrystal),
|
||||
OFFICAL_MINUS_GUILD_CRYSTAL(Constant.OfficialType.miunsGuildCrystal, "消除公会紫晶", CurrencyEnum.GUILD_CRYSTAL),
|
||||
OFFICAL_PLUS_GUILD_CRYSTAL(Constant.OfficialType.plusGuildCrystal,"赠送公会紫晶", CurrencyEnum.GUILD_CRYSTAL),
|
||||
;
|
||||
|
||||
private byte value;
|
||||
|
||||
private String desc;
|
||||
|
||||
private Byte currencyType;
|
||||
|
||||
public byte getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Byte getCurrencyType() {
|
||||
return currencyType;
|
||||
}
|
||||
|
||||
public void setCurrencyType(Byte currencyType) {
|
||||
this.currencyType = currencyType;
|
||||
}
|
||||
|
||||
OfficalSendTypeEnum(byte value, String desc, Byte currencyType) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
this.currencyType = currencyType;
|
||||
}
|
||||
private CurrencyEnum currencyType;
|
||||
|
||||
public static OfficalSendTypeEnum get(byte value) {
|
||||
Optional<OfficalSendTypeEnum> result = Arrays.stream(OfficalSendTypeEnum.values()).filter(officalSendTypeEnum ->
|
||||
officalSendTypeEnum.value == value).findAny();
|
||||
return result.isPresent() ? result.get() : null;
|
||||
return result.orElse(null);
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -75,7 +76,7 @@ public class BillRecordService extends ServiceImpl<BillRecordMapper, BillRecord>
|
||||
*/
|
||||
public void insertGiftSendBillRecord(Long uid, Long targetUid, Long roomUid, String objId, BillObjTypeEnum eventEnum,
|
||||
Double amount, Integer giftId, Integer giftNum, Long giftTotalGoldNum, Date createTime, UserPurse after) {
|
||||
Double rmbAmount = DoubleUtil.mul(amount, eventEnum.getCurrency().getExchangeRate());
|
||||
Double rmbAmount = BigDecimal.valueOf(amount).divide(eventEnum.getCurrency().getExchangeRate(), 2 , RoundingMode.HALF_UP).doubleValue();
|
||||
insertBillRecordV2(uid, targetUid, roomUid, objId, eventEnum, amount, rmbAmount, giftId, giftNum, giftTotalGoldNum, createTime, after);
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ public class BillRecordService extends ServiceImpl<BillRecordMapper, BillRecord>
|
||||
}
|
||||
|
||||
public void insertGeneralBillRecord(Long uid, Long targetUid, Long roomUid, String objId, BillObjTypeEnum eventEnum, Double amount, UserPurse afterPurse) {
|
||||
Double rmbAmount = amount * eventEnum.getCurrency().getExchangeRate();
|
||||
Double rmbAmount = BigDecimal.valueOf(amount).divide(eventEnum.getCurrency().getExchangeRate(), 2 , RoundingMode.HALF_UP).doubleValue();
|
||||
insertBillRecord(uid, targetUid, roomUid, objId, eventEnum, amount, rmbAmount, afterPurse);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user