template_key为空

来源:7-12 构造优惠券模板功能实现

洪小才

2020-06-15

生成成功后,template_key没有,我去翻了一下老师您的代码也没有关于template_key有关的set操作,具体是再哪里生成的,老师能不能直接贴代码或者告诉我大致的位置

写回答

2回答

张勤一

2020-06-15

同学你好:

    课程中对于这里的介绍讲解肯定是有的,这是个异步过程,具体执行的地方是

@Async("getAsyncExecutor")
@Override
@SuppressWarnings("all")
public void asyncConstructCouponByTemplate(CouponTemplate template) {

    Stopwatch watch = Stopwatch.createStarted();

    Set<String> couponCodes = buildCouponCode(template);

    // imooc_coupon_template_code_1
    String redisKey = String.format("%s%s",
            Constant.RedisPrefix.COUPON_TEMPLATE, template.getId().toString());
    log.info("Push CouponCode To Redis: {}",
            redisTemplate.opsForList().rightPushAll(redisKey, couponCodes));

    template.setAvailable(true);
    templateDao.save(template);

    watch.stop();
    log.info("Construct CouponCode By Template Cost: {}ms",
            watch.elapsed(TimeUnit.MILLISECONDS));

    // TODO 发送短信或者邮件通知优惠券模板已经可用
    log.info("CouponTemplate({}) Is Available!", template.getId());
}

    跟着我的代码一步步找肯定是能找到的。


    欢迎来 QQ 群随时交流、讨论,也非常感谢同学的支持!

1
2
sheisshine
回复
洪小才
序列化类里有实现
2020-08-13
共2条回复

绾绾爱吃肉

2020-09-26

优惠券模板对象定义的时候不是有优惠券模板key的生成规则嘛 产品线加种类加日期什么的

0
0

Spring Cloud微服务实战 打造企业级优惠券系统

微服务,SpringCloud,SpringBoot面试、毕设、

1210 学习 · 488 问题

查看课程