From db9b3f501855ed7d97315c27c538de05bb0f7eaf Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 12 十一月 2019 15:26:26 +0800 Subject: [PATCH] 赠送礼品退回 --- fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java | 59 ++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 32 insertions(+), 27 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java index 5f5ede2..bcc3434 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java @@ -3,7 +3,6 @@ import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.List; import javax.annotation.Resource; @@ -31,6 +30,7 @@ import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TokenUtil; +import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService; import com.yeshi.fanli.util.factory.RedPackDetailFactory; @Service @@ -65,38 +65,43 @@ public void updateByPrimaryKeySelective(RedPackGiveRecord record) { redPackGiveRecordMapper.updateByPrimaryKeySelective(record); } - + @Override - public List<RedPackGiveRecord> overdueList(int count) { - return redPackGiveRecordMapper.overdueList(count); - } - - @Override + @RequestSerializableByKeyService(key = "#id") @Transactional(rollbackFor = Exception.class) - public void overdue(List<RedPackGiveRecord> list) throws Exception { - if (list == null || list.size() == 0) + public void overdueByPrimaryKey(Long id) throws Exception { + if (id == null) return; + RedPackGiveRecord giveRecord = redPackGiveRecordMapper.selectByPrimaryKey(id); + if (giveRecord == null) + return; + + if (giveRecord.getState() != null && giveRecord.getState() != RedPackGiveRecord.STATE_INIT ) + return; + + // 璧犻�佽褰曞け鏁� + RedPackGiveRecord updateRecord = new RedPackGiveRecord(); + updateRecord.setId(giveRecord.getId()); + updateRecord.setState(RedPackGiveRecord.STATE_OVERDUE); + redPackGiveRecordMapper.updateByPrimaryKeySelective(updateRecord); + + // 鍙d护澶辨晥 + tokenRecordService.invalidByRedPack(id); + + // 閫�鍥炵孩鍖� + redPackBalanceService.addRedPack(giveRecord.getGiveUid(), giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersFail(giveRecord)); + + // 閫�鍥炴秷鎭� SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm"); - RedPackGiveRecord updateRecord = null; - for (RedPackGiveRecord giveRecord: list) { - updateRecord = new RedPackGiveRecord(); - updateRecord.setId(giveRecord.getId()); - updateRecord.setState(1); - redPackGiveRecordMapper.updateByPrimaryKeySelective(updateRecord); - - // 閫�鍥炵孩鍖� - redPackBalanceService.addRedPack(giveRecord.getGiveUid(), giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersFail(giveRecord)); - - // 閫�鍥炴秷鎭� - MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO(); - givedto.setTitle("浣犺禒閫佺殑绾㈠寘鏈鎴愬姛棰嗗彇"); - givedto.setMoney("楼" + giveRecord.getAmount().setScale(2)); - givedto.setTime(sd.format(new Date())); - givedto.setGiveTime(sd.format(giveRecord.getGiveTime())); - userMoneyMsgNotificationService.redPackMsg(giveRecord.getGiveUid(), MsgTypeMoneyTypeEnum.redPackGiveBack, new Gson().toJson(givedto), "璇峰埌鎴戠殑-绾㈠寘鏌ョ湅"); - } + MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO(); + givedto.setTitle("浣犺禒閫佺殑绾㈠寘鏈鎴愬姛棰嗗彇"); + givedto.setMoney("楼" + giveRecord.getAmount().setScale(2)); + givedto.setTime(sd.format(new Date())); + givedto.setGiveTime(sd.format(giveRecord.getGiveTime())); + userMoneyMsgNotificationService.redPackMsg(giveRecord.getGiveUid(), MsgTypeMoneyTypeEnum.redPackGiveBack, new Gson().toJson(givedto), "璇峰埌鎴戠殑-绾㈠寘鏌ョ湅"); + } -- Gitblit v1.8.0