| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.PidOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.hongbao.HongBaoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBaoDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.PidOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.HongBaoException;
|
| | | 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.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | @Resource
|
| | | private PidOrderMapper pidOrderMapper;
|
| | |
|
| | | @Override
|
| | | public int insert(HongBaoV2 record) {
|
| | |
| | | if (hb.getParent() != null)
|
| | | v2.setParent(new HongBaoV2(hb.getParent().getId()));
|
| | |
|
| | | if (hb.getPreGettime() == null || hb.getPreGettime() == 0)
|
| | | v2.setPreGetTime(null);
|
| | | else
|
| | | v2.setPreGetTime(new Date(hb.getPreGettime()));
|
| | | if (hb.getType() == HongBao.TYPE_SHARE_GOODS) {
|
| | | if (hb.getBalanceTime() != null)
|
| | | v2.setPreGetTime(new Date(hb.getPreGettime()));
|
| | | else
|
| | | v2.setPreGetTime(null);
|
| | | } else {
|
| | | if (hb.getPreGettime() == null || hb.getPreGettime() == 0)
|
| | | v2.setPreGetTime(null);
|
| | | else
|
| | | v2.setPreGetTime(new Date(hb.getPreGettime()));
|
| | | }
|
| | |
|
| | | v2.setState(hb.getState());
|
| | | if (hb.getState() == 1 && hb.getBalanceTime() != null) {
|
| | | v2.setState(HongBaoV2.STATE_KELINGQU);
|
| | | }
|
| | | v2.setType(type);
|
| | | v2.setUpdateTime(new Date(hb.getCreatetime()));
|
| | | v2.setUrank(hb.getUrank());
|
| | |
| | |
|
| | | if (list.size() <= 0)
|
| | | return;
|
| | | if (list.get(0).getType() == 20)
|
| | | for (HongBao hb1 : list) {
|
| | | PidOrder pidOrder = pidOrderMapper.getPidOrderByHongBaoId(hb1.getId());
|
| | | if (pidOrder != null)
|
| | | hb1.setAuctionId(pidOrder.getAuctionId());
|
| | |
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | |
|
| | | if (orderList == null || orderList.size() < list.size()) {
|
| | |
| | |
|
| | | // 按照auctionId,payMoney排序
|
| | | Comparator<HongBao> cm = new Comparator<HongBao>() {
|
| | |
|
| | | @Override
|
| | | public int compare(HongBao o1, HongBao o2) {
|
| | | return o1.getAuctionId() == o2.getAuctionId()
|
| | | ? (o1.getPayMoney().subtract(o2.getPayMoney()).compareTo(new BigDecimal(0)))
|
| | | : (int) (o1.getAuctionId() - o2.getAuctionId());
|
| | | if (o1.getAuctionId().longValue() < o2.getAuctionId().longValue())
|
| | | return -3;
|
| | | else if (o1.getAuctionId().longValue() > o2.getAuctionId().longValue()) {
|
| | | return 3;
|
| | | } else {
|
| | | if (o1.getState() - o2.getState() > 0)
|
| | | return 2;
|
| | | else if (o1.getState() - o2.getState() < 0)
|
| | | return -2;
|
| | | else {
|
| | | if (o1.getPayMoney().compareTo(o2.getPayMoney()) >= 0)
|
| | | return 1;
|
| | | else
|
| | | return -1;
|
| | | }
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public int compare(TaoBaoOrder o1, TaoBaoOrder o2) {
|
| | | return o1.getAuctionId() == o2.getAuctionId()
|
| | | ? (o1.getPayment().subtract(o2.getPayment()).compareTo(new BigDecimal(0)))
|
| | | : (int) (o1.getAuctionId() - o2.getAuctionId());
|
| | |
|
| | | if (o1.getAuctionId().longValue() < o2.getAuctionId().longValue())
|
| | | return -3;
|
| | | else if (o1.getAuctionId().longValue() > o2.getAuctionId().longValue()) {
|
| | | return 3;
|
| | | } else {
|
| | | if (o1.getPayment().compareTo(o2.getPayment()) < 0)
|
| | | return 2;
|
| | | else
|
| | | return -2;
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | Collections.sort(orderList, cmOrder);
|
| | |
|
| | | for (TaoBaoOrder t : orderList)
|
| | | System.out.println(t.getAuctionId());
|
| | |
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | CommonOrder commonOrder = TaoBaoOrderUtil.convert(orderList.get(i));
|
| | |
| | | // 以实际收入为准计算预估收益
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), rate.divide(new BigDecimal(100))));
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | |
| | | "yyyy-M-dd")));
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), rate.divide(new BigDecimal(100))));
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | | }
|
| | |
| | | // 以实际收入为准计算预估收益
|
| | | if (CommonOrder.STATE_JS == commonOrder.getState()) {
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), rate.divide(new BigDecimal(100))));
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | |
| | | System.out.println("");
|
| | |
|
| | | childUpdate.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), rate.divide(new BigDecimal(100))));
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
|
| | | }
|
| | |
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), firstRate.divide(new BigDecimal(100))));
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | |
| | | "yyyy-M-dd")));
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | firstHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), firstRate.divide(new BigDecimal(100))));
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.insertSelective(firstHongbao);
|
| | |
|
| | |
| | | secondHongbao.setVersion(2);
|
| | | secondHongbao.setState(hongBao.getState());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
|
| | | firstHongbao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | | firstHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(commonOrder.getSettleTime());
|
| | | calendar.add(Calendar.MONTH, 1);
|
| | |
| | | calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
|
| | | "yyyy-M-dd")));
|
| | | } else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | secondHongbao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
|
| | | secondRate.divide(new BigDecimal(100))));
|
| | | secondHongbao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
|
| | | }
|
| | | hongBaoV2Mapper.insertSelective(secondHongbao);
|
| | | }
|
| | |
| | | hongBaoOrder.setCreateTime(new Date());
|
| | | hongBaoOrder.setHongBaoV2(hongBao);
|
| | | hongBaoOrderMapper.insertSelective(hongBaoOrder);
|
| | |
|
| | | // 修改统计数据
|
| | | Long goodsId = commonOrder.getCommonOrderGoods().getId();
|
| | | // 查询商品
|
| | | CommonOrderGoods goods = commonOrderGoodsMapper.selectByPrimaryKey(goodsId);
|
| | |
|
| | | HongBao hb = new HongBao();
|
| | | if (goods != null)
|
| | | hb.setAuctionId(Long.parseLong(goods.getGoodsId()));
|
| | | hb.setUserInfo(hongBao.getUserInfo());
|
| | | hb.setMoney(hongBao.getMoney());
|
| | |
|
| | | try {
|
| | | userShareGoodsGroupService.updateOrderRecord(hb);
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | } else
|
| | | throw new HongBaoException(2, "type错误");
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoDTO> listJiangJinByUid(Long uid, int page, int pageSize) {
|
| | | return hongBaoV2Mapper.listJiangJinByUid(uid, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countJiangJinByUid(Long uid) {
|
| | | Long count = hongBaoV2Mapper.countJiangJinByUid(uid);
|
| | | return count == null ? 0 : count;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalTiChengMoney(Long uid) {
|
| | |
|
| | | return hongBaoV2Mapper.getTotalTiChengMoney(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int getTotalTiChengCount(Long uid) {
|
| | | return hongBaoV2Mapper.getTotalTiChengCount(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getUnGetTiChengMoney(Long uid) {
|
| | | return hongBaoV2Mapper.getUnGetTiChengMoney(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getTotalFanLiMoney(Long uid) {
|
| | | BigDecimal money = hongBaoV2Mapper.getTotalFanLiMoney(uid);
|
| | | return money == null ? new BigDecimal(0) : money;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getUnRecievedFanLiMoney(Long uid) {
|
| | | BigDecimal money = hongBaoV2Mapper.getUnRecievedFanLiMoney(uid);
|
| | | return money == null ? new BigDecimal(0) : money;
|
| | | }
|
| | | }
|