| | |
| | | import com.yeshi.fanli.dao.mybatis.order.OrderItemMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.PidUserMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountDetails;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoExtra;
|
| | |
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
|
| | | @Override
|
| | | public void processOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | |
| | | public void fanli(HongBao hb) throws TaoBaoWeiQuanException {
|
| | | // 查询最新的红包数据
|
| | | hb = hongBaoMapper.selectByPrimaryKeyForUpdate(hb.getId());
|
| | | // 维权中的不返利
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hb.getOrderId(), "维权创建");
|
| | | if (taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | return;
|
| | |
|
| | | taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(hb.getOrderId(), "等待处理");
|
| | | if (taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | return;
|
| | |
|
| | | long currentTimeMillis = System.currentTimeMillis();
|
| | | if (hb.getState() != HongBao.STATE_SHIXIAO) {
|
| | | // 设置为已返利
|
| | |
| | |
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(order.getOrderId());
|
| | | if (orderList != null && orderList.size() > 0 & !StringUtil.isNullOrEmpty(orderList.get(0).getSettlementTime()))
|
| | | order.setJieSuanTime(orderList.get(0).getSettlementTime());
|
| | | if (TimeUtil.convertToTimeTemp(order.getJieSuanTime(), "yyyy-MM-dd HH:mm:ss") >= TimeUtil
|
| | | .convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | order.setJieSuanTime(
|
| | | new Date(TimeUtil.convertToTimeTemp(orderList.get(0).getSettlementTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | | if (order.getJieSuanTime().getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | return;
|
| | | }
|
| | | try {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private HongBao filterWeiQuanINGHongBao(HongBao hongBao) {
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongBao.getOrderId(), "维权创建");
|
| | |
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList1 = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongBao.getOrderId(), "等待处理");
|
| | | if ((taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | || (taoBaoWeiQuanList1 != null && taoBaoWeiQuanList1.size() > 0)) {
|
| | | return null;
|
| | | }
|
| | | return hongBao;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
|
| | | /**
|
| | | * 处理邀请赚订单
|
| | | */
|
| | | // 查询UID的邀请赚订单
|
| | | List<HongBao> hongBaoList = hongBaoMapper.selectCanBalanceHongBaoByChildHongBaoAndUid(uid);
|
| | | BigDecimal money = new BigDecimal(0);
|
| | |
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | // 需要判断退款的订单号
|
| | | Set<String> drawBackOrders = new HashSet<String>();
|
| | |
|
| | | for (HongBao hongBao : hongBaoList) {
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | | |
| | | hongBao = hongBaoMapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | if (hongBao.getState() == HongBao.STATE_BUKELINGQU || hongBao.getState() == HongBao.STATE_KELINGQU) {
|
| | | money = money.add(hongBao.getMoney());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理顶级分享赚
|
| | | */
|
| | |
|
| | | // 查询UID的分享赚订单
|
| | | List<PidOrder> pidOrderList = pidOrderMapper.getCanBalanceListByUid(uid);
|
| | | for (PidOrder pidOrder : pidOrderList) {
|
| | | HongBao hongBao = hongBaoMapper.selectByPrimaryKeyForUpdate(pidOrder.getHongBao().getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | | if (hongBao == null)
|
| | | continue;
|
| | | if (hongBao.getState() == HongBao.STATE_BUKELINGQU || hongBao.getState() == HongBao.STATE_KELINGQU) {
|
| | | money = money.add(hongBao.getMoney());
|
| | | HongBao updateHongBao = new HongBao();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理一级二级分享赚
|
| | | */
|
| | |
|
| | | List<HongBao> totalHongBaoList = new ArrayList<>();
|
| | | // 查询UID的二级或者三级分享赚订单
|
| | | // TODO 暂时查询10000条数据,后面再做分页
|
| | | List<HongBao> hbList = hongBaoMapper.selectCanBalanceHongBaoByTypeAndUid(HongBao.TYPE_SHARE_YIJI, uid, 10000);
|
| | |
|
| | | if (hbList != null && hbList.size() > 0)
|
| | | totalHongBaoList.addAll(hbList);
|
| | |
|
| | |
| | | if (hbList != null && hbList.size() > 0)
|
| | | totalHongBaoList.addAll(hbList);
|
| | |
|
| | |
|
| | | for (HongBao hb : totalHongBaoList) {
|
| | | if (hb.getState() == HongBao.STATE_BUKELINGQU || hb.getState() == HongBao.STATE_KELINGQU) {
|
| | | hb = filterWeiQuanINGHongBao(hb);
|
| | | if (hb == null)
|
| | | continue;
|
| | | money = money.add(hb.getMoney());
|
| | | HongBao updateHongBao = new HongBao();
|
| | | updateHongBao.setId(hb.getId());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 增加用户资金记录
|
| | | */
|
| | |
|
| | | if (money.compareTo(new BigDecimal(0)) > 0) {
|
| | | userInfoMapper.addHongBaoByUid(uid, money);
|
| | | // 添加记录
|