| | |
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.money.ExtractOrderStatisticDTO;
|
| | | 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.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderUserStatisticService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.ExtractRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.ExtractService;
|
| | | 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.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | @Resource
|
| | | private UserMoneyDebtService userMoneyDebtService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private OrderUserStatisticService orderUserStatisticService;
|
| | |
|
| | | @Transactional
|
| | | public Integer addExtract(Extract extract) {
|
| | | Integer integer = extract(extract);
|
| | |
| | |
|
| | | UserInfo user = find.getUserInfo();
|
| | |
|
| | | userInfoMapper.addHongBaoByUid(user.getId(), find.getMoney());
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | try {
|
| | | userMoneyDetail = UserMoneyDetailFactory.createExtractReject(find);
|
| | | } catch (UserMoneyDetailException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(user.getId(), find.getMoney(), userMoneyDetail);
|
| | | // 更新原来的状态
|
| | | Extract updateExtract = new Extract();
|
| | | updateExtract.setId(id);
|
| | |
| | | // 更新提现记录审核表
|
| | | extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord);
|
| | | // 新版资金详情
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractReject(find);
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e2) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e2);
|
| | | } catch (Exception e3) {
|
| | | e3.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | userNotificationService.extractWrong(user.getId(), find,
|
| | |
| | | ExtractAuditRecord auditRecord = new ExtractAuditRecord();
|
| | | auditRecord.setBeforeMoney(user.getMyHongBao());
|
| | | auditRecord.setExtract(extract);
|
| | |
|
| | | Date minTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 180L);
|
| | | // 统计数据
|
| | | int orderCount50More = orderUserStatisticService.countOrderCount100MoreByUidAndMinTime(user.getId(), minTime);
|
| | |
|
| | | BigDecimal weiQuanOrderFanAmount = orderUserStatisticService.sumWeiQuanOrderFanAmountByUid(user.getId(),
|
| | | minTime);
|
| | | int weiQuanOrderCount = orderUserStatisticService.countWeiQuanOrderByUid(user.getId(), minTime);
|
| | | auditRecord.setExtraInfoStr(new Gson()
|
| | | .toJson(new ExtractOrderStatisticDTO(orderCount50More, weiQuanOrderCount, weiQuanOrderFanAmount, 0)));
|
| | | extractAuditRecordMapper.insertSelective(auditRecord);
|
| | |
|
| | | // 减去账户资金
|
| | | userInfoMapper.subHongBaoByUid(extract.getUserInfo().getId(), extract.getMoney());
|
| | |
|
| | | // 新版资金详情
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtract(extract);
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | userMoneyDetail = UserMoneyDetailFactory.createExtract(extract);
|
| | | } catch (UserMoneyDetailException e2) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e2);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 减去账户资金
|
| | | userMoneyService.subUserMoney(extract.getUserInfo().getId(), extract.getMoney(), userMoneyDetail);
|
| | |
|
| | | userNotificationService.extractApply(extract.getUserInfo().getId());
|
| | | // 添加新版通知
|
| | |
| | | */
|
| | | @Transactional
|
| | | private void extractByZhiFuBao(Extract extract, AdminUser adminUser) {
|
| | | LogHelper.userErrorInfo("提现:开始通过提现-"+extract.getId());
|
| | | String privateKey = Constant.alipayConfig.getPrivateKey();
|
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
|
| | | Constant.alipayConfig.getAppId(), privateKey, "json", "gbk", null, "RSA2");
|
| | |
| | | AlipayFundTransToaccountTransferResponse response = null;
|
| | | try {
|
| | | response = alipayClient.execute(request);
|
| | | LogHelper.userErrorInfo("提现:支付宝通过提现成功-"+extract.getId());
|
| | | } catch (AlipayApiException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.userErrorInfo("支付宝提现异常:" + response + ",提现信息" + GsonUtil.toJson(extract));
|
| | | LogHelper.userErrorInfo("提现:支付宝提现异常:" + response + ",提现信息" + GsonUtil.toJson(extract));
|
| | | }
|
| | |
|
| | | try {
|
| | | CMQManager.getInstance().addExtractResultMsg(extract, response, adminUser);
|
| | | LogHelper.userErrorInfo("提现:添加处理队列成功-"+extract.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.userErrorInfo("支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
|
| | | LogHelper.userErrorInfo("提现:支付宝提现CMQ异常:" + new Gson().toJson(response) + ",提现信息" + GsonUtil.toJson(extract));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | updateExtract.setReason(msg);
|
| | | extractMapper.updateByPrimaryKeySelective(updateExtract);
|
| | |
|
| | | userInfoMapper.addHongBaoByUid(user.getId(), extract.getMoney());
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | // 新版资金详情
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createExtractReject(extract);
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | userMoneyDetail = UserMoneyDetailFactory.createExtractReject(extract);
|
| | | } catch (UserMoneyDetailException e2) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e2);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(user.getId(), extract.getMoney(), userMoneyDetail);
|
| | |
|
| | | try {
|
| | |
|
| | |
| | | @Transactional
|
| | | @Override
|
| | | public void checkExtract(Long uid) throws ExtractException {
|
| | | BigDecimal compensateMoney = extractMapper.computeCompensateByUid(uid);
|
| | | if (compensateMoney == null)
|
| | | compensateMoney = new BigDecimal(0);
|
| | | // 不判定到账红包问题
|
| | | Long count = hongBaoV2Mapper.countByUidAndState(uid, HongBao.STATE_YILINGQU);
|
| | | if (count == null || count == 0)
|
| | | if ((count == null || count == 0) && compensateMoney.compareTo(new BigDecimal(0)) == 0) {
|
| | | throw new ExtractException(1, "没有已到账的红包");
|
| | | }
|
| | | // 查询是否有欠账
|
| | | boolean isDebt = userMoneyDebtService.isHaveDebtToRepay(uid);
|
| | | if (isDebt)
|
| | |
| | | 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));
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public double countTodayMoney(Long uid) {
|
| | | return extractMapper.countTodayMoney(uid);
|
| | | public BigDecimal sumTodayApplyMoney(Long uid,String day) {
|
| | | return extractMapper.sumToadyApplyByUid(uid,day);
|
| | | }
|
| | | }
|