| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | | import org.hibernate.HibernateException;
|
| | | import org.hibernate.Query;
|
| | | import org.hibernate.SQLQuery;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.ThreeSaleMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.hongbao.HongBaoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderItemMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.entity.admin.OrderAdmin;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleGift;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.taobao.OrderVital;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | |
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.order.OrderItemServcie;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.AccountDetailsService;
|
| | | import com.yeshi.fanli.service.inter.user.AccountMessageService;
|
| | | import com.yeshi.fanli.service.inter.user.MoneyRecordService;
|
| | |
| | | import com.yeshi.fanli.util.factory.AccountDetailsFactory;
|
| | | import com.yeshi.fanli.util.factory.AccountMessageFactory;
|
| | | import com.yeshi.fanli.util.factory.HongBaoFactory;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.push.XiaoMiPushUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserNotificationService userNotificationService;
|
| | | |
| | | @Resource
|
| | | private UserMoneyDetailMapper userMoneyDetailMapper;
|
| | |
|
| | | private static final String NEW_USER_HONGBAO = "new_user_hongbao";
|
| | |
|
| | |
| | |
|
| | | AccountDetails ac = AccountDetailsFactory.create("+" + money, AccountDetailsFactory.XINREN, null, null, form);
|
| | | accountDetailsMapper.insertSelective(ac);
|
| | | // 新版资金明细
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createNewerHongBao(hongBao);
|
| | | userMoneyDetail.setId(ac.getId());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userInfoMapper.addHongBaoByUid(form.getId(), new BigDecimal(money));
|
| | | userNotificationService.newerHongBao(form.getId(), new BigDecimal(money));
|
| | |
| | |
|
| | | @Transactional
|
| | | public void updateHongBao(HongBao hongBao, TaoBaoOrder taoBaoOrder) {
|
| | | BigDecimal rate = new BigDecimal(hongBaoManageMapper.selectByKey("hongbao_goods_proportion").getValue())
|
| | | .divide(new BigDecimal(100));
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal rate = proportion.divide(new BigDecimal(100));
|
| | | // 更新红包项
|
| | | HongBao updateHongBao = new HongBao();
|
| | | updateHongBao.setId(hongBao.getId());
|
| | |
| | | });
|
| | | }
|
| | | } else if ("订单结算".equals(taoBaoOrder.getOrderState())) {// 更新预估获取时间
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), rate);
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(taoBaoOrder.geteIncome(), rate);
|
| | | // 设置预计领取时间
|
| | | long settlementTime = TimeUtil.convertDateToTemp2(taoBaoOrder.getSettlementTime().trim());
|
| | | // 预计领取时间
|
| | |
| | | hongBaoMapper.updateByPrimaryKeySelective(updateChildHongBao);
|
| | | });
|
| | |
|
| | | BigDecimal estimate = taoBaoOrder.getEstimate();
|
| | | BigDecimal estimate = taoBaoOrder.geteIncome();
|
| | | updateHongBao.setPayMoney(taoBaoOrder.getSettlement());
|
| | | updateHongBao.setMoney(MoneyBigDecimalUtil.mul(estimate, rate));
|
| | | }
|
| | |
|
| | |
| | | public void addHongBao(Order order, TaoBaoOrder taoBaoOrder, Long orderItemId) {
|
| | | OrderItem orderItem = orderItemMapper.selectByPrimaryKey(orderItemId);
|
| | | // 订单返利比例
|
| | | BigDecimal baseRate = new BigDecimal(hongBaoManageMapper.selectByKey("hongbao_goods_proportion").getValue())
|
| | | .divide(new BigDecimal(100));
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal baseRate = proportion.divide(new BigDecimal(100));
|
| | |
|
| | | // 创建红包
|
| | | JSONObject data = new JSONObject();
|
| | | HongBao hongBao = HongBaoFactory.createHongBao(MoneyBigDecimalUtil.mul(baseRate, taoBaoOrder.getEstimate()),
|
| | | data.toString(), order.getId(), null, order.getUserInfo(), 1, taoBaoOrder.getPayment(),
|
| | | taoBaoOrder.getAuctionId());
|
| | | HongBao hongBao = null;
|
| | | if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算"))
|
| | | // 订单结算应该取结算金额与预估收入
|
| | | hongBao = HongBaoFactory.createHongBao(MoneyBigDecimalUtil.mul(baseRate, taoBaoOrder.geteIncome()),
|
| | | data.toString(), order.getId(), null, order.getUserInfo(), 1, taoBaoOrder.getSettlement(),
|
| | | taoBaoOrder.getAuctionId());
|
| | | else
|
| | | hongBao = HongBaoFactory.createHongBao(MoneyBigDecimalUtil.mul(baseRate, taoBaoOrder.getEstimate()),
|
| | | data.toString(), order.getId(), null, order.getUserInfo(), 1, taoBaoOrder.getPayment(),
|
| | | taoBaoOrder.getAuctionId());
|
| | |
|
| | | hongBao.setOrderId(taoBaoOrder.getOrderId());
|
| | | hongBao.setOrderItemId(orderItem.getId());
|
| | | hongBao.setPreGettime(0L);
|
| | |
| | | if (boss != null) {
|
| | | hongBao.setHasChild(true);
|
| | | }
|
| | |
|
| | | // 如果失效就判定已经失效
|
| | | if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单失效"))
|
| | | hongBao.setState(HongBao.STATE_SHIXIAO);
|
| | |
|
| | | hongBaoMapper.insertSelective(hongBao);
|
| | | // 通知用户订单被统计
|
| | |
| | | else
|
| | | rate = new BigDecimal(hbm.getValue()).divide(new BigDecimal(100));
|
| | | if (rate.compareTo(new BigDecimal(0)) > 0) {
|
| | | HongBao hongBao2 = HongBaoFactory.createHongBao(
|
| | | HongBao hongBao2 = null;
|
| | | if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算")) {
|
| | | // 订单结算应该取结算金额与预估收入
|
| | | hongBao2 = HongBaoFactory.createHongBao(
|
| | | MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.geteIncome(), baseRate)),
|
| | | null, hongBao, boss, Constant.ONESALE);
|
| | | } else {
|
| | | hongBao2 = HongBaoFactory.createHongBao(
|
| | | MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)),
|
| | | null, hongBao, boss, Constant.ONESALE);
|
| | | }
|
| | |
|
| | | HongBaoFactory.createHongBao(
|
| | | MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)),
|
| | | null, hongBao, boss, Constant.ONESALE);
|
| | | // 设置订单号
|
| | |
| | | else
|
| | | rate = new BigDecimal(hbm.getValue()).divide(new BigDecimal(100));
|
| | | if (rate.compareTo(new BigDecimal(0)) > 0) {
|
| | |
|
| | | HongBao hongBao3 = HongBaoFactory.createHongBao(
|
| | | MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)),
|
| | | null, hongBao, boss2, Constant.TWOSALE);
|
| | | // 订单结算应该取结算金额与预估收入
|
| | | HongBao hongBao3 = null;
|
| | | if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算"))
|
| | | hongBao3 = HongBaoFactory.createHongBao(
|
| | | MoneyBigDecimalUtil.mul(rate,
|
| | | MoneyBigDecimalUtil.mul(taoBaoOrder.geteIncome(), baseRate)),
|
| | | null, hongBao, boss2, Constant.TWOSALE);
|
| | | else
|
| | | hongBao3 = HongBaoFactory.createHongBao(
|
| | | MoneyBigDecimalUtil.mul(rate,
|
| | | MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)),
|
| | | null, hongBao, boss2, Constant.TWOSALE);
|
| | | // 设置返利订单号
|
| | | hongBao3.setOrderId(taoBaoOrder.getOrderId());
|
| | | hongBaoMapper.insertSelective(hongBao3);
|