|
|
@ -11,6 +11,7 @@ import com.hai.common.utils.IDGenerator; |
|
|
|
import com.hai.common.utils.RedisUtil; |
|
|
|
import com.hai.common.utils.RedisUtil; |
|
|
|
import com.hai.dao.*; |
|
|
|
import com.hai.dao.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.*; |
|
|
|
|
|
|
|
import com.hai.enum_type.DiscountPlatform; |
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.HighDiscountPackageService; |
|
|
|
import com.hai.service.HighDiscountPackageService; |
|
|
@ -265,7 +266,6 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
public HighDiscountPackageActual freeUserDiscountPackage(Map<String , Object> map) throws Exception { |
|
|
|
public HighDiscountPackageActual freeUserDiscountPackage(Map<String , Object> map) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(MapUtils.getInteger(map , "discountPackageId")); |
|
|
|
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(MapUtils.getInteger(map , "discountPackageId")); |
|
|
|
|
|
|
|
|
|
|
|
// 查询优惠券包实际库存
|
|
|
|
// 查询优惠券包实际库存
|
|
|
@ -282,6 +282,39 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
|
|
|
|
|
|
|
|
// 循环赠送优惠券
|
|
|
|
// 循环赠送优惠券
|
|
|
|
for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) { |
|
|
|
for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) { |
|
|
|
|
|
|
|
HighDiscount discount = highDiscountService.getDiscountById(actualList.getDiscountId()); |
|
|
|
|
|
|
|
if (discount == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券信息不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
HighDiscountUserRel userRel = new HighDiscountUserRel(); |
|
|
|
|
|
|
|
userRel.setDiscountPlatform(DiscountPlatform.getPlatformByCode(discount.getPlatform()).getNumber()); |
|
|
|
|
|
|
|
userRel.setDiscountCompanyId(discount.getCompanyId()); |
|
|
|
|
|
|
|
userRel.setDiscountId(discount.getId()); |
|
|
|
|
|
|
|
userRel.setDiscountName(discount.getDiscountName()); |
|
|
|
|
|
|
|
userRel.setDiscountImg(discount.getDiscountImg()); |
|
|
|
|
|
|
|
userRel.setDiscountUseScope(discount.getUseScope()); |
|
|
|
|
|
|
|
userRel.setDiscountUsingRange(discount.getUsingRange()); |
|
|
|
|
|
|
|
userRel.setDiscountType(discount.getDiscountType()); |
|
|
|
|
|
|
|
userRel.setDiscountCondition(discount.getDiscountCondition()); |
|
|
|
|
|
|
|
userRel.setDiscountPrice(discount.getDiscountPrice()); |
|
|
|
|
|
|
|
userRel.setAgentId(actualList.getAgentId()); |
|
|
|
|
|
|
|
userRel.setUserId(MapUtils.getLong(map , "userId")); |
|
|
|
|
|
|
|
userRel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
|
|
|
userRel.setCreateTime(new Date()); |
|
|
|
|
|
|
|
userRel.setDiscountAgentCodeId(actualList.getAgentDiscountCodeId()); |
|
|
|
|
|
|
|
// 计算使用有效期
|
|
|
|
|
|
|
|
Calendar userEndTime = Calendar.getInstance(); |
|
|
|
|
|
|
|
userEndTime.setTime(new Date()); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.MINUTE, 59); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.SECOND, 59); |
|
|
|
|
|
|
|
userEndTime.add(Calendar.DATE, discount.getEffectiveDay()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userEndTime.getTime().compareTo(discount.getSalesEndTime()) == 1) { |
|
|
|
|
|
|
|
userRel.setUseEndTime(discount.getSalesEndTime()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
userRel.setUseEndTime(userEndTime.getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); |
|
|
|
HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); |
|
|
|
highDiscountUserRel.setDiscountId(actualList.getDiscountId()); |
|
|
|
highDiscountUserRel.setDiscountId(actualList.getDiscountId()); |
|
|
@ -291,17 +324,6 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic |
|
|
|
highDiscountUserRel.setStatus(1); |
|
|
|
highDiscountUserRel.setStatus(1); |
|
|
|
highDiscountUserRel.setCreateTime(new Date()); |
|
|
|
highDiscountUserRel.setCreateTime(new Date()); |
|
|
|
|
|
|
|
|
|
|
|
HighDiscount highDiscount = highDiscountService.getDiscountById(actualList.getDiscountId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算使用有效期
|
|
|
|
|
|
|
|
Calendar userEndTime = Calendar.getInstance(); |
|
|
|
|
|
|
|
userEndTime.setTime(new Date()); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.MINUTE, 59); |
|
|
|
|
|
|
|
userEndTime.set(Calendar.SECOND, 59); |
|
|
|
|
|
|
|
userEndTime.add(Calendar.DATE, highDiscount.getEffectiveDay()); |
|
|
|
|
|
|
|
highDiscountUserRel.setUseEndTime(userEndTime.getTime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId()); |
|
|
|
HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId()); |
|
|
|
|
|
|
|
|
|
|
|
// 修改优惠券二维码状态
|
|
|
|
// 修改优惠券二维码状态
|
|
|
|