| | |
| | | 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.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.ExtractException;
|
| | | import com.yeshi.fanli.exception.NotExistObjectException;
|
| | | import com.yeshi.fanli.exception.ObjectStateException;
|
| | |
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractService;
|
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractWeiXinRecordService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.OrderUserStatisticService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | |
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | |
|
| | |
| | | @Resource
|
| | | private ExtractWeiXinRecordService extractWeiXinRecordService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderCountService commonOrderCountService;
|
| | |
|
| | | @Transactional
|
| | | public Integer addExtract(Extract extract) {
|
| | | Integer integer = extract(extract);
|
| | |
| | | updateExtract.setId(id);
|
| | | updateExtract.setState(Extract.STATE_PROCESSING);
|
| | | extractMapper.updateByPrimaryKeySelective(updateExtract);
|
| | | //TODO 新版部署后删除
|
| | | // 改变资金记录状态
|
| | | UserMoneyDetail detail = userMoneyDetailService
|
| | | .selectByTypeAndUidAndIdentifyCode(UserMoneyDetailTypeEnum.extract, find.getUserInfo().getId(), find.getId());
|
| | | UserMoneyDetail detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode(
|
| | | UserMoneyDetailTypeEnum.extract, find.getUserInfo().getId(), find.getId());
|
| | | if (detail != null) {
|
| | | UserMoneyDetail update = new UserMoneyDetail(detail.getId());
|
| | | update.setShow(true);
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public synchronized void rejectExtract(long id, String reason, AdminUser admin)
|
| | | throws ObjectStateException, NotExistObjectException {
|
| | | Extract find = extractMapper.selectByPrimaryKey(id);
|
| | |
| | | && (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");
|
| | | final String autoExtract = configService.get(ConfigKeyEnum.extractWay.getKey()); // 是否自动转账
|
| | | final String maxCount = configService.get(ConfigKeyEnum.extractDayCount.getKey());
|
| | | final String maxMoney = configService.get(ConfigKeyEnum.extractMoneyDay.getKey());
|
| | |
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKeyForUpdate(extract.getUserInfo().getId());
|
| | | // 余额不足
|
| | |
| | |
|
| | | extractMapper.insertSelective(extract);
|
| | |
|
| | | ExtractAuditRecord auditRecord = new ExtractAuditRecord();
|
| | | final 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);
|
| | |
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | // 统计数据
|
| | | int less10Count = commonOrderCountService.countOderByUidAndLess10(user.getId());
|
| | | ExtractAuditRecord update = new ExtractAuditRecord();
|
| | | update.setId(auditRecord.getId());
|
| | | int orderCount50More = orderUserStatisticService.countOrderCount100MoreByUidAndMinTime(user.getId(),
|
| | | minTime);
|
| | | BigDecimal weiQuanOrderFanAmount = orderUserStatisticService.sumWeiQuanOrderFanAmountByUid(user.getId(),
|
| | | minTime);
|
| | | int weiQuanOrderCount = orderUserStatisticService.countWeiQuanOrderByUid(user.getId(), minTime);
|
| | | update.setExtraInfoStr(new Gson().toJson(new ExtractOrderStatisticDTO(orderCount50More,
|
| | | weiQuanOrderCount, weiQuanOrderFanAmount, 0, less10Count)));
|
| | | extractAuditRecordMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | });
|
| | |
|
| | | // 新版资金详情
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | try {
|
| | | userMoneyDetail = UserMoneyDetailFactory.createExtract(extract);
|
| | | userMoneyDetail = UserMoneyDetailFactory.createExtract(extract, null);
|
| | | } catch (UserMoneyDetailException e2) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e2);
|
| | |
| | | response = alipayClient.execute(request);
|
| | | LogHelper.userErrorInfo("提现:支付宝通过提现成功-" + extract.getId());
|
| | | } catch (AlipayApiException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, "支付宝转账异常:" + extract.getId(), "");
|
| | | LogHelper.userErrorInfo("提现:支付宝提现异常:" + response + ",提现信息" + GsonUtil.toJson(extract));
|
| | | }
|
| | |
|
| | |
| | | * @param session
|
| | | */
|
| | | @Transactional
|
| | | private void extractSuccess(Extract extract) {
|
| | | private void extractSuccess(Extract extract,String alipayNo) {
|
| | | // 老版本功能
|
| | | // List<MoneyRecord> list = moneyRecordDao.list("from MoneyRecord mr
|
| | | // where mr.extract.id = " + extract.getId());
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | UserMoneyDetail detailNew = null;
|
| | | try {
|
| | | detailNew = UserMoneyDetailFactory.createExtract(extract, alipayNo);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 外显账户明细
|
| | | UserMoneyDetail userMoneyDetail = userMoneyDetailMapper.selectByTypeAndUidAndIdentifyCode(
|
| | | UserMoneyDetailTypeEnum.extractNew, extract.getUserInfo().getId(), extract.getId());
|
| | | if (userMoneyDetail != null) {
|
| | | UserMoneyDetail detail = new UserMoneyDetail(userMoneyDetail.getId());
|
| | | detail.setShow(true);
|
| | | detail.setUpdateTime(new Date());
|
| | | if (detailNew != null)
|
| | | detail.setDescInfo(detailNew.getDescInfo());
|
| | | userMoneyDetailMapper.updateByPrimaryKeySelective(detail);
|
| | | }
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.extractSuccess(extract);
|
| | | userMoneyMsgNotificationService.extractSuccess(extract, alipayNo);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return extractMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void checkExtract(Long uid) throws ExtractException {
|
| | | BigDecimal compensateMoney = extractMapper.computeCompensateByUid(uid);
|
| | |
| | | // 获取提现,获取提现验证
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.extract);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractNew);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractReject);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerify);
|
| | | typeList.add(UserMoneyDetailTypeEnum.extractVerifyNew);
|
| | | BigDecimal extractMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, new Date(0),
|
| | | now);
|
| | | extractMoney = extractMoney.abs();
|
| | |
| | | if (response.isSuccess()) {
|
| | | String code = response.getCode();
|
| | | if ("10000".equals(code)) {
|
| | | extractSuccess(extract);
|
| | | extractSuccess(extract,response.getOrderId());
|
| | | } else {
|
| | | extractFail(extract, response.getSubMsg());
|
| | | }
|
| | |
| | | extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord);
|
| | | }
|
| | |
|
| | | // 外显账户明细
|
| | | UserMoneyDetail userMoneyDetail = userMoneyDetailMapper.selectByTypeAndUidAndIdentifyCode(
|
| | | UserMoneyDetailTypeEnum.extract, extract.getUserInfo().getId(), extract.getId());
|
| | | if (userMoneyDetail != null) {
|
| | | UserMoneyDetail detail = new UserMoneyDetail(userMoneyDetail.getId());
|
| | | detail.setShow(true);
|
| | | detail.setUpdateTime(new Date());
|
| | | userMoneyDetailMapper.updateByPrimaryKeySelective(detail);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void testExtractSuccess(Long id) {
|
| | | Extract extract = extractMapper.selectByPrimaryKey(id);
|
| | | extractSuccess(extract);
|
| | | extractSuccess(extract,null);
|
| | | Long uid = extract.getUserInfo().getId();
|
| | |
|
| | | // 更新审核记录
|
| | |
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | // 4、发送消息通知
|
| | | String desc = "为保障你的账户余额安全,自动提现金额将不会高于5元";
|
| | | String beizu = "账户中剩余余额请在本App内完成提现";
|
| | | userMoneyMsgNotificationService.extractAuto(extractRecord, "未领取-提现中", desc, beizu);
|
| | | }
|
| | |
|
| | | private boolean parseSendResult(String result) {
|
| | |
| | | }
|
| | | return listOpendIDs;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<UserInfo> preAutoUserTo1212() throws Exception {
|
| | | int page = 0;
|
| | |
| | | }
|
| | | return list;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<String> getAutoExtractOpenIdsTo1212() throws Exception {
|
| | | int page = 0;
|
| | |
| | | String refundDate = DateUtil.reduceDayTostring(15, nowDate);
|
| | |
|
| | | // 提现金额
|
| | | BigDecimal money = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MONEY);
|
| | | // 余额最低限制
|
| | | BigDecimal minSurplus = BigDecimal.valueOf(Constant.AUTO_EXTRACT_MIN_SURPLUS);
|
| | | BigDecimal money = BigDecimal.valueOf(1);
|
| | |
|
| | | List<String> listOpendIDs = new ArrayList<String>();
|
| | | // 首行appID
|
| | |
| | | }
|
| | |
|
| | | for (Long uid : listValid) {
|
| | | UserInfo userInfo = subHongBaoByUid(uid, money, minSurplus);
|
| | | UserInfo userInfo = subHongBaoByUid(uid, money, money);
|
| | | if (userInfo != null) {
|
| | | listOpendIDs.add(userInfo.getWxOpenId());
|
| | | if (listOpendIDs.size() >= maxSize)
|
| | |
| | |
|
| | | // 资金计算
|
| | | userMoneyService.subUserMoney(userInfo.getId(), money, detail);
|
| | |
|
| | | // 4、发送消息通知
|
| | | String desc = "为保障你的账户余额安全,自动提现金额将不会高于5元";
|
| | | String beizu = "账户中剩余余额请在本App内完成提现";
|
| | | userMoneyMsgNotificationService.extractAuto(extractRecord, "未领取-提现中", desc, beizu);
|
| | |
|
| | | // 满足条件返回信息
|
| | | return userInfo;
|
| | |
| | | extractWeiXinRecordService.updateByPrimaryKeySelective(updeteRecord);
|
| | |
|
| | | if (ExtractWeiXinRecord.RECEIVED.equals(status)) {
|
| | | // 发送消息通知
|
| | | userMoneyMsgNotificationService.extractAuto(record, "已领取-已提现", null, null);
|
| | | } else if (ExtractWeiXinRecord.REFUND.equals(status)) {
|
| | | // 资金明细
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | |
| | | detail.setType(UserMoneyDetailTypeEnum.extractAutoWXRefund);
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(record.getUid()));
|
| | |
|
| | | // 资金计算
|
| | | userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail);
|
| | |
|
| | | // 发送消息通知
|
| | | userMoneyMsgNotificationService.extractAuto(record, "已退回-余额中", null, null);
|
| | | }
|
| | | }
|
| | |
|