v1.1转赠钻石: 转赠发送消息通知、账单调整

This commit is contained in:
lzm
2022-10-19 10:46:31 +08:00
parent 71b718de8e
commit af1fbddf18
3 changed files with 21 additions and 3 deletions

View File

@@ -3,9 +3,12 @@ package com.accompany.business.service.purse;
import com.accompany.business.model.DiamondGiveHistory;
import com.accompany.business.model.UserPurse;
import com.accompany.business.mybatismapper.DiamondGiveHistoryMapper;
import com.accompany.business.param.neteasepush.NeteaseSendMsgParam;
import com.accompany.business.service.SendSysMsgService;
import com.accompany.business.service.record.BillRecordService;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.vo.DiamondGiveHistoryVo;
import com.accompany.common.config.SystemConfig;
import com.accompany.common.constant.Constant;
import com.accompany.common.redis.RedisKey;
import com.accompany.common.result.BusiResult;
@@ -59,6 +62,8 @@ public class DiamondGiveHistoryService extends ServiceImpl<DiamondGiveHistoryMap
private JedisService jedisService;
@Autowired
private JedisLockService jedisLockService;
@Autowired
private SendSysMsgService sendSysMsgService;
public List<DiamondGiveHistoryVo> getRecordVos(Long uid, Integer pageSize, Integer pageNum) {
if (uid == null) {
@@ -95,14 +100,28 @@ public class DiamondGiveHistoryService extends ServiceImpl<DiamondGiveHistoryMap
// 转赠记录
DiamondGiveHistory history = insertHistory(uid, toUid, diamondNum, rate, rateNum, realSpendDiamondNum);
// 账单记录
billRecordService.insertGeneralBillRecord(uid, toUid, history.getId().toString(), BillObjTypeEnum.SEND_DIAMOND_OUT, -realSpendDiamondNum.doubleValue());
billRecordService.insertGeneralBillRecord(uid, toUid, history.getId().toString(), BillObjTypeEnum.SEND_DIAMOND_OUT, -realSpendDiamondNum);
billRecordService.insertGeneralBillRecord(toUid, uid, history.getId().toString(), BillObjTypeEnum.SEND_DIAMOND_IN, diamondNum.doubleValue());
// 发送消息
String msg = "我贈送了%d鑽石給你快去查看吧~";
sendGoldMsg(uid.toString(),toUid.toString(),String.format(msg,diamondNum));
} finally {
jedisLockService.unlock(lockKey,lockVal);
}
}
private void sendGoldMsg(String uid, String toUid, String msg) {
NeteaseSendMsgParam neteaseSendMsgParam = new NeteaseSendMsgParam();
neteaseSendMsgParam.setType(0);
neteaseSendMsgParam.setFrom(uid);
neteaseSendMsgParam.setOpe(0);
neteaseSendMsgParam.setTo(toUid);
neteaseSendMsgParam.setBody(msg);
neteaseSendMsgParam.setUseYidun(0);
sendSysMsgService.sendMsg(neteaseSendMsgParam);
}
private DiamondGiveHistory insertHistory(Long uid, Long toUid, Long diamondNum, Double rate, Double rateNum, Double realSpendDiamondNum) {
DiamondGiveHistory history = new DiamondGiveHistory();
history.setDiamondNum(diamondNum);

View File

@@ -439,7 +439,7 @@ public class BillRecordService extends ServiceImpl<BillRecordMapper,BillRecord>
private void fillSendDiamondSearchVo(List<BillSearchVo> searchVos) {
List<Long> recordIds = searchVos.stream().filter(it -> BillObjTypeEnum.SEND_DIAMOND_OUT.getType().equals(it.getObjType())).map(it -> Long.valueOf(it.getObjId())).collect(Collectors.toList());
List<Long> recordIds = searchVos.stream().filter(it -> BillObjTypeEnum.SEND_DIAMOND_OUT.getValue() == it.getObjType()).map(it -> Long.valueOf(it.getObjId())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(recordIds)) {
return;
}

View File

@@ -30,7 +30,6 @@ public class DiamondGiveHistoryController extends BaseController {
@ApiOperation("用户转赠记录")
@GetMapping("/giveRecord")
@ApiImplicitParam(name = "type", value = "1-别人给我发的邀请2-我给别人发的邀请", required = true, dataType = "Byte", paramType = "query")
public BusiResult<List<UserCpRecordDto>> list(@RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "20")Integer pageSize) {
return new BusiResult(diamondGiveHistoryService.getRecordVos(this.getUid(),pageNum,pageSize));
}