| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | @Resource
|
| | | private RedPackDetailService redPackDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | |
|
| | | @Override
|
| | | public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state){
|
| | |
| | | }
|
| | |
|
| | | @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
|
| | |
| | | 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();
|
| | |
| | | // 添加资金
|
| | | 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);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | 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);
|
| | |
| | |
|
| | | // 退回红包
|
| | | try {
|
| | | redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchange(record));
|
| | | redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchangeReject(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);
|
| | | }
|
| | |
|
| | | }
|