| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | |
| | |
|
| | | @Override
|
| | | public void fanli() {
|
| | | LogHelper.test("处理返利到账");
|
| | | // 获取主红包
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBao.TYPE_TAOBAO, 100);
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBaoV2.TYPE_ZIGOU, 1000);
|
| | | //
|
| | | // /**
|
| | | // * 需要实时更新待返利的订单
|
| | |
| | | public void fanli(HongBaoV2 hb1) throws TaoBaoWeiQuanException {
|
| | | // 查询最新的红包数据
|
| | | hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
|
| | | // 正常用户才能到账
|
| | | UserInfo mainUser = userInfoMapper.selectByPrimaryKey(hb1.getUserInfo().getId());
|
| | | if (mainUser == null || mainUser.getState() != UserInfo.STATE_NORMAL) {
|
| | | return;
|
| | | }
|
| | | // 查询红包相关联的订单
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hb1.getId());
|
| | | if (hongBaoOrder == null) {
|
| | | LogHelper.error("返利失败:" + hb1.getId());
|
| | | return;
|
| | | }
|
| | |
|
| | | // 灰度测试中,京东/拼多多不返利
|
| | | if (hongBaoOrder.getCommonOrder() == null
|
| | | || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD
|
| | | || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD) {
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | if (olist != null && olist.size() > 0) {
|
| | | long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoAllOrder(TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"),
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoKeOrderApiUtil.TK_STATUS_ALL);
|
| | | List<TaoBaoOrder> thirdOList = TaoKeOrderApiUtil.getTaoBaoThirdAllOrder(
|
| | | TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"), 30, 1,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | TaoKeOrderApiUtil.TK_STATUS_ALL, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | if (thirdOList != null && thirdOList.size() > 0)
|
| | | olist.addAll(thirdOList);
|
| | |
|
| | |
| | | public void weiQuanOrder(List<TaoBaoWeiQuanOrder> orderList) {
|
| | | if (orderList != null)
|
| | | for (TaoBaoWeiQuanOrder order : orderList) {
|
| | | if (order.getState().contains("维权成功")) {
|
| | | CMQManager.getInstance().addWeiQuanOrderMsg(order);
|
| | | try {
|
| | | if (order.getState().contains("维权成功")) {
|
| | | CMQManager.getInstance().addWeiQuanOrderMsg(order);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("维权订单加入到队列出错:" + order != null ? new Gson().toJson(order) : null);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 1000);
|
| | | long count= hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid);
|
| | | List<HongBaoV2> hongBaoList =new ArrayList<>();
|
| | | //1000条数据为1页
|
| | | int page=(int) (count%1000==0?count/1000:count/1000+1);
|
| | | for(int i=0;i<page;i++)
|
| | | {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, i*1000,1000);
|
| | | if(tempHongBaoList!=null&&tempHongBaoList.size()>0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | | // 灰度测试中,京东/拼多多订单分享/邀请订单不返利
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item.getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | } else {
|
| | | item = item.getParent();
|
| | | }
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | if (co.getSourceType() == Constant.SOURCE_TYPE_JD
|
| | | || co.getSourceType() == Constant.SOURCE_TYPE_PDD) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | } else {// 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | |
|
| | |
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000);
|
| | | //TODO 需要处理超过1w条数据的订单
|
| | | List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid,0, 10000);
|
| | |
|
| | | if (hbList != null && hbList.size() > 0)
|
| | | totalHongBaoList.addAll(hbList);
|
| | |
| | | // 查询UID的分享赚订单
|
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000);
|
| | | //TODO 需要处理超过10000条数据的订单
|
| | | List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid,0, 10000);
|
| | | for (HongBaoV2 hongBao : hongBaoShareList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | |
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = commonOrderService.countByUidAndOrderStateWithOrderBalanceTime(uid,
|
| | | CommonOrder.STATE_JS, minDate, maxDate);
|
| | | long weiQuanCount = commonOrderService.countByUidAndOrderStateWithOrderBalanceTime(uid,
|
| | | CommonOrder.STATE_WQ, minDate, maxDate);
|
| | | long invalidCount = commonOrderService.countByUidAndOrderStateWithOrderBalanceTime(uid,
|
| | | CommonOrder.STATE_SX, minDate, maxDate);
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | | long invalidCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, (int) invalidCount, sharemoney, new Date());
|
| | |
| | | public void processJDOrder(JDOrder order) {
|
| | | if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
|
| | | return;
|
| | |
|
| | | // 拆单的不做处理
|
| | | if (order.getValidCode() == 2)
|
| | | return;
|
| | |
|
| | | String uidStr = order.getExt1();
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr))
|
| | | if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | | Long positionId = order.getOrderItemList().get(0).getPositionId();
|
| | | if (positionId == JDApiUtil.POSITION_FANLI)// 返利订单
|
| | |
| | |
|
| | | /**
|
| | | * 处理京东返利订单
|
| | | * |
| | | * @param jdOrder
|
| | | * @param uid
|
| | | */
|
| | |
| | | // 加入订单
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(jdOrder.getOrderId() + "",
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | if (uid == null && oldOrder.getBeizhu().contains("补单"))
|
| | | if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("补单"))
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
|
| | | if (uid == null)
|
| | |
| | |
|
| | | /**
|
| | | * 处理京东分享订单
|
| | | * |
| | | * @param order
|
| | | * @param uid
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 处理拼多多自购返利订单
|
| | | * |
| | | * @param pddOrder
|
| | | * @param uid
|
| | | */
|
| | |
| | |
|
| | | // 加入订单
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD);
|
| | | if (uid == null && oldOrder.getBeizhu().contains("补单"))
|
| | | if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("补单"))
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
|
| | | if (uid == null)
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 处理拼多多分享订单
|
| | | * |
| | | * @param order
|
| | | * @param uid
|
| | | */
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void repairCommonOrderByByTaoBaoOrder(String orderId) {
|
| | | // 根据订单号查询淘宝订单
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
|
| | | if (orderList != null)
|
| | | for (TaoBaoOrder order : orderList) {
|
| | | // 根据交易ID查询常规订单
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | order.getTradeId());
|
| | | // 修复orderby
|
| | | if (commonOrder != null) {
|
| | | CommonOrder update = new CommonOrder(commonOrder.getId());
|
| | | update.setOrderBy(order.getOrderBy());
|
| | | update.setUpdateTime(new Date());
|
| | | commonOrderService.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|