| | |
| | | package com.yeshi.fanli.service.impl.order.tb;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoPunishOrderMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoPunishOrder;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoPunishOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class TaoBaoPunishOrderServiceImpl implements TaoBaoPunishOrderService {
|
| | |
|
| | | @Resource
|
| | | private TaoBaoPunishOrderMapper taoBaoPunishOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountService userAccountService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void doPunishOrder(TaoBaoPunishOrder order, Set<Long> uidSets) {
|
| | | if (order == null)
|
| | | return;
|
| | | // 首先保存
|
| | | if (taoBaoPunishOrderMapper.selectByTradeId(order.getTbTradeId()) == null)
|
| | | savePunishOrder(order);
|
| | | // 然后
|
| | | CommonOrder co = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | order.getTbTradeId());
|
| | | if (co != null) {
|
| | | uidSets.add(co.getUserInfo().getId());
|
| | | HongBaoOrder hongBaoOder = hongBaoOrderService.selectDetailByCommonOrderId(co.getId());
|
| | | if (hongBaoOder.getHongBaoV2() != null
|
| | | && (hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_BUKELINGQU
|
| | | || hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_KELINGQU)) {
|
| | | HongBaoV2 updateHongBao = new HongBaoV2(hongBaoOder.getHongBaoV2().getId());
|
| | | updateHongBao.setUpdateTime(new Date());
|
| | | updateHongBao.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | updateHongBao.setBeizhu("联盟违规");
|
| | | hongBaoV2Service.updateByPrimaryKeySelective(updateHongBao);
|
| | | // 查询是否有子红包
|
| | | List<HongBaoV2> childList = hongBaoV2Service.listChildrenById(hongBaoOder.getHongBaoV2().getId());
|
| | | for (HongBaoV2 child : childList) {
|
| | | if ((child.getState() == HongBaoV2.STATE_BUKELINGQU
|
| | | || child.getState() == HongBaoV2.STATE_KELINGQU)) {
|
| | | HongBaoV2 update = new HongBaoV2(child.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | update.setBeizhu("联盟违规");
|
| | | hongBaoV2Service.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | } else if (hongBaoOder.getHongBaoV2() != null
|
| | | && hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | List<HongBaoV2> childList = hongBaoV2Service.listChildrenById(hongBaoOder.getHongBaoV2().getId());
|
| | | for (HongBaoV2 child : childList) {
|
| | | if ((child.getState() == HongBaoV2.STATE_BUKELINGQU
|
| | | || child.getState() == HongBaoV2.STATE_KELINGQU)) {
|
| | | //未到账的子红包也需要失效
|
| | | HongBaoV2 update = new HongBaoV2(child.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | update.setBeizhu("联盟违规");
|
| | | hongBaoV2Service.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void savePunishOrder(TaoBaoPunishOrder order) {
|
| | | if (order == null)
|
| | | return;
|
| | | TaoBaoPunishOrder old = taoBaoPunishOrderMapper.selectByTradeId(order.getTbTradeId());
|
| | | if (old == null) {
|
| | | if (order.getCreateTime() == null)
|
| | | order.setCreateTime(new Date());
|
| | | }
|
| | | taoBaoPunishOrderMapper.insertSelective(order);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void doPunishOrder(List<TaoBaoPunishOrder> orderList) {
|
| | | Set<String> relationIdSets = new HashSet<>();
|
| | | Set<String> specialIdSets = new HashSet<>();
|
| | | Set<Long> uidSets = new HashSet<>();
|
| | |
|
| | | // for (TaoBaoPunishOrder order : orderList) {
|
| | | // if (!StringUtil.isNullOrEmpty(order.getRelationId()))
|
| | | // relationIdSets.add(order.getRelationId());
|
| | | //
|
| | | // if (!StringUtil.isNullOrEmpty(order.getSpecialId()))
|
| | | // specialIdSets.add(order.getSpecialId());
|
| | | //
|
| | | // doPunishOrder(order, uidSets);
|
| | | // }
|
| | |
|
| | | for (Iterator<String> its = relationIdSets.iterator(); its.hasNext();) {
|
| | | String relationId = its.next();
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(relationId,null);
|
| | | if (info != null && info.getUser() != null)
|
| | | uidSets.add(info.getUser().getId());
|
| | | }
|
| | |
|
| | | for (Iterator<String> its = specialIdSets.iterator(); its.hasNext();) {
|
| | | String specialId = its.next();
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getBySpecialId(specialId,null);
|
| | | if (info != null && info.getUser() != null)
|
| | | uidSets.add(info.getUser().getId());
|
| | | }
|
| | | // 封禁用户
|
| | |
|
| | | for (Iterator<Long> its = uidSets.iterator(); its.hasNext();) {
|
| | | Long uid = its.next();
|
| | | userAccountService.forbiddenUserAll(uid, "产生违规订单自动封禁");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int countByTradeParentId(String orderId) {
|
| | | return (int) (taoBaoPunishOrderMapper.countByParentTradeId(orderId));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.order.tb; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoPunishOrderMapper; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoPunishOrder; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoPunishOrderService; |
| | | import com.yeshi.fanli.service.inter.user.UserAccountService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | |
| | | @Service |
| | | public class TaoBaoPunishOrderServiceImpl implements TaoBaoPunishOrderService { |
| | | |
| | | @Resource |
| | | private TaoBaoPunishOrderMapper taoBaoPunishOrderMapper; |
| | | |
| | | @Resource |
| | | private HongBaoV2Service hongBaoV2Service; |
| | | |
| | | @Resource |
| | | private HongBaoOrderService hongBaoOrderService; |
| | | |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserAccountService userAccountService; |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void doPunishOrder(TaoBaoPunishOrder order, Set<Long> uidSets) { |
| | | if (order == null) |
| | | return; |
| | | // 首先保存 |
| | | if (taoBaoPunishOrderMapper.selectByTradeId(order.getTbTradeId()) == null) |
| | | savePunishOrder(order); |
| | | // 然后 |
| | | CommonOrder co = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, |
| | | order.getTbTradeId()); |
| | | if (co != null) { |
| | | uidSets.add(co.getUserInfo().getId()); |
| | | HongBaoOrder hongBaoOder = hongBaoOrderService.selectDetailByCommonOrderId(co.getId()); |
| | | if (hongBaoOder.getHongBaoV2() != null |
| | | && (hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_BUKELINGQU |
| | | || hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_KELINGQU)) { |
| | | HongBaoV2 updateHongBao = new HongBaoV2(hongBaoOder.getHongBaoV2().getId()); |
| | | updateHongBao.setUpdateTime(new Date()); |
| | | updateHongBao.setState(HongBaoV2.STATE_SHIXIAO); |
| | | updateHongBao.setBeizhu("联盟违规"); |
| | | hongBaoV2Service.updateByPrimaryKeySelective(updateHongBao); |
| | | // 查询是否有子红包 |
| | | List<HongBaoV2> childList = hongBaoV2Service.listChildrenById(hongBaoOder.getHongBaoV2().getId()); |
| | | for (HongBaoV2 child : childList) { |
| | | if ((child.getState() == HongBaoV2.STATE_BUKELINGQU |
| | | || child.getState() == HongBaoV2.STATE_KELINGQU)) { |
| | | HongBaoV2 update = new HongBaoV2(child.getId()); |
| | | update.setUpdateTime(new Date()); |
| | | update.setState(HongBaoV2.STATE_SHIXIAO); |
| | | update.setBeizhu("联盟违规"); |
| | | hongBaoV2Service.updateByPrimaryKeySelective(update); |
| | | } |
| | | } |
| | | } else if (hongBaoOder.getHongBaoV2() != null |
| | | && hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU) { |
| | | List<HongBaoV2> childList = hongBaoV2Service.listChildrenById(hongBaoOder.getHongBaoV2().getId()); |
| | | for (HongBaoV2 child : childList) { |
| | | if ((child.getState() == HongBaoV2.STATE_BUKELINGQU |
| | | || child.getState() == HongBaoV2.STATE_KELINGQU)) { |
| | | //未到账的子红包也需要失效 |
| | | HongBaoV2 update = new HongBaoV2(child.getId()); |
| | | update.setUpdateTime(new Date()); |
| | | update.setState(HongBaoV2.STATE_SHIXIAO); |
| | | update.setBeizhu("联盟违规"); |
| | | hongBaoV2Service.updateByPrimaryKeySelective(update); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void savePunishOrder(TaoBaoPunishOrder order) { |
| | | if (order == null) |
| | | return; |
| | | TaoBaoPunishOrder old = taoBaoPunishOrderMapper.selectByTradeId(order.getTbTradeId()); |
| | | if (old == null) { |
| | | if (order.getCreateTime() == null) |
| | | order.setCreateTime(new Date()); |
| | | } |
| | | taoBaoPunishOrderMapper.insertSelective(order); |
| | | } |
| | | |
| | | @Override |
| | | public void doPunishOrder(List<TaoBaoPunishOrder> orderList) { |
| | | Set<String> relationIdSets = new HashSet<>(); |
| | | Set<String> specialIdSets = new HashSet<>(); |
| | | Set<Long> uidSets = new HashSet<>(); |
| | | |
| | | // for (TaoBaoPunishOrder order : orderList) { |
| | | // if (!StringUtil.isNullOrEmpty(order.getRelationId())) |
| | | // relationIdSets.add(order.getRelationId()); |
| | | // |
| | | // if (!StringUtil.isNullOrEmpty(order.getSpecialId())) |
| | | // specialIdSets.add(order.getSpecialId()); |
| | | // |
| | | // doPunishOrder(order, uidSets); |
| | | // } |
| | | |
| | | for (Iterator<String> its = relationIdSets.iterator(); its.hasNext();) { |
| | | String relationId = its.next(); |
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByRelationId(relationId,null); |
| | | if (info != null && info.getUser() != null) |
| | | uidSets.add(info.getUser().getId()); |
| | | } |
| | | |
| | | for (Iterator<String> its = specialIdSets.iterator(); its.hasNext();) { |
| | | String specialId = its.next(); |
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getBySpecialId(specialId,null); |
| | | if (info != null && info.getUser() != null) |
| | | uidSets.add(info.getUser().getId()); |
| | | } |
| | | // 封禁用户 |
| | | |
| | | for (Iterator<Long> its = uidSets.iterator(); its.hasNext();) { |
| | | Long uid = its.next(); |
| | | userAccountService.forbiddenUserAll(uid, "产生违规订单自动封禁"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int countByTradeParentId(String orderId) { |
| | | return (int) (taoBaoPunishOrderMapper.countByParentTradeId(orderId)); |
| | | } |
| | | |
| | | } |