Java Open source Fresh e-commerce platform-coupon design and architecture (source code can be downloaded)

Source: Internet
Author: User

Java Open source Fresh e-commerce platform-coupon design and architecture (source code can be downloaded)

Description: Now the level of e-commerce, whether it is fresh electricity or other e-commerce, and so on, there will be a promotion of this system, the purpose is to increase order volume and visibility and so on

So for Java Open Source Fresh e-commerce platform, we use coupons to promote this way. (The subsidy price war is very scary for the burning of money, too much to burn money)

1. Coupon Basic Information Sheet

Note: Any coupon or voucher is a basic description, such as: coupon name, type, price, validity, status, description, etc. basic information.

CREATE TABLE ' coupon ' (' id ' bigint (Unsigned not NULL auto_increment COMMENT ' Auto increment id ', ' region_id ' bigint (DEFAULT NULL COMMENT ' belongs to zone ', ' type 'int(one) DEFAULT NULL COMMENT ' belongs to type, 1 is full minus ', ' name ' varchar (DEFAULT NULL COMMENT ' coupon name ', ' img ' varchar (DEFAULT NULL COMMENT ' picture URL address ', ' start_time ' datetime DEFAULT NULL COMMENT' Coupon start time ', ' end_time ' datetime DEFAULT NULL COMMENT' Coupon End Time ', ' Money ' decimal (11,2) Default NULL COMMENT ' coupon amount, with integer, fixed value present. ‘, ' status 'int(one) DEFAULT NULL COMMENT ' state, 0 means not started, 1 means in progress,-1 means end ', ' remarks ' varchar ((+) DEFAULT NULL COMMENT ' coupon description ', ' create_time ' datetime DEFAULT NULL COMMENT' Create Time ', ' Full_money ' Decimal (12,2) DEFAULT NULL COMMENT ' full amount ', PRIMARY KEY (' id ')) ENGINE=innodb DEFAULT Charset=utf8 comment= ' coupon base configuration table ';

Description: The business said can be defined in a certain area, do coupons, and is naxin after, so increase the buyer's users. The price can be set at the back end.

The significance of the state is that the user needs to register after the completion, and then actively claim to be effective, why this design? The goal is only one: let the user play with the app this software for a while to increase the level of familiarity.

2. Coupon Collection Record form

Description: We need to record the buyer, when the pick, pick up the time, the amount of the coupon is how much, etc., whether the information has been used, etc.

CREATE TABLE ' coupon_receive ' (  ' id ' bigint () unsigned not NULL auto_increment COMMENT ' auto increment id ',  ' buyer_id ' bigint () default NULL COMMENT ' buyer ID ',  ' coupon_id ' bigint (default null COMMENT ' Coupon number ') ,  ' Coupon_money ' decimal (12,2) DEFAULT NULL COMMENT ' coupon amount ',  ' pick time ',  ' Full_money ' Decimal (12,2) default null COMMENT ' Amount full ',  int(one) default null COMMENT ' state, 1 is used, 0 for the received unused, 1 for expired ',  PRIMARY KEY (' id ')) ENGINE=innodb DEFAULT charset=utf8 comment= ' coupon collection record form ';

3. Coupon Consumption record form

Description: Coupon consumption record form, it is necessary to know that the buyer, that coupon, the order used the coupon, there is a special note here is that this coupon execution in the payment after the successful callback.

CREATE TABLE ' coupon_logs ' (' id ' bigint (Unsigned not NULL auto_increment COMMENT ' Auto increment id ', ' buyer_id ' bigint (DEFAULT NULL COMMENT ' buyer ID ', ' coupon_receive_id ' bigint (DEFAULT NULL COMMENT ' coupon ID ', ' order_number ' varchar () DEFAULT NULL COMMENT ' order number ', ' Order_original_amount ' Decimal (12,2) DEFAULT NULL COMMENT ' original Order Amount ', ' Coupon_amount ' Decimal (11,2) DEFAULT NULL COMMENT ' coupon amount ', ' Order_final_amount ' Decimal (12,2) DEFAULT NULL COMMENT ' The order amount after the coupon is deducted ', ' create_time ' datetime DEFAULT NULL COMMENT' Pick up Time ', ' status 'int(2) Default ' 0 ' COMMENT ' Log status: defaults to 0, payment callback succeeds after 1 ', PRIMARY KEY (' id ')) ENGINE=innodb DEFAULT Charset=utf8 comment= ' coupon consumption record form ';

Note: Relatively speaking, the difficulty of the coupon is not big, the focus is the business guidance and learning, including the database architecture and design, and there is the idea of learning.

The relevant core code is as follows:

The app needs to provide several interfaces in the background:

3.1 Check all buyers ' coupons.

3.2 Determine if the buyer can claim the coupon.

3.3 of buyers take the initiative to collect coupons

/*** Coupon Controller*/@RestController @requestmapping ("/buyer/coupon") Public classCouponcontrollerextendsBasecontroller {Private Static FinalLogger Logger = Loggerfactory.getlogger (Couponcontroller.class); @AutowiredPrivateCouponreceiveservice Couponreceiveservice; @AutowiredPrivateUsersservice Usersservice; /*** Check all buyers ' coupons * *@paramRequest *@paramResponse *@paramBuyerid *@return     */@RequestMapping (Value= "/list", method ={requestmethod.get, requestmethod.post}) PublicJsonresult getcouponlist (httpservletrequest request, httpservletresponse response, Long Buyerid) {Try {            if(Buyerid = =NULL) {                return NewJsonresult (Jsonresultcode.failure, "buyer does not exist", ""); } List<CouponReceive> result =Couponreceiveservice.selectallbybuyerid (Buyerid); return NewJsonresult (jsonresultcode.success, "Query succeeded", result); } Catch(Exception ex) {Logger.error ("[Couponcontroller][getcouponlist] Exception", ex); return NewJsonresult (jsonresultcode.failure, "system error, please retry later", "" "); }    }    /*** Determine if the buyer can claim the coupon * *@paramRequest *@paramResponse *@paramBuyerid *@return     */@RequestMapping (Value= "/judge", method ={requestmethod.get, requestmethod.post}) PublicJsonresult judgereceive (httpservletrequest request, httpservletresponse response, Long Buyerid) {Try {            //determine if the current user is availableUsers users =Usersservice.getusersbyid (Buyerid); if(Users = =NULL) {Logger.info ("OrderController.judgeReceive.buyerId" +Buyerid); return NewJsonresult (Jsonresultcode.failure, "Your account is wrong, please login again", ""); }            intStatus =Users.getstatus (); if(Userstatus.forbidden = =status) {                return NewJsonresult (Jsonresultcode.failure, "Your account has been disabled, please contact the company customer service", ""); } List<Coupon> result =Couponreceiveservice.selectbybuyerid (Buyerid); if(Collectionutils.isempty (Result)) {result=NewArraylist<coupon>(); }            return NewJsonresult (jsonresultcode.success, "Query succeeded", result); } Catch(Exception ex) {Logger.error ("[Couponcontroller][judgereceive] Exception", ex); return NewJsonresult (jsonresultcode.failure, "system error, please retry later", "" "); }    }    /*** Buyer Claim Coupon * *@paramRequest *@paramResponse *@paramBuyerid *@return     */@RequestMapping (Value= "/add", method ={requestmethod.get, requestmethod.post}) PublicJsonresult Savecoupon (httpservletrequest request, httpservletresponse response, long buyerid, long Couponi d) {Try {            //determine if the current user is availableUsers users =Usersservice.getusersbyid (Buyerid); if(Users = =NULL) {Logger.info ("OrderController.saveCoupon.buyerId" +Buyerid); return NewJsonresult (Jsonresultcode.failure, "Your account is wrong, please login again", ""); }            //determine if the current user's state is available            intStatus =Users.getstatus (); if(Userstatus.forbidden = =status) {                return NewJsonresult (Jsonresultcode.failure, "Your account has been disabled, please contact the company customer service", ""); }            if(Couponid = =NULL) {                return NewJsonresult (jsonresultcode.success, "activity is Over", "" "); }            //New            intresult =Couponreceiveservice.insert (Buyerid, Couponid); if(Result = =-1) {                return NewJsonresult (Jsonresultcode.success, "failed to receive the coupon has been received," "); } Else if(Result = = 0) {                return NewJsonresult (Jsonresultcode.failure, "claim failed, activity is over", "" "); } Else {                return NewJsonresult (jsonresultcode.success, "Pick up Success", ""); }        } Catch(Exception ex) {Logger.error ("[Couponcontroller][savecoupon] Exception", ex); return NewJsonresult (jsonresultcode.failure, "system error, please retry later", "" "); }    }}

Final Summary: The user coupon will be issued in the buyer's app in the Personal center, then click to view and collect, and then at the time of payment will automatically display the coupon data, very flexible and convenient.

Java Open source Fresh e-commerce platform-coupon design and architecture (source can be downloaded), if you need to download, you can download under my github.

Java Open source Fresh e-commerce platform-coupon design and architecture (source code can be downloaded)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.