| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void useGoodsCoupon(Long uid, Long id, Long goodId) throws UserSystemCouponException, Exception {
|
| | | public void useGoodsCoupon(Long uid, Long id, Long goodId, Integer sourceType) throws UserSystemCouponException, Exception {
|
| | | if (uid == null) {
|
| | | throw new UserSystemCouponException(1, "用户未登录");
|
| | | }
|
| | |
| | | // 插入使用券记录
|
| | | UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
|
| | | couponRecord.setGoodId(goodId);
|
| | | couponRecord.setGoodSource(Constant.SOURCE_TYPE_TAOBAO); // 默认淘宝
|
| | | couponRecord.setGoodSource(sourceType); // 默认淘宝
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_WAIT); // 正在匹配
|
| | | couponRecord.setUserSystemCoupon(userSystemCoupon);
|
| | | couponRecord.setCouponType(baseCoupon.getType().name());
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void useOrderCoupon(Long uid, Long id, String orderNo, Integer goodsType) throws UserSystemCouponException, Exception {
|
| | | public void useOrderCoupon(Long uid, Long id, String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
|
| | |
|
| | | if (id == null) {
|
| | | throw new UserSystemCouponException(1, "券id不存在");
|
| | | }
|
| | |
|
| | | |
| | | if (sourceType == null) {
|
| | | sourceType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | }
|
| | | |
| | | // 用户券
|
| | | UserSystemCoupon userSystemCoupon = selectByPrimaryKey(id);
|
| | | if (userSystemCoupon == null) {
|
| | |
| | | }
|
| | |
|
| | | // 订单
|
| | | CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS);
|
| | | CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS, sourceType);
|
| | | if (orderVO == null) {
|
| | | throw new UserSystemCouponException(1, "订单信息获取失败");
|
| | | }
|
| | |
| | | // 条件: A:必须是返利订单 、B:必须已经处于已到账状态
|
| | | if (HongBaoV2.TYPE_ZIGOU == hongBaoType && HongBaoV2.STATE_YILINGQU == hongBaoState || hongBao != null) {
|
| | |
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderNo, goodsType);
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderNo, sourceType);
|
| | | if (order == null)
|
| | | return;
|
| | |
|
| | |
| | | // 2.插入关联
|
| | | orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
|
| | |
|
| | | // 3.插入资金明细,用户余额 // TODO
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo,goodsType, money,
|
| | | // 3.插入资金明细,用户余额
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo, sourceType, money,
|
| | | new UserInfo(uid));
|
| | | userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
|
| | | userInfoService.addMoney(new UserInfo(uid), money);
|
| | |
|
| | | // 插入资金通知
|
| | | userMoneyMsgNotificationService.orderReward(uid, orderNo,goodsType, money,
|
| | | userMoneyMsgNotificationService.orderReward(uid, orderNo, sourceType, money,
|
| | | userInfoService.selectByPKey(uid).getMyHongBao());
|
| | |
|
| | | /* 用户券信息状态及记录处理 */
|
| | |
| | | // 插入使用券记录
|
| | | UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
|
| | | couponRecord.setGoodSource(goodsType);
|
| | | couponRecord.setGoodSource(sourceType);
|
| | | couponRecord.setOrderNo(orderNo);
|
| | | couponRecord.setUserSystemCoupon(userSystemCoupon);
|
| | | couponRecord.setCouponType(systemCoupon.getType().name());
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
|
| | | public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
|
| | |
|
| | | if (orderNo == null || orderNo.trim().length() == 0) {
|
| | | throw new UserSystemCouponException(1, "订单号不存在");
|
| | |
| | | Long uid = userSystemCoupon.getUid();
|
| | |
|
| | | CommonOrderVO commonOrderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo,
|
| | | CommonOrder.STATE_JS);
|
| | | CommonOrder.STATE_JS, sourceType);
|
| | |
|
| | | if (commonOrderVO == null) {
|
| | | throw new UserSystemCouponException(1, "订单信息获取失败");
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
|
| | | public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
|
| | |
|
| | | if (orderNo == null || orderNo.trim().length() == 0) {
|
| | | throw new UserSystemCouponException(1, "订单号不存在");
|
| | |
| | | }
|
| | |
|
| | | // 订单
|
| | | CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null);
|
| | | CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null, sourceType);
|
| | | if (orderVO == null) {
|
| | | throw new UserSystemCouponException(1, "订单信息获取失败");
|
| | | }
|