| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
|
| | | import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserMoneyChangeMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class UserMoneyServiceImpl implements UserMoneyService {
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailMapper userMoneyDetailMapper;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Override
|
| | | public BigDecimal getMoneyToday(Long uid) {
|
| | |
| | | userMoneyDetailMapper.insertSelective(detail);
|
| | | userInfoMapper.subHongBaoByUid(uid, money);
|
| | | try {
|
| | | UserMoneyChangeCMQManager.getInstance()
|
| | | .addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, new BigDecimal(0).subtract(money)));
|
| | | if (!Constant.IS_TEST)
|
| | | UserMoneyChangeCMQManager.getInstance()
|
| | | .addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, new BigDecimal(0).subtract(money)));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | userMoneyDetailMapper.insertSelective(detail);
|
| | | userInfoMapper.addHongBaoByUid(uid, money);
|
| | | try {
|
| | | UserMoneyChangeCMQManager.getInstance().addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, money));
|
| | | if (!Constant.IS_TEST)
|
| | | UserMoneyChangeCMQManager.getInstance().addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, money));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 发送资金到账消息
|
| | |
|
| | | if (!Constant.IS_TEST) {
|
| | | UserMoneyChangeMQMsg msg = new UserMoneyChangeMQMsg(uid, money, new Date());
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userMoneyAdd, msg);
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getBalance(Long uid) {
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKey(uid);
|
| | | if (userInfo == null)
|
| | | return null;
|
| | | return userInfo.getMyHongBao();
|
| | | }
|
| | |
|
| | | }
|