| @@ -239,6 +239,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| couponOrder = wxOrderService.sendFreeCouponToUser(tempCUser.getId(), wxCoupon.getId()); | couponOrder = wxOrderService.sendFreeCouponToUser(tempCUser.getId(), wxCoupon.getId()); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return false; | |||||
| } | } | ||||
| if (couponOrder != null) { | if (couponOrder != null) { | ||||
| wxCouponActionLogService.addOne(tempCUser.getTenantId(), wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId); | wxCouponActionLogService.addOne(tempCUser.getTenantId(), wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId); | ||||
| @@ -15,6 +15,7 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Propagation; | |||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -103,7 +104,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public boolean sendCouponToUser(EnumCouponSendSendType type, Object param) { | public boolean sendCouponToUser(EnumCouponSendSendType type, Object param) { | ||||
| String tenantId; | String tenantId; | ||||
| @@ -177,12 +178,17 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| continue; | continue; | ||||
| // 发放免费券 | // 发放免费券 | ||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId()); | |||||
| if (couponOrder != null) { | |||||
| wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId()); | |||||
| bRet = true; | |||||
| WxCouponOrder couponOrder = null; | |||||
| try { | |||||
| couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId()); | |||||
| if (couponOrder != null) { | |||||
| wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId()); | |||||
| bRet = true; | |||||
| } | |||||
| // wxCouponService.reduceInventory(send.getCouponId(), 1); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | } | ||||
| wxCouponService.reduceInventory(send.getCouponId(), 1); | |||||
| } | } | ||||
| return bRet; | return bRet; | ||||
| @@ -614,7 +614,12 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } | } | ||||
| // 减库存操作 | // 减库存操作 | ||||
| stockReduce(user, coupon, couponIdStr); | |||||
| try { | |||||
| stockReduce(user, coupon, couponIdStr); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| int payment = coupon.getSalePrice(); | int payment = coupon.getSalePrice(); | ||||
| @@ -665,7 +670,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId) { | public WxCouponOrder sendFreeCouponToUser(Long userId, Long couponId) { | ||||
| // check 用户状态 | // check 用户状态 | ||||
| WxCUser user = null; | WxCUser user = null; | ||||
| @@ -771,7 +776,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| updateOrder.setUpdateDate(currentDate); | updateOrder.setUpdateDate(currentDate); | ||||
| int ret = 0; | int ret = 0; | ||||
| try { | try { | ||||
| ret = wxOrderMapper.updateByPrimaryKey(updateOrder); | |||||
| wxOrderMapper.updateByPrimaryKey(updateOrder); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("订单更新失败:" + e.getMessage()); | logger.error("订单更新失败:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); | throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); | ||||
| @@ -1191,10 +1191,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| // 修改订单状态 | // 修改订单状态 | ||||
| try { | try { | ||||
| int _count = wxOrderService.couponOrderSuccess(order); | |||||
| if (_count > 1) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL); | |||||
| } | |||||
| wxOrderService.couponOrderSuccess(order); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单更新"); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单更新"); | ||||