title: “SecKill Develop Journey (II)” lang: en ref: seckill-development-journey-part-II permalink: /docs/seckill-development-journey-part-II/ excerpt: “an introduction how to build seckill demo project step by step” last_modified_at: 2017-09-13T09:00:00+08:00 author: Yangyong Zheng tags: [seckill] redirect_from:
[Previous article]({{ site.url }}{{ site.baseurl }}/docs/seckill-development-journey-part/) We only built a core function seckill demo, this article we will gradually improve more features in order to let it had complete function.
Review what we has been done, we can find that:
Maybe you would say that customer management and customer login function are not listed? Indeed, the customer is indispensable in our scenario, in order to simply design, we don‘t include login and token authentication etc., if you are interesting about this, you can see ServiceComb’s Company demo application to get more information.
For entity, domain-driven design (DDD) recommended to use a separate interface, so we design a new Admin micro-service to provide service:
{: .align-center}
Admin micro-service only provide services for promotion entity, we can map this function to REST method:
New promotion map to Post;
Modify promotion map to Put;
Query promotion map to Get;
Delete promotion map to Delete.
To match current requirement we only need implement Post and Get, In addition, already started promotion should not be able to modify, so we increased the corresponding check.
Add a HashSet per promotion to check whether customer had grab coupon;
Add “SecKillPromotionBootstrap” class as promotion bootstrap manager for support multi active, “SecKillCommandService” and “SecKillPersistentRunner” now managed(create) by it。
Add “SecKillRecoveryService” class to check state of promotion, uncomplement promotions whether unstart or activing all need check by it to init start-up information including left coupons, grabbed customers list, etc.
Finally, we use PostMan to check completed functions, Please ensure request body fill with JSON format, and set Content-Type to application/json:
{: .align-center}
{: .align-center}
{: .align-center}