| | |
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.PidOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.AccountDetailsFactory;
|
| | | import com.yeshi.fanli.util.factory.HongBaoFactory;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | |
|
| | | @Service
|
| | |
| | |
|
| | | // @Resource
|
| | | // private LostOrderService lostOrderService;
|
| | | |
| | | @Resource |
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | |
| | | @Override
|
| | | @Transactional
|
| | | public void doPidOrder(String orderId) {
|
| | | BigDecimal rate = hongBaoManageService.getFanLiRate();
|
| | |
|
| | | List<PidOrder> orders = pidOrderMapper.getPidOrderListByOrderId(orderId);
|
| | | // 只看有用户Id的情况
|
| | | if (orders.get(0).getUserInfo() != null) {
|
| | | // 根据第一个的订单创建时间来确定返利比例
|
| | | BigDecimal rate = hongBaoManageService.getShareRate(orders.get(0).getOrderCreateTime().getTime())
|
| | | .divide(new BigDecimal("100"));
|
| | | List<HongBao> hbList = hongBaoMapper.selectByOrderId(orderId);
|
| | | if (hbList.size() <= 0) {// 还没有加入红包
|
| | | // 加入红包
|
| | | for (PidOrder order : orders) {
|
| | |
|
| | | // 防止同一订单号来源于不同的PID
|
| | | if (order.getUserInfo() == null)
|
| | | continue;
|
| | |
| | | }
|
| | |
|
| | | hongBaoMapper.insertSelective(hongBao);
|
| | |
|
| | | |
| | | //统计分享订单的数据
|
| | | try {
|
| | | // 第三方提成订单被统计的通知
|
| | | userNotificationService.tiChengStatisticed(hongBao.getUserInfo().getId(),
|
| | | hongBao.getOrderId(), hongBao.getMoney());
|
| | | } catch (Exception e) {
|
| | |
|
| | | hongBao.setAuctionId(order.getAuctionId());
|
| | | userShareGoodsGroupService.updateOrderRecord(hongBao);
|
| | | } catch (UserShareGoodsRecordException e1) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | PidOrder updatePidOrder = new PidOrder();
|
| | | updatePidOrder.setId(order.getId());
|
| | |
| | | hongBao2.setOrderId(order.getOrderId());
|
| | |
|
| | | hongBaoMapper.insertSelective(hongBao2);
|
| | | try {
|
| | | // 第三方提成订单被统计的通知
|
| | | userNotificationService.tiChengStatisticed(hongBao2.getUserInfo().getId(),
|
| | | hongBao2.getOrderId(), hongBao2.getMoney());
|
| | | } catch (Exception e) {
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | |
| | | hongBao3.setOrderId(order.getOrderId());
|
| | | hongBaoMapper.insertSelective(hongBao3);
|
| | |
|
| | | try {
|
| | | // 第三方提成订单被统计的通知
|
| | | userNotificationService.tiChengStatisticed(hongBao3.getUserInfo().getId(),
|
| | | hongBao3.getOrderId(), hongBao3.getMoney());
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // 结算到账户
|
| | |
|
| | | @Override
|
| | | public void balanceOrder() {
|
| | | // 获取到该月25日可结算的订单
|
| | | List<PidOrder> list = pidOrderMapper.getCanBalanceList(1000);
|
| | | if (list != null) {
|
| | | Map<String, List<PidOrder>> map = parseOrderMap(list);
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String orderId = its.next();
|
| | | List<PidOrder> orders = map.get(orderId);
|
| | | for (int i = 0; i < orders.size(); i++)
|
| | | balanceOrder(orders.get(i));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void compareOrderAndHongBao() {
|
| | | List<PidOrder> list = pidOrderMapper.selectByState("订单付款", 100);
|
| | | list.addAll(pidOrderMapper.selectByState("订单结算", 100));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void balanceOrder(PidOrder pidOrder) {
|
| | | if (pidOrder.getHongBao() == null)
|
| | | return;
|
| | | // 查找红包
|
| | | HongBao hongBao = hongBaoMapper.selectByPrimaryKey(pidOrder.getHongBao().getId());
|
| | | if (hongBao.getState() == HongBao.STATE_SHIXIAO || hongBao.getState() == HongBao.STATE_YILINGQU)
|
| | | return;
|
| | |
|
| | | HongBao updateHongBao = new HongBao();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | | updateHongBao.setGetTime(System.currentTimeMillis());
|
| | | updateHongBao.setState(HongBao.STATE_YILINGQU);
|
| | | hongBaoMapper.updateByPrimaryKeySelective(updateHongBao);
|
| | |
|
| | | // 加入用户余额
|
| | | userInfoMapper.addHongBaoByUid(hongBao.getUserInfo().getId(), hongBao.getMoney());
|
| | | // 加入账户明细
|
| | | AccountDetails ad = AccountDetailsFactory.create("+" + hongBao.getMoney(), AccountDetailsFactory.SHARE_GOODS,
|
| | | null, null, hongBao.getUserInfo());
|
| | | accountDetailsMapper.insertSelective(ad);
|
| | | try {
|
| | | userNotificationService.tiChengRecieved(hongBao.getUserInfo().getId(), hongBao.getMoney());
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | PidOrder updatePidOrder = new PidOrder();
|
| | | updatePidOrder.setId(pidOrder.getId());
|
| | | updatePidOrder.setAccountBalance(true);
|
| | | updatePidOrder.setAccountBalanceTime(new Date());
|
| | | pidOrderMapper.updateByPrimaryKeySelective(updatePidOrder);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void weiQuan(String orderId) {
|
| | |
| | | AccountDetails ad = AccountDetailsFactory.create("-" + hongBao.getMoney(),
|
| | | AccountDetailsFactory.SHARE_GOODS_DRAWBACK, null, null, hongBao.getUserInfo());
|
| | | accountDetailsMapper.insertSelective(ad);
|
| | | |
| | | |
| | | |
| | |
|
| | | // 维权通知
|
| | | try {
|