| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.ExtractMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.ExtractRecordMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.MoneyRecordMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.PayInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.SystemMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | | import com.yeshi.fanli.dao.user.AccountMessageDao;
|
| | | import com.yeshi.fanli.dao.user.ExtractDao;
|
| | | import com.yeshi.fanli.dao.user.ExtractRecordDao;
|
| | | import com.yeshi.fanli.dao.user.MoneyRecordDao;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.ExtractRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.MoneyRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.PayInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserAccountBindingHistory;
|
| | | 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.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.exception.ExtractException;
|
| | | import com.yeshi.fanli.exception.NotExistObjectException;
|
| | | import com.yeshi.fanli.exception.ObjectStateException;
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.AccountMessageService;
|
| | | import com.yeshi.fanli.service.inter.user.ExtractRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.ExtractService;
|
| | | import com.yeshi.fanli.service.inter.user.MoneyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | public class ExtractServiceImpl implements ExtractService {
|
| | |
|
| | | @Resource
|
| | | private ExtractDao extractDao;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private MoneyRecordService moneyRecordService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
| | |
|
| | | @Resource
|
| | | private SystemConfigService systemConfigService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private AccountMessageService accountMessageService;
|
| | |
|
| | | @Resource
|
| | | private ExtractMapper extractMapper;
|
| | |
| | | private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private ExtractRecordDao extractRecordDao;
|
| | |
|
| | | @Resource
|
| | | private MoneyRecordDao moneyRecordDao;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageDao accountMessageDao;
|
| | |
|
| | | @Resource
|
| | | private PayInfoMapper payInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private MoneyRecordMapper moneyRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageMapper accountMessageMapper;
|
| | |
| | | private ExtractRecordMapper extractRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private SystemMapper systemMapper;
|
| | | private HongBaoV2Mapper hongBaoV2Mapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Mapper hongBaoV2Mapper;
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
| | | @Resource
|
| | | private AlipayAccountValidNormalHistoryMapper alipayAccountValidNormalHistoryMapper;
|
| | |
|
| | | public List<Extract> getExtractInfoByUid(long uid) {
|
| | | return extractDao.list("from Extract e where e.userInfo.id=? and e.state != 2", new Serializable[] { uid });
|
| | | }
|
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountBindingHistoryService userAccountBindingHistoryService;
|
| | |
|
| | | @Transactional
|
| | | public Integer addExtract(Extract extract) {
|
| | | Integer integer = extract(extract);
|
| | | return integer;
|
| | | }
|
| | |
|
| | | public List<Extract> getExtractList(int index) {
|
| | | int start = index * Constant.PAGE_SIZE;
|
| | | return extractDao.list("from Extract e order by e.id desc", start, Constant.PAGE_SIZE, new Serializable[] {});
|
| | | }
|
| | |
|
| | | public int getCount() {
|
| | | Long lcount = extractDao.getCount("select count(e.id) from Extract e");
|
| | | return lcount.intValue();
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | }
|
| | |
|
| | | @Transactional
|
| | | public synchronized void rejectExtract(long id, String reason, long extractTime, AdminUser admin)
|
| | | public synchronized void rejectExtract(long id, String reason, AdminUser admin)
|
| | | throws ObjectStateException, NotExistObjectException {
|
| | | Extract find = extractMapper.selectByPrimaryKey(id);
|
| | |
|
| | |
| | | UserInfo user = find.getUserInfo();
|
| | |
|
| | | userInfoMapper.addHongBaoByUid(user.getId(), find.getMoney());
|
| | |
|
| | | // 删除提现记录
|
| | | moneyRecordMapper.deleteMoneyRecordByExtractId(id);
|
| | |
|
| | | // 更新原来的状态
|
| | | Extract updateExtract = new Extract();
|
| | |
| | | */
|
| | | @Transactional
|
| | | private Integer extract(Extract extract) {
|
| | | UserAccountBindingHistory history = userAccountBindingHistoryService
|
| | | .getLatestHistory(extract.getUserInfo().getId(), UserAccountBindingHistory.TYPE_PHONE);
|
| | | // 手机号更换绑定的7天内不能提现
|
| | | if (history != null && !history.getFirst()
|
| | | && (System.currentTimeMillis() - history.getCreateTime().getTime()) < 1000 * 60 * 60 * 24 * 7L)
|
| | | return 111;
|
| | |
|
| | | final String autoExtract = configService.get("extract_way"); // 是否自动转账
|
| | | final String maxCount = configService.get("extract_count_day");
|
| | | final String maxMoney = configService.get("extract_money_day");
|
| | |
| | |
|
| | | // 减去账户资金
|
| | | userInfoMapper.subHongBaoByUid(extract.getUserInfo().getId(), extract.getMoney());
|
| | |
|
| | | MoneyRecord moneyRecord = new MoneyRecord(user, null, extract.getMoney(), "提现", "", extract.getExtractTime(),
|
| | | 2);
|
| | | moneyRecord.setExtract(extract);
|
| | | moneyRecordMapper.insertSelective(moneyRecord);
|
| | |
|
| | | // 新版资金详情
|
| | | try {
|
| | |
| | | */
|
| | | @Override
|
| | | public Extract getExtractById(long id) {
|
| | | return extractDao.find(Extract.class, id);
|
| | | return extractMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void checkExtract(String uid) throws ExtractException {
|
| | | Long count = hongBaoV2Mapper.countByUidAndState(Long.parseLong(uid), HongBao.STATE_YILINGQU);
|
| | | public void checkExtract(Long uid) throws ExtractException {
|
| | | Long count = hongBaoV2Mapper.countByUidAndState(uid, HongBao.STATE_YILINGQU);
|
| | | if (count == null || count == 0)
|
| | | throw new ExtractException(1, "没有已到账的红包");
|
| | | List<Integer> list = extractMapper.checkExtract(uid);
|
| | | if (list != null && list.size() > 0 && list.get(0) == 0)
|
| | | // 获取所有收入所得
|
| | | BigDecimal hongBaoMoney = hongBaoV2Service.computeMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU);
|
| | |
|
| | | Date now = new Date();
|
| | | // 获取提现,获取提现验证
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.extract);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractReject);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerify);
|
| | | BigDecimal extractMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, new Date(0),
|
| | | now);
|
| | | extractMoney = extractMoney.abs();
|
| | | // 获取维权
|
| | | typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.weiQuan);
|
| | | typeList.add(UserMoneyDetailTypeEnum.fanliWeiQuan);
|
| | | typeList.add(UserMoneyDetailTypeEnum.inviteWeiQuan);
|
| | | typeList.add(UserMoneyDetailTypeEnum.shareWeiQuan);
|
| | | typeList.add(UserMoneyDetailTypeEnum.hongbaoDeduct);
|
| | | BigDecimal weiqaunMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, new Date(0),
|
| | | now);
|
| | | weiqaunMoney = weiqaunMoney.abs();
|
| | |
|
| | | BigDecimal balance = userInfoService.selectByPKey(uid).getMyHongBao();
|
| | |
|
| | | BigDecimal compensateMoney = extractMapper.computeCompensateByUid(uid);
|
| | | if (compensateMoney == null)
|
| | | compensateMoney = new BigDecimal(0);
|
| | |
|
| | | BigDecimal after = hongBaoMoney.subtract(extractMoney.add(weiqaunMoney).add(balance).add(compensateMoney));
|
| | |
|
| | | if (after.compareTo(new BigDecimal("0")) != 0)
|
| | | throw new ExtractException(2, "结算资金异常");
|
| | | }
|
| | |
|