日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

電商平臺(tái)

 quasiceo 2018-09-11

說(shuō)明:現(xiàn)在電商白熱化的程度,無(wú)論是生鮮電商還是其他的電商等等,都會(huì)有促銷的這個(gè)體系,目的就是增加訂單量與知名度等等

           那么對(duì)于Java開(kāi)源生鮮電商平臺(tái)而言,我們采用優(yōu)惠券的這種方式進(jìn)行促銷。(補(bǔ)貼價(jià)格戰(zhàn)對(duì)燒錢而言非常的恐怖的,太燒錢了)


1. 優(yōu)惠券基礎(chǔ)信息表

說(shuō)明:任何一個(gè)優(yōu)惠券或者說(shuō)代金券都是有一個(gè)基礎(chǔ)的說(shuō)明,比如:優(yōu)惠券名稱,類型,價(jià)格,有效期,狀態(tài),說(shuō)明等等基礎(chǔ)信息。


  1. CREATE TABLE `coupon` (
  2. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自動(dòng)增加ID',
  3. `region_id` bigint(20) DEFAULT NULL COMMENT '所屬區(qū)域',
  4. `type` int(11) DEFAULT NULL COMMENT '所屬類型,1為滿減',
  5. `name` varchar(32) DEFAULT NULL COMMENT '優(yōu)惠券名稱',
  6. `img` varchar(64) DEFAULT NULL COMMENT '圖片的URL地址',
  7. `start_time` datetime DEFAULT NULL COMMENT '優(yōu)惠券開(kāi)始時(shí)間',
  8. `end_time` datetime DEFAULT NULL COMMENT '優(yōu)惠券結(jié)束時(shí)間',
  9. `money` decimal(11,2) DEFAULT NULL COMMENT '優(yōu)惠券金額,用整數(shù),固定值目前。',
  10. `status` int(11) DEFAULT NULL COMMENT '狀態(tài),0表示未開(kāi)始,1表示進(jìn)行中,-1表示結(jié)束',
  11. `remarks` varchar(512) DEFAULT NULL COMMENT '優(yōu)惠券的說(shuō)明',
  12. `create_time` datetime DEFAULT NULL COMMENT '創(chuàng)建時(shí)間',
  13. `full_money` decimal(12,2) DEFAULT NULL COMMENT '金額滿',
  14. PRIMARY KEY (`id`)
  15. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='優(yōu)惠券基礎(chǔ)配置表';

說(shuō)明:業(yè)務(wù)說(shuō)可以規(guī)定某個(gè)區(qū)域,做優(yōu)惠券,而且是納新后才有,這樣增加買家用戶。價(jià)格可以后端進(jìn)行設(shè)置。

           狀態(tài)的意義在于,用戶需要注冊(cè)完成后,然后主動(dòng)認(rèn)領(lǐng)才有效,為什么要這樣設(shè)計(jì)呢?目的只有一個(gè):讓用戶在對(duì)APP這個(gè)軟件玩一會(huì)兒,增加熟悉程度.

2. 優(yōu)惠券領(lǐng)取記錄表

說(shuō)明:我們需要記錄那個(gè)買家,什么時(shí)候進(jìn)行的領(lǐng)取,領(lǐng)取的的時(shí)間,券的額度是多少等等,是否已經(jīng)使用等信息


  1. CREATE TABLE `coupon_receive` (
  2. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自動(dòng)增加ID',
  3. `buyer_id` bigint(20) DEFAULT NULL COMMENT '買家ID',
  4. `coupon_id` bigint(20) DEFAULT NULL COMMENT '優(yōu)惠券編號(hào)',
  5. `coupon_money` decimal(12,2) DEFAULT NULL COMMENT '券額',
  6. `create_time` datetime DEFAULT NULL COMMENT '領(lǐng)取時(shí)間',
  7. `full_money` decimal(12,2) DEFAULT NULL COMMENT '金額滿',
  8. `status` int(11) DEFAULT NULL COMMENT '狀態(tài),1為已使用,0為已領(lǐng)取未使用,-1為已過(guò)期',
  9. PRIMARY KEY (`id`)
  10. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='優(yōu)惠券領(lǐng)取記錄表';

3.優(yōu)惠券消費(fèi)記錄表

說(shuō)明:優(yōu)惠券消費(fèi)記錄表,是需要知道那個(gè)買家,那個(gè)優(yōu)惠券,那個(gè)訂單使用了優(yōu)惠券,這邊有個(gè)特別注意的地方是,這個(gè)優(yōu)惠券的執(zhí)行在支付成功后的回調(diào)。


  1. CREATE TABLE `coupon_logs` (
  2. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自動(dòng)增加ID',
  3. `buyer_id` bigint(20) DEFAULT NULL COMMENT '買家ID',
  4. `coupon_receive_id` bigint(20) DEFAULT NULL COMMENT '優(yōu)惠券id',
  5. `order_number` varchar(64) DEFAULT NULL COMMENT '訂單號(hào)',
  6. `order_original_amount` decimal(12,2) DEFAULT NULL COMMENT '原訂單金額',
  7. `coupon_amount` decimal(11,2) DEFAULT NULL COMMENT '優(yōu)惠券的金額',
  8. `order_final_amount` decimal(12,2) DEFAULT NULL COMMENT '抵扣優(yōu)惠券之后的訂單金額',
  9. `create_time` datetime DEFAULT NULL COMMENT '領(lǐng)取時(shí)間',
  10. `status` int(2) DEFAULT '0' COMMENT '日志狀態(tài): 默認(rèn)為0,支付回調(diào)成功后為1',
  11. PRIMARY KEY (`id`)
  12. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='優(yōu)惠券消費(fèi)記錄表';

說(shuō)明:相對(duì)而言,優(yōu)惠券的難度不算大,重點(diǎn)的是業(yè)務(wù)方面的指導(dǎo)與學(xué)習(xí),包括數(shù)據(jù)庫(kù)的架構(gòu)與設(shè)計(jì)等等,還有就是思路的學(xué)習(xí)。

 

相關(guān)核心代碼如下:

APP需要后臺(tái)提供以下幾個(gè)接口:

3.1 查詢所有買家的優(yōu)惠券。

3.2 判斷買家是否可以領(lǐng)取優(yōu)惠券。

3.3 買家主動(dòng)領(lǐng)取優(yōu)惠券


  1. /**
  2. * 優(yōu)惠券controller
  3. */
  4. @RestController
  5. @RequestMapping("/buyer/coupon")
  6. public class CouponController extends BaseController {

  7. private static final Logger logger = LoggerFactory.getLogger(CouponController.class);

  8. @Autowired
  9. private CouponReceiveService couponReceiveService;

  10. @Autowired
  11. private UsersService usersService;

  12. /**
  13. * 查詢買家所有優(yōu)惠券
  14. *
  15. * @param request
  16. * @param response
  17. * @param buyerId
  18. * @return
  19. */
  20. @RequestMapping(value = "/list", method = { RequestMethod.GET, RequestMethod.POST })
  21. public JsonResult getCouponList(HttpServletRequest request, HttpServletResponse response, Long buyerId) {
  22. try {
  23. if (buyerId == null) {
  24. return new JsonResult(JsonResultCode.FAILURE, "買家不存在", "");
  25. }
  26. List<CouponReceive> result = couponReceiveService.selectAllByBuyerId(buyerId);
  27. return new JsonResult(JsonResultCode.SUCCESS, "查詢成功", result);
  28. } catch (Exception ex) {
  29. logger.error("[CouponController][getCouponList] exception", ex);
  30. return new JsonResult(JsonResultCode.FAILURE, "系統(tǒng)錯(cuò)誤,請(qǐng)稍后重試", "");
  31. }
  32. }

  33. /**
  34. * 判斷買家是否可以領(lǐng)取優(yōu)惠券
  35. *
  36. * @param request
  37. * @param response
  38. * @param buyerId
  39. * @return
  40. */
  41. @RequestMapping(value = "/judge", method = { RequestMethod.GET, RequestMethod.POST })
  42. public JsonResult judgeReceive(HttpServletRequest request, HttpServletResponse response, Long buyerId) {
  43. try {
  44. // 判斷當(dāng)前用戶是否可用
  45. Users users = usersService.getUsersById(buyerId);
  46. if (users == null) {
  47. logger.info("OrderController.judgeReceive.buyerId " + buyerId);
  48. return new JsonResult(JsonResultCode.FAILURE, "你的賬號(hào)有誤,請(qǐng)重新登錄", "");
  49. }
  50. int status = users.getStatus();
  51. if (UserStatus.FORBIDDEN == status) {
  52. return new JsonResult(JsonResultCode.FAILURE, "你的賬號(hào)已經(jīng)被禁用了,請(qǐng)聯(lián)系公司客服", "");
  53. }
  54. List<Coupon> result = couponReceiveService.selectByBuyerId(buyerId);
  55. if (CollectionUtils.isEmpty(result)) {
  56. result = new ArrayList<Coupon>();
  57. }
  58. return new JsonResult(JsonResultCode.SUCCESS, "查詢成功", result);
  59. } catch (Exception ex) {
  60. logger.error("[CouponController][judgeReceive] exception", ex);
  61. return new JsonResult(JsonResultCode.FAILURE, "系統(tǒng)錯(cuò)誤,請(qǐng)稍后重試", "");
  62. }
  63. }

  64. /**
  65. * 買家領(lǐng)取優(yōu)惠券
  66. *
  67. * @param request
  68. * @param response
  69. * @param buyerId
  70. * @return
  71. */
  72. @RequestMapping(value = "/add", method = { RequestMethod.GET, RequestMethod.POST })
  73. public JsonResult saveCoupon(HttpServletRequest request, HttpServletResponse response, Long buyerId,
  74. Long couponId) {
  75. try {
  76. // 判斷當(dāng)前用戶是否可用
  77. Users users = usersService.getUsersById(buyerId);
  78. if (users == null) {
  79. logger.info("OrderController.saveCoupon.buyerId " + buyerId);
  80. return new JsonResult(JsonResultCode.FAILURE, "你的賬號(hào)有誤,請(qǐng)重新登錄", "");
  81. }
  82. //判斷當(dāng)前用戶的狀態(tài)是否可用
  83. int status = users.getStatus();
  84. if (UserStatus.FORBIDDEN == status) {
  85. return new JsonResult(JsonResultCode.FAILURE, "你的賬號(hào)已經(jīng)被禁用了,請(qǐng)聯(lián)系公司客服", "");
  86. }
  87. if (couponId == null) {
  88. return new JsonResult(JsonResultCode.SUCCESS, "活動(dòng)已經(jīng)結(jié)束", "");
  89. }
  90. //新增
  91. int result = couponReceiveService.insert(buyerId, couponId);
  92. if (result == -1) {
  93. return new JsonResult(JsonResultCode.SUCCESS, "領(lǐng)取失敗,已經(jīng)領(lǐng)取過(guò)優(yōu)惠券了", "");
  94. } else if (result == 0) {
  95. return new JsonResult(JsonResultCode.FAILURE, "領(lǐng)取失敗,活動(dòng)已經(jīng)結(jié)束", "");
  96. } else {
  97. return new JsonResult(JsonResultCode.SUCCESS, "領(lǐng)取成功", "");
  98. }
  99. } catch (Exception ex) {
  100. logger.error("[CouponController][saveCoupon] exception", ex);
  101. return new JsonResult(JsonResultCode.FAILURE, "系統(tǒng)錯(cuò)誤,請(qǐng)稍后重試", "");
  102. }
  103. }
  104. }

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多