From 0612e7e4104f41c3f8b683073e08cdbb65dad44a Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 29 十月 2019 13:58:20 +0800 Subject: [PATCH] 红包相关 --- fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 41 insertions(+), 13 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java index 00dcbf9..1b06307 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java @@ -1,15 +1,20 @@ package com.yeshi.fanli.service.impl.redpack; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import javax.annotation.Resource; +import org.omg.CORBA.LongHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.google.gson.Gson; import com.yeshi.fanli.dao.mybatis.redpack.RedPackExchangeMapper; +import com.yeshi.fanli.dto.msg.MsgRedPackExchangeContentDTO; +import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.common.AdminUser; import com.yeshi.fanli.entity.money.UserMoneyDetail; @@ -18,7 +23,9 @@ import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum; import com.yeshi.fanli.entity.redpack.RedPackExchange; import com.yeshi.fanli.exception.redpack.RedPackExchangeException; +import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.money.UserMoneyService; +import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService; import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService; import com.yeshi.fanli.service.inter.redpack.RedPackConfigService; import com.yeshi.fanli.service.inter.redpack.RedPackDetailService; @@ -45,6 +52,9 @@ @Resource private RedPackDetailService redPackDetailService; + @Resource + private UserMoneyMsgNotificationService userMoneyMsgNotificationService; + @Override public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state){ @@ -57,19 +67,13 @@ } @Override - public List<Long> countState(long uid){ - return redPackExchangeMapper.countState(uid); - } - - - @Override - public List<BigDecimal> countMoneyState(long uid){ - return redPackExchangeMapper.countMoneyState(uid); + public Long countByUidAndState(long uid, Integer state) { + return redPackExchangeMapper.countByUidAndState(uid, state); } @Override - public BigDecimal countMoneyByState(Long uid, Integer state){ - return redPackExchangeMapper.countMoneyByState(uid, state); + public BigDecimal countMoneyByUidAndState(Long uid, Integer state){ + return redPackExchangeMapper.countMoneyByUidAndState(uid, state); } @Override @@ -125,7 +129,7 @@ if (record == null) throw new RedPackExchangeException(1,"鐢宠璁板綍宸蹭笉瀛樺湪"); - if (RedPackExchange.STATE_INIT == record.getState()) + if (RedPackExchange.STATE_INIT != record.getState()) throw new RedPackExchangeException(1,"璇ョ敵璇峰凡琚鐞嗭紝璇峰埛鏂�"); Date nowDate = new Date(); @@ -148,14 +152,28 @@ // 娣诲姞璧勯噾 userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail); + // 鏇存柊绾㈠寘鎻愮幇鏄庣粏 try { - String identifyCode = StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + record.getId()); + String identifyCode = StringUtil.Md5(RedPackDetailTypeEnum.redExchange.name() + ":" + record.getId()); RedPackDetail redPackDetail = redPackDetailService.getByIdentifyCode(identifyCode); + // 鍒涘缓鏄庣粏鏇存柊 RedPackDetail updateDetail = RedPackDetailFactory.updateExchangePass(redPackDetail.getId(), record); redPackDetailService.updateByPrimaryKeySelective(updateDetail); } catch (Exception e) { + LogHelper.errorDetailInfo(e); throw new RedPackExchangeException(1,"鏇存柊鎻愮幇鏄庣粏鍑洪敊"); } + + //娑堟伅 + SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm"); + String beizu = "绾㈠寘鎻愮幇鎴愬姛鍚庤鍒扳�滄垜鐨�-璐︽埛浣欓鈥濅腑鏌ョ湅"; + MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO(); + dto.setTitle("绾㈠寘鎻愮幇"); + dto.setTime(sd.format(record.getCreateTime())); + dto.setHandle("浜哄伐瀹℃牳" + sd.format(new Date())); + dto.setMoney("楼" + record.getMoney().setScale(2)); + dto.setBalance("楼" + redPackBalanceService.getBalance(record.getUid())); + userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu); } @@ -166,7 +184,7 @@ if (record == null) throw new RedPackExchangeException(1,"鐢宠璁板綍宸蹭笉瀛樺湪"); - if (RedPackExchange.STATE_INIT == record.getState()) + if (RedPackExchange.STATE_INIT != record.getState()) throw new RedPackExchangeException(1,"璇ョ敵璇峰凡琚鐞嗭紝璇峰埛鏂�"); record.setReason(reason); @@ -179,8 +197,18 @@ try { redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchange(record)); } catch (Exception e) { + LogHelper.errorDetailInfo(e); throw new RedPackExchangeException(1, "绾㈠寘閫�鍥炴椂鍑洪敊"); } + + //娑堟伅 + SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm"); + MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO(); + dto.setTitle("绾㈠寘鎻愮幇"); + dto.setReason(reason); + dto.setHandle(""); // TODO 澶勭悊鏂瑰紡寰呭畾 + dto.setTime(sd.format(record.getCreateTime())); + userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangeReject, new Gson().toJson(dto), null); } } -- Gitblit v1.8.0