{"id":1228,"date":"2025-09-16T14:16:31","date_gmt":"2025-09-16T06:16:31","guid":{"rendered":"https:\/\/eve2333.top\/?p=1228"},"modified":"2025-09-18T17:24:08","modified_gmt":"2025-09-18T09:24:08","slug":"%e7%89%9b%e5%88%b8onecoupon%e7%b3%bb%e7%bb%9f-%e7%ac%ac%e2%91%a1%e7%ab%a0%e8%8a%82%ef%bc%9a%e5%90%8e%e5%8f%b0%e7%ae%a1%e7%90%86%e6%9c%8d%e5%8a%a1-%e4%b8%8a","status":"publish","type":"post","link":"https:\/\/eve2333.top\/?p=1228","title":{"rendered":"\u725b\u5238oneCoupon\u7cfb\u7edf \u7b2c\u2461\u7ae0\u8282\uff1a\u540e\u53f0\u7ba1\u7406\u670d\u52a1-\u4e0a"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">&nbsp;\u25aa\u7b2c05\u5c0f\u8282\uff1a\u4ece\u96f6\u5230\u4e00\u521b\u5efaSpringBoot\u9879\u76ee&amp;\u521d\u59cb\u5316\u901a\u7528\u914d\u7f6e<\/h1>\n\n\n\n<p>\u300a\u725b\u5238oneCoupon\u4f18\u60e0\u7cfb\u7edf\u89c6\u9891\u6559\u5b66\u300b\u7b2c05\u5c0f\u8282<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4ece\u96f6\u5230\u4e00\u521b\u5efaSpringBoot\u9879\u76ee&amp;\u521d\u59cb\u5316\u901a\u7528\u914d\u7f6e<\/li>\n\n\n\n<li>20240708_init-code_ding.ma<\/li>\n<\/ul>\n\n\n\n<p>\u300a\u725b\u5238oneCoupon\u4f18\u60e0\u7cfb\u7edf\u89c6\u9891\u6559\u5b66\u300b\u7b2c06\u5c0f\u8282<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u57fa\u4e8e\u8d23\u4efb\u94fe\u6a21\u5f0f\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f<\/li>\n\n\n\n<li>2024xxxxx_dev_create-template_chain_ding.ma<\/li>\n<\/ul>\n\n\n\n<p>\u300a\u725b\u5238oneCoupon\u4f18\u60e0\u7cfb\u7edf\u89c6\u9891\u6559\u5b66\u300b\u7b2c07\u5c0f\u8282<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u901a\u8fc7ShardingSphere\u5b8c\u6210\u4f18\u60e0\u5238\u5206\u5e93\u5206\u8868<\/li>\n\n\n\n<li>2024xxxx_dev_coupon-tablue_shardingsphere_ding.ma<\/li>\n<\/ul>\n\n\n\n<p>\u300a\u725b\u5238oneCoupon\u4f18\u60e0\u7cfb\u7edf\u89c6\u9891\u6559\u5b66\u300b\u7b2c08\u5c0f\u8282<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f15\u5165\u65e5\u5fd7\u7ec4\u4ef6\u4f18\u96c5\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7<\/li>\n\n\n\n<li>2024xxxx_dev_operation-log_mzt-biz-log_ding.ma<\/li>\n<\/ul>\n\n\n\n<p>\u300a\u725b\u5238oneCoupon\u4f18\u60e0\u7cfb\u7edf\u89c6\u9891\u6559\u5b66\u300b\u7b2c09\u5c0f\u8282<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u57fa\u4e8e\u6ce8\u89e3\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u9632\u91cd\u590d\u63d0\u4ea4<\/li>\n\n\n\n<li>2024xxxxx_dev_repeat-submit_lock-annotation_ding.ma<\/li>\n<\/ul>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"844\" width=\"504\" src=\"https:\/\/i-blog.csdnimg.cn\/direct\/cf52eefb14f14beabff01ad35c9fcd4a.png\" alt=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u521d\u59cb\u5316\u901a\u7528\u914d\u7f6e<\/h2>\n\n\n\n<p>\u5982\u679c\u5927\u5bb6\u5bf9\u4e8e\u591a Modules \u7684\u9879\u76ee\u521b\u5efa\u4e0d\u592a\u719f\u6089\uff0c\u53ef\u4ee5\u67e5\u770b\u4ee5\u4e0b\u89c6\u9891\u5b66\u4e60\uff1a\u4ece\u96f6\u5230\u4e00\u521b\u5efa\u57fa\u7840\u9879\u76ee\uff1b\u4ece\u96f6\u5230\u4e00\u521b\u5efa\u5b50\u6a21\u5757\u9879\u76ee<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u5f02\u5e38\u7801<\/h3>\n\n\n\n<p>\u5f02\u5e38\u7801\u8bbe\u8ba1<br>\u963f\u91cc\u5df4\u5df4\u6cf0\u5c71\u7248java\u5f00\u53d1\u624b\u518c@\u5f02\u5e38\u65e5\u5fd7-\u9519\u8bef\u7801\u7ae0\u8282<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u5168\u5c40\u7edf\u4e00\u8fd4\u56de\u7c7b<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5168\u5c40\u7edf\u4e00\u8fd4\u56de\u7c7b Result \u8bb2\u89e3<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u5168\u5c40\u5f02\u5e38\u62e6\u622a\u5668<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5168\u5c40\u5f02\u5e38\u62e6\u622a\u5668 GlobalExceptionHandler \u8bb2\u89e3<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-spring-boot-starter\">4. SpringBoot Starter<\/h3>\n\n\n\n<p>SpringBoot Starter \u662f SpringBoot \u63d0\u4f9b\u7684\u4e00\u79cd\u7b80\u5316\u914d\u7f6e\u548c\u4f9d\u8d56\u7ba1\u7406\u7684\u673a\u5236\u3002\u5b83\u662f\u9884\u914d\u7f6e\u7684\u4f9d\u8d56\u96c6\u5408\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u96c6\u6210\u5e38\u7528\u7684\u5e93\u548c\u529f\u80fd\uff0c\u4ece\u800c\u52a0\u901f\u5f00\u53d1\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>Starter \u662f\u5e2e\u52a9\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5316\u914d\u7f6e\u548c\u4f9d\u8d56\u7ba1\u7406\u7684\u5de5\u5177\uff0c\u6216\u8005\u8bf4\u5b83\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5f00\u53d1\u67d0\u4e9b\u5185\u90e8\u529f\u80fd\uff0c\u5bf9\u5427\uff1f\u8fdb\u800c\u5e2e\u6211\u4eec\u63d0\u9ad8\u4ee3\u7801\u5f00\u53d1\u7684\u6548\u7387\u3002\u8fd9\u662f\u5b83\u7684\u4e00\u4e2a\u5b9a\u4e49\uff0c\u5982\u679c\u4e0d\u7406\u89e3\u4e0d\u8981\u7d27\uff0c\u6211\u4eec\u7ee7\u7eed\u5f80\u4e0b\u770b\u3002<\/p>\n\n\n\n<p>\u5b83\u7684\u4f18\u70b9\u662f\u4ec0\u4e48\uff1f\u4f18\u70b9\u5c31\u662f\uff1a<\/p>\n\n\n\n<p>\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u505a\u4e00\u4e9b\u81ea\u52a8\u914d\u7f6e\u7684\u4e8b\u60c5\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u5728\u6ca1\u6709\u4f7f\u7528 Starter \u4e4b\u524d\uff0c\u5982\u679c\u60f3\u8981\u5b9a\u4e49\u4e00\u4e2a Spring Bean\uff0c\u5c31\u9700\u8981\u624b\u52a8\u53bb\u521b\u5efa\uff0c\u7136\u540e\u8fdb\u884c\u5b9a\u4e49\u3002\u5982\u679c\u8bf4\u6211\u4eec\u5c01\u88c5\u4e86\u4e00\u4e9b\u5185\u90e8\u7ec4\u4ef6\uff0c\u6bd4\u5982\u4f60\u50cf XXX \u7ec4\u4ef6\u8fd9\u79cd\uff0c\u4f60\u60f3\u5f15\u7528\u5b83\uff0c\u5f15\u5165\u4e4b\u540e\u8fd8\u8981\u5bf9\u5b83\u505a Bean \u7684\u914d\u7f6e\u3002\u6211\u7ed9\u5927\u5bb6\u770b\u4e00\u4e0b\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>\u5176\u5b9e\u8fd9\u79cd Bean \u7684\u914d\u7f6e\u5bf9\u6211\u4eec\u6765\u8bf4\uff0c\u4ece\u4f7f\u7528\u89d2\u5ea6\u6765\u8bb2\u662f\u5b8c\u5168\u6ca1\u6709\u5fc5\u8981\u7684\u3002\u4e3a\u4ec0\u4e48\u6ca1\u6709\u5fc5\u8981\uff1f\u662f\u56e0\u4e3a Spring Boot \u63d0\u4f9b\u4e86\u4e00\u79cd\u81ea\u52a8\u88c5\u914d\u7684\u673a\u5236\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u50cf\u8fd9\u6837\u7684 Bean\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 Starter \u91cc\u9762\u53bb\u6307\u5b9a\u521b\u5efa\uff0c\u7136\u540e\u5f53\u6211\u4eec\u628a\u4f9d\u8d56\u5f15\u5165\u8fdb\u6765\u4e4b\u540e\uff0cSpring Boot \u5728\u542f\u52a8\u8fc7\u7a0b\u4e2d\u4f1a\u81ea\u52a8\u628a Bean \u626b\u63cf\u5e76\u6ce8\u518c\u5230\u5bb9\u5668\u4e2d\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u8bf4\u6211\u4eec\u8fd9\u91cc\u7684\u201c\u5168\u5c40\u5f02\u5e38\u5904\u7406\u5668\u201d\uff0c\u6709\u540c\u5b66\u53ef\u80fd\u4f1a\u6bd4\u8f83\u7591\u95ee\uff1a\u4e3a\u4ec0\u4e48\u6211\u4eec\u8fd9\u91cc\u8981\u53bb\u624b\u52a8\u521b\u5efa\uff1f\u5f88\u591a\u540c\u5b66\u53ef\u80fd\u6709\u8fd9\u6837\u7684\u7591\u95ee\uff1a\u6211\u4eec\u96be\u9053\u4e0d\u80fd\u76f4\u63a5\u52a0\u4e00\u4e2a\u6ce8\u89e3\u5417\uff1f\u6bd4\u5982 <code>@Component<\/code>\uff1f\u52a0\u6ce8\u89e3\u53ef\u4e0d\u53ef\u4ee5\uff1f\u52a0\u6ce8\u89e3\u4e0d\u80fd\u8bf4\u5b8c\u5168\u4e0d\u884c\uff0c\u53ea\u80fd\u8bf4<strong>\u4e0d\u63a8\u8350<\/strong>\u3002\u4e3a\u4ec0\u4e48\uff1f\u6211\u7ed9\u5927\u5bb6\u518d\u89e3\u91ca\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0cSpring \u626b\u63cf\u7684<strong>\u5305\u8def\u5f84\u8303\u56f4<\/strong>\u5927\u5bb6\u5e94\u8be5\u90fd\u77e5\u9053\uff0c\u5728 Spring \u7684\u57fa\u7840\u8bfe\u7a0b\u91cc\u8bb2\u8fc7\uff1a\u5b83\u9ed8\u8ba4\u53ea\u4f1a\u626b\u63cf\u542f\u52a8\u7c7b\u6240\u5728\u5305\u53ca\u5176\u5b50\u5305\u4e0b\u7684\u7c7b\u3002\u5982\u679c\u4f60\u7684\u7c7b\u4e0d\u5728\u8fd9\u4e2a\u8def\u5f84\u4e0b\u9762\uff0c\u4f60\u5c31\u9700\u8981\u663e\u5f0f\u5730\u6307\u5b9a\u626b\u63cf\u8def\u5f84\uff0c\u5bf9\u5427\uff1f<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7 <code>@ComponentScan<\/code> \u53bb\u914d\u7f6e\uff0c\u6bd4\u5982\u5728\u8fd9\u91cc\u52a0\u4e0a\u8981\u626b\u63cf\u7684\u5916\u90e8\u5305\u8def\u5f84\uff0c\u5b83\u662f\u53ef\u4ee5\u5b9e\u73b0\u7684\u3002\u628a\u5916\u90e8\u5305\u52a0\u8fdb\u53bb\uff0c\u8fd9\u6837\u662f\u53ef\u4ee5\u7684\u3002\u4f46\u662f\u5927\u5bb6\u6709\u6ca1\u6709\u60f3\u8fc7\uff1a\u5982\u679c\u6211\u6240\u6709\u7684\u57fa\u7840\u7ec4\u4ef6\u90fd\u4e0d\u6309\u8fd9\u79cd\u65b9\u5f0f\u6765\u5199\uff0c\u800c\u662f\u5168\u90fd\u4f9d\u8d56\u5305\u626b\u63cf\u7684\u65b9\u5f0f\uff0c\u90a3\u4f60\u8981\u5199\u591a\u5c11\u914d\u7f6e\uff1f<\/p>\n\n\n\n<p>\u6211\u7ed9\u5927\u5bb6\u7b80\u5355\u5217\u4e3e\u4e00\u4e0b\uff1a\u4f60\u8981\u5199\u6d88\u606f\u961f\u5217\u7684\u914d\u7f6e\uff0c\u8981\u5199\u63a5\u53e3\u4f9d\u8d56\u7684\u914d\u7f6e\uff0c\u8981\u5199 RPC \u7684\u914d\u7f6e\uff0c\u8981\u5199\u7f13\u5b58\u7684\u914d\u7f6e\uff0c\u8fd8\u8981\u5199\u5404\u79cd\u5de5\u5177\u7c7b\u7684\u914d\u7f6e\u2026\u2026\u4f60\u7684\u914d\u7f6e\u4f1a\u975e\u5e38\u5197\u6742\u3002<\/p>\n\n\n\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u57fa\u4e8e<strong>\u4f9d\u8d56\u6700\u5c0f\u5316\u7ba1\u7406<\/strong>\u7684\u539f\u5219\uff0c\u6211\u4eec\u4e3a\u4ec0\u4e48\u4e0d\u5728 Starter \u91cc\u9762\u5c31\u628a\u8fd9\u4e9b Bean \u521b\u5efa\u597d\uff1f\u76f4\u63a5\u628a\u5b83\u4eec\u6ce8\u5165\u5230 Spring \u7684 IOC \u5bb9\u5668\u91cc\u9762\u3002\u8fd9\u6837\u4f9d\u8d56\u65b9\u5c31\u4e0d\u518d\u9700\u8981\u505a\u4efb\u4f55\u989d\u5916\u64cd\u4f5c\uff0c\u53ea\u9700\u8981\u5f15\u5165\u8fd9\u4e2a Starter \u7684 jar \u5305\u5c31\u53ef\u4ee5\u4e86\uff0c\u5bf9\u4e0d\u5bf9\uff1f\u8fd9\u6837\u7684\u8bdd\u80af\u5b9a\u662f\u6700\u7b80\u5355\u7684\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u7b2c\u4e8c\u4e2a\u4f18\u70b9\u5c31\u662f\uff1a\u5b83<strong>\u7b80\u5316\u4e86\u4f9d\u8d56\u914d\u7f6e<\/strong>\u3002\u4ee5\u524d\u5982\u679c\u6211\u4eec\u60f3\u5f15\u5165\u5916\u90e8\u670d\u52a1\uff0c\u6bd4\u5982\u6211\u4eec\u7684\u670d\u52a1\u60f3\u8981\u5bf9\u5916\u8bbf\u95ee\uff0c\u5c31\u9700\u8981\u624b\u52a8\u5f15\u5165\u5f88\u591a\u4f9d\u8d56\u5305\u3002\u6bd4\u5982\u4f60\u60f3\u5f15\u5165 HTTP \u5ba2\u6237\u7aef\uff0c\u5c31\u5f97\u5f15\u5165 OkHttp \u6216 HttpClient\uff1b\u4f60\u60f3\u5f15\u5165 Spring Data JPA\uff0c\u4e5f\u9700\u8981\u5f15\u5165\u4e00\u5806\u76f8\u5173\u4f9d\u8d56\uff1b\u518d\u6bd4\u5982\u4e00\u4e2a\u5927\u5bb6\u6bd4\u8f83\u719f\u6089\u7684\u573a\u666f\uff1a\u4f60\u60f3\u5f15\u5165 Redis\uff0c\u662f\u4e0d\u662f\u5f97\u5148\u5f15\u5165\u8fde\u63a5\u6c60\uff0c\u518d\u5f15\u5165 Redis \u5ba2\u6237\u7aef\uff0c\u518d\u52a0\u4e0a\u5404\u79cd\u5de5\u5177\u5305\uff1f<\/p>\n\n\n\n<p>\u800c Spring Boot \u901a\u8fc7 Starter \u7684\u65b9\u5f0f\uff0c\u5e2e\u6211\u4eec\u628a\u8fd9\u4e9b\u57fa\u7840\u7684\u4f9d\u8d56\u90fd\u5c01\u88c5\u597d\u4e86\u3002\u6211\u4eec\u53ea\u9700\u8981\u5f15\u5165\u4e00\u4e2a starter\uff0c\u6bd4\u5982 <code>spring-boot-starter-data-redis<\/code>\uff0c\u5b83\u5c31\u4f1a\u81ea\u52a8\u5f15\u5165\u6240\u6709\u5fc5\u8981\u7684\u4f9d\u8d56\uff0c\u4e0d\u9700\u8981\u6211\u4eec\u4e00\u4e2a\u4e2a\u53bb\u7ba1\u7406\u3002\u6211\u7ed9\u5927\u5bb6\u7b80\u5355\u770b\u4e00\u773c\u3002<\/p>\n\n\n\n<p>\u50cf\u6211\u4eec\u8fd9\u8fb9\u63d0\u4f9b\u7684 <code>spring-boot-starter-test<\/code>\uff0c\u90fd\u662f\u5b98\u65b9\u63d0\u4f9b\u7684\u6807\u51c6 Starter\u3002\u4f60\u6bd4\u5982\u8bf4\u5927\u5bb6\u5e38\u89c1\u7684 <code>spring-boot-starter-web<\/code>\u3001<code>spring-boot-starter-jdbc<\/code> \u7b49\u7b49\uff0c\u4e5f\u90fd\u662f\u4e00\u6837\u7684\u673a\u5236\u3002\u8fd9\u6837\u7684\u8bdd\uff0c\u76f8\u4fe1\u5927\u5bb6\u5bf9 Starter \u5c31\u6709\u4e00\u4e2a\u57fa\u672c\u7684\u8ba4\u8bc6\u4e86\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u804a\u4e00\u4e0b\uff1a\u5982\u4f55\u53bb\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5df1\u7684 Starter\uff1f\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981 5 \u6b65\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e00\u6b65\uff1a\u521b\u5efa\u4e00\u4e2a\u9879\u76ee\u3002<br>\u7b2c\u4e8c\u6b65\uff1a\u7f16\u5199\u5bf9\u5e94\u7684\u4e1a\u52a1\u4ee3\u7801\uff0c\u6bd4\u5982\u6211\u4eec\u521a\u624d\u63d0\u5230\u7684\u201c\u5168\u5c40\u5f02\u5e38\u5904\u7406\u5668\u201d\u6216\u201c\u7edf\u4e00\u65e5\u5fd7\u5207\u9762\u201d\u8fd9\u7c7b\u7ec4\u4ef6\u3002<br>\u7b2c\u4e09\u6b65\uff1a\u5b9a\u4e49\u4e00\u4e2a\u914d\u7f6e\u7c7b\uff08Configuration Class\uff09\uff0c\u5b83\u672c\u8d28\u4e0a\u662f\u63d0\u4f9b\u4e86\u4e00\u4e2a Bean \u7684\u5bb9\u5668\uff0c\u8ba9\u8fd9\u4e9b Bean \u80fd\u591f\u88ab IOC \u5bb9\u5668\u6ce8\u518c\u548c\u7ba1\u7406\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u6211\u4eec\u9700\u8981\u628a\u8fd9\u4e2a\u914d\u7f6e\u7c7b\u4ea4\u7ed9 Spring Boot \u7684<strong>\u81ea\u52a8\u88c5\u914d\u673a\u5236<\/strong>\uff0c\u8ba9\u5b83\u80fd\u591f\u88ab\u53d1\u73b0\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728 <code>resources\/META-INF<\/code> \u8def\u5f84\u4e0b\u521b\u5efa\u4e00\u4e2a\u7279\u6b8a\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u662f\u56fa\u5b9a\u7684\uff1a<code>spring.factories<\/code>\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u683c\u5f0f\u662f\u56fa\u5b9a\u7684\u3002\u53ea\u8981\u6211\u4eec\u60f3\u8ba9\u67d0\u4e2a\u914d\u7f6e\u7c7b\u5728\u9879\u76ee\u542f\u52a8\u65f6\u88ab\u81ea\u52a8\u52a0\u8f7d\uff0c\u5c31\u5fc5\u987b\u5728\u8fd9\u4e2a\u6587\u4ef6\u91cc\u58f0\u660e\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>org.springframework.boot.autoconfigure.EnableAutoConfiguration=\\\n\ncom.example.starter.MyAutoConfiguration<\/code><\/pre>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:https:\/\/eve2333.top\/c73efe25-c28e-47f4-9963-337e21ac1775\" width=\"15\"><\/p>\n\n\n\n<p>\u4ee5\u201c\u5916\u90e8\u7ec4\u4ef6\u201d\u4e3a\u4f8b\uff0c\u5982\u679c\u4f60\u6709\u591a\u4e2a\u81ea\u52a8\u914d\u7f6e\u7c7b\uff0c\u53ef\u4ee5\u6362\u884c\u5199\u591a\u4e2a\u3002\u6211\u4eec\u70b9\u8fdb\u53bb\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5176\u5b9e\u5c31\u662f\u6211\u4eec\u81ea\u5df1\u5199\u7684\u914d\u7f6e\u7c7b\u7684\u5168\u9650\u5b9a\u540d\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u901a\u8fc7 <code>@Bean<\/code> \u6ce8\u89e3\uff0c\u628a\u8fd9\u4e9b\u7ec4\u4ef6\u6ce8\u518c\u5230 Spring \u5bb9\u5668\u4e2d\u3002\u8fd9\u6837\u7684\u8bdd\uff0c\u53ea\u8981\u6211\u4eec\u7684\u4e1a\u52a1\u9879\u76ee\uff08\u6bd4\u5982\u201c\u8d37\u6b3e\u7cfb\u7edf\u201d\uff09\u5f15\u5165\u4e86\u8fd9\u4e2a Starter \u5305\uff0c\u5b83\u5728\u542f\u52a8\u7684\u65f6\u5019\u5c31\u4f1a\u81ea\u52a8\u52a0\u8f7d\u8fd9\u4e2a\u914d\u7f6e\u7c7b\uff0c\u5b8c\u6210\u81ea\u52a8\u88c5\u914d\u3002<code>@Bean<\/code> \u7684\u6ce8\u89e3\u4e5f\u5c31\u751f\u6548\u4e86\uff0c\u8fd9\u4e9b Bean \u4f1a\u81ea\u52a8\u6ce8\u518c\u5230\u4e0a\u4e0b\u6587\u4e2d\uff0c\u4e0d\u9700\u8981\u6211\u4eec\u518d\u505a\u4efb\u4f55\u989d\u5916\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u4e0d\u77e5\u9053\u8fd9\u4e48\u8ddf\u5927\u5bb6\u8bb2\uff0c\u5927\u5bb6\u80fd\u4e0d\u80fd\u542c\u6e05\u695a\uff1f\u5982\u679c\u6709\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u518d\u6c9f\u901a\u8ba8\u8bba\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u6709\u4e00\u4e2a\u5c0f\u77e5\u8bc6\u70b9\uff1aSpring Boot 2.x \u548c 3.x \u5728\u81ea\u52a8\u88c5\u914d\u7684\u5b9e\u73b0\u65b9\u5f0f\u4e0a\u6709\u4e00\u4e9b\u533a\u522b\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u521a\u624d\u5c55\u793a\u7684\u662f Spring Boot 3.x \u7684\u65b9\u5f0f\uff0c\u4e5f\u5c31\u662f\u901a\u8fc7 <code>spring.factories<\/code> \u6587\u4ef6\u6765\u5b9e\u73b0\u81ea\u52a8\u88c5\u914d\u3002\u4f46\u5728 2.x \u7248\u672c\u4e2d\uff0c\u5b83\u5176\u5b9e\u662f <code>META-INF\/spring.factories<\/code> \u6587\u4ef6\u76f4\u63a5\u5b9a\u4e49\u81ea\u52a8\u914d\u7f6e\u7c7b\u3002<\/p>\n\n\n\n<p>\u800c\u5728 3.x \u4e2d\uff0cSpring Boot \u5f15\u5165\u4e86\u65b0\u7684\u673a\u5236\uff1a<code>META-INF\/spring\/org.springframework.boot.autoconfigure.AutoConfiguration.imports<\/code> \u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u91cc\u53ea\u9700\u8981\u5199\u914d\u7f6e\u7c7b\u7684\u5168\u9650\u5b9a\u540d\uff0c\u4e00\u884c\u4e00\u4e2a\uff0c\u4e0d\u518d\u4f7f\u7528 <code>spring.factories<\/code> \u7684\u952e\u503c\u5bf9\u683c\u5f0f\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u53d8\u5316\u6211\u4e5f\u5728\u7f51\u4e0a\u67e5\u8fc7\uff0c\u5176\u5b9e\u5f88\u591a\u8d44\u6599\u8bb2\u5f97\u4e0d\u592a\u6e05\u695a\u3002\u6211\u7ed3\u5408 GPT \u548c\u5b98\u65b9\u6587\u6863\u505a\u4e86\u4e00\u4e9b\u4e86\u89e3\uff0c\u603b\u7ed3\u51fa\u4e24\u4e2a\u4e3b\u8981\u53d8\u5316\uff1a<\/p>\n\n\n\n<p>\u7b2c\u4e00\u4e2a\u662f<strong>\u542f\u52a8\u901f\u5ea6\u66f4\u5feb<\/strong>\u3002\u867d\u7136\u6211\u81ea\u5df1\u6ca1\u5b9e\u6d4b\u51fa\u6765\uff0c\u4f46\u5b98\u65b9\u6587\u6863\u548c\u793e\u533a\u666e\u904d\u8fd9\u4e48\u8bf4\u3002\u56e0\u4e3a\u65b0\u7684\u673a\u5236\u51cf\u5c11\u4e86\u53cd\u5c04\u626b\u63cf\u548c\u7c7b\u52a0\u8f7d\u7684\u5f00\u9500\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u4e2a\u662f<strong>\u6a21\u5757\u5212\u5206\u66f4\u6e05\u6670<\/strong>\u3002\u8fd9\u4e00\u70b9\u662f\u53ef\u4ee5\u660e\u663e\u770b\u51fa\u6765\u7684\u3002\u4ee5\u524d\u5728 <code>spring.factories<\/code> \u6587\u4ef6\u91cc\uff0c\u9664\u4e86\u81ea\u52a8\u914d\u7f6e\uff0c\u8fd8\u53ef\u4ee5\u914d\u7f6e\u5176\u4ed6\u5185\u5bb9\uff0c\u6bd4\u5982\u521d\u59cb\u5316\u5668\u3001\u76d1\u542c\u5668\u7b49\uff0c\u6240\u6709\u4e1c\u897f\u90fd\u6df7\u5728\u4e00\u8d77\u3002\u800c\u73b0\u5728\uff0c<code>imports<\/code> \u6587\u4ef6\u53ea\u8d1f\u8d23\u81ea\u52a8\u914d\u7f6e\uff0c\u804c\u8d23\u66f4\u5355\u4e00\uff0c\u7ed3\u6784\u66f4\u6e05\u6670\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u770b\u4e00\u4e0b\u4ee3\u7801\u5427\uff0c\u9996\u6b21\u63d0\u4ea4\u7ed9\u5230\u521b\u5efa\u4e86search\u548csettlement\uff0cdistribution\uff1bframework\u8fd94\u4e2a\u529f\u80fd\u533a\uff0c\u8fd8\u6709format\uff0c\u8fd8\u6709database\u653e\u5230\u7684sql\u6587\u4ef6\uff1b\u8c03\u6574IDEA\u9879\u76ee\u56fe\u6807\u548c\u63d0\u4ea4\u4ee3\u7801\u7248\u6743\u4fe1\u606f\u548c\u5176\u4ed6\u53d8\u66f4\u6ca1\u4ec0\u4e48\u7528\u554a\uff1b<\/p>\n\n\n\n<p>\u521d\u59cb\u5316\u725b\u5238\u5546\u5bb6\u540e\u7ba1\u6a21\u5757merchant-admin,\u5bf9\u542f\u52a8\u9879\u7b49\u6765\u4fee\u6539\u83b7\u5f97\uff1b\u8fd9\u662f\u603bxml\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n    &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n    &lt;groupId&gt;com.nageoffer.onecoupon&lt;\/groupId&gt;\n    &lt;artifactId&gt;onecoupon-all&lt;\/artifactId&gt;\n    &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n    &lt;packaging&gt;pom&lt;\/packaging&gt;\n\n    &lt;description&gt;\n        \ud83d\udd25\u70ed\u95e8\u63a8\u8350\ud83d\udd25\u725b\u5238\u7cfb\u7edf\uff0c\u6625\u62db\u3001\u79cb\u62db\u3001\u5e94\u5c4a\u3001\u793e\u62db\u9879\u76ee\u3002SpringBoot3+Java17+SpringCloudAlibaba+RocketMQ+ElasticSearch\u7b49\u6280\u672f\u67b6\u6784\uff0c\u5b8c\u6210\u4f18\u60e0\u5238\u79d2\u6740+\u5206\u53d1+\u7ed3\u7b97+\u641c\u7d22\u7b49\u670d\u52a1\uff0c\u5e2e\u52a9\u5b66\u751f\u4e3b\u6253\u5c31\u4e1a\u7684\u9879\u76ee\u3002\n    &lt;\/description&gt;\n\n    &lt;developers&gt;\n        &lt;developer&gt;\n            &lt;name&gt;\u9a6c\u4e01&lt;\/name&gt;\n            &lt;email&gt;machen@apache.org&lt;\/email&gt;\n            &lt;url&gt;https:\/\/github.com\/magestacks&lt;\/url&gt;\n            &lt;organization&gt;Apache and openGoofy&lt;\/organization&gt;\n        &lt;\/developer&gt;\n    &lt;\/developers&gt;\n\n    &lt;modules&gt;\n        &lt;!-- \u57fa\u7840\u67b6\u6784\u6a21\u5757\uff1a\u4ec5\u5305\u542b\u516c\u5171\u5185\u5bb9\uff0c\u4e0d\u6d89\u53caSpringBean\u5b9a\u4e49 --&gt;\n        &lt;module&gt;framework&lt;\/module&gt;\n        &lt;!-- \u5206\u53d1\u6a21\u5757\uff1a\u8d1f\u8d23\u6309\u6279\u6b21\u5206\u53d1\u7528\u6237\u4f18\u60e0\u5238\uff0c\u53ef\u63d0\u4f9b\u5e94\u7528\u5f39\u6846\u63a8\u9001\u3001\u7ad9\u5185\u4fe1\u6216\u77ed\u4fe1\u901a\u77e5\u7b49 --&gt;\n        &lt;module&gt;distribution&lt;\/module&gt;\n        &lt;!-- \u7ed3\u7b97\u6a21\u5757\uff1a\u8d1f\u8d23\u7528\u6237\u4e0b\u5355\u65f6\u8ba2\u5355\u91d1\u989d\u8ba1\u7b97\u529f\u80fd --&gt;\n        &lt;module&gt;settlement&lt;\/module&gt;\n        &lt;!-- \u641c\u7d22\u6a21\u5757\uff1a\u63d0\u4f9b\u7528\u6237\u4f18\u60e0\u5238\u641c\u7d22\u529f\u80fd --&gt;\n        &lt;module&gt;search&lt;\/module&gt;\n        &lt;!-- \u5f15\u64ce\u6a21\u5757\uff1a\u8d1f\u8d23\u4f18\u60e0\u5238\u5355\u4e2a\u67e5\u770b\u3001\u5217\u8868\u67e5\u770b\u3001\u9501\u5b9a\u4ee5\u53ca\u6838\u9500\u7b49\u529f\u80fd --&gt;\n        &lt;module&gt;engine&lt;\/module&gt;\n        &lt;!-- \u4e3a\u4f55\u5176\u4ed6\u6a21\u5757\u4ec5\u4e00\u4e2a\u5355\u8bcd\uff0c\u800c\u540e\u7ba1\u662f\u4e24\u4e2a\uff1f --&gt;\n        &lt;!-- \u8fd9\u662f\u56e0\u4e3a\u5728\u4f01\u4e1a\u7684\u5b9e\u9645\u8fd0\u8425\u4e2d\uff0c\u5e76\u975e\u4ec5\u6709\u5355\u4e00\u7684\u4f18\u60e0\u5238\u7ba1\u7406\u540e\u53f0\uff0c\u800c\u662f\u666e\u904d\u5b58\u5728\u7edf\u79f0\u4e3a\u201c\u5546\u5bb6\u540e\u53f0\u201d\u7684\u591a\u529f\u80fd\u7ba1\u7406\u5e73\u53f0 --&gt;\n        &lt;module&gt;merchant-admin&lt;\/module&gt; &lt;!-- \u540e\u7ba1\u6a21\u5757\uff1a\u521b\u5efa\u4f18\u60e0\u5238\u3001\u5e97\u5bb6\u67e5\u770b\u4ee5\u53ca\u7ba1\u7406\u4f18\u60e0\u5238\u3001\u521b\u5efa\u4f18\u60e0\u5238\u53d1\u653e\u6279\u6b21 --&gt;\n    &lt;\/modules&gt;\n\n    &lt;properties&gt;\n        &lt;java.version&gt;17&lt;\/java.version&gt;\n        &lt;spring-boot.version&gt;3.0.7&lt;\/spring-boot.version&gt;\n        &lt;spring-cloud.version&gt;2022.0.3&lt;\/spring-cloud.version&gt;\n        &lt;spring-cloud-alibaba.version&gt;2022.0.0.0-RC2&lt;\/spring-cloud-alibaba.version&gt;\n        &lt;mybatis-spring-boot-starter.version&gt;3.0.2&lt;\/mybatis-spring-boot-starter.version&gt;\n        &lt;shardingsphere.version&gt;5.3.2&lt;\/shardingsphere.version&gt;\n        &lt;fastjson2.version&gt;2.0.36&lt;\/fastjson2.version&gt;\n        &lt;mybatis-plus.version&gt;3.5.3.1&lt;\/mybatis-plus.version&gt;\n        &lt;dozer-core.version&gt;6.5.2&lt;\/dozer-core.version&gt;\n        &lt;hutool-all.version&gt;5.8.27&lt;\/hutool-all.version&gt;\n        &lt;redisson.version&gt;3.27.2&lt;\/redisson.version&gt;\n        &lt;guava.version&gt;30.0-jre&lt;\/guava.version&gt;\n        &lt;jsoup.version&gt;1.15.3&lt;\/jsoup.version&gt;\n        &lt;easyexcel.version&gt;3.1.3&lt;\/easyexcel.version&gt;\n        &lt;spotless-maven-plugin.version&gt;2.22.1&lt;\/spotless-maven-plugin.version&gt;\n        &lt;maven-compiler-plugin.version&gt;3.6.1&lt;\/maven-compiler-plugin.version&gt;\n    &lt;\/properties&gt;\n\n    &lt;dependencies&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt;\n            &lt;artifactId&gt;lombok&lt;\/artifactId&gt;\n        &lt;\/dependency&gt;\n    &lt;\/dependencies&gt;\n\n    &lt;dependencyManagement&gt;\n        &lt;dependencies&gt;\n            &lt;dependency&gt;\n                &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n                &lt;artifactId&gt;spring-boot-dependencies&lt;\/artifactId&gt;\n                &lt;version&gt;${spring-boot.version}&lt;\/version&gt;\n                &lt;type&gt;pom&lt;\/type&gt;\n                &lt;scope&gt;import&lt;\/scope&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\n                &lt;artifactId&gt;spring-cloud-dependencies&lt;\/artifactId&gt;\n                &lt;version&gt;${spring-cloud.version}&lt;\/version&gt;\n                &lt;type&gt;pom&lt;\/type&gt;\n                &lt;scope&gt;import&lt;\/scope&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;com.alibaba.cloud&lt;\/groupId&gt;\n                &lt;artifactId&gt;spring-cloud-alibaba-dependencies&lt;\/artifactId&gt;\n                &lt;version&gt;${spring-cloud-alibaba.version}&lt;\/version&gt;\n                &lt;type&gt;pom&lt;\/type&gt;\n                &lt;scope&gt;import&lt;\/scope&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;com.baomidou&lt;\/groupId&gt;\n                &lt;artifactId&gt;mybatis-plus-boot-starter&lt;\/artifactId&gt;\n                &lt;version&gt;${mybatis-plus.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;org.apache.shardingsphere&lt;\/groupId&gt;\n                &lt;artifactId&gt;shardingsphere-jdbc-core&lt;\/artifactId&gt;\n                &lt;version&gt;${shardingsphere.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;com.alibaba.fastjson2&lt;\/groupId&gt;\n                &lt;artifactId&gt;fastjson2&lt;\/artifactId&gt;\n                &lt;version&gt;${fastjson2.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;com.github.dozermapper&lt;\/groupId&gt;\n                &lt;artifactId&gt;dozer-core&lt;\/artifactId&gt;\n                &lt;version&gt;${dozer-core.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;cn.hutool&lt;\/groupId&gt;\n                &lt;artifactId&gt;hutool-all&lt;\/artifactId&gt;\n                &lt;version&gt;${hutool-all.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;org.redisson&lt;\/groupId&gt;\n                &lt;artifactId&gt;redisson-spring-boot-starter&lt;\/artifactId&gt;\n                &lt;version&gt;${redisson.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n\n            &lt;dependency&gt;\n                &lt;groupId&gt;com.google.guava&lt;\/groupId&gt;\n                &lt;artifactId&gt;guava&lt;\/artifactId&gt;\n                &lt;version&gt;${guava.version}&lt;\/version&gt;\n            &lt;\/dependency&gt;\n        &lt;\/dependencies&gt;\n    &lt;\/dependencyManagement&gt;\n\n    &lt;build&gt;\n        &lt;plugins&gt;\n            &lt;plugin&gt;\n                &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\n                &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;\n                &lt;version&gt;${maven-compiler-plugin.version}&lt;\/version&gt;\n                &lt;configuration&gt;\n                    &lt;source&gt;${java.version}&lt;\/source&gt;\n                    &lt;target&gt;${java.version}&lt;\/target&gt;\n                &lt;\/configuration&gt;\n            &lt;\/plugin&gt;\n\n            &lt;plugin&gt;\n                &lt;groupId&gt;com.diffplug.spotless&lt;\/groupId&gt;\n                &lt;artifactId&gt;spotless-maven-plugin&lt;\/artifactId&gt;\n                &lt;version&gt;${spotless-maven-plugin.version}&lt;\/version&gt;\n                &lt;configuration&gt;\n                    &lt;java&gt;\n                        &lt;!--&lt;eclipse&gt;\n                            &lt;file&gt;${maven.multiModuleProjectDirectory}\/format\/one-coupon_spotless_formatter.xml&lt;\/file&gt;\n                        &lt;\/eclipse&gt;--&gt;\n                        &lt;licenseHeader&gt;\n                            &lt;!-- ${maven.multiModuleProjectDirectory} \u7206\u7ea2\u5c5e\u4e8e\u6b63\u5e38\uff0c\u5e76\u4e0d\u5f71\u54cd\u7f16\u8bd1\u6216\u8005\u8fd0\u884c\uff0c\u5ffd\u7565\u5c31\u597d --&gt;\n                            &lt;file&gt;${maven.multiModuleProjectDirectory}\/copyright\/copyright.txt&lt;\/file&gt;\n                        &lt;\/licenseHeader&gt;\n                    &lt;\/java&gt;\n                &lt;\/configuration&gt;\n                &lt;executions&gt;\n                    &lt;execution&gt;\n                        &lt;goals&gt;\n                            &lt;goal&gt;apply&lt;\/goal&gt;\n                        &lt;\/goals&gt;\n                        &lt;phase&gt;compile&lt;\/phase&gt;\n                    &lt;\/execution&gt;\n                &lt;\/executions&gt;\n            &lt;\/plugin&gt;\n        &lt;\/plugins&gt;\n    &lt;\/build&gt;\n&lt;\/project&gt;\n<\/code><\/pre>\n\n\n\n<p>\u521d\u59cb\u5316\u725b\u5238\u5f15\u64ce\u7cfb\u7edfengine\uff0c\u8d1f\u8d23\u5238\u9501\u5b9a\u3001\u6838\u9500\u3001\u67e5\u770b\u7b49\u529f\u80fd\uff1b\u7aef\u53e3\u53f7\u7ed9\u523010010<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u25aa\u7b2c06\u5c0f\u8282\uff1a\u57fa\u4e8e\u8d23\u4efb\u94fe\u6a21\u5f0f\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f18\u60e0\u5238\u6a21\u677f\u521b\u5efa\u4e1a\u52a1<\/li>\n\n\n\n<li>\u4f18\u60e0\u5238\u6a21\u677f\u89e3\u6790<\/li>\n\n\n\n<li>Git \u5206\u652f\u540d\u79f0<\/li>\n\n\n\n<li>\u524d\u7f6e\u903b\u8f91<\/li>\n\n\n\n<li>\u4ee3\u7801\u6267\u884c\u903b\u8f91<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f18\u60e0\u5238\u6a21\u677f\u521b\u5efa\u4e1a\u52a1<\/h2>\n\n\n\n<p>\u4f18\u60e0\u5238\u5206\u4e3a\u5e73\u53f0\u5238\u548c\u5e97\u94fa\u5238\uff0c\u5e73\u53f0\u5238\u7531\u5e73\u53f0\u8fd0\u8425\u4eba\u5458\u521b\u5efa\u548c\u7ba1\u7406\u5458\u5ba1\u6279\uff0c\u5173\u7cfb\u96b6\u5c5e\u4e8e\u5e73\u53f0\uff0c\u7528\u6237\u4f7f\u7528\u540e\u6210\u672c\u4e00\u822c\u6765\u8bf4\u7531\u5e73\u53f0\u548c\u5546\u5bb6\u5171\u540c\u627f\u62c5\uff1b\u800c\u5e97\u94fa\u5238\u7531\u5546\u5bb6\u5728\u5546\u5bb6\u540e\u53f0\u76f4\u63a5\u521b\u5efa\uff0c\u65e0\u9700\u5ba1\u6838\uff0c\u6210\u672c\u7531\u5e97\u5bb6\u72ec\u81ea\u627f\u62c5\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"502\" width=\"1071\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/86eea1d5c6250047da6cb514a502b775.png\" alt=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f18\u60e0\u5238\u6a21\u677f\u89e3\u6790<\/h2>\n\n\n\n<p>\u521b\u5efa\u6570\u636e\u5e93 <code>one_coupon_rebuild<\/code> \u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<p><code>CREATE DATABASE IF NOT EXISTS one_coupon_rebuild;<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u6570\u636e\u5e93\u8868<\/h3>\n\n\n\n<p>\u53ef\u4ee5\u8fdb\u5165\u5230\u6211\u4eec\u7684 <code>one_coupon_rebuild<\/code> \u6570\u636e\u5e93\u4e2d\u6267\u884c\u4e0b\u8ff0 SQL \u8bed\u53e5\u3002<\/p>\n\n\n\n<p><code>CREATE TABLE `t_coupon_template` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967816300515330 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868';<\/code><\/p>\n\n\n\n<p>\u56e0\u4e3a\u9886\u53d6\u89c4\u5219\u548c\u6d88\u8017\u89c4\u5219\u591a\u53d8\uff0c\u6240\u4ee5\u4f7f\u7528 JSON \u5b58\u50a8\u3002\u540e\u7eed\u5982\u679c\u6709\u53d8\u5316\u4e0d\u9700\u8981\u6539\u52a8\u8868\u5b57\u6bb5\uff0c\u6539\u52a8 JSON \u5185\u5bb9\u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u9886\u53d6\u89c4\u5219<\/h3>\n\n\n\n<p><code>JSONObject receiveRule = new JSONObject(); receiveRule.put(\"limitPerPerson\", 1); \/\/ \u6bcf\u4eba\u9650\u9886 receiveRule.put(\"usageInstructions\", \"xxx\"); \/\/ \u4f7f\u7528\u8bf4\u660e<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u6d88\u8017\u89c4\u5219<\/h3>\n\n\n\n<p><code>JSONObject consumeRule = new JSONObject(); consumeRule.put(\"termsOfUse\", new BigDecimal(\"10\")); \/\/ \u4f7f\u7528\u6761\u4ef6 \u6ee1 x \u5143\u53ef\u7528 consumeRule.put(\"maximumDiscountAmount\", new BigDecimal(\"3\")); \/\/ \u6700\u5927\u4f18\u60e0\u91d1\u989d consumeRule.put(\"explanationOfUnmetC 3onditions\", \"xxx\"); \/\/ \u4e0d\u6ee1\u8db3\u4f7f\u7528\u6761\u4ef6\u8bf4\u660e consumeRule.put(\"validityPeriod\", 48); \/\/ \u81ea\u9886\u53d6\u4f18\u60e0\u5238\u540e\u6709\u6548\u65f6\u95f4\uff0c\u5355\u4f4d\u5c0f\u65f6<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"git\">Git \u5206\u652f\u540d\u79f0<\/h2>\n\n\n\n<p>20240814_dev_create-template_chain_ding.ma<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u524d\u7f6e\u903b\u8f91<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-api\">1. \u4f7f\u7528\u63a5\u53e3 API \u5de5\u5177<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-1-maven\">1.1 Maven \u4f9d\u8d56\u5f15\u5165<\/h4>\n\n\n\n<p><code>&lt;dependency&gt; &nbsp; &nbsp;&lt;groupId&gt;com.github.xiaoymin&lt;\/groupId&gt; &nbsp; &nbsp;&lt;artifactId&gt;knife4j-openapi3-jakarta-spring-boot-starter&lt;\/artifactId&gt; &nbsp; &nbsp;&lt;version&gt;4.5.0&lt;\/version&gt; &lt;\/dependency&gt;<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-2-application-yaml\">1.2 application.yaml \u6dfb\u52a0\u914d\u7f6e<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\nserver:\n  port: 10010\n\nspring:\n  application:\n    name: oneCoupon-merchant-admin\n  datasource:\n    url: jdbc:mysql:\/\/127.0.0.1:3306\/one_coupon_rebuild?useUnicode=true&amp;characterEncoding=UTF-8&amp;rewriteBatchedStatements=true&amp;allowMultiQueries=true&amp;serverTimezone=Asia\/Shanghai\n    username: root\n    password: root\n  data:\n    redis:\n      host: 127.0.0.1\n      port: 6379\n      password: 123456\n\nmybatis-plus:\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n\nspringdoc:\n  default-flat-param-object: true\n  swagger-ui:\n    path: \/swagger-ui.html\n    tags-sorter: alpha\n    operations-sorter: alpha\n  api-docs:\n    path: \/v3\/api-docs\n  group-configs:\n    - group: 'default'\n      paths-to-match: '\/**'\n      packages-to-scan: com.nageoffer.onecoupon\n\nknife4j:\n  enable: true\n  setting:\n    language: zh_cn\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-3\">1.3 \u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6<\/h4>\n\n\n\n<p>\u4e3b\u8981\u662fconfig\u90e8\u5206\u7684\u5185\u5bb9\uff0c\u8fd8\u6709UserConfiguration\u548cDataBaseConfiguration\u7684\u5185\u5bb9\u90e8\u5206\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Slf4j\n@Configuration\npublic class SwaggerConfiguration implements ApplicationRunner {\n\n    @Value(\"${server.port:8080}\")\n    private String serverPort;\n    @Value(\"${server.servlet.context-path:}\")\n    private String contextPath;\n\n    \/**\n     * \u81ea\u5b9a\u4e49 openAPI \u4e2a\u6027\u5316\u4fe1\u606f\n     *\/\n    @Bean\n    public OpenAPI openAPI() {\n        return new OpenAPI()\n                .info(new Info() \/\/ \u57fa\u672c\u4fe1\u606f\u914d\u7f6e\n                        .title(\"\u725b\u5238-\u5546\u5bb6\u540e\u53f0\u7ba1\u7406\u7cfb\u7edf\") \/\/ \u6807\u9898\n                        .description(\"\u521b\u5efa\u4f18\u60e0\u5238\u3001\u5e97\u5bb6\u67e5\u770b\u4ee5\u53ca\u7ba1\u7406\u4f18\u60e0\u5238\u3001\u521b\u5efa\u4f18\u60e0\u5238\u53d1\u653e\u6279\u6b21\u7b49\") \/\/ \u63cf\u8ff0 Api \u63a5\u53e3\u6587\u6863\u7684\u57fa\u672c\u4fe1\u606f\n                        .version(\"v1.0.0\") \/\/ \u7248\u672c\n                        \/\/ \u8bbe\u7f6e OpenAPI \u6587\u6863\u7684\u8054\u7cfb\u4fe1\u606f\uff0c\u5305\u62ec\u8054\u7cfb\u4eba\u59d3\u540d\u4e3a\"ding.ma\"\uff0c\u90ae\u7bb1\u4e3a\"machen@apache.org\"\n                        .contact(new Contact().name(\"ding.ma\").email(\"machen@apache.org\"))\n                        \/\/ \u8bbe\u7f6e OpenAPI \u6587\u6863\u7684\u8bb8\u53ef\u8bc1\u4fe1\u606f\uff0c\u5305\u62ec\u8bb8\u53ef\u8bc1\u540d\u79f0\u548c\u8bb8\u53ef\u8bc1URL\n                        .license(new License().name(\"\u5c71\u4e1c\u6d41\u5e74\u7f51\u7edc\u79d1\u6280\u6709\u9650\u516c\u53f8\").url(\"https:\/\/gitcode.net\/nageoffer\/onecoupon\/-\/blob\/main\/LICENSE\"))\n                );\n    }\n\n    \/**\n     * \u65b9\u4fbf\u5927\u5bb6\u542f\u52a8\u9879\u76ee\u540e\u53ef\u4ee5\u76f4\u63a5\u70b9\u51fb\u94fe\u63a5\u8df3\u8f6c\uff0c\u800c\u4e0d\u7528\u81ea\u5df1\u5230\u6d4f\u89c8\u5668\u8f93\u5165\u8def\u5f84\n     *\/\n    @Override\n    public void run(ApplicationArguments args) throws Exception {\n        log.info(\"API Document: http:\/\/127.0.0.1:{}{}\/doc.html\", serverPort, contextPath);\n    }\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-4\">1.4 \u4f7f\u7528\u6548\u679c<\/h4>\n\n\n\n<p>\u9879\u76ee\u542f\u52a8\u540e\u4f1a\u5728\u63a7\u5236\u53f0\u6253\u5370\u8bbf\u95ee\u5730\u5740\u3002<\/p>\n\n\n\n<p><code>2024-08-14T16:21:26.620+08:00 &nbsp;INFO 89222 --- [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; main] c.n.o.m.a.config.SwaggerConfiguration &nbsp; : API Document: http:\/\/127.0.0.1:10010\/doc.html<\/code><\/p>\n\n\n\n<p>\u70b9\u51fb\u540e\u8df3\u8f6c\u6d4f\u89c8\u5668\u8bbf\u95ee\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1912\" width=\"3352\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/84b8cdf7aad7baa3d104aa8107937a76.png\" alt=\"\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u6301\u4e45\u5316\u914d\u7f6e<\/h3>\n\n\n\n<p>\u4e3b\u8981\u4e24\u70b9\u5185\u5bb9\uff0c\u5206\u9875\u63d2\u4ef6\u548c\u6e90\u6570\u636e\u81ea\u52a8\u586b\u5145\u7c7b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Configuration\npublic class DataBaseConfiguration {\n\n    \/**\n     * MyBatis-Plus MySQL \u5206\u9875\u63d2\u4ef6\n     *\/\n    @Bean\n    public MybatisPlusInterceptor mybatisPlusInterceptor() {\n        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();\n        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));\n        return interceptor;\n    }\n\n    \/**\n     * MyBatis-Plus \u6e90\u6570\u636e\u81ea\u52a8\u586b\u5145\u7c7b\n     *\/\n    @Bean\n    public MyMetaObjectHandler myMetaObjectHandler() {\n        return new MyMetaObjectHandler();\n    }\n\n    \/**\n     * MyBatis-Plus \u6e90\u6570\u636e\u81ea\u52a8\u586b\u5145\u7c7b\n     *\/\n    static class MyMetaObjectHandler implements MetaObjectHandler {\n\n        @Override\n        public void insertFill(MetaObject metaObject) {\n            strictInsertFill(metaObject, \"createTime\", Date::new, Date.class);\n            strictInsertFill(metaObject, \"updateTime\", Date::new, Date.class);\n            strictInsertFill(metaObject, \"delFlag\", () -&gt; 0, Integer.class);\n        }\n\n        @Override\n        public void updateFill(MetaObject metaObject) {\n            strictInsertFill(metaObject, \"updateTime\", Date::new, Date.class);\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u7528\u6237\u4e0a\u4e0b\u6587<\/h3>\n\n\n\n<p>\u56e0\u4e3a\u6211\u4eec\u805a\u7126\u4f18\u60e0\u5238\u903b\u8f91\u4ee3\u7801\uff0c\u6240\u4ee5\u5173\u4e8e\u7528\u6237\u767b\u5f55\u3001\u6ce8\u518c\u7b49\u903b\u8f91\u5ffd\u7565\uff0c\u4ec5\u901a\u8fc7\u786c\u7f16\u7801\u5f62\u5f0f\u4fdd\u969c\u4f18\u60e0\u5238\u4e1a\u52a1\u4e0d\u53d7\u5f71\u54cd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public final class MerchantAdminRedisConstant {\n\n    \/**\n     * \u4f18\u60e0\u5238\u6a21\u677f\u7f13\u5b58 Key\n     *\/\n    public static final String COUPON_TEMPLATE_KEY = \"one-coupon_engine:template:%s\";\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-1\">3.1 \u7528\u6237\u5b9e\u4f53<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>@Data\n@NoArgsConstructor\n@AllArgsConstructor\n@Builder\npublic class UserInfoDTO {\n\n    \/**\n     * \u7528\u6237 ID\n     *\/\n    private String userId;\n\n    \/**\n     * \u7528\u6237\u540d\n     *\/\n    private String username;\n\n    \/**\n     * \u5e97\u94fa\u7f16\u53f7\n     *\/\n    private Long shopNumber;\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-2\">3.2 \u7528\u6237\u5b58\u50a8\u4e0a\u4e0b\u6587<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>public final class UserContext {\n\n    \/**\n     * &lt;a href=\"https:\/\/github.com\/alibaba\/transmittable-thread-local\" \/&gt;\n     *\/\n    private static final ThreadLocal&lt;UserInfoDTO&gt; USER_THREAD_LOCAL = new TransmittableThreadLocal&lt;&gt;();\n\n    \/**\n     * \u8bbe\u7f6e\u7528\u6237\u81f3\u4e0a\u4e0b\u6587\n     *\n     * @param user \u7528\u6237\u8be6\u60c5\u4fe1\u606f\n     *\/\n    public static void setUser(UserInfoDTO user) {\n        USER_THREAD_LOCAL.set(user);\n    }\n\n    \/**\n     * \u83b7\u53d6\u4e0a\u4e0b\u6587\u4e2d\u7528\u6237 ID\n     *\n     * @return \u7528\u6237 ID\n     *\/\n    public static String getUserId() {\n        UserInfoDTO userInfoDTO = USER_THREAD_LOCAL.get();\n        return Optional.ofNullable(userInfoDTO).map(UserInfoDTO::getUserId).orElse(null);\n    }\n\n    \/**\n     * \u83b7\u53d6\u4e0a\u4e0b\u6587\u4e2d\u7528\u6237\u540d\u79f0\n     *\n     * @return \u7528\u6237\u540d\u79f0\n     *\/\n    public static String getUsername() {\n        UserInfoDTO userInfoDTO = USER_THREAD_LOCAL.get();\n        return Optional.ofNullable(userInfoDTO).map(UserInfoDTO::getUsername).orElse(null);\n    }\n\n    \/**\n     * \u83b7\u53d6\u4e0a\u4e0b\u6587\u4e2d\u7528\u6237\u5e97\u94fa\u7f16\u53f7\n     *\n     * @return \u7528\u6237\u5e97\u94fa\u7f16\u53f7\n     *\/\n    public static Long getShopNumber() {\n        UserInfoDTO userInfoDTO = USER_THREAD_LOCAL.get();\n        return Optional.ofNullable(userInfoDTO).map(UserInfoDTO::getShopNumber).orElse(null);\n    }\n\n    \/**\n     * \u6e05\u7406\u7528\u6237\u4e0a\u4e0b\u6587\n     *\/\n    public static void removeUser() {\n        USER_THREAD_LOCAL.remove();\n    }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-3\">3.3 \u7528\u6237\u914d\u7f6e\u62e6\u622a\u5668<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>@Configuration\npublic class UserConfiguration implements WebMvcConfigurer {\n\n    \/**\n     * \u7528\u6237\u4fe1\u606f\u4f20\u8f93\u62e6\u622a\u5668\n     *\/\n    @Bean\n    public UserTransmitInterceptor userTransmitInterceptor() {\n        return new UserTransmitInterceptor();\n    }\n\n    \/**\n     * \u6dfb\u52a0\u7528\u6237\u4fe1\u606f\u4f20\u9012\u8fc7\u6ee4\u5668\u81f3\u76f8\u5173\u8def\u5f84\u62e6\u622a\n     *\/\n    @Override\n    public void addInterceptors(InterceptorRegistry registry) {\n        registry.addInterceptor(userTransmitInterceptor())\n                .addPathPatterns(\"\/**\");\n    }\n\n    \/**\n     * \u7528\u6237\u4fe1\u606f\u4f20\u8f93\u62e6\u622a\u5668\n     * \u5f00\u53d1\u65f6\u95f4\uff1a2024-07-09\n     *\/\n    static class UserTransmitInterceptor implements HandlerInterceptor {\n\n        @Override\n        public boolean preHandle(@Nullable HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable Object handler) throws Exception {\n            \/\/ \u7528\u6237\u5c5e\u4e8e\u975e\u6838\u5fc3\u529f\u80fd\uff0c\u8fd9\u91cc\u5148\u901a\u8fc7\u6a21\u62df\u7684\u5f62\u5f0f\u4ee3\u66ff\u3002\u540e\u7eed\u5982\u679c\u9700\u8981\u540e\u7ba1\u5c55\u793a\uff0c\u4f1a\u91cd\u6784\u8be5\u4ee3\u7801\n            UserInfoDTO userInfoDTO = new UserInfoDTO(\"1810518709471555585\", \"pdd45305558318\", 1810714735922956666L);\n            UserContext.setUser(userInfoDTO);\n            return true;\n        }\n\n        @Override\n        public void afterCompletion(@Nullable HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable Object handler, Exception exception) throws Exception {\n            UserContext.removeUser();\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-4\">3.4 \u4f7f\u7528\u7528\u6237\u4e0a\u4e0b\u6587<\/h4>\n\n\n\n<p>\u5982\u679c\u60f3\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u7528\u6237\u4e0a\u4e0b\u6587\uff0c\u76f4\u63a5\u8c03\u7528\u5373\u53ef\u3002<\/p>\n\n\n\n<p><code>UserContext.getShopNumber()<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u6267\u884c\u903b\u8f91<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u65f6\u5e8f\u56fe<\/h3>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"606\" width=\"767\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/4e28cc7d7367261ebe34e4828ea93cdf.png\" alt=\"\"><\/p>\n\n\n\n<p>controller\u91cc\u9762CouponTemplateController\uff1a\u4ed6\u4ece\u63a7\u5236\u5c42\u5f00\u59cb\u5f80\u4e0b\u53bb\u770b\uff0c\u7b2c\u4e00\u6b65\u7684\u8bdd\u5c31\u662f\u9a8c\u8bc1\u6211\u4eec\u7684\u53c2\u6570\uff0c\u6bd4\u5982\u8bf4\u4e00\u4e9b\u662f\u5426\u4e3a\u7a7a\u6216\u8005\u5de5\u4f5c\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u6211\u4eec\u8fd9\u8fb9\u8981\u6c42\u5fc5\u586b\u7684\u8bdd\u662f\u4e0d\u5141\u8bb8\u7684\uff0c\u7136\u540e\u5c31\u662f\u6211\u4eec\u7684\u5173\u7cfb\u662f\u5426\u6b63\u786e\uff0c\u6bd4\u5982\u8bf4\u6211\u4eec\u5982\u679c\u8bf4\u8bbe\u7f6e\u4e86\u4f18\u60e0\u5238\u5168\u5e97\u53ef\u4ee5\u4f7f\u7528\u7684\u8bdd\uff0c\u6211\u4eec\u7684\u5546\u54c1\u7f16\u7801\u5b57\u6bb5\u5c31\u4e0d\u80fd\u4f20\u503c\u3002\u53cd\u4e4b\u5982\u679c\u8bf4\u6211\u4eec\u9274\u5b9a\u5b83\u7684\u4e00\u4e2a\u4f18\u60e0\u5238\u53ea\u80fd\u6307\u5b9a\u5546\u54c1\u53ef\u7528\uff0c\u5b83\u7684\u5546\u54c1\u7f16\u7801\u5b57\u5c31\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u5927\u6982\u662f\u8fd9\u6837\u7684\u4e00\u4e2a\u903b\u8f91\u3002\u7136\u540e\u8fd8\u6709\u4e00\u4e9b\u7684\u8bdd\u5b83\u7684\u5e93\u5b58\u662f\u5426\u8bbe\u7f6e\u5f02\u5e38\uff0c\u4ee5\u53ca\u6211\u4eec\u76f8\u5173\u7684\u4e00\u4e2a\u6570\u636e\u662f\u5426\u6b63\u786e\uff0c\u6bd4\u5982\u8bf4\u6211\u4eec\u4f20\u5165\u7684\u5546\u54c1\u7684\u4e00\u4e9b\u4fe1\u606f\uff0c\u5546\u54c1\u4fe1\u606f\u662f\u5426\u5b58\u5728\u7b49\u7b49\uff0c\u4e0a\u9762\u662f\u6211\u4eec\u7684\u4e00\u4e2a\u9a8c\u8bc1\u903b\u8f91\uff0c\u53ea\u662f\u4e3e\u4e86\u4e00\u5c0f\u90e8\u5206\u7684\u4f8b\u5b50\uff0c\u5f53\u7136\u8fd8\u4f1a\u6709\u66f4\u591a\u3002\u7136\u540e\u7684\u8bdd\u6211\u4eec\u8981\u5c06\u4f18\u60e0\u5238\u65b0\u589e\u7684\u6570\u636e\u5e93\u7b2c\u4e00\u6b65\u8981\u6784\u5efa\u6211\u4eec\u7684\u4e00\u4e2a19\u5c42\u5b9e\u4f53\uff0c\u7136\u540e\u7ed9\u4ed6\u65b0\u589e\u5b8c\u4e86\u4e4b\u540e\uff0c\u6211\u4eec\u8fdb\u884c\u9884\u70ed\uff0c\u903b\u8f91\u5927\u6982\u5c31\u662f\u8fd9\u4e2a\u6837\u5b50\u3002\u7136\u540e\u6211\u4eec\u9884\u70ed\u8fd9\u91cc\u7684\u8bdd\u5c31\u662f\u4f7f\u7528 spring boot\u63d0\u4f9b\u7684\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u4e00\u4e2a\u901a\u7528\u64cd\u4f5crelease\u7684\u6a21\u677f\uff0c\u5927\u5bb6\u77e5\u9053\u5c31\u53ef\u4ee5\u3002\u7136\u540e\u8fd9\u91cc\u6bd4\u8f83\u6709\u610f\u601d\u7684\u4e00\u70b9\u662f\u4ec0\u4e48\uff1f\u5c31\u662f\u6211\u4eec\u5173\u4e8e\u5bf9\u8c61\u8f6c\u6362\u8fd9\u91cc\u53ef\u80fd\u6709\u5f88\u591a\u540c\u5b66\u6709\u7591\u95ee\uff0c\u4e3a\u4ec0\u4e48\u6211\u4eec\u8981\u7528\u8fd9\u4e00\u4e2a\u53bb\u8fdb\u884c\u8f6c\u6362\u5462\uff1f\u6211\u4eec\u7ed9\u5927\u5bb6\u68b3\u7406\u4e00\u4e0b\uff0c\u9996\u5148\u6211\u4eec\u4e3a\u4ec0\u4e48\u8981\u8f6c\u6362\uff1f\u5c31\u662f\u7528\u6237\u901a\u8fc7\u5165\u9910\u4e5f\u5c31\u662frequest\u7684dto\uff0c\u6211\u4eec\u8d1f\u8d23\u8fdb\u884c\u5bf9\u5b83\u9a8c\u8bc1\uff0c\u7136\u540e\u6ca1\u95ee\u9898\uff0c\u6211\u4eec\u8981\u8f6c\u621019\u5c42\u7684\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p>\u4e00\u822c\u5bf9\u4e8e\u8fd9\u79cd\u6570\u636e\u5bf9\u8c61\u8f6c\u6362\u7684\u8bdd\uff0c\u6211\u4eec\u6709\u51e0\u79cd\u5f62\u5f0f\uff0c\u6700\u57fa\u7840\u7684\u4e5f\u5c31\u662f\u6211\u4eec\u7684 set\uff0c\u901a\u8fc7\u8fd9\u79cd\u5f62\u5f0f\u7684\u8bdd\uff0c\u65e0\u7591\u5bf9\u6211\u4eec\u7684\u4ee3\u7801\u5de5\u4f5c\u91cf\u4e0a\u7684\u8bdd\u6709\u4e00\u4e2a\u6bd4\u8f83\u91cd\u7684\u8d1f\u62c5\u3002\u5176\u6b21\u5982\u679c\u8bf4\u6211\u4eec\u540e\u7eed\u8981\u65b0\u589e\u5b57\u6bb5\u6216\u8005\u6539\u52a8\u5b57\u6bb5\u5bf9\u5e94\u7684 set\uff0c\u4ee3\u7801\u4e5f\u9700\u8981\u5bf9\u5e94\u7684\u8c03\u6574\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u6848\u4f8b\u975e\u5e38\u6e05\u695a\u7684\u77e5\u9053\u8fd9\u4e2a\u4ee3\u7801\u662f\u4ec0\u4e48\u6837\u5b50\u7684\uff0c\u7136\u540e\u5b83\u7684\u4f18\u70b9\u5c31\u662f\u6027\u80fd\u662f\u6700\u9ad8\u7684\uff0c\u4e14\u4e0d\u9700\u8981\u4f9d\u8d56\u5176\u4ed6\u7684\u7ec4\u4ef6\uff0c\u7f3a\u70b9\u4e5f\u5c31\u662f\u4ee3\u7801\u6bd4\u8f83\u7e41\u7410\uff0c\u540e\u671f\u6539\u52a8\u5bb9\u6613\u6709\u9057\u6f0f\u3002&nbsp;<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662f\u4e00\u4e9b\u559c\u95fb\u4e50\u89c1\u7684\u4e1c\u897f\uff1a\u7ea6\u5b9acommon\/enums\u7684\u5224\u5b9a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@RequiredArgsConstructor\npublic enum CouponTemplateStatusEnum {\n\n    \/**\n     * 0: \u8868\u793a\u4f18\u60e0\u5238\u5904\u4e8e\u751f\u6548\u4e2d\u7684\u72b6\u6001\u3002\n     *\/\n    ACTIVE(0),\n\n    \/**\n     * 1: \u8868\u793a\u4f18\u60e0\u5238\u5df2\u7ecf\u7ed3\u675f\uff0c\u4e0d\u53ef\u518d\u4f7f\u7528\u3002\n     *\/\n    ENDED(1);\n\n    @Getter\n    private final int status;\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@RequiredArgsConstructor\npublic enum DiscountTargetEnum {\n\n    \/**\n     * \u5546\u54c1\u4e13\u5c5e\u4f18\u60e0\n     *\/\n    PRODUCT_SPECIFIC(0, \"\u5546\u54c1\u4e13\u5c5e\u4f18\u60e0\"),\n    \/**\n     * \u5168\u5e97\u901a\u7528\u4f18\u60e0\n     *\/\n    ALL_STORE_GENERAL(1, \"\u5168\u5e97\u901a\u7528\u4f18\u60e0\");\n\n    @Getter\n    private final int type;\n\n    @Getter\n    private final String value;\n\n    \/**\n     * \u6839\u636e type \u627e\u5230\u5bf9\u5e94\u7684 value\n     *\n     * @param type \u8981\u67e5\u627e\u7684\u7c7b\u578b\u4ee3\u7801\n     * @return \u5bf9\u5e94\u7684\u63cf\u8ff0\u503c\uff0c\u5982\u679c\u6ca1\u6709\u627e\u5230\u629b\u5f02\u5e38\n     *\/\n    public static String findValueByType(int type) {\n        for (DiscountTargetEnum target : DiscountTargetEnum.values()) {\n            if (target.getType() == type) {\n                return target.getValue();\n            }\n        }\n        throw new IllegalArgumentException();\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@RequiredArgsConstructor\npublic enum DiscountTypeEnum {\n\n    \/**\n     * \u7acb\u51cf\u5238\n     *\/\n    FIXED_DISCOUNT(0, \"\u7acb\u51cf\u5238\"),\n\n    \/**\n     * \u6ee1\u51cf\u5238\n     *\/\n    THRESHOLD_DISCOUNT(1, \"\u6ee1\u51cf\u5238\"),\n\n    \/**\n     * \u6298\u6263\u5238\n     *\/\n    DISCOUNT_COUPON(2, \"\u6298\u6263\u5238\");\n\n    @Getter\n    private final int type;\n\n    @Getter\n    private final String value;\n\n    \/**\n     * \u6839\u636e type \u627e\u5230\u5bf9\u5e94\u7684 value\n     *\n     * @param type \u8981\u67e5\u627e\u7684\u7c7b\u578b\u4ee3\u7801\n     * @return \u5bf9\u5e94\u7684\u63cf\u8ff0\u503c\uff0c\u5982\u679c\u6ca1\u6709\u627e\u5230\u629b\u5f02\u5e38\n     *\/\n    public static String findValueByType(int type) {\n        for (DiscountTypeEnum target : DiscountTypeEnum.values()) {\n            if (target.getType() == type) {\n                return target.getValue();\n            }\n        }\n        throw new IllegalArgumentException();\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u5bf9\u8c61\u590d\u5236<\/h3>\n\n\n\n<p>\u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93\u65f6\uff0c\u9700\u8981\u5c06\u5165\u53c2 reqDTO \u8f6c\u6362\u4e3a\u6700\u7ec8\u7684 DO \u6301\u4e45\u5c42\u5b9e\u4f53\u3002\u4e00\u822c\u5bf9\u4e8e\u5bf9\u8c61\u8f6c\u6362\uff0c\u6211\u4eec\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2-1-get-set\">2.1 get\/set<\/h4>\n\n\n\n<p>\u5982\u679c\u6bcf\u6b21\u90fd\u8fdb\u884c get\/set \u7684\u5f62\u5f0f\u8fdb\u884c\u8f6c\u6362\uff0c\u65e0\u7591\u4f1a\u5728\u4ee3\u7801\u4e0a\u6709\u8f83\u5927\u7684\u5de5\u4f5c\u91cf\u3002\u800c\u4e14\uff0c\u5982\u679c\u540e\u7eed\u6539\u52a8\u6216\u65b0\u589e\u5b57\u6bb5\u8fd8\u9700\u8981\u8fdb\u884c\u5bf9\u5e94\u8c03\u6574\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u6848\u4f8b\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<p><code>public PersonDTO personToPersonDTO(Person person) { &nbsp; &nbsp;if (person == null) { &nbsp; &nbsp; &nbsp; &nbsp;return null; &nbsp; } \u200b &nbsp; &nbsp;PersonDTO personDTO = new PersonDTO(); &nbsp; &nbsp;personDTO.setName(person.getName()); &nbsp; &nbsp;personDTO.setAge(person.getAge()); \u200b &nbsp; &nbsp;return personDTO; }<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f18\u70b9\uff1a\u6027\u80fd\u6700\u9ad8\uff0c\u4e14\u65e0\u9700\u4f9d\u8d56\u989d\u5916\u7ec4\u4ef6\u3002<\/li>\n\n\n\n<li>\u7f3a\u70b9\uff1a\u4ee3\u7801\u7e41\u7410\uff0c\u540e\u671f\u6539\u52a8\u5bb9\u6613\u6709\u9057\u6f0f\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2-2-map-struct\">2.2 MapStruct<\/h4>\n\n\n\n<p>\u5b98\u65b9\u7f51\u5740\uff1a<a href=\"https:\/\/mapstruct.org\/\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/mapstruct.org<\/a><\/p>\n\n\n\n<p>\u4f7f\u7528\u6848\u4f8b\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<p><code>\/\/ \u5b9a\u4e49\u8f6c\u6362\u6620\u5c04\u5668 @Mapper public interface PersonMapper { &nbsp; &nbsp;PersonMapper INSTANCE = Mappers.getMapper(PersonMapper.class); \u200b &nbsp; &nbsp;PersonDTO personToPersonDTO(Person person); } \u200b \/\/ \u5e95\u5c42\u5728\u7f16\u8bd1\u671f\u751f\u6210\u5bf9\u5e94\u5b9e\u73b0\u7c7b\u5e76\u901a\u8fc7 get\/set \u65b9\u5f0f\u590d\u5236 public class PersonMapperImpl implements PersonMapper { \u200b &nbsp; &nbsp;@Override &nbsp; &nbsp;public PersonDTO personToPersonDTO(Person person) { &nbsp; &nbsp; &nbsp; &nbsp;if (person == null) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null; &nbsp; &nbsp; &nbsp; } \u200b &nbsp; &nbsp; &nbsp; &nbsp;PersonDTO personDTO = new PersonDTO(); &nbsp; &nbsp; &nbsp; &nbsp;personDTO.setName(person.getName()); &nbsp; &nbsp; &nbsp; &nbsp;personDTO.setAge(person.getAge()); \u200b &nbsp; &nbsp; &nbsp; &nbsp;return personDTO; &nbsp; } } \u200b \/\/ \u4e1a\u52a1\u4ee3\u7801\u4f7f\u7528 PersonMapper.INSTANCE.personToPersonDTO(person);<\/code><\/p>\n\n\n\n<p>\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f18\u70b9\uff1a\u6027\u80fd\u7b49\u540c get\/set \u4e14\u65e0\u5e8f\u914d\u7f6e\u7e41\u7410\u4ee3\u7801\u3002<\/li>\n\n\n\n<li>\u7f3a\u70b9\uff1a\u4ee3\u7801\u914d\u7f6e\u867d\u6ca1\u6709 get\/set \u7e41\u7410\uff0c\u4f46\u662f\u4e5f\u9700\u8981\u521b\u5efa\u7c7b\u7b49\u914d\u7f6e\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2-3-hutool-or-dozer\">2.3 Hutool or Dozer<\/h4>\n\n\n\n<p>Dozer \u5b98\u65b9\u7f51\u5740\uff1a<a href=\"https:\/\/github.com\/DozerMapper\/dozer\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/github.com\/DozerMapper\/dozer<\/a><\/p>\n\n\n\n<p>Hutool \u5b98\u65b9\u7f51\u5740\uff1a<a href=\"https:\/\/hutool.cn\/\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/hutool.cn<\/a><\/p>\n\n\n\n<p>\u4f7f\u7528\u6848\u4f8b\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<p><code>CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class);<\/code><\/p>\n\n\n\n<p>\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f18\u70b9\uff1a\u4f7f\u7528\u6700\u4e3a\u65b9\u4fbf\uff0c\u4e00\u884c\u4ee3\u7801\u586b\u5165\u5165\u53c2\u548c\u6307\u5b9a\u8f6c\u6362\u5bf9\u8c61 class \u5373\u53ef\u5b8c\u6210\u8f6c\u6362\u3002<\/li>\n\n\n\n<li>\u7f3a\u70b9\uff1a\u4f7f\u7528\u53cd\u5c04\uff0c\u5bf9\u6bd4 get\/set \u6027\u80fd\u8f83\u5dee\u3002<\/li>\n<\/ul>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"474\" width=\"518\" src=\"https:\/\/i-blog.csdnimg.cn\/direct\/27d85bf21d4e4b059b63f3401dd4a882.png\" alt=\"\"><\/p>\n\n\n\n<p>\u5927\u5bb6\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u8fd9\u91cc\u7684\u8bdd\u5176\u5b9e\u9a8c\u8bc1\u4e86\u6bd4\u8f83\u591a\u7684\u903b\u8f91\uff0c\u5176\u5b9e\u771f\u5b9e\u7684\u4e00\u4e2a\u9879\u76ee\u91cc\u9762\u5b83\u9a8c\u8bc1\u7684\u53ea\u4f1a\u6bd4\u8fd9\u66f4\u591a\uff0c\u6211\u521d\u6b65\u4f30\u8ba1\u4e00\u4e2a500\u884c\u7684\u4ee3\u7801\u5b83\u662f\u9a8c\u8bc1\u4e0d\u4e86\u8fd9\u4e9b\u903b\u8f91\u7684\uff0c\u6240\u4ee5\u8bf4\u6211\u4eec\u600e\u4e48\u80fd\u591f\u628a\u8fd9\u4e9b\u4ee3\u7801\u7ed9\u5408\u7406\u7684\u8fdb\u884c\u4f18\u5316\u3002\u8fd9\u91cc\u5c31\u4e0d\u5f97\u4e0d\u5148\u8bf4\u4e00\u4e0b\u5b83\u7684\u95ee\u9898\uff0c\u6211\u4eec\u770b\u4e00\u4e0b\u5b83\u90fd\u6709\u54ea\u4e9b\u95ee\u9898\uff0c\u9996\u5148\u7b2c\u4e00\u4e2a\u5c31\u662f\u804c\u8d23\u5355\u4e00\u95ee\u9898\uff0c\u6211\u4eec\u5982\u679c\u7ec6\u5206\u7684\u8bdd\uff0c\u5176\u5b9e\u521a\u624d\u7684\u90a3\u4e9b\u9a8c\u8bc1\u903b\u8f91\u6211\u4eec\u5206\u4e3a\u4e86\u4e09\u5757\uff0c\u7b2c\u4e00\u5757\u7684\u8bdd\u662f\u9a8c\u8bc1\u662f\u5426\u975e\u7a7a\u6216\u8005\u8bf4\u7a7a\u7684\u5b57\u7b26\u4e32\uff0c\u8fd9\u4e2a\u662f\u6211\u4eec\u6bd4\u8f83\u7b80\u5355\u7684\u4e00\u4e2a\u9a8c\u8bc1\u903b\u8f91\u3002<\/p>\n\n\n\n<p>&nbsp;\u7b2c\u4e8c\u5757\u7684\u8bdd\u5c31\u662f\u6211\u4eec\u9700\u8981\u53bb\u9a8c\u8bc1\u5b83\u5bf9\u5e94\u7684\u4e00\u4e2a\u6570\u636e\u662f\u5426\u7b26\u5408\u57fa\u672c\u7684\u4e00\u4e9b\u903b\u8f91\uff0c\u6bd4\u5982\u8bf4\u5b83\u6bcf\u4e2a\u5b57\u6bb5\u4e4b\u95f4\u7684\u4f9d\u8d56\u5173\u7cfb\u662f\u5426\u7b26\u5408\u3002\u7b2c\u4e09\u4e2a\u7684\u8bdd\u662f\u6211\u4eec\u9700\u8981\u4f9d\u8d56\u5b83\u7684\u8fd9\u4e9b\u6570\u636e\u5bf9\u4e0d\u5bf9\uff1f\u6bd4\u5982\u8bf4\u4f60\u7ed9\u6211\u4f20\u7684\u5546\u54c1\u7f16\u7801\u662f\u5426\u6b63\u786e\u7b49\u7b49\uff0c\u8fd9\u6837\u7684\u8bdd\u6211\u4eec\u662f\u4e0d\u662f\u53ef\u4ee5\u628a\u8fd9\u4e09\u5757\u7ed9\u5355\u72ec\u62c6\u4e09\u4e2a\u5904\u7406\u5668\uff0c\u8fd9\u6837\u7684\u8bdd\u4e0d\u5c31\u804c\u8d23\u5355\u4e00\u4e86\uff0c\u5bf9\u4e0d\u5bf9\uff1f\u800c\u4e14\u540e\u7eed\u6539\u7684\u8bdd\u53ea\u9700\u8981\u6539\u5bf9\u5e94\u7684\u5904\u7406\u5668\u5c31\u53ef\u4ee5\u4e86\u3002\u7136\u540e\u53e6\u5916\u7684\u8bdd\uff0c\u5982\u679c\u6211\u4eec\u8981\u65b0\u589e\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6dfb\u52a0\u65b0\u7684\u5904\u7406\u5668\uff0c\u800c\u4e0d\u9700\u8981\u4fee\u6539\u73b0\u6709\u4ee3\u7801\uff0c\u8fd9\u4e5f\u5c31\u662f\u6211\u4eec\u5927\u5bb6\u5e38\u8bf4\u7684\u9ad8\u5185\u805a\u4f4e\u8026\u5408\u4ee5\u53ca\u6211\u4eec\u7684\u4e00\u4e2a\u5f00\u8f9f\u539f\u5219\u3002\u6700\u540e\u7684\u8bdd\u4e5f\u662f\u86ee\u91cd\u8981\u7684\uff0c\u5c31\u662f\u5bf9\u4e8e\u770b\u4ee3\u7801\u7684\u4eba\u6765\u8bf4\uff0c\u5b83\u662f\u6d41\u7a0b\u6bd4\u8f83\u6e05\u6670\u7684\uff0c\u4e00\u773c\u5c31\u77e5\u9053\u6211\u8fd9\u8fb9\u4f1a\u6709\u4e09\u4e2a\u903b\u8f91\uff0c\u5bf9\u4e8e\u4ed6\u7406\u89e3\u4e1a\u52a1\u4f1a\u6709\u4e00\u5b9a\u7684\u5e2e\u52a9\u4f5c\u7528\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u60f3\u4e00\u4e0b\u7528\u8d23\u4efb\u94fe\u6a21\u5f0f\u662f\u4e0d\u662f\u80fd\u89e3\u51b3\u4e0a\u9762\u7684\u8fd9\u4e9b\u95ee\u9898\uff1f<\/p>\n\n\n\n<p>\u5bf9\u4e8edao\/entity\/CouponTemplateDO.java<br>dao\/mapper\/CouponTemplateMapper.java<br>dto\/req\/CouponTemplateSaveReqDTO.java<br>dto\/resp\/CouponTemplateQueryRespDTO.java<br>\u5c31\u6682\u65f6\u4e0d\u8981\u8bf4\u4e86\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public interface CouponTemplateService extends IService&lt;CouponTemplateDO&gt; {\n\n    \/**\n     * \u521b\u5efa\u5546\u5bb6\u4f18\u60e0\u5238\u6a21\u677f\n     *\n     * @param requestParam \u8bf7\u6c42\u53c2\u6570\n     *\/\n    void createCouponTemplate(CouponTemplateSaveReqDTO requestParam);\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>@Service\n@RequiredArgsConstructor\npublic class CouponTemplateServiceImpl extends ServiceImpl&lt;CouponTemplateMapper, CouponTemplateDO&gt; implements CouponTemplateService {\n\n    private final CouponTemplateMapper couponTemplateMapper;\n    private final StringRedisTemplate stringRedisTemplate;\n\n    private final int maxStock = 20000000;\n\n    @Override\n    public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) {\n        \/\/ \u9a8c\u8bc1\u5fc5\u586b\u53c2\u6570\u662f\u5426\u4e3a\u7a7a\u6216\u7a7a\u7684\u5b57\u7b26\u4e32\n        if (StrUtil.isEmpty(requestParam.getName())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getSource())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u6765\u6e90\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getTarget())) {\n            throw new ClientException(\"\u4f18\u60e0\u5bf9\u8c61\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getType())) {\n            throw new ClientException(\"\u4f18\u60e0\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getValidStartTime())) {\n            throw new ClientException(\"\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getValidEndTime())) {\n            throw new ClientException(\"\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getStock())) {\n            throw new ClientException(\"\u5e93\u5b58\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (StrUtil.isEmpty(requestParam.getReceiveRule())) {\n            throw new ClientException(\"\u9886\u53d6\u89c4\u5219\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (StrUtil.isEmpty(requestParam.getConsumeRule())) {\n            throw new ClientException(\"\u6d88\u8017\u89c4\u5219\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        \/\/ \u9a8c\u8bc1\u53c2\u6570\u57fa\u672c\u6570\u636e\u5173\u7cfb\u662f\u5426\u6b63\u786e\n        boolean targetAnyMatch = Arrays.stream(DiscountTargetEnum.values())\n                .anyMatch(enumConstant -&gt; enumConstant.getType() == requestParam.getTarget());\n        if (!targetAnyMatch) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u4f18\u60e0\u5bf9\u8c61\u503c\u4e0d\u5b58\u5728\");\n        }\n        if (ObjectUtil.equal(requestParam.getTarget(), DiscountTargetEnum.ALL_STORE_GENERAL)\n                &amp;&amp; StrUtil.isNotEmpty(requestParam.getGoods())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u5168\u5e97\u901a\u7528\u4e0d\u53ef\u8bbe\u7f6e\u6307\u5b9a\u5546\u54c1\");\n        }\n        if (ObjectUtil.equal(requestParam.getTarget(), DiscountTargetEnum.PRODUCT_SPECIFIC)\n                &amp;&amp; StrUtil.isEmpty(requestParam.getGoods())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u5546\u54c1\u4e13\u5c5e\u672a\u8bbe\u7f6e\u6307\u5b9a\u5546\u54c1\");\n        }\n\n        boolean typeAnyMatch = Arrays.stream(DiscountTypeEnum.values())\n                .anyMatch(enumConstant -&gt; enumConstant.getType() == requestParam.getType());\n        if (!typeAnyMatch) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u4f18\u60e0\u7c7b\u578b\u4e0d\u5b58\u5728\");\n        }\n\n        Date now = new Date();\n        if (requestParam.getValidStartTime().before(now)) {\n            \/\/ \u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u6d4b\u8bd5\uff0c\u4e0d\u7528\u5173\u6ce8\u8fd9\u4e2a\u65f6\u95f4\uff0c\u8fd9\u91cc\u53d6\u6d88\u5f02\u5e38\u629b\u51fa\n            \/\/ throw new ClientException(\"\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f53\u524d\u65f6\u95f4\");\n        }\n\n        if (requestParam.getStock() &lt;= 0 || requestParam.getStock() &gt; maxStock) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u5e93\u5b58\u6570\u91cf\u8bbe\u7f6e\u5f02\u5e38\");\n        }\n\n        if (!JSON.isValid(requestParam.getReceiveRule())) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u9886\u53d6\u89c4\u5219\u683c\u5f0f\u9519\u8bef\");\n        }\n        if (!JSON.isValid(requestParam.getConsumeRule())) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u6d88\u8017\u89c4\u5219\u683c\u5f0f\u9519\u8bef\");\n        }\n\n        \/\/ \u9a8c\u8bc1\u53c2\u6570\u6570\u636e\u662f\u5426\u6b63\u786e\n        if (ObjectUtil.equal(requestParam.getTarget(), DiscountTargetEnum.PRODUCT_SPECIFIC)) {\n            \/\/ \u8c03\u7528\u5546\u54c1\u4e2d\u53f0\u9a8c\u8bc1\u5546\u54c1\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u4e0d\u5b58\u5728\u629b\u51fa\u5f02\u5e38\n            \/\/ ......\n        }\n\n        \/\/ \u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93\n        CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class);\n        couponTemplateDO.setStatus(CouponTemplateStatusEnum.ACTIVE.getStatus());\n        couponTemplateDO.setShopNumber(UserContext.getShopNumber());\n        couponTemplateMapper.insert(couponTemplateDO);\n\n        \/\/ \u7f13\u5b58\u9884\u70ed\uff1a\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u7684\u8bb0\u5f55\u5e8f\u5217\u5316\u6210 JSON \u5b57\u7b26\u4e32\u653e\u5165 Redis \u7f13\u5b58\n        CouponTemplateQueryRespDTO actualRespDTO = BeanUtil.toBean(couponTemplateDO, CouponTemplateQueryRespDTO.class);\n        Map&lt;String, Object&gt; cacheTargetMap = BeanUtil.beanToMap(actualRespDTO, false, true);\n        Map&lt;String, String&gt; actualCacheTargetMap = cacheTargetMap.entrySet().stream()\n                .collect(Collectors.toMap(\n                        Map.Entry::getKey,\n                        entry -&gt; entry.getValue() != null ? entry.getValue().toString() : \"\"\n                ));\n        String couponTemplateCacheKey = String.format(MerchantAdminRedisConstant.COUPON_TEMPLATE_KEY, couponTemplateDO.getId());\n        stringRedisTemplate.opsForHash().putAll(couponTemplateCacheKey, actualCacheTargetMap);\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>@RestController\n@RequiredArgsConstructor\n@Tag(name = \"\u4f18\u60e0\u5238\u6a21\u677f\u7ba1\u7406\")\npublic class CouponTemplateController {\n\n    private final CouponTemplateService couponTemplateService;\n\n    @Operation(summary = \"\u5546\u5bb6\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\")\n    @PostMapping(\"\/api\/merchant-admin\/coupon-template\/create\")\n    public Result&lt;Void&gt; createCouponTemplate(@RequestBody CouponTemplateSaveReqDTO requestParam) {\n        couponTemplateService.createCouponTemplate(requestParam);\n        return Results.success();\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u8d23\u4efb\u94fe\u6a21\u5f0f<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-1\">3.1 \u73b0\u6709\u4ee3\u7801\u7684\u95ee\u9898<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u804c\u8d23\u5355\u4e00<\/strong>: \u8d23\u4efb\u94fe\u6a21\u5f0f\u53ef\u4ee5\u5c06\u6bcf\u4e2a\u9a8c\u8bc1\u903b\u8f91\u5c01\u88c5\u5230\u4e00\u4e2a\u72ec\u7acb\u7684\u5904\u7406\u5668\u4e2d\uff0c\u6bcf\u4e2a\u5904\u7406\u5668\u8d1f\u8d23\u5355\u4e00\u7684\u9a8c\u8bc1\u804c\u8d23\uff0c\u7b26\u5408\u5355\u4e00\u804c\u8d23\u539f\u5219\u3002<\/li>\n\n\n\n<li><strong>\u53ef\u6269\u5c55\u6027<\/strong>: \u589e\u52a0\u65b0\u7684\u9a8c\u8bc1\u903b\u8f91\u65f6\uff0c\u53ea\u9700\u6dfb\u52a0\u65b0\u7684\u5904\u7406\u5668\uff0c\u800c\u4e0d\u9700\u8981\u4fee\u6539\u73b0\u6709\u7684\u4ee3\u7801\u3002<\/li>\n\n\n\n<li><strong>\u6e05\u6670\u7684\u6d41\u7a0b<\/strong>: \u5c06\u6240\u6709\u9a8c\u8bc1\u903b\u8f91\u7ec4\u7ec7\u5728\u4e00\u8d77\uff0c\u4f7f\u5f97\u4ee3\u7801\u7ed3\u6784\u66f4\u52a0\u6e05\u6670\uff0c\u6613\u4e8e\u7406\u89e3\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Component\npublic final class MerchantAdminChainContext&lt;T&gt; implements ApplicationContextAware, CommandLineRunner {\n\n    \/**\n     * \u5e94\u7528\u4e0a\u4e0b\u6587\uff0c\u6211\u4eec\u8fd9\u91cc\u901a\u8fc7 Spring IOC \u83b7\u53d6 Bean \u5b9e\u4f8b\n     *\/\n    private ApplicationContext applicationContext;\n    \/**\n     * \u4fdd\u5b58\u5546\u5bb6\u540e\u7ba1\u8d23\u4efb\u94fe\u5b9e\u73b0\u7c7b\n     * &lt;p&gt;\n     * Key\uff1a{@link MerchantAdminAbstractChainHandler#mark()}\n     * Val\uff1a{@link MerchantAdminAbstractChainHandler} \u4e00\u7ec4\u8d23\u4efb\u94fe\u5b9e\u73b0 Spring Bean \u96c6\u5408\n     * &lt;p&gt;\n     * \u6bd4\u5982\u6709\u4e00\u4e2a\u4f18\u60e0\u5238\u6a21\u677f\u521b\u5efa\u8d23\u4efb\u94fe\uff0c\u5b9e\u4f8b\u5982\u4e0b\uff1a\n     * Key\uff1aMERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY\n     * Val\uff1a\n     * - \u9a8c\u8bc1\u4f18\u60e0\u5238\u4fe1\u606f\u57fa\u672c\u53c2\u6570\u662f\u5426\u5fc5\u586b \u2014\u2014 \u6267\u884c\u5668 {@link CouponTemplateCreateParamNotNullChainFilter}\n     * - \u9a8c\u8bc1\u4f18\u60e0\u5238\u4fe1\u606f\u57fa\u672c\u53c2\u6570\u662f\u5426\u6309\u7167\u683c\u5f0f\u4f20\u9012 \u2014\u2014 \u6267\u884c\u5668 {@link CouponTemplateCreateParamBaseVerifyChainFilter}\n     * - \u9a8c\u8bc1\u4f18\u60e0\u5238\u4fe1\u606f\u57fa\u672c\u53c2\u6570\u662f\u5426\u6b63\u786e\uff0c\u6bd4\u5982\u5546\u54c1\u6570\u636e\u662f\u5426\u5b58\u5728\u7b49 \u2014\u2014 \u6267\u884c\u5668 {@link CouponTemplateCreateParamVerifyChainFilter}\n     * - ......\n     *\/\n    private final Map&lt;String, List&lt;MerchantAdminAbstractChainHandler&gt;&gt; abstractChainHandlerContainer = new HashMap&lt;&gt;();\n\n    \/**\n     * \u8d23\u4efb\u94fe\u7ec4\u4ef6\u6267\u884c\n     *\n     * @param mark         \u8d23\u4efb\u94fe\u7ec4\u4ef6\u6807\u8bc6\n     * @param requestParam \u8bf7\u6c42\u53c2\u6570\n     *\/\n    public void handler(String mark, T requestParam) {\n        \/\/ \u6839\u636e mark \u6807\u8bc6\u4ece\u8d23\u4efb\u94fe\u5bb9\u5668\u4e2d\u83b7\u53d6\u4e00\u7ec4\u8d23\u4efb\u94fe\u5b9e\u73b0 Bean \u96c6\u5408\n        List&lt;MerchantAdminAbstractChainHandler&gt; abstractChainHandlers = abstractChainHandlerContainer.get(mark);\n        if (CollectionUtils.isEmpty(abstractChainHandlers)) {\n            throw new RuntimeException(String.format(\"&#91;%s] Chain of Responsibility ID is undefined.\", mark));\n        }\n        abstractChainHandlers.forEach(each -&gt; each.handler(requestParam));\n    }\n\n    @Override\n    public void run(String... args) throws Exception {\n        \/\/ \u4ece Spring IOC \u5bb9\u5668\u4e2d\u83b7\u53d6\u6307\u5b9a\u63a5\u53e3 Spring Bean \u96c6\u5408\n        Map&lt;String, MerchantAdminAbstractChainHandler&gt; chainFilterMap = applicationContext.getBeansOfType(MerchantAdminAbstractChainHandler.class);\n        chainFilterMap.forEach((beanName, bean) -&gt; {\n            \/\/ \u5224\u65ad mark \u662f\u5426\u5df2\u7ecf\u5b58\u5728\u62bd\u8c61\u8d23\u4efb\u94fe\u5bb9\u5668\u4e2d\uff0c\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u76f4\u63a5\u5411\u96c6\u5408\u65b0\u589e\uff1b\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u521b\u5efa Mark \u548c\u5bf9\u5e94\u7684\u96c6\u5408\n            List&lt;MerchantAdminAbstractChainHandler&gt; abstractChainHandlers = abstractChainHandlerContainer.get(bean.mark());\n            if (CollectionUtils.isEmpty(abstractChainHandlers)) {\n                abstractChainHandlers = new ArrayList();\n            }\n            abstractChainHandlers.add(bean);\n            \/\/ \u5bf9 Mark \u4e0b\u8d23\u4efb\u94fe\u5b9e\u73b0\u7684\u5904\u7406\u7c7b\u6392\u5e8f\uff0c\u6027\u80fd\u6267\u884c\u5c0f\u7684\u5728\u524d\n            List&lt;MerchantAdminAbstractChainHandler&gt; actualAbstractChainHandlers = abstractChainHandlers.stream()\n                    .sorted(Comparator.comparing(Ordered::getOrder))\n                    .collect(Collectors.toList());\n            abstractChainHandlerContainer.put(bean.mark(), actualAbstractChainHandlers);\n        });\n    }\n\n    @Override\n    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {\n        this.applicationContext = applicationContext;\n    }\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u6211\u4eec\u5927\u5bb6\u5176\u5b9e\u53ef\u4ee5\u7c7b\u6bd4\u4e00\u4e0b\uff0c\u50cf\u6211\u4eec\u521a\u624d\u8bb2\u5230\u7684\u7528\u6237\u62e6\u622a\u5668\uff0c\u672c\u8d28\u4e0a\u5b83\u5c31\u662f\u8d23\u4efb\u94fe\u7684\u4e00\u79cd\u6a21\u5f0f\uff0c\u56e0\u4e3a\u5b83\u80fd\u914d\u7f6e\u591a\u4e2a\u62e6\u622a\u5668\uff0c\u800c\u4e14\u8fd9\u4e9b\u62e6\u622a\u5668\u4e00\u5b9a\u4f1a\u628a\u8bf7\u6c42\u7ed9\u6267\u884c\u4e00\u904d\uff0c\u9664\u975e\u4f60\u5728\u8fc7\u7a0b\u5f53\u4e2d\u629b\u51fa\u5f02\u5e38\u3002&nbsp;\u5927\u5bb6\u60f3\u4e00\u4e0b\u662f\u4e0d\u662f\u548c\u6211\u4eec\u7684\u9a8c\u8bc1\u903b\u8f91\uff0c\u5176\u5b9e\u6838\u5fc3\u601d\u60f3\u662f\u4e00\u81f4\u7684\uff0c\u5bf9\u4e0d\u5bf9\uff1f\u6211\u4eec\u53bb\u770b\u4e00\u4e0b\u8d23\u4efb\u94fe\u7684\u4e00\u4e2a\u5730\u56fe\uff0c\u9996\u5148\u6211\u4eec\u8981\u6709\u4e00\u4e2a\u8d23\u4efb\u94fe\u7684\u62bd\u8c61\u63a5\u53e3\uff0c\u7136\u540e\u901a\u8fc7\u62bd\u8c61\u63a5\u53e3\u5404\u4e2a\u5b9e\u73b0\u7c7b\u53bb\u5b9e\u73b0\u6211\u4eec\u8981\u5bf9\u8bf7\u6c42\u6240\u8981\u505a\u7684\u4e00\u4e9b\u903b\u8f91\u5904\u7406\u6b65\u9aa4\uff0c\u7136\u540e\u6211\u4eec\u9700\u8981\u4e00\u4e9b\u5904\u7406\u7c7b\u53bb\u7ee7\u627f\u6211\u4eec\u8d23\u4efb\u94fe\u7684\u63a5\u53e3\uff0c\u7136\u540e\u53bb\u5b9e\u73b0\u81ea\u5df1\u5185\u90e8\u7684\u4e00\u4e9b\u903b\u8f91\u5c01\u88c5\u3002\u540c\u65f6\u6211\u4eec\u5c06\u4e00\u7ec4\u7684\u8d23\u4efb\u94fe\u7ed9\u5b83\u653e\u5230\u4e00\u4e2a\u5bb9\u5668\u91cc\u9762\uff0c\u8fd9\u4e2a\u4e5f\u5c31\u662f\u6211\u4eec\u7684\u4e00\u4e2a\u8d23\u4efb\u94fe\u7684\u5b8c\u6574\u7684\u903b\u8f91\uff0c\u5982\u679c\u6211\u4eec\u53bb\u770b\u4ee3\u7801\u7684\u8bdd\uff0c\u4f1a\u53d1\u73b0\u6211\u4eec\u4f1a\u6709\u4ee5\u4e0b5\u4e2a\u7c7b\uff0c\u7b2c\u4e00\u4e2a\u7c7b\u7684\u8bdd\u4e5f\u5c31\u662f\u6211\u4eec\u8d23\u4efb\u94fe\u63a5\u53e3\uff0c\u7b2c\u4e8c\u4e2a\u662f\u6211\u4eec\u7684\u4e0a\u4e0b\u6587\u5b58\u50a8\uff0c\u7136\u540e\u63a5\u4e0b\u6765\u76843\u4e2a\u7684\u8bdd\uff0c\u6211\u4eec\u5177\u4f53\u76841\u4e2a\u8d23\u4efb\u94fe\u5b9e\u73b0\uff0c\u56e0\u4e3a\u65f6\u95f4\u7684\u95ee\u9898\uff0c\u6211\u8fd9\u91cc\u5c31\u4e0d\u7ed9\u5927\u5bb6\u53bb\u4ece0~1\u53bb\u6f14\u793a\u5b83\u5bf9\u5e94\u53bb\u600e\u4e48\u521b\u5efa\u4e86\uff0c\u6211\u76f4\u63a5\u7ed9\u5927\u5bb6\u53bb\u5c55\u793a\u4e00\u4e2a\u5df2\u7ecf\u505a\u597d\u7684\u8d23\u4efb\u94fe\uff0c\u6211\u4eec\u5c31\u770b\u4e00\u4e0b\u4ee3\u7801\u662f\u600e\u4e48\u5b9e\u73b0\u7684\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6309\u7167\u521a\u624d\u7684\u903b\u8f91\uff0c\u6211\u4eec\u9996\u5148\u8981\u53bb\u521b\u5efa\u4e00\u4e2a\u8d23\u4efb\u94fe\u7684\u63a5\u53e3\uff0c\u5b9e\u73b0\u8fd9\u4e2a\u63a5\u53e3\u7684\u8bdd\u5176\u5b9e\u91cc\u9762\u5c31\u4e24\u4e2a\u903b\u8f91\uff0c\u7b2c\u4e00\u5757\u6211\u4eec\u53bb\u5904\u7406\u8d23\u4efb\u94fe\u7684\u4e00\u4e2a\u6267\u884c\u903b\u8f91\u3002\u7b2c\u4e8c\u4e2a\u5c31\u662f\u6211\u4eec\u8981\u6807\u8bc6\u4e00\u7ec4\u7684\u8d23\u4efb\u94fe\u7684\u5904\u7406\u5668\uff0c\u7136\u540e\u7684\u8bdd\u4e0b\u9762\u662f\u4e00\u4e9b\u5b83\u53bb\u5b9e\u73b0\u4e86\u63a5\u53e3\u7684\u5bf9\u5e94\u7684\u4e00\u4e2a\u65f6\u9650\u5185\uff0c\u7136\u540e\u8fd9\u91cc\u9762\u90fd\u662f\u5b83\u5bf9\u5e94\u7684\u4e00\u4e9b\u5177\u4f53\u7684\u5c01\u88c5\u903b\u8f91\uff0c\u5bf9\u5e94\u6211\u521a\u624d\u8bb2\u7684\u4e09\u5757\u5185\u5bb9\uff0c\u7b2c\u4e00\u5757\u7684\u8bdd\u5c31\u662f\u8fdb\u884c\u975e\u7a7a\u7684\u9a8c\u8bc1\uff0c\u7b2c\u4e8c\u5757\u8fdb\u884c\u57fa\u7840\u6570\u636e\u7684\u4e00\u4e2a\u6821\u9a8c\u3002\u7b2c\u4e09\u5757\u9488\u5bf9\u6570\u636e\u7684\u771f\u5b9e\u6027\u505a\u4e00\u4e2a\u6821\u9a8c\uff0c\u53ef\u4ee5\u770b\u5230\u8fd8\u662f\u6bd4\u8f83\u6e05\u6670\u7684\u5bf9\u5427\uff1f\u7136\u540e\u6211\u4eec\u5728\u4f7f\u7528\u65b9\u9762\u5c31\u53ea\u9700\u8981\u5f15\u5165\u6211\u4eec\u5bf9\u5e94\u7684\u4e00\u4e2a\u4e0a\u4e0b\u6587\uff0c\u7136\u540e\u53bb\u6267\u884c\u5904\u7406\u5c31\u53ef\u4ee5\u4e86\uff0c\u6211\u4eec\u5c31\u770b\u4e00\u4e0b\u5b83\u5177\u4f53\u662f\u600e\u4e48\u628a\u8fd9\u4e00\u7ec4\u7684\u8d23\u4efb\u94fe\u7684\u5904\u7406\u5668\u7ed9\u805a\u5408\u5230\u5bb9\u5668\u91cc\u9762\u7684\uff0c\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u7684\u4e0a\u4e0b\u6587\u5bb9\u5668\u662f\u5b9e\u73b0\u4e86\u4e24\u4e2a\u63a5\u53e3\uff0c\u7b2c\u4e00\u4e2a\u63a5\u53e3\u662fsport\u7684\u4e00\u4e2a\u4e0a\u4e0b\u6587OA\u63a5\u53e3\uff0c\u5b9e\u73b0\u8fd9\u4e2a\u63a5\u53e3\u7684\u8bdd\u6211\u4eec\u80fd\u591f\u62ff\u662f\u4e0d\u662f\u5bf9\u8c61\u7684\u4e00\u4e2aIOC\u7684\u4e0a\u4e0b\u6587\uff0c\u4e5f\u5c31\u662fapplication context\u3002\u901a\u8fc7\u6211\u4eec\u53ef\u4ee5\u53bb\u62ff\u8d23\u4efb\u94fe\u7684\u5904\u7406\u5668\u7684spring\u75c5\u3002\u7136\u540e\u7b2c\u4e8c\u4e2a\u5c31\u662f\u6211\u4eec\u8981\u5728spring boot\u542f\u52a8\u4e86\u4e4b\u540e\uff0c\u8981\u53bb\u505a\u4e00\u4e9b\u540e\u7f6e\u7684\u903b\u8f91\uff0c\u6211\u4eec\u5148\u4ece\u5165\u53e3\u51fa\u53d1\uff0c\u5165\u53e3\u7684\u8bdd\u5c31\u662f\u6211\u4eec\u901a\u8fc7\u5404\u4f4d\u63a5\u53e3\u62ff\u5230\u4e86\u5bf9\u5e94\u7684\u662f\u670b\u53cb\u7684\u4e0a\u4e0b\u6587\uff0c\u7136\u540e\u6211\u4eec\u901a\u8fc7\u83b7\u53d6\u7c7b\u578b\u7684\u5f62\u5f0f\uff0c\u4e5f\u5c31\u662f\u83b7\u53d6\u6211\u4eec\u5f53\u524d\u63a5\u53e3\u4e0b\u9762\u6709\u54ea\u4e9b\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\uff0c\u7136\u540e\u62ff\u5230\u4e00\u4e2amap\u91cc\u9762\uff0c\u6211\u4eec\u901a\u8fc7 map\u518d\u8fdb\u800c\u53bb\u83b7\u53d6\u5230\u6211\u4eec\u60f3\u8981\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u90a3\u5c31\u662f\u6211\u4eec\u5bf9\u5e94\u7684\u4e00\u4e2a\u5b58\u50a8\u5bb9\u5668\u662f\u7528\u4e86\u4e00\u4e2amap\u53bb\u505a\u7684\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a\u5e0c\u9ea6\u514b\uff0c\u7136\u540e\u5b83\u7684K\u5c31\u662f\u6211\u4eec\u5bf9\u5e94\u7684\u4e00\u4e2a\u9ea6\u514b\u5b57\u6bb5\uff0c\u8fd9\u4e2a\u4e5f\u5c31\u662f\u6211\u4eec\u6807\u8bc6\u4e00\u7ec4\u8d23\u4efb\u94fe\u7684\u4e00\u4e2a\u5173\u952e\u5b57\u6bb5\u3002\u7136\u540e value\u5c31\u662f\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6807\u8bc6\u4e86\u6211\u4eec\u4e00\u4e2a\u6807\u8bc6\u4e0b\u9762\u5b83\u7684\u90a3\u4e00\u7ec4\u8d23\u4efb\u94fe\u7684\u5904\u7406\u5668\u3002\u6211\u4e3e\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u6709\u4e00\u4e2aK\u662f\u8fd9\u6837\u7684\uff0c\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677fK\uff0c\u7136\u540e\u7684\u8bdd\u5b83\u7684value\u5c31\u662f\u6211\u4eec\u521a\u624d\u8bb2\u5230\u7684\u90a3\u4e09\u4e2a\u7c7b\uff0c\u8fd9\u4e2a\u65f6\u5019\u8d23\u4efb\u94fe\u7684\u5bb9\u5668\u600e\u4e48\u5b58\u50a8\uff0c\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86\u5b83\u662f\u600e\u4e48\u7ed9\u5b83\u653e\u8fdb\u53bb\u7684\uff0c\u9996\u5148\u7b2c\u4e00\u6b65\u6211\u4eec\u8981\u6839\u636e\u5b83\u5bf9\u5e94\u7684\u4e00\u4e2aMark\uff0c\u786e\u5b9a\u6211\u4eec\u7684\u5bb9\u5668\u91cc\u9762\u662f\u5426\u5df2\u7ecf\u6709\u6807\u8bc6\u5bf9\u5e94\u7684\u96c6\u5408\u4e86\uff0c\u5982\u679c\u6ca1\u6709\u7684\u8bdd\u6211\u4eec\u8981\u53bb\u7ed9\u4ed6\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u4f8b\u5b50\uff0c\u5982\u679c\u6709\u7684\u8bdd\u76f4\u63a5\u83b7\u53d6\uff0c\u7136\u540e\u5c06\u5f53\u524d\u56e0\u4e3a\u662f\u4e2a\u5faa\u73af\uff0c\u5c06\u5f53\u524d\u7684\u75c5\u653e\u5230\u5b83\u5bf9\u5e94\u6807\u8bc6\u4e0b\u7684\u4f8b\u5b50\u7684\u5bb9\u5668\u91cc\u9762\uff0c\u7136\u540e\u6211\u4eec\u518d\u5c06\u5bf9\u5e94\u7684\u6807\u8bc6\u548c\u96c6\u5408\u653e\u56de\u5230\u6211\u4eec\u7684\u5bb9\u5668\u91cc\u9762\uff0c\u7136\u540e\u6211\u4eec\u662f\u9700\u8981\u7ed9\u5b83\u8fdb\u884c\u4e00\u4e2a\u6392\u5e8f\u7684\uff0c\u7136\u540e\u5177\u4f53\u4e3a\u4ec0\u4e48\u6392\u5e8f\u540e\u9762\u4f1a\u8ddf\u5927\u5bb6\u6709\u8bb2\u3002\u7136\u540e\u5230\u6211\u4eec\u5177\u4f53\u7684\u4e1a\u52a1\u4ee3\u7801\u91cc\u9762\u7684\u8bdd\uff0c\u5c31\u53ea\u9700\u8981\u53bb\u5f15\u5165\u6211\u4eec\u7684\u4e00\u4e2a\u4e0a\u4e0b\u6587\u5bb9\u5668\uff0c\u7136\u540e\u53bb\u6267\u884c\u6211\u4eec\u7684handle\u7684\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\u3002\u90a3handle\u7684\u65b9\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u90a3\u5c31\u662f\u6211\u4eec\u53bbget\u5bf9\u5e94\u7684\u4e00\u4e2a\u8d23\u4efb\u94fe\u903b\u8f91\u96c6\u5408\u3002\u7136\u540e\u5982\u679c\u8bf4\u5b83\u7b49\u4e8e\u7a7a\u7684\u8bdd\uff0c\u5c31\u610f\u5473\u7740\u6211\u4eec\u7684\u4e1a\u52a1\u4ee3\u7801\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u76f4\u63a5\u629b\u5f02\u5e38\u5c31\u884c\u4e86\uff0c\u5982\u679c\u4e0d\u51fa\u5f02\u5e38\u6211\u4eec\u5c31\u76f4\u63a5\u6309\u7167\u987a\u5e8f\u53bb\u6267\u884c\uff0c\u8fd9\u6837\u7684\u8bdd\u6211\u4eec\u7684\u4e00\u4e2a\u8d23\u4efb\u94fe\u5176\u5b9e\u4e5f\u5c31\u5df2\u7ecf\u5b8c\u6210\u4e86\uff0c\u5982\u679c\u8bf4\u540e\u7eed\u6211\u6709\u65b0\u7684\u4e1a\u52a1\u8981\u6dfb\u52a0\uff0c\u6211\u76f4\u63a5\u5728\u8fd9\u91cccopy\u4e00\u4e2a\uff0c\u8fd9\u6837\u7684\u8bdd\u5bf9\u6211\u4eec\u539f\u6765\u7684\u903b\u8f91\u662f\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\u7684\uff0c\u5982\u679c\u8bf4\u6211\u7684\u975e\u516c\u9a8c\u8bc1\u6216\u8005\u8bf4\u6211\u7684\u9a8c\u8bc1\u6570\u636e\u903b\u8f91\u6709\u4e00\u4e9b\u53d8\u5316\uff0c\u6211\u5c31\u76f4\u63a5\u5728\u5bf9\u5e94\u7684\u90a3\u91cc\u6539\u5c31\u884c\u4e86\uff0c\u5bf9\u5176\u4ed6\u4e5f\u662f\u5b8c\u5168\u6ca1\u6709\u5f71\u54cd\u7684<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-2\">3.2 \u4ec0\u4e48\u662f\u8d23\u4efb\u94fe\u6a21\u5f0f<\/h4>\n\n\n\n<p>\u8d23\u4efb\u94fe\u6a21\u5f0f\uff08Chain of Responsibility Pattern\uff09\u662f\u4e00\u79cd\u884c\u4e3a\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5b83\u5141\u8bb8\u5c06\u8bf7\u6c42\u6cbf\u7740\u4e00\u4e2a\u5904\u7406\u94fe\u4f20\u9012\uff0c\u76f4\u5230\u94fe\u4e2d\u7684\u67d0\u4e2a\u5bf9\u8c61\u5904\u7406\u5b83\u3002\u8fd9\u6837\uff0c\u53d1\u9001\u8005\u65e0\u9700\u77e5\u9053\u54ea\u4e2a\u5bf9\u8c61\u5c06\u5904\u7406\u8bf7\u6c42\uff0c\u6240\u6709\u7684\u5904\u7406\u5bf9\u8c61\u90fd\u53ef\u4ee5\u5c1d\u8bd5\u5904\u7406\u8bf7\u6c42\u6216\u5c06\u8bf7\u6c42\u4f20\u9012\u7ed9\u94fe\u4e0a\u7684\u4e0b\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"392\" width=\"1149\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/821749f9a71107c3c20db8adecae1be9.png\" alt=\"\"><\/p>\n\n\n\n<p>\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\u8d23\u4efb\u94fe\u6a21\u5f0f\u7c7b\u5206\u5e03\u3002\u8fd8\u6709common\/enums\u91cc\u9762<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public enum ChainBizMarkEnum {\n\n    \/**\n     * \u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\u9a8c\u8bc1\u53c2\u6570\u662f\u5426\u6b63\u786e\u8d23\u4efb\u94fe\u6d41\u7a0b\n     *\/\n    MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY;\n\n    @Override\n    public String toString() {\n        return this.name();\n    }\n}<\/code><\/pre>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"914\" width=\"1046\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/1e444c3ac291b175c56e559fef152051.png\" alt=\"\"><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-3\">3.3 \u5b9e\u73b0\u903b\u8f91<\/h4>\n\n\n\n<p>\u5b9a\u4e49\u8d23\u4efb\u94fe\u62bd\u8c61\u63a5\u53e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public interface MerchantAdminAbstractChainHandler&lt;T&gt; extends Ordered {\n\n    \/**\n     * \u6267\u884c\u8d23\u4efb\u94fe\u903b\u8f91\n     *\n     * @param requestParam \u8d23\u4efb\u94fe\u6267\u884c\u5165\u53c2\n     *\/\n    void handler(T requestParam);\n\n    \/**\n     * @return \u8d23\u4efb\u94fe\u7ec4\u4ef6\u6807\u8bc6\n     *\/\n    String mark();\n}\n<\/code><\/pre>\n\n\n\n<p>\u521b\u5efa\u8d23\u4efb\u94fe\u6a21\u5f0f\u4e0a\u4e0b\u6587\u5bb9\u5668\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/**\n * \u5546\u5bb6\u540e\u7ba1\u8d23\u4efb\u94fe\u4e0a\u4e0b\u6587\u5bb9\u5668\n * ApplicationContextAware \u63a5\u53e3\u83b7\u53d6\u5e94\u7528\u4e0a\u4e0b\u6587\uff0c\u5e76\u590d\u5236\u5c40\u90e8\u53d8\u91cf\u65b9\u4fbf\u540e\u7eed\u4f7f\u7528\uff1bCommandLineRunner \u9879\u76ee\u542f\u52a8\u540e\u6267\u884c\u8d23\u4efb\u94fe\u5bb9\u5668\u7684\u586b\u5145\u5de5\u4f5c\n * &lt;p&gt;\n * \u4f5c\u8005\uff1a\u9a6c\u4e01\n * \u52a0\u9879\u76ee\u7fa4\uff1a\u65e9\u52a0\u5165\u5c31\u662f\u4f18\u52bf\uff01500\u4eba\u5185\u90e8\u9879\u76ee\u7fa4\uff0c\u5206\u4eab\u7684\u77e5\u8bc6\u603b\u6709\u4f60\u9700\u8981\u7684 &lt;a href=\"https:\/\/t.zsxq.com\/cw7b9\" \/&gt;\n * \u5f00\u53d1\u65f6\u95f4\uff1a2024-07-09\n *\/\n@Component\npublic final class MerchantAdminChainContext&lt;T&gt; implements ApplicationContextAware, CommandLineRunner {\n\n    \/**\n     * \u5e94\u7528\u4e0a\u4e0b\u6587\uff0c\u6211\u4eec\u8fd9\u91cc\u901a\u8fc7 Spring IOC \u83b7\u53d6 Bean \u5b9e\u4f8b\n     *\/\n    private ApplicationContext applicationContext;\n    \/**\n     * \u4fdd\u5b58\u5546\u5bb6\u540e\u7ba1\u8d23\u4efb\u94fe\u5b9e\u73b0\u7c7b\n     * &lt;p&gt;\n     * Key\uff1a{@link MerchantAdminAbstractChainHandler#mark()}\n     * Val\uff1a{@link MerchantAdminAbstractChainHandler} \u4e00\u7ec4\u8d23\u4efb\u94fe\u5b9e\u73b0 Spring Bean \u96c6\u5408\n     * &lt;p&gt;\n     * \u6bd4\u5982\u6709\u4e00\u4e2a\u4f18\u60e0\u5238\u6a21\u677f\u521b\u5efa\u8d23\u4efb\u94fe\uff0c\u5b9e\u4f8b\u5982\u4e0b\uff1a\n     * Key\uff1aMERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY\n     * Val\uff1a\n     * - \u9a8c\u8bc1\u4f18\u60e0\u5238\u4fe1\u606f\u57fa\u672c\u53c2\u6570\u662f\u5426\u5fc5\u586b \u2014\u2014 \u6267\u884c\u5668 {@link CouponTemplateCreateParamNotNullChainFilter}\n     * - \u9a8c\u8bc1\u4f18\u60e0\u5238\u4fe1\u606f\u57fa\u672c\u53c2\u6570\u662f\u5426\u6309\u7167\u683c\u5f0f\u4f20\u9012 \u2014\u2014 \u6267\u884c\u5668 {@link CouponTemplateCreateParamBaseVerifyChainFilter}\n     * - \u9a8c\u8bc1\u4f18\u60e0\u5238\u4fe1\u606f\u57fa\u672c\u53c2\u6570\u662f\u5426\u6b63\u786e\uff0c\u6bd4\u5982\u5546\u54c1\u6570\u636e\u662f\u5426\u5b58\u5728\u7b49 \u2014\u2014 \u6267\u884c\u5668 {@link CouponTemplateCreateParamVerifyChainFilter}\n     * - ......\n     *\/\n    private final Map&lt;String, List&lt;MerchantAdminAbstractChainHandler&gt;&gt; abstractChainHandlerContainer = new HashMap&lt;&gt;();\n\n    \/**\n     * \u8d23\u4efb\u94fe\u7ec4\u4ef6\u6267\u884c\n     *\n     * @param mark         \u8d23\u4efb\u94fe\u7ec4\u4ef6\u6807\u8bc6\n     * @param requestParam \u8bf7\u6c42\u53c2\u6570\n     *\/\n    public void handler(String mark, T requestParam) {\n        \/\/ \u6839\u636e mark \u6807\u8bc6\u4ece\u8d23\u4efb\u94fe\u5bb9\u5668\u4e2d\u83b7\u53d6\u4e00\u7ec4\u8d23\u4efb\u94fe\u5b9e\u73b0 Bean \u96c6\u5408\n        List&lt;MerchantAdminAbstractChainHandler&gt; abstractChainHandlers = abstractChainHandlerContainer.get(mark);\n        if (CollectionUtils.isEmpty(abstractChainHandlers)) {\n            throw new RuntimeException(String.format(\"&#91;%s] Chain of Responsibility ID is undefined.\", mark));\n        }\n        abstractChainHandlers.forEach(each -&gt; each.handler(requestParam));\n    }\n\n    @Override\n    public void run(String... args) throws Exception {\n        \/\/ \u4ece Spring IOC \u5bb9\u5668\u4e2d\u83b7\u53d6\u6307\u5b9a\u63a5\u53e3 Spring Bean \u96c6\u5408\n        Map&lt;String, MerchantAdminAbstractChainHandler&gt; chainFilterMap = applicationContext.getBeansOfType(MerchantAdminAbstractChainHandler.class);\n        chainFilterMap.forEach((beanName, bean) -&gt; {\n            \/\/ \u5224\u65ad Mark \u662f\u5426\u5df2\u7ecf\u5b58\u5728\u62bd\u8c61\u8d23\u4efb\u94fe\u5bb9\u5668\u4e2d\uff0c\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u76f4\u63a5\u5411\u96c6\u5408\u65b0\u589e\uff1b\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u521b\u5efa Mark \u548c\u5bf9\u5e94\u7684\u96c6\u5408\n            List&lt;MerchantAdminAbstractChainHandler&gt; abstractChainHandlers = abstractChainHandlerContainer.getOrDefault(bean.mark(), new ArrayList&lt;&gt;());\n            abstractChainHandlers.add(bean);\n            abstractChainHandlerContainer.put(bean.mark(), abstractChainHandlers);\n        });\n        abstractChainHandlerContainer.forEach((mark, unsortedChainHandlers) -&gt; {\n            \/\/ \u5bf9\u6bcf\u4e2a Mark \u5bf9\u5e94\u7684\u8d23\u4efb\u94fe\u5b9e\u73b0\u7c7b\u96c6\u5408\u8fdb\u884c\u6392\u5e8f\uff0c\u4f18\u5148\u7ea7\u5c0f\u7684\u5728\u524d\n            unsortedChainHandlers.sort(Comparator.comparing(Ordered::getOrder));\n        });\n    }\n\n    @Override\n    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {\n        this.applicationContext = applicationContext;\n    }\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-4\">3.4 \u5982\u4f55\u4f7f\u7528\uff1f<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Service\n@RequiredArgsConstructor\npublic class CouponTemplateServiceImpl extends ServiceImpl&lt;CouponTemplateMapper, CouponTemplateDO&gt; implements CouponTemplateService {\n\n    private final CouponTemplateMapper couponTemplateMapper;\n    private final MerchantAdminChainContext merchantAdminChainContext;\n    private final StringRedisTemplate stringRedisTemplate;\n\n    @Override\n    public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) {\n        \/\/ \u901a\u8fc7\u8d23\u4efb\u94fe\u9a8c\u8bc1\u8bf7\u6c42\u53c2\u6570\u662f\u5426\u6b63\u786e\n        merchantAdminChainContext.handler(MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY.name(), requestParam);\n\n        \/\/ \u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93\n        CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class);\n        couponTemplateDO.setStatus(CouponTemplateStatusEnum.ACTIVE.getStatus());\n        couponTemplateDO.setShopNumber(UserContext.getShopNumber());\n        couponTemplateMapper.insert(couponTemplateDO);\n\n        \/\/ \u7f13\u5b58\u9884\u70ed\uff1a\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u7684\u8bb0\u5f55\u5e8f\u5217\u5316\u6210 JSON \u5b57\u7b26\u4e32\u653e\u5165 Redis \u7f13\u5b58\n        CouponTemplateQueryRespDTO actualRespDTO = BeanUtil.toBean(couponTemplateDO, CouponTemplateQueryRespDTO.class);\n        Map&lt;String, Object&gt; cacheTargetMap = BeanUtil.beanToMap(actualRespDTO, false, true);\n        Map&lt;String, String&gt; actualCacheTargetMap = cacheTargetMap.entrySet().stream()\n                .collect(Collectors.toMap(\n                        Map.Entry::getKey,\n                        entry -&gt; entry.getValue() != null ? entry.getValue().toString() : \"\"\n                ));\n        String couponTemplateCacheKey = String.format(MerchantAdminRedisConstant.COUPON_TEMPLATE_KEY, couponTemplateDO.getId());\n        stringRedisTemplate.opsForHash().putAll(couponTemplateCacheKey, actualCacheTargetMap);\n    }\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><br>\u662f\u4e0d\u662f\u5bf9\u8c61\u7684\u4e00\u4e2a Spring \u7684\u4e0a\u4e0b\u6587\uff0c\u4e5f\u5c31\u662f ApplicationContext\u3002\u901a\u8fc7\u5b83\u53ef\u4ee5\u53bb\u83b7\u53d6\u8d23\u4efb\u94fe\u5904\u7406\u5668\u7684 Spring Bean\u3002\u7136\u540e\u7b2c\u4e8c\u4e2a\u5c31\u662f\u6211\u4eec\u8981\u5728 Spring Boot \u542f\u52a8\u4e4b\u540e\uff0c\u6267\u884c\u4e00\u4e9b\u540e\u7f6e\u903b\u8f91\u3002\u6211\u4eec\u5148\u4ece\u5165\u53e3\u51fa\u53d1\uff1a\u5165\u53e3\u662f\u901a\u8fc7\u672c\u4f4d\u63a5\u53e3\u62ff\u5230\u5bf9\u5e94\u7684 Spring \u4e0a\u4e0b\u6587\uff0c\u7136\u540e\u901a\u8fc7\u83b7\u53d6\u7c7b\u578b\u7684\u5f62\u5f0f\uff0c\u4e5f\u5c31\u662f\u83b7\u53d6\u5f53\u524d\u63a5\u53e3\u4e0b\u6709\u54ea\u4e9b\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\uff0c\u518d\u62ff\u5230 Map \u91cc\u9762\uff0c\u901a\u8fc7 Map \u8fdb\u800c\u83b7\u53d6\u5230\u6211\u4eec\u60f3\u8981\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5bf9\u5e94\u7684\u4e00\u4e2a\u5b58\u50a8\u5bb9\u5668\u662f\u7528\u4e86\u4e00\u4e2a Map \u53bb\u505a\u7684\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a HashMap\uff0c\u5b83\u7684 Key \u5c31\u662f\u6211\u4eec\u5bf9\u5e94\u7684\u4e00\u4e2a mark \u5b57\u6bb5\uff0c\u8fd9\u4e2a\u4e5f\u5c31\u662f\u6211\u4eec\u6807\u8bc6\u4e00\u7ec4\u8d23\u4efb\u94fe\u7684\u5173\u952e\u5b57\u6bb5\uff0cValue \u5c31\u662f\u4e00\u4e2a List\uff0c\u6807\u8bc6\u4e86\u8be5\u6807\u8bc6\u4e0b\u90a3\u4e00\u7ec4\u8d23\u4efb\u94fe\u7684\u5904\u7406\u5668\u3002\u6211\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u6709\u4e00\u4e2a Key \u662f\u8fd9\u6837\u7684\uff1a\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\u7684 mark\uff08MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY\uff09\uff0c\u5b83\u7684 Value \u5c31\u662f\u6211\u521a\u624d\u8bb2\u5230\u7684\u4e09\u4e2a\u7c7b\uff1aCouponTemplateCreateParamNotNullChainFilter\u3001CouponTemplateCreateParamBaseVerifyChainFilter\u3001CouponTemplateCreateParamVerifyChainFilter\u3002\u8fd9\u4e2a\u65f6\u5019\u8d23\u4efb\u94fe\u7684\u5bb9\u5668\u600e\u4e48\u5b58\u50a8\uff1f\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86\u5b83\u662f\u600e\u4e48\u653e\u8fdb\u53bb\u7684\uff1a\u9996\u5148\u7b2c\u4e00\u6b65\uff0c\u6211\u4eec\u8981\u6839\u636e\u5b83\u5bf9\u5e94\u7684 mark\uff0c\u5224\u65ad\u5bb9\u5668\u91cc\u662f\u5426\u5df2\u7ecf\u6709\u8be5\u6807\u8bc6\u5bf9\u5e94\u7684\u96c6\u5408\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u5c31\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684 List\uff1b\u5982\u679c\u6709\u7684\u8bdd\uff0c\u76f4\u63a5\u83b7\u53d6\uff0c\u7136\u540e\u56e0\u4e3a\u662f\u5faa\u73af\u5904\u7406\uff0c\u5c06\u5f53\u524d\u7684 Bean \u653e\u5230\u5b83\u5bf9\u5e94\u6807\u8bc6\u4e0b\u7684 List \u5bb9\u5668\u91cc\uff0c\u518d\u5c06\u5bf9\u5e94\u7684\u6807\u8bc6\u548c\u96c6\u5408\u653e\u56de\u6211\u4eec\u7684\u5bb9\u5668\u4e2d\u3002\u7136\u540e\u6211\u4eec\u9700\u8981\u5bf9\u5b83\u8fdb\u884c\u6392\u5e8f\uff0c\u5177\u4f53\u4e3a\u4ec0\u4e48\u6392\u5e8f\u540e\u9762\u4f1a\u8bb2\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u5230\u6211\u4eec\u5177\u4f53\u7684\u4e1a\u52a1\u4ee3\u7801\u91cc\uff0c\u53ea\u9700\u8981\u5f15\u5165\u6211\u4eec\u7684\u4e0a\u4e0b\u6587\u7ec4\u4ef6\uff0c\u7136\u540e\u8c03\u7528 execute \u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\u3002\u5b83\u7684\u65b9\u6cd5\u975e\u5e38\u7b80\u5355\uff1a\u6211\u4eec\u53bb get \u5bf9\u5e94\u8d23\u4efb\u94fe\u7684\u96c6\u5408\uff0c\u5982\u679c\u7b49\u4e8e null\uff0c\u5c31\u610f\u5473\u7740\u4e1a\u52a1\u914d\u7f6e\u6709\u95ee\u9898\uff0c\u76f4\u63a5\u629b\u5f02\u5e38\uff1b\u5982\u679c\u4e0d\u629b\u5f02\u5e38\uff0c\u6211\u4eec\u5c31\u76f4\u63a5\u6309 getOrder() \u7684\u987a\u5e8f\u4f9d\u6b21\u6267\u884c\u3002\u8fd9\u6837\u7684\u8bdd\uff0c\u6211\u4eec\u7684\u8d23\u4efb\u94fe\u5176\u5b9e\u4e5f\u5c31\u5b8c\u6210\u4e86\u3002\u5982\u679c\u540e\u7eed\u6709\u65b0\u7684\u4e1a\u52a1\u8981\u6dfb\u52a0\uff0c\u6211\u76f4\u63a5\u65b0\u589e\u4e00\u4e2a @Component \u5b9e\u73b0\u7c7b\u5373\u53ef\uff0c\u5bf9\u539f\u6765\u7684\u903b\u8f91\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\uff1b\u5982\u679c\u67d0\u4e2a\u9a8c\u8bc1\u903b\u8f91\u9700\u8981\u8c03\u6574\uff0c\u76f4\u63a5\u4fee\u6539\u5bf9\u5e94\u7c7b\u5373\u53ef\uff0c\u5bf9\u5176\u4ed6\u5904\u7406\u5668\u4e5f\u5b8c\u5168\u6ca1\u6709\u5f71\u54cd\u3002\u76f8\u4fe1\u8bf4\u5230\u8fd9\u91cc\uff0c\u5f88\u591a\u540c\u5b66\u5df2\u7ecf\u660e\u767d\u4e86\u8d23\u4efb\u94fe\u7684\u4f18\u70b9\u3002\u5982\u679c\u5927\u5bb6\u8fd8\u6709\u95ee\u9898\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u533a\u6c9f\u901a\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8bb2\u521a\u624d\u9884\u7559\u7684\u70b9\uff1a\u4e3a\u4ec0\u4e48\u7ee7\u627f\u7684\u63a5\u53e3\u8981\u5b9e\u73b0\u6392\u5e8f\uff1f\u56e0\u4e3a\u8d23\u4efb\u94fe\u4f1a\u6709\u591a\u4e2a\u5904\u7406\u5668\uff0c\u6211\u4eec\u4e00\u822c\u4f1a\u628a\u6027\u80fd\u597d\u3001\u5bf9\u5176\u4ed6\u7ec4\u4ef6\u65e0\u4f9d\u8d56\u7684\u5904\u7406\u5668\u653e\u5728\u524d\u9762\u3002\u6211\u7ed9\u5927\u5bb6\u770b\u4e00\u4e0b\uff1a\u6bd4\u5982\u975e\u7a7a\u9a8c\u8bc1\uff08CouponTemplateCreateParamNotNullChainFilter\uff09\uff0c\u6027\u80fd\u6700\u597d\uff0c\u5b83\u7684 getOrder() \u8fd4\u56de 0\uff1b\u57fa\u7840\u6821\u9a8c\uff08CouponTemplateCreateParamBaseVerifyChainFilter\uff09\u7d27\u968f\u5176\u540e\uff0c\u8fd4\u56de 10\uff1b\u800c\u5546\u54c1\u5b58\u5728\u6027\u6821\u9a8c\uff08CouponTemplateCreateParamVerifyChainFilter\uff09\u53ef\u80fd\u9700\u8981 RPC \u8c03\u7528\u5546\u54c1\u670d\u52a1\uff0c\u6027\u80fd\u6700\u5dee\uff0c\u6240\u4ee5\u8fd4\u56de 20\uff0c\u6392\u5728\u6700\u540e\u3002<\/p>\n\n\n\n<p>\u76f8\u4fe1\u5927\u5bb6\u80fd\u660e\u767d\u4e3a\u4ec0\u4e48\u8981\u6709 order\uff1a\u5982\u679c\u6211\u4eec\u5148\u628a\u5546\u54c1\u5b58\u5728\u6027\u6821\u9a8c\u653e\u5728\u7b2c\u4e00\u4f4d\uff0c\u5047\u8bbe\u5546\u54c1\u786e\u5b9e\u5b58\u5728\uff0c\u4f46\u7528\u6237\u6839\u672c\u6ca1\u4f20\u201c\u9886\u53d6\u89c4\u5219\u201d\uff0c\u90a3\u8fd9\u6b21 RPC \u8c03\u7528\u5c31\u662f\u6d6a\u8d39\u7684\u3002\u6240\u4ee5\u6211\u4eec\u5e94\u8be5\u628a\u6027\u80fd\u6700\u597d\u7684\u6821\u9a8c\u653e\u5728\u6700\u524d\u9762\uff0c\u9010\u6b65\u6267\u884c\uff0c\u6027\u80fd\u5dee\u7684\u653e\u540e\u9762\u3002<\/p>\n\n\n\n<p>\u7136\u540e\uff0c\u6211\u4eec\u7684\u8d23\u4efb\u94fe\u6a21\u5f0f\u7b26\u5408\u5f00\u95ed\u539f\u5219\u3002\u5927\u5bb6\u53ef\u80fd\u5728\u7f51\u4e0a\u770b\u7684\u65f6\u5019\u4f1a\u6709\u7591\u95ee\uff1a\u5f88\u591a\u4eba\u8bb2\u8d23\u4efb\u94fe\u65f6\u4f1a\u8bf4\uff0c\u4f60\u8981\u628a\u5904\u7406\u5668\u52a0\u5165\u8d23\u4efb\u94fe\u5bb9\u5668\uff0c\u9700\u8981\u624b\u52a8\u8c03\u7528 register \u65b9\u6cd5\u2014\u2014\u5927\u5bb6\u5c31\u6709\u7591\u95ee\u4e86\uff1a\u90a3\u5c82\u4e0d\u662f\u6bcf\u6b21\u65b0\u589e\u5904\u7406\u5668\u90fd\u8981\u6539\u6ce8\u518c\u903b\u8f91\uff1f<\/p>\n\n\n\n<p>\u4f46\u6211\u4eec\u521a\u624d\u7684\u5b9e\u73b0\u6ca1\u6709\u8fd9\u4e2a\u95ee\u9898\u3002\u6211\u4eec\u5b9e\u73b0\u7684\u8d23\u4efb\u94fe\u662f\u7b26\u5408\u5f00\u95ed\u539f\u5219\u7684\uff0c\u56e0\u4e3a\u901a\u8fc7 Spring ApplicationContext \u81ea\u52a8\u626b\u63cf\u548c\u6ce8\u5165\uff0c\u5e2e\u52a9\u6211\u4eec\u5b8c\u6210\u6ce8\u518c\u903b\u8f91\u3002\u5982\u679c\u4f60\u4e0d\u662f\u5728 Spring \u73af\u5883\u4e0b\uff0c\u6709\u4e9b\u5b9e\u73b0\u786e\u5b9e\u4e0d\u7b26\u5408\u5f00\u95ed\u539f\u5219\u3002\u8fd9\u4e2a\u70b9\u7b97\u662f\u4e00\u4e2a\u6269\u5c55\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u6846\u67b6\u5904\u7406\u5f97\u975e\u5e38\u5468\u5168\uff0c\u6240\u4ee5\u6211\u4eec\u5bf9\u4e8e\u8fd9\u79cd\u5f00\u7bb1\u5373\u7528\u7684\u673a\u5236\uff0c\u76f4\u63a5\u4f7f\u7528\u5373\u53ef\uff0c\u4e0d\u9700\u8981\u81ea\u5df1\u518d\u5199\u6ce8\u518c\u903b\u8f91\uff0c\u6216\u8005\u628a\u4e1a\u52a1\u590d\u6742\u5316\u3002\u4e0d\u77e5\u9053\u8fd9\u4e48\u8bb2\u5927\u5bb6\u80fd\u4e0d\u80fd\u7406\u89e3\uff1f<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u9a8c\u8bc1\u4e00\u4e0b\u73b0\u5728\u7684\u903b\u8f91\u662f\u5426\u597d\u4f7f\u3002\u6211\u73b0\u5728\u5df2\u7ecf\u628a\u9879\u76ee\u542f\u52a8\u8d77\u6765\u4e86\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u5bf9\u5e94\u7684 API \u63a5\u53e3\u3002\u56e0\u4e3a\u6211\u7a97\u53e3\u5df2\u7ecf\u6253\u5f00\u4e86\uff0c\u6211\u70b9\u4e86\u53d1\u9001\u2014\u2014\u8fd9\u91cc\u6211\u5df2\u7ecf\u9884\u7f6e\u4e86\u4e00\u4e9b\u793a\u4f8b\u5b57\u6bb5\uff0c\u5927\u5bb6\u76f4\u63a5\u7528\u5373\u53ef\u3002\u70b9\u51fb\u53d1\u9001\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u8bb0\u5f55\u5df2\u7ecf\u6210\u529f\u5b58\u50a8\u5230\u6570\u636e\u5e93\u91cc\u4e86\u3002\u5173\u4e8e\u6570\u636e\u5e93\u8fd9\u5757\u4e5f\u8981\u8ddf\u5927\u5bb6\u8bf4\u660e\u4e00\u4e0b\uff1a\u6211\u4eec\u4ece 0 \u5230 1 \u642d\u5efa\u7684\u6570\u636e\u5e93\u8868\uff0c\u5176\u5b9e\u540e\u9762\u4e5f\u52a0\u4e86\u5b57\u6bb5\u6269\u5c55\uff08\u6bd4\u5982 radio\uff09\uff0c\u4f46\u5982\u679c\u4f60\u770b\u7684\u662f\u80a1\u4efd\u5236\u516c\u53f8\u7684\u539f\u59cb\u8868\u7ed3\u6784\uff0c\u53ef\u80fd\u662f\u6ca1\u6709\u8fd9\u4e9b\u5b57\u6bb5\u7684\u2014\u2014\u8fd9\u70b9\u8981\u8ddf\u5927\u5bb6\u8bf4\u6e05\u695a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Component\npublic class CouponTemplateCreateParamVerifyChainFilter implements MerchantAdminAbstractChainHandler&lt;CouponTemplateSaveReqDTO&gt; {\n\n    @Override\n    public void handler(CouponTemplateSaveReqDTO requestParam) {\n        if (ObjectUtil.equal(requestParam.getTarget(), DiscountTargetEnum.PRODUCT_SPECIFIC)) {\n            \/\/ \u8c03\u7528\u5546\u54c1\u4e2d\u53f0\u9a8c\u8bc1\u5546\u54c1\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u4e0d\u5b58\u5728\u629b\u51fa\u5f02\u5e38\n            \/\/ ......\n        }\n    }\n\n    @Override\n    public String mark() {\n        return MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY.name();\n    }\n\n    @Override\n    public int getOrder() {\n        return 20;\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Component\npublic class CouponTemplateCreateParamNotNullChainFilter implements MerchantAdminAbstractChainHandler&lt;CouponTemplateSaveReqDTO&gt; {\n\n    @Override\n    public void handler(CouponTemplateSaveReqDTO requestParam) {\n        if (StrUtil.isEmpty(requestParam.getName())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getSource())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u6765\u6e90\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getTarget())) {\n            throw new ClientException(\"\u4f18\u60e0\u5bf9\u8c61\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getType())) {\n            throw new ClientException(\"\u4f18\u60e0\u7c7b\u578b\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getValidStartTime())) {\n            throw new ClientException(\"\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getValidEndTime())) {\n            throw new ClientException(\"\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (ObjectUtil.isEmpty(requestParam.getStock())) {\n            throw new ClientException(\"\u5e93\u5b58\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (StrUtil.isEmpty(requestParam.getReceiveRule())) {\n            throw new ClientException(\"\u9886\u53d6\u89c4\u5219\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n\n        if (StrUtil.isEmpty(requestParam.getConsumeRule())) {\n            throw new ClientException(\"\u6d88\u8017\u89c4\u5219\u4e0d\u80fd\u4e3a\u7a7a\");\n        }\n    }\n\n    @Override\n    public String mark() {\n        return MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY.name();\n    }\n\n    @Override\n    public int getOrder() {\n        return 0;\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>@Component\npublic class CouponTemplateCreateParamBaseVerifyChainFilter implements MerchantAdminAbstractChainHandler&lt;CouponTemplateSaveReqDTO&gt; {\n\n    private final int maxStock = 20000000;\n\n    @Override\n    public void handler(CouponTemplateSaveReqDTO requestParam) {\n        boolean targetAnyMatch = Arrays.stream(DiscountTargetEnum.values())\n                .anyMatch(enumConstant -&gt; enumConstant.getType() == requestParam.getTarget());\n        if (!targetAnyMatch) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u4f18\u60e0\u5bf9\u8c61\u503c\u4e0d\u5b58\u5728\");\n        }\n        if (ObjectUtil.equal(requestParam.getTarget(), DiscountTargetEnum.ALL_STORE_GENERAL)\n                &amp;&amp; StrUtil.isNotEmpty(requestParam.getGoods())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u5168\u5e97\u901a\u7528\u4e0d\u53ef\u8bbe\u7f6e\u6307\u5b9a\u5546\u54c1\");\n        }\n        if (ObjectUtil.equal(requestParam.getTarget(), DiscountTargetEnum.PRODUCT_SPECIFIC)\n                &amp;&amp; StrUtil.isEmpty(requestParam.getGoods())) {\n            throw new ClientException(\"\u4f18\u60e0\u5238\u5546\u54c1\u4e13\u5c5e\u672a\u8bbe\u7f6e\u6307\u5b9a\u5546\u54c1\");\n        }\n\n        boolean typeAnyMatch = Arrays.stream(DiscountTypeEnum.values())\n                .anyMatch(enumConstant -&gt; enumConstant.getType() == requestParam.getType());\n        if (!typeAnyMatch) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u4f18\u60e0\u7c7b\u578b\u4e0d\u5b58\u5728\");\n        }\n\n        Date now = new Date();\n        if (requestParam.getValidStartTime().before(now)) {\n            \/\/ \u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u6d4b\u8bd5\uff0c\u4e0d\u7528\u5173\u6ce8\u8fd9\u4e2a\u65f6\u95f4\uff0c\u8fd9\u91cc\u53d6\u6d88\u5f02\u5e38\u629b\u51fa\n            \/\/ throw new ClientException(\"\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f53\u524d\u65f6\u95f4\");\n        }\n\n        if (requestParam.getStock() &lt;= 0 || requestParam.getStock() &gt; maxStock) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u5e93\u5b58\u6570\u91cf\u8bbe\u7f6e\u5f02\u5e38\");\n        }\n\n        if (!JSON.isValid(requestParam.getReceiveRule())) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u9886\u53d6\u89c4\u5219\u683c\u5f0f\u9519\u8bef\");\n        }\n        if (!JSON.isValid(requestParam.getConsumeRule())) {\n            \/\/ \u6b64\u5904\u5df2\u7ecf\u57fa\u672c\u80fd\u5224\u65ad\u6570\u636e\u8bf7\u6c42\u5c5e\u4e8e\u6076\u610f\u653b\u51fb\uff0c\u53ef\u4ee5\u4e0a\u62a5\u98ce\u63a7\u4e2d\u5fc3\u8fdb\u884c\u5c01\u7981\u8d26\u53f7\n            throw new ClientException(\"\u6d88\u8017\u89c4\u5219\u683c\u5f0f\u9519\u8bef\");\n        }\n    }\n\n    @Override\n    public String mark() {\n        return MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY.name();\n    }\n\n    @Override\n    public int getOrder() {\n        return 10;\n    }\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-5\">3.5 \u5e38\u89c1\u95ee\u9898\u7b54\u7591<\/h4>\n\n\n\n<p>Q\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981 Order \u63a5\u53e3\uff1f<\/p>\n\n\n\n<p>A\uff1a\u56e0\u4e3a\u5b9e\u73b0\u8d23\u4efb\u94fe\u7684\u8bdd\u4f1a\u6709\u591a\u4e2a\u5904\u7406\u5668\uff0c\u521b\u5efa\u4f18\u60e0\u5238\u4e1a\u52a1\u4f18\u5148\u5904\u7406\u6027\u80fd\u8f83\u597d\u7684\uff0c\u7136\u540e\u9010\u6b65\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<p>Q\uff1a\u8d23\u4efb\u94fe\u6a21\u5f0f\u6ee1\u8db3\u5f00\u95ed\u539f\u5219\u4e48\uff1f<\/p>\n\n\n\n<p>A\uff1a\u6211\u4eec\u662f\u901a\u8fc7 Spring IOC \u5bb9\u5668\u53bb\u83b7\u53d6\u8d23\u4efb\u94fe\u5904\u7406\u5668\u7684\uff0c\u6240\u4ee5\u4e0d\u7ba1\u65b0\u589e\u548c\u5220\u9664\u90fd\u4e0d\u9700\u8981\u53d8\u66f4\u83b7\u53d6\u903b\u8f91\u3002\u65b0\u589e\u7684\u8bdd\u521b\u5efa\u5bf9\u5e94\u5904\u7406\u5668\u5373\u53ef\uff0c\u7b26\u5408\u5f00\u95ed\u539f\u5219\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4\">4. \u7f13\u5b58\u9884\u70ed<\/h3>\n\n\n\n<p>\u5728\u89c6\u9891\u4e2d\u7f13\u5b58\u9884\u70ed\u4e00\u7b14\u5e26\u8fc7\uff0c\u4f46\u662f\u6709\u540c\u5b66\u63d0\u4e86\u4e24\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u89e3\u7b54\u4e0b\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4-1-hash-string\">4.1 \u4e3a\u4ec0\u4e48\u4f7f\u7528 Hash \u4e0d\u662f String\uff1f<\/h4>\n\n\n\n<p>\u56e0\u4e3a\u4f18\u60e0\u5238\u6a21\u677f\u5b58\u5728\u5e93\u5b58\uff0c\u800c\u6211\u4eec\u540e\u7eed\u4f1a\u901a\u8fc7\u7f13\u5b58\u6263\u51cf\uff0c\u5982\u679c\u4f7f\u7528\u5b57\u7b26\u4e32\u6ca1\u529e\u6cd5\u505a\u539f\u5b50\u81ea\u51cf\uff0c\u800c\u4f7f\u7528 Redis Hash \u7ed3\u6784\u662f\u53ef\u4ee5\u9488\u5bf9\u67d0\u4e2a\u5b57\u6bb5\u8fdb\u884c\u81ea\u51cf\u7684\u3002<\/p>\n\n\n\n<p>\u3001<img loading=\"lazy\" decoding=\"async\" height=\"1212\" width=\"1986\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/e1f1334bf83a5a8217b69565e110edb6.png\" alt=\"\"><\/p>\n\n\n\n<p>\u5982\u679c\u5bf9\u5e94 Redis \u547d\u4ee4\u7684\u8bdd\uff0c\u5982\u4e0b\u6240\u793a\uff0c\u5373\u53ef\u5b8c\u6210\u7528\u6237\u9886\u53d6\u4f18\u60e0\u5238\u65f6\u7684\u539f\u5b50\u81ea\u51cf\u903b\u8f91\u3002<\/p>\n\n\n\n<p><code>HINCRBY HashKey stock -1<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4-2\">4.2 \u5982\u4f55\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\uff1f<\/h4>\n\n\n\n<p>\u6709\u4f4d\u540c\u5b66\u6307\u6b63\u4e86\u4e00\u4e2a\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u54b1\u4eec\u6ca1\u6709\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\u3002<\/p>\n\n\n\n<p>\u4e4b\u524d\u4ee3\u7801\u903b\u8f91\u5982\u4e0b\uff0c\u8fc7\u671f\u65f6\u95f4\u9ed8\u8ba4 -1\uff0c\u4e5f\u5c31\u662f\u4e0d\u4f1a\u8fc7\u671f\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u4f18\u60e0\u5238\u6a21\u677f\u8fc7\u671f\u4e86\uff0c\u4f46\u662f\u7f13\u5b58\u8fd8\u5728\uff0c\u5bf9 Redis \u5185\u5b58\u5b58\u50a8\u538b\u529b\u8f83\u5927\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6e Key \u7684\u8fc7\u671f\u65f6\u95f4\u3002<\/p>\n\n\n\n<p><code>stringRedisTemplate.opsForHash().putAll(couponTemplateCacheKey, actualCacheTargetMap);<\/code><\/p>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u57fa\u7840\u4e0a\uff0c\u6dfb\u52a0\u5bf9\u5e94\u4f18\u60e0\u5238\u7684\u622a\u6b62\u65f6\u95f4\u4f5c\u4e3a\u8fc7\u671f\u65f6\u95f4\u5373\u53ef\u3002<\/p>\n\n\n\n<p><code>stringRedisTemplate.opsForHash().putAll(couponTemplateCacheKey, actualCacheTargetMap); stringRedisTemplate.expireAt(couponTemplateCacheKey, couponTemplateDO.getValidEndTime());<\/code><\/p>\n\n\n\n<p>\u5f88\u591a\u540c\u5b66\u5230\u8fd9\u91cc\u5c31\u7ed3\u675f\u4e86\uff0c\u4f46\u662f\u6b8a\u4e0d\u77e5\u8fd8\u662f\u6709\u70b9\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u8fd9\u4e2a\u662f\u975e\u539f\u5b50\u6027\u7684\u3002\u5982\u679c\u60f3\u8981\u539f\u5b50\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 LUA \u811a\u672c\u6267\u884c\u7ec4\u5408\u547d\u4ee4\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u5176\u5b9e\u8fd9\u91cc\u8003\u8651\u7684\u6781\u7aef\u60c5\u51b5\uff0c\u4e5f\u5c31\u662f\u521a\u6267\u884c\u5b8c\u65b0\u589e Hash \u7f13\u5b58\uff0c\u4f46\u662f\u8fd8\u6ca1\u6267\u884c\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\u65f6\u5b95\u673a\u4e86\u3002\u4f46\u662f\u6b63\u5f0f\u4f01\u4e1a\u4e2d\u5f80\u5f80\u6ca1\u90a3\u4e48\u591a\u6781\u7aef\u60c5\u51b5\uff0c\u5373\u4f7f\u51fa\u73b0\u4e86\u65e0\u5916\u4e4e\u591a\u4e00\u6761\u8bb0\u5f55\u800c\u5df2\uff0c\u5bf9\u4e8e\u4f01\u4e1a\u5b58\u50a8\u6765\u8bf4\u65e0\u5173\u7d27\u8981\u3002<\/em><\/p>\n\n\n\n<p><em>\u4f46\u662f\u65e2\u7136\u8003\u8651\u5230\u4e86\u8fd9\u79cd\u6781\u7aef\u60c5\u51b5\uff0c\u5c31\u548c\u5927\u5bb6\u8bf4\u4e0b\u5e94\u8be5\u600e\u4e48\u53bb\u9632\u6b62\u95ee\u9898\u3002<strong>\u4f60\u53ef\u4ee5\u4e0d\u8fd9\u4e48\u5199\uff0c\u4f46\u662f\u4e0d\u80fd\u4e0d\u77e5\u9053\u89e3\u9898\u601d\u8def<\/strong>\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<p>CouponTemplateServiceImpl\u6dfb\u52a0\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u901a\u8fc7 LUA \u811a\u672c\u6267\u884c\u8bbe\u7f6e Hash \u6570\u636e\u4ee5\u53ca\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\n        String luaScript = \"redis.call('HMSET', KEYS&#91;1], unpack(ARGV, 1, #ARGV - 1)) \" +\n                \"redis.call('EXPIREAT', KEYS&#91;1], ARGV&#91;#ARGV])\";\n\n        List&lt;String&gt; keys = Collections.singletonList(couponTemplateCacheKey);\n        List&lt;String&gt; args = new ArrayList&lt;&gt;(actualCacheTargetMap.size() * 2 + 1);\n        actualCacheTargetMap.forEach((key, value) -&gt; {\n            args.add(key);\n            args.add(value);\n        });\n\n        \/\/ \u4f18\u60e0\u5238\u6d3b\u52a8\u8fc7\u671f\u65f6\u95f4\u8f6c\u6362\u4e3a\u79d2\u7ea7\u522b\u7684 Unix \u65f6\u95f4\u6233\n        args.add(String.valueOf(couponTemplateDO.getValidEndTime().getTime() \/ 1000));\n\n        \/\/ \u6267\u884c LUA \u811a\u672c\n        stringRedisTemplate.execute(\n                new DefaultRedisScript&lt;&gt;(luaScript, Long.class),\n                keys,\n                args.toArray()\n        );<code> <\/code><\/code><\/pre>\n\n\n\n<p>\u901a\u8fc7 LUA \u811a\u672c\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u7684\u539f\u5b50\u95ee\u9898\uff0c\u5e76\u8bbe\u7f6e\u4f18\u60e0\u5238\u622a\u6b62\u65f6\u95f4\u4e3a Key \u8fc7\u671f\u65f6\u95f4\u3002<strong>\u6ce8\u610f\uff1a\u540e\u7eed\u6dfb\u52a0\u4f18\u60e0\u5238\u6a21\u677f\u5165\u53c2\u4e2d\u7684 validEndTime \u53c2\u6570\u4e0d\u80fd\u5c0f\u4e8e\u5f53\u524d\u65f6\u95f4\uff0c\u4e0d\u7136\u7f13\u5b58\u8bbe\u7f6e\u4e0d\u6210\u529f<\/strong>\u3002<\/p>\n\n\n\n<p>\u81f3\u6b64\uff0c\u95ee\u9898\u5230\u8fd9\u91cc\u5706\u6ee1\u89e3\u51b3\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u25aa\u7b2c07\u5c0f\u8282\uff1a<strong>\u901a\u8fc7ShardingSphere\u5b8c\u6210\u4f18\u60e0\u5238\u5206\u5e93\u5206\u8868<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e1a\u52a1\u8bf4\u660e<\/h2>\n\n\n\n<p>\u521b\u5efa\u4f18\u60e0\u5238\u7684\u4e3b\u529b\u662f\u5546\u5bb6\u7528\u6237\uff0c\u6309\u7167\u6dd8\u5b9d\u3001\u5929\u732b\u975e\u5b98\u65b9\u6570\u636e\u7edf\u8ba1\uff0c\u5546\u5bb6\u6570\u91cf\u5df2\u6709\u8fd1 3000\u4e07\u3002\u6211\u4eec\u5047\u8bbe\u6bcf\u4e2a\u5546\u5bb6\u4f1a\u521b\u5efa 100 \u5f20\u4f18\u60e0\u5238\uff08\u8fd9\u4e2a\u6570\u636e\u662f\u6298\u4e2d\u8bb0\u5f55\uff0c\u6709\u4e9b\u5546\u5bb6\u53ef\u80fd\u521b\u5efa\u51e0\u5341\uff0c\u6709\u4e9b\u5546\u5bb6\u53ef\u80fd\u4f1a\u521b\u5efa 1000 \u4e0d\u6b62\uff09\uff0c\u90a3\u4f18\u60e0\u5238\u6a21\u677f\u8868\u5c31\u4f1a\u63a5\u8fd1 30 \u4ebf\u6570\u636e\u91cf\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u4e3a\u4ec0\u4e48\u662f\u5047\u8bbe\uff1f\u56e0\u4e3a\u4f18\u60e0\u5238\u521b\u5efa\u884c\u4e3a\u96b6\u5c5e\u4e8e\u6bcf\u4e00\u4e2a\u5546\u5bb6\uff0c\u4e0d\u7ba1\u662f\u5e73\u53f0\u8fd8\u662f\u4efb\u4f55\u4eba\uff0c\u90fd\u53ea\u80fd\u4ee5\u5e38\u89c4\u6570\u636e\u8fdb\u884c\u63a8\u6d4b\u3002<\/em><\/p>\n\n\n\n<p><em>\u8fd9\u4e2a\u63a8\u6d4b\u4e5f\u662f\u5177\u5907\u65f6\u6548\u6027\u7684\uff0c\u968f\u7740\u65f6\u95f4\u7684\u63a8\u8fdf\uff0c\u5546\u5bb6\u4f1a\u66f4\u591a\uff0c\u540c\u65f6\u521b\u5efa\u7684\u4f18\u60e0\u5238\u4e5f\u53ef\u80fd\u4f1a\u66f4\u591a\uff0c\u9884\u4f30\u6570\u636e\u4e5f\u4f1a\u968f\u4e4b\u589e\u52a0\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"360\" width=\"1171\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/2b57a63990820099b1f9d0109babbd53.png\" alt=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u5e93\u5206\u8868\u6982\u8ff0<\/h2>\n\n\n\n<p>\u5206\u5e93\u662f\u5c06\u539f\u672c\u7684\u5355\u5e93\u62c6\u5206\u4e3a\u591a\u4e2a\u5e93\uff0c\u5206\u8868\u662f\u5c06\u539f\u6765\u7684\u5355\u8868\u62c6\u5206\u4e3a\u591a\u4e2a\u8868\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"521\" width=\"903\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/e60a811310f7081e0e42a484adb3179a.png\" alt=\"\"><\/p>\n\n\n\n<p>\u5206\u5e93\u6709\u4e24\u79cd\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5782\u76f4\u62c6\u5e93\uff1a\u7535\u5546\u5e93 MallDB\uff0c\u4e1a\u52a1\u62c6\u5206\u540e\u5c31\u662f UserDB\u3001OrderDB\u3001PayDB \u7b49\u3002<\/li>\n\n\n\n<li>\u5206\u7247\u62c6\u5e93\uff1a\u7528\u6237\u5e93 UserDB\uff0c\u5206\u7247\u5e93\u540e\u5c31\u662f UserDB_0\u3001UserDB_1\u3001UserDB_xx\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5206\u8868\u4e5f\u6709\u4e24\u79cd\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5782\u76f4\u62c6\u5206\uff1a\u8ba2\u5355\u8868 OrderTable\uff0c\u62c6\u5206\u540e\u5c31\u662f OrderTable \u4ee5\u53ca OrderExtTable\u3002<\/li>\n\n\n\n<li>\u6c34\u5e73\u62c6\u5206\uff1a\u8ba2\u5355\u8868 OrderTable\uff0c\u62c6\u5206\u540e\u5c31\u662f OrderTable_0\u3001 OrderTable_xxx\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u4ec0\u4e48\u573a\u666f\u5206\u8868\uff1f<\/h3>\n\n\n\n<p>\u5f53\u51fa\u73b0\u4ee5\u4e0b\u4e09\u79cd\u60c5\u51b5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u8003\u8651\u5206\u8868\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5355\u8868\u7684<strong>\u6570\u636e\u91cf\u8fc7\u5927<\/strong>\u3002<\/li>\n\n\n\n<li>\u5355\u8868\u5b58\u5728\u8f83\u9ad8\u7684\u5199\u5165\u573a\u666f\uff0c\u53ef\u80fd\u5f15\u53d1\u884c\u9501\u7ade\u4e89\u3002<\/li>\n\n\n\n<li>\u5f53\u8868\u4e2d\u5305\u542b\u5927\u91cf\u7684 TEXT\u3001LONGTEXT \u6216 BLOB \u7b49\u5927\u5b57\u6bb5\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u4ec0\u4e48\u573a\u666f\u5206\u5e93\uff1f<\/h3>\n\n\n\n<p>\u5f53\u51fa\u73b0\u4ee5\u4e0b\u4e24\u79cd\u60c5\u51b5\u65f6\uff0c\u6211\u4eec\u9700\u8981\u8003\u8651\u901a\u8fc7\u5206\u5e93\u6765\u5c06\u6570\u636e\u5206\u6563\u5230\u591a\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u4e0a\uff0c\u4ee5\u63d0\u5347\u6574\u4f53\u7cfb\u7edf\u7684\u6027\u80fd\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f53\u5355\u4e2a\u6570\u636e\u5e93\u652f\u6301\u7684\u8fde\u63a5\u6570\u5df2\u7ecf\u4e0d\u8db3\u4ee5\u6ee1\u8db3\u5ba2\u6237\u7aef\u9700\u6c42\u3002<\/li>\n\n\n\n<li>\u6570\u636e\u91cf\u5df2\u7ecf\u8d85\u8fc7\u5355\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u7684\u5904\u7406\u80fd\u529b\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u4ec0\u4e48\u573a\u666f\u5206\u5e93\u5206\u8868\uff1f<\/h3>\n\n\n\n<p>\u5f53\u51fa\u73b0\u4ee5\u4e0b\u4e24\u79cd\u573a\u666f\u4e0b\uff0c\u9700\u8981\u8fdb\u884c\u5206\u5e93\u53c8\u5206\u8868\uff1a\u9ad8\u5e76\u53d1\u5199\u5165\u548c\u6d77\u91cf\u6570\u636e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9ad8\u5e76\u53d1\u5199\u5165\u573a\u666f<\/strong>\uff1a\u5f53\u5e94\u7528\u9762\u4e34\u9ad8\u5e76\u53d1\u7684\u5199\u5165\u8bf7\u6c42\u65f6\uff0c\u5355\u4e00\u6570\u636e\u5e93\u53ef\u80fd\u65e0\u6cd5\u6ee1\u8db3\u5199\u5165\u538b\u529b\uff0c\u6b64\u65f6\u53ef\u4ee5\u5c06\u6570\u636e\u6309\u7167\u4e00\u5b9a\u89c4\u5219\u62c6\u5206\u5230\u591a\u4e2a\u6570\u636e\u5e93\u4e2d\uff0c\u6bcf\u4e2a\u6570\u636e\u5e93\u5904\u7406\u90e8\u5206\u6570\u636e\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u4ece\u800c\u63d0\u9ad8\u5199\u5165\u6027\u80fd\u3002<\/li>\n\n\n\n<li><strong>\u6d77\u91cf\u6570\u636e\u573a\u666f<\/strong>\uff1a\u968f\u7740\u6570\u636e\u91cf\u7684\u4e0d\u65ad\u589e\u52a0\uff0c\u5355\u4e00\u6570\u636e\u5e93\u7684\u5b58\u50a8\u548c\u67e5\u8be2\u6027\u80fd\u53ef\u80fd\u9010\u6e10\u4e0b\u964d\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u5c06\u6570\u636e\u6309\u7167\u4e00\u5b9a\u7684\u89c4\u5219\u62c6\u5206\u5230\u591a\u4e2a\u8868\u4e2d\uff0c\u6bcf\u4e2a\u8868\u5b58\u50a8\u90e8\u5206\u6570\u636e\uff0c\u4ece\u800c\u5206\u6563\u6570\u636e\u7684\u5b58\u50a8\u538b\u529b\uff0c\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u5e93\u5206\u8868\u8bbe\u8ba1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u5982\u4f55\u9009\u62e9\u5206\u7247\u952e\uff1f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6570\u636e\u5747\u5300\u6027\uff1a\u5206\u7247\u952e\u5e94\u8be5\u4fdd\u8bc1\u6570\u636e\u7684\u5747\u5300\u5206\u5e03\u5728\u5404\u4e2a\u5206\u7247\u4e0a\uff0c\u907f\u514d\u51fa\u73b0\u70ed\u70b9\u6570\u636e\u96c6\u4e2d\u5728\u67d0\u4e2a\u5206\u7247\u4e0a\u7684\u60c5\u51b5\u3002<\/li>\n\n\n\n<li>\u4e1a\u52a1\u5173\u8054\u6027\uff1a\u5206\u7247\u952e\u5e94\u8be5\u4e0e\u4e1a\u52a1\u5173\u8054\u7d27\u5bc6\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u8de8\u5206\u7247\u67e5\u8be2\u548c\u8de8\u5e93\u4e8b\u52a1\u7684\u590d\u6742\u6027\u3002<\/li>\n\n\n\n<li>\u6570\u636e\u4e0d\u53ef\u53d8\uff1a\u4e00\u65e6\u9009\u62e9\u4e86\u5206\u7247\u952e\uff0c\u5b83\u5e94\u8be5\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u4e0d\u80fd\u968f\u7740\u4e1a\u52a1\u7684\u53d8\u5316\u800c\u9891\u7e41\u4fee\u6539\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u5206\u5e93\u5206\u8868\u7b97\u6cd5\uff1f<\/h3>\n\n\n\n<p>\u5206\u5e93\u5206\u8868\u7684\u7b97\u6cd5\u4f1a\u6839\u636e\u4e1a\u52a1\u7684\u4e0d\u540c\u800c\u53d8\u5316\uff0c\u6240\u4ee5\u5e76\u6ca1\u6709\u56fa\u5b9a\u7b97\u6cd5\u3002\u5728\u4e1a\u754c\u91cc\u7528\u7684\u6bd4\u8f83\u591a\u7684\u6709\u4e24\u79cd\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>HashMod\uff1a\u901a\u8fc7\u5bf9\u5206\u7247\u952e\u8fdb\u884c\u54c8\u5e0c\u53d6\u6a21\u7684\u5206\u7247\u7b97\u6cd5\u3002<\/li>\n\n\n\n<li>\u65f6\u95f4\u8303\u56f4\uff1a \u57fa\u4e8e\u65f6\u95f4\u8303\u56f4\u5206\u7247\u7b97\u6cd5\u3002<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u5206\u7247\u7b97\u6cd5\u8bb2\u89e3\u4e00\u4e2a\u6570\u636e\u5747\u5300\uff0c\u65f6\u95f4\u8303\u56f4\u5e76\u4e0d\u9002\u5408\u4f18\u60e0\u5238\u6a21\u677f\u4e1a\u52a1\uff0c\u56e0\u4e3a\u5546\u5bb6\u7528\u6237\u524d\u671f\u6bd4\u8f83\u5c11\uff0c\u540e\u9762\u4f1a\u8d8a\u6765\u8d8a\u591a\uff0c\u6240\u4ee5\u6709\u6bd4\u8f83\u660e\u663e\u7684\u4e0d\u5747\u5300\u95ee\u9898\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u5e93\u5206\u8868\u6846\u67b6\u9009\u578b<\/h2>\n\n\n\n<p>\u9009\u62e9 MyCat \u8fd8\u662f ShardingSphere \u53d6\u51b3\u4e8e\u9879\u76ee\u7684\u5177\u4f53\u9700\u6c42\u3001\u67b6\u6784\u8bbe\u8ba1\u3001\u56e2\u961f\u6280\u672f\u6808\u548c\u4e2a\u4eba\u504f\u597d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MyCat\uff1a<a href=\"https:\/\/gitee.com\/MycatOne\/Mycat2\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/gitee.com\/MycatOne\/Mycat2<\/a><\/li>\n\n\n\n<li>ShardingSphere\uff1a<a href=\"https:\/\/shardingsphere.apache.org\/\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/shardingsphere.apache.org<\/a><\/li>\n<\/ul>\n\n\n\n<p>\u5982\u679c\u9879\u76ee\u5bf9\u529f\u80fd\u9700\u6c42\u8f83\u9ad8\uff0c\u5e0c\u671b\u5728\u4e00\u4e2a\u8f83\u4e3a\u6d3b\u8dc3\u7684\u793e\u533a\u4e2d\u83b7\u53d6\u652f\u6301\uff0c\u4e14\u5bf9\u6570\u636e\u5e93\u7684\u652f\u6301\u8981\u6c42\u8f83\u9ad8\uff0c\u90a3\u4e48 ShardingSphere \u53ef\u80fd\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u9009\u62e9\u3002\u5982\u679c\u9879\u76ee\u76f8\u5bf9\u7b80\u5355\uff0c\u5bf9\u751f\u6001\u548c\u793e\u533a\u652f\u6301\u8981\u6c42\u4e0d\u9ad8\uff0c\u90a3\u4e48 Mycat \u4e5f\u662f\u4e00\u4e2a\u7a33\u5b9a\u7684\u9009\u62e9\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u4ece\u4e0b\u9762\u51e0\u4e2a\u7ef4\u5ea6\u505a\u4e00\u4e0b\u8bc4\u4f30\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u751f\u6001\u548c\u793e\u533a\u652f\u6301<\/h3>\n\n\n\n<p><strong>Mycat<\/strong>\uff1aMyCat \u7684\u793e\u533a\u76f8\u5bf9\u8f83\u5c0f\uff0c\u66f4\u65b0\u548c\u652f\u6301\u76f8\u5bf9\u6709\u9650\u3002<\/p>\n\n\n\n<p><strong>ShardingSphere<\/strong>\uff1aShardingSphere \u662f Apache \u65d7\u4e0b\u7684\u9879\u76ee\uff0c\u6709\u8f83\u5927\u7684\u793e\u533a\u652f\u6301\uff0c\u5f97\u5230\u4e86\u5e7f\u6cdb\u7684\u8ba4\u53ef\u548c\u4f7f\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u793e\u533a\u6d3b\u8dc3\u5ea6<\/h3>\n\n\n\n<p><strong>Mycat<\/strong>\uff1a\u793e\u533a\u76f8\u5bf9\u8f83\u5c0f\uff0c\u66f4\u65b0\u548c\u65b0\u529f\u80fd\u5f00\u53d1\u53ef\u80fd\u76f8\u5bf9\u7f13\u6162\u3002<\/p>\n\n\n\n<p><strong>ShardingSphere<\/strong>\uff1a\u7531\u4e8e\u662f Apache \u9876\u7ea7\u9879\u76ee\uff0c\u793e\u533a\u6d3b\u8dc3\u5ea6\u8f83\u9ad8\uff0c\u66f4\u65b0\u548c\u65b0\u529f\u80fd\u7684\u5f00\u53d1\u8f83\u4e3a\u8fc5\u901f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u5206\u5e93\u5206\u8868\u7b56\u7565<\/h3>\n\n\n\n<p><strong>Mycat<\/strong>\uff1aMycat \u4e3b\u8981\u652f\u6301\u6c34\u5e73\u5206\u8868\u548c\u5782\u76f4\u5206\u5e93\uff0c\u63d0\u4f9b\u76f8\u5bf9\u57fa\u7840\u7684\u5206\u7247\u7b56\u7565\u3002<\/p>\n\n\n\n<p><strong>ShardingSphere<\/strong>\uff1aShardingSphere \u63d0\u4f9b\u4e86\u66f4\u4e3a\u7075\u6d3b\u548c\u4e30\u5bcc\u7684\u5206\u5e93\u5206\u8868\u7b56\u7565\uff0c\u652f\u6301\u5e7f\u6cdb\u7684\u5206\u7247\u89c4\u5219\uff0c\u5305\u62ec\u8303\u56f4\u3001\u54c8\u5e0c\u3001\u590d\u5408\u5206\u7247\u7b49\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u4e0d\u7528\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff1f<\/h2>\n\n\n\n<p>\u5177\u5907\u4ee3\u8868\u6027\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u963f\u91cc\u4e91 PolarDB for MySQL\u3002<\/li>\n\n\n\n<li>\u817e\u8baf\u4e91 TDSQL for MySQL\u3002<\/li>\n\n\n\n<li>PingCAP TiDB\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u8bf4\u6cd5\u8c28\u4ee3\u8868\u6211\u4e2a\u4eba\u770b\u6cd5\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u517c\u5bb9\u6027\uff1a\u90e8\u5206\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u5e76\u4e0d\u80fd 100%\u517c\u5bb9 MySQL\uff0c\u5bfc\u81f4\u4e1a\u52a1\u65e0\u6cd5\u5e73\u6ed1\u8fc1\u79fb\u3002<\/li>\n\n\n\n<li>\u6280\u672f\u50a8\u5907\uff1a\u9700\u8981\u6709\u8fd9\u65b9\u9762\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u4e13\u5bb6\uff0c\u5e73\u5e38\u4f7f\u7528\u8c01\u90fd\u53ef\u4ee5\uff0c\u7ebf\u4e0a\u51fa\u73b0\u4e86\u95ee\u9898\u4e0d\u77e5\u9053\u600e\u4e48\u89e3\u51b3\u624d\u662f\u81f4\u547d\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528\u6210\u672c\uff1a\u963f\u91cc\u4e91\u548c\u817e\u8baf\u4e91\u6ca1\u6709\u5f00\u6e90\u7248\u672c\uff0c\u4ed8\u8d39\u7248\u672c\u76f8\u5bf9\u4e8e MySQL \u6210\u672c\u504f\u9ad8\u3002TiDB \u5f00\u6e90\u7248\u672c Issue BUG \u8f83\u591a\uff0c\u5546\u4e1a\u672a\u77e5\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u622a\u56fe\u81ea 2024\u5e7408\u670815\u65e5 TiDB GitHub \u4ed3\u5e93\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"676\" width=\"1896\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/1c0487528bac992a99f040de2215cc06.png\" alt=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"git\">Git \u5206\u652f<\/h2>\n\n\n\n<p>20240815_dev_coupon-tablue_shardingsphere_ding.ma<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f18\u60e0\u5238\u6a21\u677f\u5982\u4f55\u5206\u5e93\u5206\u8868\uff1f<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u4f18\u60e0\u5238\u6a21\u677f\u5206\u591a\u5c11\u8868\uff1f<\/h3>\n\n\n\n<p>\u6839\u636e\u4e0a\u9762\u6570\u636e\u4f30\u7b97\uff0c30 \u4ebf\u6570\u636e\u91cf\u9700\u8981\u5206\u591a\u5c11\u4e2a\u8868\uff1f\u8fd9\u5176\u5b9e\u53c8\u4f1a\u6d89\u53ca\u5230\u4e00\u4e2a\u77e5\u8bc6\u70b9\uff0c\u90a3\u5c31\u662f SQL \u590d\u6742\u4e48\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SQL \u590d\u6742\uff0c\u62c6\u5206\u767e\u4e07\u7ea7\u522b\u3002<\/li>\n\n\n\n<li>SQL \u4e0d\u590d\u6742\uff0c\u5168\u90e8\u8d70\u7d22\u5f15\uff0c\u5343\u4e07\u751a\u81f3\u4ebf\u7ea7\u522b\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6211\u4eec\u4ee5\u4f18\u60e0\u5238\u6a21\u677f\u4e3e\u4f8b\uff0c\u4e0d\u6d89\u53ca\u590d\u6742 SQL\uff0c\u4f46\u662f\u4f9d\u7136\u4e0d\u5efa\u8bae\u5927\u5bb6\u6570\u636e\u91cf\u5230\u8fbe\u4ebf\u7ea7\u522b\uff0c\u603b\u5f52\u8981\u7559\u6709\u4f59\u91cf\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u53d6\u7ecf\u9a8c\u503c 2000 \u4e07\uff0c30 \u4ebf\u6570\u636e\u5c31\u662f\u62c6\u5206 150 \u5f20\u8868\u5373\u53ef\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u4e3a\u4ec0\u4e48\u53d6 2000 \u4e07\uff1f\u5176\u5b9e\u6570\u636e\u91cf\u4e0d\u662f\u7279\u522b\u591a\u7684\u60c5\u51b5\u4e0b\uff0c\u57fa\u672c\u4e0a 3 \u6b21\u78c1\u76d8 IO \u5c31\u80fd\u83b7\u53d6\u5230\u6570\u636e\u3002\u518d\u591a\u7684\u8bdd\u53ef\u80fd\u78c1\u76d8 IO \u4f1a\u589e\u52a0\uff0c\u4f46\u662f\u8fd8\u597d\u3002\u8003\u8651\u5230\u6570\u636e\u5e93\u8868\u5907\u4efd\u7b49\u5176\u4ed6\u64cd\u4f5c\uff0c\u4e0d\u5efa\u8bae\u5355\u8868\u592a\u591a\u6570\u636e\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u4f18\u60e0\u5238\u6a21\u677f\u662f\u5426\u9700\u8981\u5206\u5e93\uff1f<\/h3>\n\n\n\n<p>\u4e0d\u9700\u8981\uff0c\u56e0\u4e3a\u5e76\u53d1\u4e0d\u9ad8\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u9700\u8981\u5206\u6790\u4e00\u4e2a\u4e1a\u52a1\u573a\u666f\u5982\u4f55\u5206\u5e93\uff0c\u90a3\u5c31\u9700\u8981\u77e5\u9053\u5355\u4e2a MySQL Server \u7684\u74f6\u9888\u662f\u591a\u5c11\uff1f\u901a\u8fc7\u4e4b\u524d\u538b\u6d4b\u5f97\u77e5\uff0c\u5355\u53f0 MySQL Server \u7684\u5199\u74f6\u9888\u5927\u6982\u5728 4000-5000\/TPS\uff0c\u67e5\u8be2\u53ef\u80fd\u66f4\u9ad8\u4e00\u4e9b\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u7684\u573a\u666f\u4e1a\u52a1\u6bcf\u79d2 TPS \u5728 1 \u4e07\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u81f3\u5c11\u5206\u4e24\u4e2a\u5e93\uff0c\u7136\u540e\u5c06\u4e0a\u9762\u7684 150 \u5f20\u8868\u5206\u522b\u653e\u5165\u5373\u53ef\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u540e\u9762\u4f18\u60e0\u5238\u7684\u5206\u53d1\u548c\u9886\u53d6\u662f\u9700\u8981\u5206\u5e93\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u4e3a\u4e86\u4e0d\u91cd\u590d\u521b\u5efa\u8868\uff0c\u5728\u8fd9\u91cc\u76f4\u63a5\u901a\u8fc7\u5206\u5e93\u7684\u5f62\u5f0f\u5c55\u793a\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u4f18\u60e0\u5238\u6a21\u677f\u8868\u5206\u7247\u952e\u5982\u4f55\u9009\u62e9\uff1f<\/h3>\n\n\n\n<p>\u53c2\u8003\u56fd\u5185\u67d0\u7535\u5546\u5e73\u53f0\u4f18\u60e0\u5238\u7ba1\u7406\u9875\u9762\uff0c\u9700\u8981\u6839\u636e\u5f53\u524d\u5e97\u94fa\u521b\u5efa\u7684\u4f18\u60e0\u5238\u5206\u9875\u67e5\u8be2\u3002<\/p>\n\n\n\n<p>\u7b54\u6848\u547c\u4e4b\u6b32\u51fa\uff0c\u90a3\u5c31\u662f<strong>\u5e97\u94fa\u7f16\u53f7\u5b57\u6bb5<\/strong>\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"912\" width=\"2726\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/b26bb06a7415cbe21bb71cbcdf5c2dad.png\" alt=\"\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"sharding-sphere\">ShardingSphere \u9879\u76ee\u5b9e\u6218<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-and\">1. \u521d\u59cb\u5316\u6570\u636e\u5e93&amp;\u8868<\/h3>\n\n\n\n<p>\u9996\u5148\u521b\u5efa\u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u53bb MySQL \u6267\u884c\uff0c\u6216\u8005\u53bb\u53ef\u89c6\u5316\u5de5\u5177\u521b\u5efa\uff1a<\/p>\n\n\n\n<p><code>CREATE DATABASE IF NOT EXISTS one_coupon_rebuild_0; CREATE DATABASE IF NOT EXISTS one_coupon_rebuild_1;<\/code><\/p>\n\n\n\n<p>\u5206\u522b\u5728\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\u8868\uff1a<\/p>\n\n\n\n<p><code>CREATE TABLE `t_coupon_template_0` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967816300515330 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_1` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967812836020227 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_2` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967817126793218 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_3` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967817122598915 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_4` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967797723942918 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_5` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967789205311493 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_6` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967789150785539 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_7` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`name` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`source` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', &nbsp; &nbsp;`target` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', &nbsp; &nbsp;`goods` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;varchar(64) &nbsp;DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', &nbsp; &nbsp;`type` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', &nbsp; &nbsp;`valid_start_time` datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', &nbsp; &nbsp;`valid_end_time` &nbsp; datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', &nbsp; &nbsp;`stock` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', &nbsp; &nbsp;`receive_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', &nbsp; &nbsp;`consume_rule` &nbsp; &nbsp; json &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', &nbsp; &nbsp;`status` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;`update_time` &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', &nbsp; &nbsp;`del_flag` &nbsp; &nbsp; &nbsp; &nbsp; tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967780615376898 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; \u200b<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-sharding-sphere-maven-jar\">2. \u5f15\u5165 ShardingSphere Maven Jar \u4f9d\u8d56<\/h3>\n\n\n\n<p><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.shardingsphere&lt;\/groupId&gt; &lt;artifactId&gt;shardingsphere-jdbc-core&lt;\/artifactId&gt; &lt;version&gt;5.3.2&lt;\/version&gt; &lt;\/dependency&gt;<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-application-yaml-sharding-sphere\">3. \u53d8\u66f4 Application.yaml \u548c\u521b\u5efa ShardingSphere \u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<p>ShardingSphere \u81ea 5.x.x \u7248\u672c\u540e\u81ea\u5b9a\u4e86\u6846\u67b6\u6570\u636e\u5e93\u9a71\u52a8\uff0c\u6240\u4ee5\u4e4b\u524d\u7684 ShardingSphere \u914d\u7f6e\u90fd\u662f\u5199\u5230 application.yaml \u4e2d\uff0c\u73b0\u5728\u9700\u8981\u62c6\u5206\u51fa\u6765\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server:\n  port: 10010\n\nspring:\n  application:\n    name: oneCoupon-merchant-admin\n  datasource:\n    driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver\n    url: jdbc:shardingsphere:classpath:shardingsphere-config.yaml\n  data:\n    redis:\n      host: 127.0.0.1\n      port: 6379\n      password: 123456\n\nmybatis-plus:\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n\nspringdoc:\n  default-flat-param-object: true\n  swagger-ui:\n    path: \/swagger-ui.html\n    tags-sorter: alpha\n    operations-sorter: alpha\n  api-docs:\n    path: \/v3\/api-docs\n  group-configs:\n    - group: 'default'\n      paths-to-match: '\/**'\n      packages-to-scan: com.nageoffer.onecoupon\n\nknife4j:\n  enable: true\n  setting:\n    language: zh_cn<\/code><\/pre>\n\n\n\n<p>\u521b\u5efa <code>shardingsphere-config.yaml<\/code> \u6570\u636e\u5e93\u5206\u7247\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u6570\u636e\u6e90\u96c6\u5408\ndataSources:\n  # \u81ea\u5b9a\u4e49\u6570\u636e\u6e90\u540d\u79f0\uff0c\u53ef\u4ee5\u662f ds_0 \u4e5f\u53ef\u4ee5\u53eb datasource_0 \u90fd\u53ef\u4ee5\n  ds_0:\n    dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n    driverClassName: com.mysql.cj.jdbc.Driver\n    jdbcUrl: jdbc:mysql:\/\/127.0.0.1:3306\/one_coupon_rebuild_0?useUnicode=true&amp;characterEncoding=UTF-8&amp;rewriteBatchedStatements=true&amp;allowMultiQueries=true&amp;serverTimezone=Asia\/Shanghai\n    username: root\n    password: root\n  ds_1:\n    dataSourceClassName: com.zaxxer.hikari.HikariDataSource\n    driverClassName: com.mysql.cj.jdbc.Driver\n    jdbcUrl: jdbc:mysql:\/\/127.0.0.1:3306\/one_coupon_rebuild_1?useUnicode=true&amp;characterEncoding=UTF-8&amp;rewriteBatchedStatements=true&amp;allowMultiQueries=true&amp;serverTimezone=Asia\/Shanghai\n    username: root\n    password: root\n\nrules:\n  - !SHARDING\n    tables: # \u9700\u8981\u5206\u7247\u7684\u6570\u636e\u5e93\u8868\u96c6\u5408\n      t_coupon_template: # \u4f18\u60e0\u5238\u6a21\u677f\u8868\n        # \u771f\u5b9e\u5b58\u5728\u6570\u636e\u5e93\u4e2d\u7684\u7269\u7406\u8868\n        actualDataNodes: ds_${0..1}.t_coupon_template_${0..8}\n        databaseStrategy: # \u5206\u5e93\u7b56\u7565\n          standard: # \u5355\u5206\u7247\u952e\u5206\u5e93\n            shardingColumn: shop_number # \u5206\u7247\u952e\n            shardingAlgorithmName: coupon_template_database_mod # \u5e93\u5206\u7247\u7b97\u6cd5\u540d\u79f0\uff0c\u5bf9\u5e94 rules&#91;0].shardingAlgorithms\n        tableStrategy: # \u5206\u8868\u7b56\u7565\n          standard: # \u5355\u5206\u7247\u952e\u5206\u8868\n            shardingColumn: shop_number # \u5206\u7247\u952e\n            shardingAlgorithmName: coupon_template_table_mod # \u8868\u5206\u7247\u7b97\u6cd5\u540d\u79f0\uff0c\u5bf9\u5e94 rules&#91;0].shardingAlgorithms\n    shardingAlgorithms: # \u5206\u7247\u7b97\u6cd5\u5b9a\u4e49\u96c6\u5408\n      coupon_template_database_mod: # \u4f18\u60e0\u5238\u5206\u5e93\u7b97\u6cd5\u5b9a\u4e49\n        type: HASH_MOD # \u57fa\u4e8e Hash \u65b9\u5f0f\u5206\u7247\n        props:\n          sharding-count: 2 # \u4e00\u5171\u6709 2 \u4e2a\u5e93\n      coupon_template_table_mod: # \u4f18\u60e0\u5238\u5206\u8868\u7b97\u6cd5\u5b9a\u4e49\n        type: HASH_MOD # \u57fa\u4e8e Hash \u65b9\u5f0f\u5206\u7247\n        props:\n          sharding-count: 8 # \u5355\u5e93 8 \u5f20\u8868\n\nprops:\n  # \u914d\u7f6e ShardingSphere \u9ed8\u8ba4\u6253\u5370 SQL \u6267\u884c\u8bed\u53e5\n  sql-show: true\n<\/code><\/pre>\n\n\n\n<p>\u89e3\u91ca\u4e0b\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u884c\u8868\u8fbe\u5f0f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ds_${0..1} \u610f\u5473\u7740 ds_0\u3001ds_1\u3002<\/li>\n\n\n\n<li>t_coupon_template_${0..8} \u540c\u4e0a\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4\">4. \u4ec0\u4e48\u662f\u903b\u8f91\u5e93\u3001\u7269\u7406\u5e93\u3001\u903b\u8f91\u8868\u3001\u7269\u7406\u8868\uff1f<\/h3>\n\n\n\n<p>\u6211\u4eec\u65b0\u589e\u4e00\u6761\u4f18\u60e0\u5238\u6a21\u677f\u65f6\u53ef\u4ee5\u770b\u5230 ShardingSphere \u6253\u5370\u7684\u4e24\u6761\u65e5\u5fd7\uff0c\u5206\u522b\u662f\u903b\u8f91 SQL \u548c\u771f\u5b9e SQL\u3002<\/p>\n\n\n\n<p><code>\u903b\u8f91SQL\uff1a \u200b 2024-08-15T17:32:55.566+08:00 &nbsp;INFO 259 --- [pool-1-thread-1] ShardingSphere-SQL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : Logic SQL: INSERT INTO t_coupon_template ( id, shop_number, name, source, target, &nbsp;type, valid_start_time, valid_end_time, stock, receive_rule, consume_rule, status, create_time, update_time, del_flag ) &nbsp;VALUES ( &nbsp;?, ?, ?, ?, ?, &nbsp;?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) \u200b \u771f\u5b9eSQL\uff1a 2024-08-15T17:32:55.566+08:00 &nbsp;INFO 259 --- [pool-1-thread-1] ShardingSphere-SQL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : Actual SQL: ds_0 ::: INSERT INTO t_coupon_template_6 ( id, shop_number, name, source, target, &nbsp;type, valid_start_time, valid_end_time, stock, receive_rule, consume_rule, status, create_time, update_time, del_flag ) &nbsp;VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ::: [1824016410750246914, 1824016410750300160, \u5546\u54c1\u7acb\u51cf\u5238, 0, 1, 0, 2024-08-15 17:32:55.566, 2024-08-15 17:32:55.566, 10, {\"limitPerPerson\":1,\"usageInstructions\":\"3\"}, {\"termsOfUse\":10,\"maximumDiscountAmount\":3,\"explanationOfUnmetC 3onditions\":\"3\",\"validityPeriod\":48}, 0, 2024-08-15 17:32:55.566, 2024-08-15 17:32:55.566, 0] \u200b<\/code><\/p>\n\n\n\n<p>\u4e0a\u9762\u6570\u636e\u5e93\u5206\u7247\u6570\u636e\u6e90\u914d\u7f6e\u586b\u7684 <code>ds_0<\/code>\u3001<code>ds_1<\/code> \u5c31\u662f\u903b\u8f91\u5e93\uff0c<code>one_coupon_rebuild_0<\/code>\u3001<code>one_coupon_rebuild_1<\/code> \u5bf9\u5e94\u7269\u7406\u5e93\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u662f\u6ca1\u6709\u53d8\u66f4\u4efb\u4f55\u4e1a\u52a1\u4ee3\u7801\u7684\uff0c\u6240\u4ee5\u903b\u8f91 SQL \u91cc\u7684\u8868\u540d\u4f9d\u7136\u662f <code>t_coupon_template<\/code>\uff0c\u4e5f\u5c31\u662f\u903b\u8f91\u8868\u3002\u771f\u5b9e SQL \u91cc\u7684 <code>t_coupon_template_6<\/code> \u662f\u7269\u7406\u8868\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u7269\u7406\u8868\u4e5f\u53eb\u505a\u771f\u5b9e\u8868\uff0c\u6307\u7684\u662f\u6570\u636e\u5e93\u4e2d\u771f\u5b9e\u5b58\u5728\u7684\u8868\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5\">5. \u6570\u636e\u5206\u7247\u4e0d\u5747\u5300\u95ee\u9898<\/h3>\n\n\n\n<p>\u5927\u5bb6\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u8fd9\u4e2a Mock \u6570\u636e\u5355\u5143\u6d4b\u8bd5\u7c7b\u8dd1\u4e00\u4e0b\uff0c\u4f1a\u51fa\u73b0\u5206\u7247\u4e0d\u5747\u5300\u95ee\u9898\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MockCouponTemplateDataTests#mockCouponTemplateTest<\/li>\n<\/ul>\n\n\n\n<p>\u8868\u8c61\u5c31\u662f 0 \u5e93\u7684\u5947\u6570\u8868\u6ca1\u6709\u6570\u636e\uff0c1 \u5e93\u7684\u5076\u6570\u8868\u6ca1\u6709\u503c\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1100\" width=\"2174\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/3f51552c01a14ad30c28fd70f413e125.png\" alt=\"\"><\/p>\n\n\n\n<p>\u56e0\u4e3a\u6211\u4eec\u7684\u5206\u7247\u952e\u5e97\u94fa\u7f16\u53f7\u7ecf\u8fc7\u6570\u636e\u5e93 Hash \u540e\u5df2\u7ecf\u786e\u5b9a\u662f\u5947\u6570\u8fd8\u662f\u5076\u6570\u4e86\uff0c\u6240\u4ee5\u54ea\u6015 Hash \u7684\u6570\u503c\uff08\u5e93\u548c\u8868\u6570\u91cf\uff09\u53d8\u4e86\uff0c\u4f46\u662f\u4f9d\u7136\u53ea\u80fd\u662f\u5947\u6570\u548c\u5076\u6570\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u53d8\u66f4 Hash \u7b97\u6cd5\uff0c\u901a\u8fc7\u81ea\u5b9a\u4e49\u7684 Hash \u7b97\u6cd5\u6270\u52a8\u5206\u7247\u7ed3\u679c\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5-1\">5.1 \u4fee\u6539\u6570\u636e\u5e93\u8868<\/h4>\n\n\n\n<p>\u6211\u4eec\u5c06 <code>one_coupon_rebuild_1<\/code> \u6570\u636e\u5e93\u4e2d\u7684 t_coupon_template_0-7 \u8868\u5220\u9664\uff0c\u521b\u5efa\u4ee5\u4e0b\u6570\u636e\u5e93\u8868\uff1a<\/p>\n\n\n\n<p><code>CREATE TABLE `t_coupon_template_10` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967787024273416 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_11` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967787062022148 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_12` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967795496767492 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_13` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967817328119814 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_14` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967817407811587 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_15` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1811614173755469826 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_8` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967783614304261 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868'; CREATE TABLE `t_coupon_template_9` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(256) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u540d\u79f0', `shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', `source` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6765\u6e90 0\uff1a\u5e97\u94fa\u5238 1\uff1a\u5e73\u53f0\u5238', `target` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5bf9\u8c61 0\uff1a\u5546\u54c1\u4e13\u5c5e 1\uff1a\u5168\u5e97\u901a\u7528', `goods` varchar(64) DEFAULT NULL COMMENT '\u4f18\u60e0\u5546\u54c1\u7f16\u7801', `type` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u7c7b\u578b 0\uff1a\u7acb\u51cf\u5238 1\uff1a\u6ee1\u51cf\u5238 2\uff1a\u6298\u6263\u5238', `valid_start_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4', `valid_end_time` datetime DEFAULT NULL COMMENT '\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4', `stock` int(11) DEFAULT NULL COMMENT '\u5e93\u5b58', `receive_rule` json DEFAULT NULL COMMENT '\u9886\u53d6\u89c4\u5219', `consume_rule` json DEFAULT NULL COMMENT '\u6d88\u8017\u89c4\u5219', `status` tinyint(1) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u72b6\u6001 0\uff1a\u751f\u6548\u4e2d 1\uff1a\u5df2\u7ed3\u675f', `create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', `update_time` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4', `del_flag` tinyint(1) DEFAULT NULL COMMENT '\u5220\u9664\u6807\u8bc6 0\uff1a\u672a\u5220\u9664 1\uff1a\u5df2\u5220\u9664', PRIMARY KEY (`id`), KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1810967778472087554 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u8868';<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5-2\">5.2 \u4fee\u6539\u5206\u7247\u914d\u7f6e<\/h4>\n\n\n\n<p>\u6709\u4e24\u4e2a\u53d8\u66f4\u70b9\uff0c\u90a3\u5c31\u662f\u6570\u636e\u5e93\u8868\u7684\u5206\u7247\u4ece\u6bcf\u4e2a\u6570\u636e\u5e93\u7684 0..8 \u53d8\u66f4\u4e3a\u6240\u6709\u6570\u636e\u5e93\u91cc\u7684\u8868 0..16\uff0c\u4ee5\u53ca\u4ece\u6846\u67b6\u81ea\u5e26\u7684 HashMod \u5206\u7247\u7b97\u6cd5\u4fee\u6539\u4e3a\u81ea\u5b9a\u4e49\u5206\u7247\u7b97\u6cd5\u3002\u5206\u7247\u7b97\u6cd5\u89c1\u4e0b\u6587\u6240\u793a\u3002<\/p>\n\n\n\n<p><code>rules: - !SHARDING tables: # \u9700\u8981\u5206\u7247\u7684\u6570\u636e\u5e93\u8868\u96c6\u5408 t_coupon_template: # \u4f18\u60e0\u5238\u6a21\u677f\u8868 # \u771f\u5b9e\u5b58\u5728\u6570\u636e\u5e93\u4e2d\u7684\u7269\u7406\u8868 actualDataNodes: ds_${0..1}.t_coupon_template_${0..15} databaseStrategy: # \u5206\u5e93\u7b56\u7565 standard: # \u5355\u5206\u7247\u952e\u5206\u5e93 shardingColumn: shop_number # \u5206\u7247\u952e shardingAlgorithmName: coupon_template_database_mod # \u5e93\u5206\u7247\u7b97\u6cd5\u540d\u79f0\uff0c\u5bf9\u5e94 rules[0].shardingAlgorithms tableStrategy: # \u5206\u8868\u7b56\u7565 standard: # \u5355\u5206\u7247\u952e\u5206\u8868 shardingColumn: shop_number # \u5206\u7247\u952e shardingAlgorithmName: coupon_template_table_mod # \u8868\u5206\u7247\u7b97\u6cd5\u540d\u79f0\uff0c\u5bf9\u5e94 rules[0].shardingAlgorithms shardingAlgorithms: # \u5206\u7247\u7b97\u6cd5\u5b9a\u4e49\u96c6\u5408 coupon_template_database_mod: # \u4f18\u60e0\u5238\u5206\u5e93\u7b97\u6cd5\u5b9a\u4e49 type: CLASS_BASED # \u6839\u636e\u81ea\u5b9a\u4e49\u5e93\u5206\u7247\u7b97\u6cd5\u7c7b\u8fdb\u884c\u5206\u7247 props: # \u5206\u7247\u76f8\u5173\u5c5e\u6027 # \u81ea\u5b9a\u4e49\u5e93\u5206\u7247\u7b97\u6cd5Class algorithmClassName: com.nageoffer.onecoupon.merchant.admin.dao.sharding.DBHashModShardingAlgorithm sharding-count: 16 # \u5206\u7247\u603b\u6570\u91cf strategy: standard # \u5206\u7247\u7c7b\u578b\uff0c\u5355\u5b57\u6bb5\u5206\u7247 coupon_template_table_mod: # \u4f18\u60e0\u5238\u5206\u8868\u7b97\u6cd5\u5b9a\u4e49 type: CLASS_BASED # \u6839\u636e\u81ea\u5b9a\u4e49\u5e93\u5206\u7247\u7b97\u6cd5\u7c7b\u8fdb\u884c\u5206\u7247 props: # \u5206\u7247\u76f8\u5173\u5c5e\u6027 # \u81ea\u5b9a\u4e49\u8868\u5206\u7247\u7b97\u6cd5Class algorithmClassName: com.nageoffer.onecoupon.merchant.admin.dao.sharding.TableHashModShardingAlgorithm strategy: standard # \u5206\u7247\u7c7b\u578b\uff0c\u5355\u5b57\u6bb5\u5206\u7247<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5-2\">5.2 \u521b\u5efa\u81ea\u5b9a\u4e49\u5206\u7247\u7b97\u6cd5<\/h4>\n\n\n\n<p>\u521b\u5efa\u81ea\u5b9a\u4e49\u5206\u7247\u7b97\u6cd5\uff0c\u5305\u62ec\u5206\u5e93\u548c\u5206\u8868\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>com.nageoffer.onecoupon.merchant.admin.dao.sharding.DBHashModShardingAlgorithm<\/li>\n\n\n\n<li>com.nageoffer.onecoupon.merchant.admin.dao.sharding.TableHashModShardingAlgorithm<\/li>\n<\/ul>\n\n\n\n<p>\u5206\u5e93\u548c\u5206\u8868\u7b97\u6cd5\u7c7b\u4f3c\uff0c\u6211\u4eec\u4ee5\u5206\u5e93\u7b97\u6cd5\u89e3\u6790\uff1a<\/p>\n\n\n\n<p><code>@Override public String doSharding(Collection&lt;String&gt; availableTargetNames, PreciseShardingValue&lt;Long&gt; shardingValue) { long id = shardingValue.getValue(); \/\/ \u5206\u7247\u952e\u503c\uff0c\u4e5f\u5c31\u662f\u5546\u5bb6\u5e97\u94fa\u7f16\u53f7 int dbSize = availableTargetNames.size(); \/\/ \u4e00\u5171\u6709\u591a\u5c11\u4e2a\u771f\u5b9e\u7684\u6570\u636e\u5e93\uff0c\u54b1\u4eec\u5c31\u4e24\u4e2a ds_0\u3001ds_1 int mod = (int) hashShardingValue(id) % shardingCount \/ (shardingCount \/ dbSize); \/\/ \u53d6\u6a21 int index = 0; \/\/ \u901a\u8fc7\u521a\u624d\u7684\u6570\u636e\u5e93\u4e0b\u6807\uff0c\u83b7\u53d6\u5230\u6570\u636e\u5e93\u903b\u8f91\u540d\u79f0 ds_0 \u6216\u8005 ds_1 for (String targetName : availableTargetNames) { if (index == mod) { return targetName; } index++; } throw new IllegalArgumentException(\"No target found for value: \" + id); }<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public final class TableHashModShardingAlgorithm implements StandardShardingAlgorithm&lt;Long&gt; {\n\n    @Override\n    public String doSharding(Collection&lt;String&gt; availableTargetNames, PreciseShardingValue&lt;Long&gt; shardingValue) {\n        long id = shardingValue.getValue();\n        int shardingCount = availableTargetNames.size();\n        int mod = (int) hashShardingValue(id) % shardingCount;\n        int index = 0;\n        for (String targetName : availableTargetNames) {\n            if (index == mod) {\n                return targetName;\n            }\n            index++;\n        }\n        throw new IllegalArgumentException(\"No target found for value: \" + id);\n    }\n\n    @Override\n    public Collection&lt;String&gt; doSharding(Collection&lt;String&gt; availableTargetNames, RangeShardingValue&lt;Long&gt; shardingValue) {\n        \/\/ \u6682\u65e0\u8303\u56f4\u5206\u7247\u573a\u666f\uff0c\u9ed8\u8ba4\u8fd4\u56de\u7a7a\n        return List.of();\n    }\n\n    private long hashShardingValue(final Comparable&lt;?&gt; shardingValue) {\n        return Math.abs((long) shardingValue.hashCode());\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\npublic final class DBHashModShardingAlgorithm implements StandardShardingAlgorithm&lt;Long&gt; {\n\n    @Getter\n    private Properties props;\n\n    private int shardingCount;\n    private static final String SHARDING_COUNT_KEY = \"sharding-count\";\n\n    @Override\n    public String doSharding(Collection&lt;String&gt; availableTargetNames, PreciseShardingValue&lt;Long&gt; shardingValue) {\n        long id = shardingValue.getValue();\n        int dbSize = availableTargetNames.size();\n        int mod = (int) hashShardingValue(id) % shardingCount \/ (shardingCount \/ dbSize);\n        int index = 0;\n        for (String targetName : availableTargetNames) {\n            if (index == mod) {\n                return targetName;\n            }\n            index++;\n        }\n        throw new IllegalArgumentException(\"No target found for value: \" + id);\n    }\n\n    @Override\n    public Collection&lt;String&gt; doSharding(Collection&lt;String&gt; availableTargetNames, RangeShardingValue&lt;Long&gt; shardingValue) {\n        \/\/ \u6682\u65e0\u8303\u56f4\u5206\u7247\u573a\u666f\uff0c\u9ed8\u8ba4\u8fd4\u56de\u7a7a\n        return List.of();\n    }\n\n    @Override\n    public void init(Properties props) {\n        this.props = props;\n        shardingCount = getShardingCount(props);\n    }\n\n    private int getShardingCount(final Properties props) {\n        ShardingSpherePreconditions.checkState(props.containsKey(SHARDING_COUNT_KEY), () -&gt; new ShardingAlgorithmInitializationException(getType(), \"Sharding count cannot be null.\"));\n        return Integer.parseInt(props.getProperty(SHARDING_COUNT_KEY));\n    }\n\n    private long hashShardingValue(final Comparable&lt;?&gt; shardingValue) {\n        return Math.abs((long) shardingValue.hashCode());\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u4fee\u6539\u5b8c\u5206\u7247\u7b97\u6cd5\u4e4b\u540e\uff0c\u6211\u4eec\u8c03\u7528\u4e0a\u9762\u7684 Mock \u5355\u5143\u6d4b\u8bd5\u7c7b\u6a21\u62df 5 \u4e07\u6570\u636e\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u901a\u8fc7\u67e5\u770b\u6570\u636e\u91cf\u5f97\u77e5\uff0c\u4e0d\u5b58\u5728\u660e\u663e\u503e\u659c\u95ee\u9898\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1100\" width=\"2086\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/4b329318ef7c09cbd6cf99088aa38cce.png\" alt=\"\"><\/p>\n\n\n\n<p>\u63d0\u793a\uff1a\u5bf9\u4e8e\u6ca1\u63a5\u89e6\u8fc7\u5206\u5e93\u5206\u8868\u7684\u540c\u5b66\uff0c\u6ca1\u90a3\u4e48\u5bb9\u6613\u5feb\u901f\u63a5\u53d7\uff0c\u5927\u5bb6\u53ef\u4ee5\u591a Debug \u5206\u5e93\u5206\u8868\u7b97\u6cd5\u7c7b\u8fd9\u5757\u7684\u4ee3\u7801\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021301-image-1024x1024.png\" alt=\"\" class=\"wp-image-1256\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021301-image-1024x1024.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021301-image-300x300.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021301-image-150x150.png 150w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021301-image-768x769.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021301-image.png 1147w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"976\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021322-image-1024x976.png\" alt=\"\" class=\"wp-image-1258\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021322-image-1024x976.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021322-image-300x286.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021322-image-768x732.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/09\/1758021322-image.png 1202w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5e38\u89c1\u95ee\u9898\u7b54\u7591<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u6570\u636e\u662f\u5426\u5b58\u5728\u4e0d\u5747\u5300\u95ee\u9898\uff1f<\/h3>\n\n\n\n<p>\u5e38\u89c4\u7684 HashMod \u65b9\u5f0f\u4f1a\u5b58\u5728\u4e0d\u5747\u5300\u60c5\u51b5\uff0c\u901a\u8fc7\u81ea\u5b9a\u4e49 Hash \u5206\u7247\u7b97\u6cd5\u5df2\u89e3\u51b3\u8be5\u95ee\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u5982\u679c\u67e5\u8be2\u4e0d\u8d70\u5206\u7247\u952e\u4f1a\u6709\u4ec0\u4e48\u95ee\u9898\uff1f<\/h3>\n\n\n\n<p>\u4f1a\u51fa\u73b0\u67e5\u8be2\u6240\u6709\u5206\u7247\u5e93\u7684\u6240\u6709\u5206\u7247\u8868\uff0c\u901a\u8fc7 UNION ALL \u7684\u5f62\u5f0f\u5173\u8054\uff0c\u8be5\u4e3e\u52a8\u5b58\u5728\u8bfb\u6269\u6563\u95ee\u9898\uff0c\u6240\u4ee5\u6211\u4eec\u7684\u67e5\u8be2\u4e00\u5b9a\u8981\u5e26\u4e0a\u5206\u7247\u952e\u3002<\/p>\n\n\n\n<p>\u8bfb\u6269\u6563 SQL \u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><code>SELECT * FROM `t_coupon_template_0` WHERE name = '\u6d4b\u8bd5' UNION ALL SELECT * FROM `t_coupon_template_1` WHERE name = '\u6d4b\u8bd5' UNION ALL SELECT * FROM `t_coupon_template_2` WHERE name = '\u6d4b\u8bd5' UNION ALL SELECT * FROM `t_coupon_template_x` WHERE name = '\u6d4b\u8bd5'<\/code><\/p>\n\n\n\n<p>ShardingSphere \u901a\u8fc7\u8fd9\u79cd\u5f62\u5f0f\u67e5\u8be2\u6240\u6709\u5e93\u6240\u6709\u8868\uff0c\u5c06\u6240\u6709\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\u5168\u90e8\u67e5\u8be2\u8fd4\u56de\u3002\u8fd9\u5c31\u662f\u8bfb\u6269\u6563\u95ee\u9898\uff0c\u6781\u7aef\u60c5\u51b5\u4e0b\u4f1a\u5b58\u5728\u6027\u80fd\u6df1\u6e0a\u3002<\/p>\n\n\n\n<p>\u5b8c\u7ed3\uff0c\u6492\u82b1 \ud83c\udf89<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u25aa\u7b2c08\u5c0f\u8282\uff1a\u5f15\u5165\u65e5\u5fd7\u7ec4\u4ef6\u4f18\u96c5\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e1a\u52a1\u80cc\u666f<\/h2>\n\n\n\n<p><strong>\u7cfb\u7edf\u64cd\u4f5c\u65e5\u5fd7<\/strong>\u662f\u7528\u4e8e\u8bb0\u5f55\u7cfb\u7edf\u4e2d\u7528\u6237\u6216\u7cfb\u7edf\u672c\u8eab\u6240\u6267\u884c\u7684\u5404\u7c7b\u64cd\u4f5c\u7684\u65e5\u5fd7\u4fe1\u606f\u3002\u8fd9\u4e9b\u65e5\u5fd7\u901a\u5e38\u5305\u62ec\u64cd\u4f5c\u7684\u65f6\u95f4\u3001\u64cd\u4f5c\u7684\u7528\u6237\u3001\u5177\u4f53\u64cd\u4f5c\u5185\u5bb9\u3001\u64cd\u4f5c\u7ed3\u679c\u4ee5\u53ca\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b89\u5168\u5ba1\u8ba1<\/strong>\uff1a\u8bb0\u5f55\u7528\u6237\u64cd\u4f5c\u4ee5\u9632\u6b62\u6076\u610f\u884c\u4e3a\uff0c\u786e\u4fdd\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002<\/li>\n\n\n\n<li><strong>\u95ee\u9898\u6392\u67e5<\/strong>\uff1a\u5728\u7cfb\u7edf\u51fa\u73b0\u95ee\u9898\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u64cd\u4f5c\u65e5\u5fd7\u5feb\u901f\u5b9a\u4f4d\u95ee\u9898\u6765\u6e90\u3002<\/li>\n<\/ul>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"365\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/a16d086e183996d656d2aad5dcfa266a.png\" width=\"618\">\u200b<img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:https:\/\/eve2333.top\/03421351-9d4b-48a9-815f-1a04fb7544de\" width=\"15\">\u7f16\u8f91<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"git\">Git \u5206\u652f<\/h2>\n\n\n\n<p>20240816_dev_operation-log_mzt-biz-log_ding.ma<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7<\/h2>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u5728\u5df2\u6709\u4e1a\u52a1\u52a0\u4e0a\u64cd\u4f5c\u65e5\u5fd7\uff0c\u65f6\u5e8f\u56fe\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"696\" width=\"889\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/8ba38c791ec5e63a0473200162da7eb7.png\" alt=\"\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u6570\u636e\u5e93\u8868\u8bbe\u8ba1<\/h3>\n\n\n\n<p>\u5173\u4e8e\u64cd\u4f5c\u65e5\u5fd7\u8bb0\u5f55\u8868\uff0c\u6709\u4e24\u79cd\u8bbe\u8ba1\u601d\u8def\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7edf\u4e00\u7ba1\u7406\uff1at_operation_log\uff0c\u6bd4\u5982\u4f18\u60e0\u5238\u64cd\u4f5c\u3001\u6743\u9650\u64cd\u4f5c\u7b49\u653e\u5728\u4e00\u5f20\u8868\u3002<\/li>\n\n\n\n<li>\u7ec6\u7c92\u5ea6\u62c6\u5206\uff1at_coupon_template_log\uff0c\u64cd\u4f5c\u8bb0\u5f55\u968f\u7740\u4e1a\u52a1\u9694\u79bb\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5982\u679c\u7cfb\u7edf\u4e0d\u5927\u4e1a\u52a1\u4e0d\u590d\u6742\u6211\u5efa\u8bae\u524d\u8005\uff0c\u5982\u679c\u7cfb\u7edf\u633a\u5927\uff0c\u6211\u5efa\u8bae\u540e\u8005\u3002<\/p>\n\n\n\n<p><code>CREATE TABLE `t_coupon_template_log` ( &nbsp;`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp;`shop_number` bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp;`operator_id` bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp;`operation_log` text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp;`original_data` varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp;`modified_data` varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp;`create_time` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp;PRIMARY KEY (`id`), &nbsp;KEY `idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1817866003552428034 DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868';<\/code><\/p>\n\n\n\n<p>\u56e0\u4e3a\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868\u4f1a\u8bb0\u5f55\u6a21\u677f\u7684\u521b\u5efa\u3001\u4fee\u6539\u7b49\u4efb\u610f\u64cd\u4f5c\uff0c\u6240\u4ee5\u4e5f\u9700\u8981\u5206\u8868\uff0c\u89c4\u5219\u540c\u4f18\u60e0\u5238\u6a21\u677f\u8868\u3002<\/p>\n\n\n\n<p>\u8fdb\u5165 <code>one_coupon_rebuild_0<\/code> \u6570\u636e\u5e93\uff0c\u6267\u884c\u4e0b\u8ff0 SQL\u3002<\/p>\n\n\n\n<p><code>CREATE TABLE `t_coupon_template_log_0` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_1` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_2` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_3` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_4` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_5` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_6` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_7` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868';<\/code><\/p>\n\n\n\n<p>\u518d\u8fdb\u5165 <code>one_coupon_rebuild_1<\/code> \u6570\u636e\u5e93\uff0c\u6267\u884c\u4e0b\u8ff0 SQL\u3002<\/p>\n\n\n\n<p><code>\u200b CREATE TABLE `t_coupon_template_log_10` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_11` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_12` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_13` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_14` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_15` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_8` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868'; \u200b CREATE TABLE `t_coupon_template_log_9` ( &nbsp; &nbsp;`id` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', &nbsp; &nbsp;`shop_number` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u5e97\u94fa\u7f16\u53f7', &nbsp; &nbsp;`coupon_template_id` bigint(20) DEFAULT NULL COMMENT '\u4f18\u60e0\u5238\u6a21\u677fID', &nbsp; &nbsp;`operator_id` &nbsp; &nbsp; &nbsp; &nbsp;bigint(20) DEFAULT NULL COMMENT '\u64cd\u4f5c\u4eba', &nbsp; &nbsp;`operation_log` &nbsp; &nbsp; &nbsp;text COMMENT '\u64cd\u4f5c\u65e5\u5fd7', &nbsp; &nbsp;`original_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u539f\u59cb\u6570\u636e', &nbsp; &nbsp;`modified_data` &nbsp; &nbsp; &nbsp;varchar(1024) DEFAULT NULL COMMENT '\u4fee\u6539\u540e\u6570\u636e', &nbsp; &nbsp;`create_time` &nbsp; &nbsp; &nbsp; &nbsp;datetime &nbsp; &nbsp; &nbsp;DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4', &nbsp; &nbsp;PRIMARY KEY (`id`), &nbsp; &nbsp;KEY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`idx_shop_number` (`shop_number`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='\u4f18\u60e0\u5238\u6a21\u677f\u64cd\u4f5c\u65e5\u5fd7\u8868';<\/code><\/p>\n\n\n\n<p>\u5bf9\u5e94\u7684do\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Data\n@NoArgsConstructor\n@AllArgsConstructor\n@Builder\n@TableName(\"t_coupon_template_log\")\npublic class CouponTemplateLogDO {\n\n    \/**\n     * id\n     *\/\n    private Long id;\n\n    \/**\n     * \u5e97\u94fa\u7f16\u53f7\n     *\/\n    private Long shopNumber;\n\n    \/**\n     * \u4f18\u60e0\u5238\u6a21\u677fID\n     *\/\n    private String couponTemplateId;\n\n    \/**\n     * \u64cd\u4f5c\u4eba\n     *\/\n    private String operatorId;\n\n    \/**\n     * \u64cd\u4f5c\u65e5\u5fd7\n     *\/\n    private String operationLog;\n\n    \/**\n     * \u539f\u59cb\u6570\u636e\n     *\/\n    private String originalData;\n\n    \/**\n     * \u4fee\u6539\u540e\u6570\u636e\n     *\/\n    private String modifiedData;\n\n    \/**\n     * \u521b\u5efa\u65f6\u95f4\n     *\/\n    @TableField(fill = FieldFill.INSERT)\n    private Date createTime;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u6570\u636e\u5206\u7247<\/h3>\n\n\n\n<p>\u56e0\u4e3a\u5206\u7247\u89c4\u5219\u57fa\u672c\u7b49\u540c\u4e8e\u4f18\u60e0\u5238\u6a21\u677f\u8868\uff0c\u6240\u4ee5\u8fd9\u91cc\u4e5f\u5c31\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7<\/h3>\n\n\n\n<p>\u6211\u4eec\u5148\u5b9e\u73b0\u4e1a\u52a1\u4ee3\u7801\u529f\u80fd\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><code>@Override public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;\/\/ ...... &nbsp; &nbsp;try { &nbsp; &nbsp; &nbsp; &nbsp;String operationLog = String.format(\"%s \u7528\u6237\u521b\u5efa\u4f18\u60e0\u5238\uff1a%s\uff0c\u4f18\u60e0\u5bf9\u8c61\uff1a%s\uff0c\u4f18\u60e0\u7c7b\u578b\uff1a%s\uff0c\u5e93\u5b58\u6570\u91cf\uff1a%d\uff0c\u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a%s\uff0c\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1a%s\uff0c\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1a%s\uff0c\u9886\u53d6\u89c4\u5219\uff1a%s\uff0c\u6d88\u8017\u89c4\u5219\uff1a%s;\", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;UserContext.getUsername(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getName(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DiscountTargetEnum.findValueByType(requestParam.getTarget()), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DiscountTypeEnum.findValueByType(requestParam.getType()), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getStock(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getGoods() == null ? \"\" : requestParam.getGoods(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getValidStartTime(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getValidEndTime(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getReceiveRule(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;requestParam.getConsumeRule()); \u200b &nbsp; &nbsp; &nbsp; &nbsp;CouponTemplateLogDO couponTemplateLogDO = CouponTemplateLogDO.builder() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .couponTemplateId(String.valueOf(couponTemplateDO.getId())) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .operatorId(UserContext.getUserId()) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .shopNumber(UserContext.getShopNumber()) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .operationLog(operationLog) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .modifiedData(JSON.toJSONString(couponTemplateDO)) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build(); &nbsp; &nbsp; &nbsp; &nbsp;couponTemplateLogMapper.insert(couponTemplateLogDO); &nbsp; } catch (Exception ex) { &nbsp; &nbsp; &nbsp; &nbsp;log.error(\"\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7\u9519\u8bef\", ex); &nbsp; } }<\/code><\/p>\n\n\n\n<p>\u7f3a\u70b9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f53\u4e1a\u52a1\u53d8\u5f97\u590d\u6742\u540e\uff0c\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7\u653e\u5728\u4e1a\u52a1\u4ee3\u7801\u4e2d\u4f1a\u5bfc\u81f4\u4e1a\u52a1\u7684\u903b\u8f91\u6bd4\u8f83\u7e41\u7410\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u6765\u8bf4\u662f\u4e00\u4e2a\u707e\u96be\uff0c\u56e0\u4e3a\u4e0d\u6b62\u8fd9\u4e00\u5904\u4f7f\u7528\uff0c\u5b58\u5728\u5927\u91cf\u7684\u5197\u4f59\u4ee3\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"spring-aop-sp-el\">\u901a\u8fc7 SpringAOP \u548c SpEL \u4f18\u96c5\u8bb0\u5f55<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-spring-aop\">1. \u4ec0\u4e48\u662f SpringAOP\uff1f<\/h3>\n\n\n\n<p><strong>Spring AOP (Aspect-Oriented Programming)<\/strong> \u662f Spring \u6846\u67b6\u4e2d\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u5b83\u901a\u8fc7\u9762\u5411\u5207\u9762\u7f16\u7a0b\u7684\u65b9\u5f0f\u5c06\u5173\u6ce8\u70b9\uff08\u5982\u65e5\u5fd7\u8bb0\u5f55\u3001\u5b89\u5168\u6027\u3001\u4e8b\u52a1\u7ba1\u7406\u7b49\uff09\u4e0e\u4e1a\u52a1\u903b\u8f91\u4ee3\u7801\u5206\u79bb\uff0c\u4ece\u800c\u5b9e\u73b0\u4ee3\u7801\u7684\u6a21\u5757\u5316\u548c\u590d\u7528\u3002<\/p>\n\n\n\n<p>\u63a8\u8350\u5b66\u4e60\u6587\u7ae0\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.cnblogs.com\/cxuanBlog\/p\/13060510.html\" target=\"_blank\"  rel=\"nofollow\" >SpringAOP\u77e5\u8bc6\u70b9\u626b\u76f2<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/apifox.com\/apiskills\/how-to-use-spring-boot-aop\" target=\"_blank\"  rel=\"nofollow\" >Spring Boot AOP \u5982\u4f55\u4f7f\u7528\uff1f\u4e00\u6587\u4ecb\u7ecd Spring Boot AOP \u7684\u7528\u6cd5<\/a><\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u7b2c\u4e00\u7bc7\u6587\u7ae0\u5b66\u4e60 SpringAOP \u77e5\u8bc6\u70b9\uff0c\u4f46\u662f\u5176\u4e2d\u7684\u793a\u4f8b\u8fd8\u662f Spring XML \u914d\u7f6e\u65b9\u5f0f\uff0c\u5982\u679c\u60f3\u5b66\u4e60\u76ee\u524d\u4e3b\u6d41\u914d\u7f6e\u67e5\u770b\u7b2c\u4e8c\u7bc7\u6587\u7ae0\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-sp-el\">2. \u4ec0\u4e48\u662f SpEL\uff1f<\/h3>\n\n\n\n<p>SpEL \u5373 Spring \u8868\u8fbe\u5f0f\u8bed\u8a00\uff0c\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u8868\u8fbe\u5f0f\u8bed\u8a00\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u8bc4\u4f30\u8868\u8fbe\u5f0f\u5e76\u751f\u6210\u503c\u3002SpEL \u6700\u5e38\u7528\u4e8e Spring Framework \u4e2d\u7684\u6ce8\u89e3\u7b49\u573a\u666f\uff0c\u4e5f\u53ef\u4ee5\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u5728 Java \u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>SpEL \u5e94\u7528\u573a\u666f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52a8\u6001\u53c2\u6570\u914d\u7f6e\uff1a\u53ef\u4ee5\u901a\u8fc7 SpEL \u5c06\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u5404\u79cd\u53c2\u6570\u914d\u7f6e\u5316\uff0c\u4f8b\u5982\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f\u3001\u4e1a\u52a1\u89c4\u5219\u7b49\u3002\u901a\u8fc7\u52a8\u6001\u914d\u7f6e\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u6839\u636e\u4e0d\u540c\u7684\u73af\u5883\u6216\u9700\u6c42\u6765\u8fdb\u884c\u7075\u6d3b\u7684\u53c2\u6570\u8bbe\u7f6e\u3002<\/li>\n\n\n\n<li>\u8fd0\u884c\u65f6\u6ce8\u5165\uff1a\u4f7f\u7528SpEL\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u6ce8\u5165\u5c5e\u6027\u503c\uff0c\u800c\u4e0d\u9700\u8981\u5728\u7f16\u7801\u65f6\u786c\u7f16\u7801\u3002\u8fd9\u5bf9\u4e8e\u9700\u8981\u6839\u636e\u5f53\u524d\u4e0a\u4e0b\u6587\u52a8\u6001\u8c03\u6574\u5c5e\u6027\u503c\u7684\u573a\u666f\u975e\u5e38\u6709\u7528\u3002<\/li>\n\n\n\n<li>\u6761\u4ef6\u5224\u65ad\u4e0e\u4e1a\u52a1\u903b\u8f91\uff1aSpEL\u652f\u6301\u590d\u6742\u7684\u6761\u4ef6\u5224\u65ad\u548c\u903b\u8f91\u8ba1\u7b97\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u8fd0\u884c\u65f6\u6839\u636e\u6761\u4ef6\u6765\u6267\u884c\u7279\u5b9a\u7684\u4ee3\u7801\u903b\u8f91\u3002\u4f8b\u5982\uff0c\u5728\u6743\u9650\u63a7\u5236\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528SpEL\u8fdb\u884c\u8d44\u6e90\u548c\u89d2\u8272\u7684\u52a8\u6001\u6388\u6743\u5224\u65ad\u3002<\/li>\n<\/ul>\n\n\n\n<p>SpEL \u7b80\u5355\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/**\n * SpEL \u8868\u8fbe\u5f0f\u6d4b\u8bd5\u7c7b\n *\/\npublic class CouponTemplateLogSpELTests {\n\n    \/**\n     * \u8c03\u7528\u9759\u6001\u7c7b\u65b9\u6cd5\n     *\/\n    @Test\n    public void testSpELGetRandom() {\n        String spELKey = \"T(java.lang.Math).random()\";\n        ExpressionParser parser = new SpelExpressionParser();\n        Expression expression = parser.parseExpression(spELKey);\n        Assert.isTrue(expression.getValue() instanceof Double);\n    }\n\n    \/**\n     * \u8c03\u7528\u9759\u6001\u7c7b\u65b9\u6cd5\u5e76\u8fd0\u7b97\n     *\/\n    @Test\n    public void testSpELGetRandomV2() {\n        String spELKey = \"T(java.lang.Math).random() * 100.0\";\n        ExpressionParser parser = new SpelExpressionParser();\n        Expression expression = parser.parseExpression(spELKey);\n        Assert.isTrue(expression.getValue() instanceof Double);\n    }\n\n    \/**\n     * \u8c03\u7528\u5f53\u524d\u767b\u5f55\u7528\u6237\u9759\u6001\u7c7b\u65b9\u6cd5\n     *\/\n    @Test\n    public void testSpELGetCurrentUser() {\n        \/\/ \u521d\u59cb\u5316\u6570\u636e\n        String userid = \"1810518709471555585\";\n        UserContext.setUser(new UserInfoDTO(userid, \"pdd45305558318\", 1810714735922956666L));\n\n        \/\/ \u8c03\u7528\u7528\u6237\u4e0a\u4e0b\u6587\u83b7\u53d6\u5f53\u524d\u7528\u6237 ID\n        String spELKey = \"T(com.nageoffer.onecoupon.merchant.admin.common.context.UserContext).getUserId()\";\n        ExpressionParser parser = new SpelExpressionParser();\n        Expression expression = parser.parseExpression(spELKey);\n        try {\n            Assert.equals(expression.getValue(), userid);\n        } finally {\n            UserContext.removeUser();\n        }\n    }\n\n    \/**\n     * \u8c03\u7528\u5f53\u524d\u767b\u5f55\u7528\u6237\u9759\u6001\u7c7b\u65b9\u6cd5\uff0c\u5982\u679c\u4e3a\u7a7a\u53d6\u9ed8\u8ba4\u503c\n     *\/\n    @Test\n    public void testSpELGetCurrentUserDefaultValue() {\n        \/\/ \u8c03\u7528\u7528\u6237\u4e0a\u4e0b\u6587\u83b7\u53d6\u5f53\u524d\u7528\u6237 ID\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u53d6\u9ed8\u8ba4\u503c\n        String spELKey = \"T(com.nageoffer.onecoupon.merchant.admin.common.context.UserContext).getUserId() ?: 'ding.ma'\";\n        ExpressionParser parser = new SpelExpressionParser();\n        Expression expression = parser.parseExpression(spELKey);\n        Assert.equals(expression.getValue(), \"ding.ma\");\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>\u9664\u4e86\u4e0a\u9762\u7684\u7b80\u5355\u903b\u8f91\u4e4b\u5916\uff0c\u8fd8\u652f\u6301\u5f88\u591a\u7279\u6027\uff0c\u5927\u5bb6\u53ef\u4ee5\u67e5\u770b\u5b98\u65b9\u6587\u7ae0\u5b66\u4e60\uff1a<a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/3.2.x\/spring-framework-reference\/html\/expressions.html\" target=\"_blank\"  rel=\"nofollow\" >Spring EL \u8868\u8fbe\u5f0f\u5b98\u65b9\u6587\u6863\uff08\u82f1\u6587\u7248\uff09<\/a>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mzt-biz-log\">\u7f8e\u56e2 mzt-biz-log \u64cd\u4f5c\u65e5\u5fd7\u6846\u67b6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-mzt-biz-log\">1. mzt-biz-log \u4ecb\u7ecd<\/h3>\n\n\n\n<p>\u53ef\u80fd\u5f88\u591a\u540c\u5b66\u770b\u8fc7\u7f8e\u56e2 2021 \u5e74\u53d1\u5e03\u4e00\u7bc7\u73b0\u8c61\u7ea7\u6587\u7ae0\uff1a<a href=\"https:\/\/juejin.cn\/post\/7009116644031070244\" target=\"_blank\"  rel=\"nofollow\" >\u7f8e\u56e22021\u5e74\u6700\u53d7\u6b22\u8fce\u7684\u6587\u7ae0\u4e4b\u4e00\uff1a\u5982\u4f55\u4f18\u96c5\u5730\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7\uff1f<\/a>\uff0c\u4e5f\u662f\u5173\u4e8e\u64cd\u4f5c\u65e5\u5fd7\u7684\uff0c\u6ca1\u770b\u8fc7\u7684\u5efa\u8bae\u770b\u770b\u3002<\/p>\n\n\n\n<p>\u4f5c\u8005\u5c06\u5bf9\u5e94\u6587\u7ae0\u4e2d\u7684\u601d\u8def\u5f00\u6e90\u4e86\uff0c\u4e5f\u5c31\u662f\u4eca\u5929\u8981\u8bb2\u7684 <a href=\"https:\/\/github.com\/mouzt\/mzt-biz-log\" target=\"_blank\"  rel=\"nofollow\" >mzt-biz-log<\/a>\uff1a\u652f\u6301 Springboot\uff0c\u57fa\u4e8e\u6ce8\u89e3\u7684\u53ef\u4f7f\u7528\u53d8\u91cf\u3001\u53ef\u4ee5\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u901a\u7528\u64cd\u4f5c\u65e5\u5fd7\u7ec4\u4ef6\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>mzt-biz-log \u4ee5\u4e0b\u7b80\u79f0 biz-log\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u5982\u4f55\u9009\u62e9\u9020\u8f6e\u5b50\u548c\u73b0\u6709\u6846\u67b6\uff1f<\/h3>\n\n\n\n<p>\u4e3a\u4ec0\u4e48\u4f7f\u7528\u73b0\u6709\u6846\u67b6\u800c\u4e0d\u662f\u91cd\u590d\u9020\u8f6e\u5b50\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6548\u7387\u63d0\u5347\u3002<\/li>\n\n\n\n<li>\u8d28\u91cf\u4fdd\u969c\u3002<\/li>\n\n\n\n<li>\u6301\u7eed\u66f4\u65b0<\/li>\n<\/ul>\n\n\n\n<p>\u4ec0\u4e48\u65f6\u5019\u9020\u8f6e\u5b50\u800c\u4e0d\u662f\u9009\u62e9\u73b0\u6709\u6846\u67b6\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7279\u5b9a\u9700\u6c42\u65e0\u6cd5\u6ee1\u8db3\u3002<\/li>\n\n\n\n<li>\u6027\u80fd\u4f18\u5316\u3002<\/li>\n\n\n\n<li>\u5b66\u4e60\u548c\u63a2\u7d22\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-mzt-biz-log\">3. \u4f7f\u7528 mzt-biz-log \u6539\u9020<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-1-maven\">3.1 \u5f15\u5165 Maven \u4f9d\u8d56<\/h4>\n\n\n\n<p><code>&lt;dependency&gt; &nbsp; &nbsp;&lt;groupId&gt;io.github.mouzt&lt;\/groupId&gt; &nbsp; &nbsp;&lt;artifactId&gt;bizlog-sdk&lt;\/artifactId&gt; &lt;version&gt;3.0.6&lt;\/version&gt; &lt;\/dependency&gt;<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-2\">3.2 \u5e94\u7528\u6dfb\u52a0\u542f\u52a8\u6ce8\u89e3<\/h4>\n\n\n\n<p>\u5e94\u7528\u542f\u52a8\u7c7b\u6dfb\u52a0 <code>@EnableLogRecord<\/code> \u6ce8\u89e3\uff0c\u5e76\u914d\u7f6e\u79df\u6237\u3002tenant \u662f\u4ee3\u8868\u79df\u6237\u7684\u6807\u8bc6\uff0c\u4e00\u822c\u4e00\u4e2a\u670d\u52a1\u6216\u8005\u4e00\u4e2a\u4e1a\u52a1\u4e0b\u7684\u591a\u4e2a\u670d\u52a1\u90fd\u56fa\u5b9a\u4e00\u4e2a tenant \u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n\n<p><code>@EnableLogRecord(tenant = \"MerchantAdmin\") public class MerchantAdminApplication { &nbsp; &nbsp;\/\/ ...... }<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-3-log-record\">3.3 \u6dfb\u52a0\u6ce8\u89e3 @LogRecord<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>@Service\n@RequiredArgsConstructor\npublic class CouponTemplateServiceImpl extends ServiceImpl&lt;CouponTemplateMapper, CouponTemplateDO&gt; implements CouponTemplateService {\n\n    private final CouponTemplateMapper couponTemplateMapper;\n    private final MerchantAdminChainContext merchantAdminChainContext;\n    private final StringRedisTemplate stringRedisTemplate;\n\n    @LogRecord(\n            success = \"\"\"\n                    \u521b\u5efa\u4f18\u60e0\u5238\uff1a{{#requestParam.name}}\uff0c \\\n                    \u4f18\u60e0\u5bf9\u8c61\uff1a{COMMON_ENUM_PARSE{'DiscountTargetEnum' + '_' + #requestParam.target}}\uff0c \\\n                    \u4f18\u60e0\u7c7b\u578b\uff1a{COMMON_ENUM_PARSE{'DiscountTypeEnum' + '_' + #requestParam.type}}\uff0c \\\n                    \u5e93\u5b58\u6570\u91cf\uff1a{{#requestParam.stock}}\uff0c \\\n                    \u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a{{#requestParam.goods}}\uff0c \\\n                    \u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1a{{#requestParam.validStartTime}}\uff0c \\\n                    \u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1a{{#requestParam.validEndTime}}\uff0c \\\n                    \u9886\u53d6\u89c4\u5219\uff1a{{#requestParam.receiveRule}}\uff0c \\\n                    \u6d88\u8017\u89c4\u5219\uff1a{{#requestParam.consumeRule}};\n                    \"\"\",\n            type = \"CouponTemplate\",\n            bizNo = \"{{#bizNo}}\",\n            extra = \"{{#requestParam.toString()}}\"\n    )\n    @Override\n    public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) {\n        \/\/ \u901a\u8fc7\u8d23\u4efb\u94fe\u9a8c\u8bc1\u8bf7\u6c42\u53c2\u6570\u662f\u5426\u6b63\u786e\n        merchantAdminChainContext.handler(MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY.name(), requestParam);\n\n        \/\/ \u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93\n        CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class);\n        couponTemplateDO.setStatus(CouponTemplateStatusEnum.ACTIVE.getStatus());\n        couponTemplateDO.setShopNumber(UserContext.getShopNumber());\n        couponTemplateMapper.insert(couponTemplateDO);\n\n        \/\/ \u56e0\u4e3a\u6a21\u677f ID \u662f\u8fd0\u884c\u4e2d\u751f\u6210\u7684\uff0c@LogRecord \u9ed8\u8ba4\u62ff\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\n        LogRecordContext.putVariable(\"bizNo\", couponTemplateDO.getId());\n\n        \/\/ \u7f13\u5b58\u9884\u70ed\uff1a\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u7684\u8bb0\u5f55\u5e8f\u5217\u5316\u6210 JSON \u5b57\u7b26\u4e32\u653e\u5165 Redis \u7f13\u5b58\n        CouponTemplateQueryRespDTO actualRespDTO = BeanUtil.toBean(couponTemplateDO, CouponTemplateQueryRespDTO.class);\n        Map&lt;String, Object&gt; cacheTargetMap = BeanUtil.beanToMap(actualRespDTO, false, true);\n        Map&lt;String, String&gt; actualCacheTargetMap = cacheTargetMap.entrySet().stream()\n                .collect(Collectors.toMap(\n                        Map.Entry::getKey,\n                        entry -&gt; entry.getValue() != null ? entry.getValue().toString() : \"\"\n                ));\n        String couponTemplateCacheKey = String.format(MerchantAdminRedisConstant.COUPON_TEMPLATE_KEY, couponTemplateDO.getId());\n        stringRedisTemplate.opsForHash().putAll(couponTemplateCacheKey, actualCacheTargetMap);\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>\u89e3\u6790\u4e0b\u4e0a\u9762\u56db\u4e2a\u6ce8\u89e3\u5c5e\u6027\u5206\u522b\u5bf9\u5e94\u4ec0\u4e48\u8bed\u4e49\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>success\uff1a\u65b9\u6cd5\u6267\u884c\u6210\u529f\u540e\u7684\u65e5\u5fd7\u6a21\u7248\u3002<\/li>\n\n\n\n<li>type\uff1a\u64cd\u4f5c\u65e5\u5fd7\u7684\u7c7b\u578b\uff0c\u6bd4\u5982\uff1a\u8ba2\u5355\u7c7b\u578b\u3001\u5546\u54c1\u7c7b\u578b\u3002<\/li>\n\n\n\n<li>bizNo\uff1a\u65e5\u5fd7\u7ed1\u5b9a\u7684\u4e1a\u52a1\u6807\u8bc6\uff0c\u9700\u8981\u662f\u6211\u4eec\u4f18\u60e0\u5238\u6a21\u677f\u7684 ID\uff0c\u4f46\u662f\u76ee\u524d\u62ff\u4e0d\u5230\uff0c\u653e\u4e00\u4e2a\u5360\u4f4d\u7b26\u3002<\/li>\n\n\n\n<li>extra\uff1a\u65e5\u5fd7\u7684\u989d\u5916\u4fe1\u606f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u52a0\u4e0a\u6539\u65b9\u6cd5\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u6253\u5370\u65e5\u5fd7\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p><code>2024-08-16T23:47:46.838+08:00 INFO 16761 --- [io-10010-exec-1] c.m.l.s.i.DefaultLogRecordServiceImpl &nbsp; : \u3010logRecord\u3011log=LogRecord(id=null, tenant=MerchantAdmin, type=CouponTemplate, subType=, bizNo={{#bizNo}}, operator=111, action=\u521b\u5efa\u4f18\u60e0\u5238\uff1a\u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0\uff0c\u4f18\u60e0\u5bf9\u8c61\uff1a1\uff0c\u4f18\u60e0\u7c7b\u578b\uff1a0\uff0c\u5e93\u5b58\u6570\u91cf\uff1a20990\uff0c\u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a\uff0c\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1aMon Jul 08 12:00:00 CST 2024\uff0c\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1aTue Jul 08 12:00:00 CST 2025\uff0c\u9886\u53d6\u89c4\u5219\uff1a{\"limitPerPerson\":10,\"usageInstructions\":\"3\"}\uff0c\u6d88\u8017\u89c4\u5219\uff1a{\"termsOfUse\":10,\"maximumDiscountAmount\":3,\"explanationOfUnmetConditions\":\"3\",\"validityPeriod\":\"48\"};, fail=false, createTime=Fri Aug 16 23:47:46 CST 2024, extra={\"consumeRule\":\"{\\\"termsOfUse\\\":10,\\\"maximumDiscountAmount\\\":3,\\\"explanationOfUnmetConditions\\\":\\\"3\\\",\\\"validityPeriod\\\":\\\"48\\\"}\",\"goods\":\"\",\"name\":\"\u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0\",\"receiveRule\":\"{\\\"limitPerPerson\\\":10,\\\"usageInstructions\\\":\\\"3\\\"}\",\"source\":0,\"stock\":20990,\"target\":1,\"type\":0,\"validEndTime\":\"2025-07-08 12:00:00\",\"validStartTime\":\"2024-07-08 12:00:00\"}, codeVariable={MethodName=createCouponTemplate, ClassName=class com.nageoffer.onecoupon.merchant.admin.service.impl.CouponTemplateServiceImpl})<\/code><\/p>\n\n\n\n<p>\u770b\u5230\u8be5\u65e5\u5fd7\u6253\u5370\uff0c\u8bc1\u660e\u6211\u4eec\u7684 <code>@LogRecord<\/code> \u6ce8\u89e3\u751f\u6548\u4e86\u3002\u4f46\u662f\uff0c\u4e0a\u9762\u8fd9\u4e9b\u4fe1\u606f\u8fd8\u662f\u6709\u4e00\u4e9b\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u4f18\u60e0\u5bf9\u8c61\u548c\u4f18\u60e0\u5238\u7c7b\u578b\u90fd\u662f type \u503c\uff0c\u6211\u4eec\u5e0c\u671b\u5c55\u793a\u7684\u65f6\u5019\u662f\u5177\u4f53\u503c\uff0c\u8fd9\u79cd\u5e94\u8be5\u600e\u4e48\u89e3\u51b3\uff1f<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-4\">3.4 \u81ea\u5b9a\u4e49\u51fd\u6570<\/h4>\n\n\n\n<p>\u4e0a\u9762 biz-log \u63d0\u5230\u8fc7\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u8bd5\u8bd5\u8fd9\u4e2a\u51fd\u6570\u529f\u80fd\u3002\u4ec5\u9700\u8981\u5b9e\u73b0 <code>IParseFunction<\/code> \u63a5\u53e3\u5373\u53ef\u5b8c\u6210\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/**\n * \u64cd\u4f5c\u65e5\u5fd7\u7ec4\u4ef6\u89e3\u6790\u679a\u4e3e\u503c\u5bf9\u5e94\u63cf\u8ff0\u4fe1\u606f\n *\/\n@Component\npublic class CommonEnumParseFunction implements IParseFunction {\n\n    public static final String DISCOUNT_TARGET_ENUM_NAME = DiscountTargetEnum.class.getSimpleName();\n    private static final String DISCOUNT_TYPE_ENUM_NAME = DiscountTypeEnum.class.getSimpleName();\n\n    @Override\n    public String functionName() {\n        return \"COMMON_ENUM_PARSE\";\n    }\n\n    @Override\n    public String apply(Object value) {\n        try {\n            List&lt;String&gt; parts = StrUtil.split(value.toString(), \"_\");\n            if (parts.size() != 2) {\n                throw new IllegalArgumentException(\"\u683c\u5f0f\u9519\u8bef\uff0c\u9700\u8981 '\u679a\u4e3e\u7c7b_\u5177\u4f53\u503c' \u7684\u5f62\u5f0f\u3002\");\n            }\n\n            String enumClassName = parts.get(0);\n            int enumValue = Integer.parseInt(parts.get(1));\n\n            return findEnumValueByName(enumClassName, enumValue);\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\"\u7b2c\u4e8c\u4e2a\u4e0b\u5212\u7ebf\u540e\u9762\u7684\u503c\u9700\u8981\u662f\u6574\u6570\u3002\", e);\n        }\n    }\n\n    private String findEnumValueByName(String enumClassName, int enumValue) {\n        if (DISCOUNT_TARGET_ENUM_NAME.equals(enumClassName)) {\n            return DiscountTargetEnum.findValueByType(enumValue);\n        } else if (DISCOUNT_TYPE_ENUM_NAME.equals(enumClassName)) {\n            return DiscountTypeEnum.findValueByType(enumValue);\n        } else {\n            throw new IllegalArgumentException(\"\u672a\u77e5\u7684\u679a\u4e3e\u7c7b\u540d: \" + enumClassName);\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p><code>COMMON_ENUM_PARSE<\/code> \u662f\u8fd9\u4e2a\u51fd\u6570\u7684\u6807\u8bc6\uff0c\u52a0\u5230 success \u5b57\u7b26\u4e32\u53d8\u91cf\u4e2d\uff0c\u5373\u53ef\u81ea\u52a8\u5b8c\u6210\u89e3\u6790\u3002\u5982\u679c\u68c0\u67e5\u5230 success \u5305\u542b\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u4ea4\u7531 IParseFunction#apply \u65b9\u6cd5\u6267\u884c\u3002<\/p>\n\n\n\n<p>\u4e1a\u52a1\u4ee3\u7801\u6539\u9020\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><code>@LogRecord( &nbsp; &nbsp; &nbsp; &nbsp;success = \"\"\" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u521b\u5efa\u4f18\u60e0\u5238\uff1a{{#requestParam.name}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u4f18\u60e0\u5bf9\u8c61\uff1a{COMMON_ENUM_PARSE{'DiscountTargetEnum' + '_' + #requestParam.target}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u4f18\u60e0\u7c7b\u578b\uff1a{COMMON_ENUM_PARSE{'DiscountTypeEnum' + '_' + #requestParam.type}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u5e93\u5b58\u6570\u91cf\uff1a{{#requestParam.stock}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a{{#requestParam.goods}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1a{{#requestParam.validStartTime}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1a{{#requestParam.validEndTime}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u9886\u53d6\u89c4\u5219\uff1a{{#requestParam.receiveRule}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u6d88\u8017\u89c4\u5219\uff1a{{#requestParam.consumeRule}}; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\"\", &nbsp; &nbsp; &nbsp; &nbsp;type = \"CouponTemplate\", &nbsp; &nbsp; &nbsp; &nbsp;bizNo = \"{{#bizNo}}\", &nbsp; &nbsp; &nbsp; &nbsp;extra = \"{{#requestParam.toString()}}\" ) @Override public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;\/\/ ...... }<\/code><\/p>\n\n\n\n<p>\u6253\u5370\u65e5\u5fd7\u5982\u4e0b\uff0c\u53ef\u4ee5\u770b\u5230\u5df2\u5c06 type \u503c\u5207\u6362\u4e3a\u5177\u4f53\u540d\u79f0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2024-08-17T00:00:28.540+08:00 &nbsp;INFO 16923 --- &#91;io-10010-exec-1] c.m.l.s.i.DefaultLogRecordServiceImpl &nbsp; : \u3010logRecord\u3011log=LogRecord(id=null, tenant=MerchantAdmin, type=CouponTemplate, subType=, bizNo={{#bizNo}}, operator=111, action=\u521b\u5efa\u4f18\u60e0\u5238\uff1a\u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0\uff0c \u4f18\u60e0\u5bf9\u8c61\uff1a\u5168\u5e97\u901a\u7528\u4f18\u60e0\uff0c \u4f18\u60e0\u7c7b\u578b\uff1a\u7acb\u51cf\u5238\uff0c \u5e93\u5b58\u6570\u91cf\uff1a20990\uff0c \u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a\uff0c \u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1aMon Jul 08 12:00:00 CST 2024\uff0c \u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1aTue Jul 08 12:00:00 CST 2025\uff0c \u9886\u53d6\u89c4\u5219\uff1a{\"limitPerPerson\":10,\"usageInstructions\":\"3\"}\uff0c \u6d88\u8017\u89c4\u5219\uff1a{\"termsOfUse\":10,\"maximumDiscountAmount\":3,\"explanationOfUnmetConditions\":\"3\",\"validityPeriod\":\"48\"}; , fail=false, createTime=Sat Aug 17 00:00:28 CST 2024, extra={\"consumeRule\":\"{\\\"termsOfUse\\\":10,\\\"maximumDiscountAmount\\\":3,\\\"explanationOfUnmetConditions\\\":\\\"3\\\",\\\"validityPeriod\\\":\\\"48\\\"}\",\"goods\":\"\",\"name\":\"\u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0\",\"receiveRule\":\"{\\\"limitPerPerson\\\":10,\\\"usageInstructions\\\":\\\"3\\\"}\",\"source\":0,\"stock\":20990,\"target\":1,\"type\":0,\"validEndTime\":\"2025-07-08 12:00:00\",\"validStartTime\":\"2024-07-08 12:00:00\"}, codeVariable={MethodName=createCouponTemplate, ClassName=class com.nageoffer.onecoupon.merchant.admin.service.impl.CouponTemplateServiceImpl})<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-5\">3.5 \u65e5\u5fd7\u8bb0\u5f55\u4e0a\u4e0b\u6587<\/h4>\n\n\n\n<p>\u4e0a\u9762\u8fd8\u63d0\u5230\u4e00\u4e2a\u70b9\uff0c\u90a3\u5c31\u662f bizNo \u8fd9\u4e2a\u503c\u8fd8\u7a7a\u7740\u5462\u3002\u6b63\u5e38\u5e94\u8be5\u662f\u4f18\u60e0\u5238\u6a21\u677f\u7684 ID\uff0c\u4f46\u662f\u4f18\u60e0\u5238\u6a21\u677f ID \u6211\u4eec\u4e5f\u62ff\u4e0d\u5230\uff0c\u56e0\u4e3a\u662f\u4e34\u65f6\u751f\u6210\u7684\u3002<\/p>\n\n\n\n<p><code>@Override public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;\/\/ \u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93 &nbsp; &nbsp;CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class); &nbsp; &nbsp;couponTemplateDO.setStatus(CouponTemplateStatusEnum.ACTIVE.getStatus()); &nbsp; &nbsp;couponTemplateDO.setShopNumber(UserContext.getShopNumber()); &nbsp; &nbsp;couponTemplateMapper.insert(couponTemplateDO); &nbsp; &nbsp;\/\/ \u65b0\u589e\u5230\u6570\u636e\u5e93\u6210\u529f\u540e\uff0c\u4f1a\u81ea\u52a8\u4e3a couponTemplateDO \u8d4b\u503c ID }<\/code><\/p>\n\n\n\n<p>biz-log \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u65e5\u5fd7\u8bb0\u5f55\u4e0a\u4e0b\u6587\u529f\u80fd\uff0c\u5c06\u503c\u653e\u5230\u4e0a\u4e0b\u6587 <code>LogRecordContext<\/code> \u91cc\u9762\uff0c\u6211\u4eec\u5c31\u80fd\u5728\u8fd0\u884c\u65f6\u62ff\u5230\u3002<\/p>\n\n\n\n<p>\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p><code>@LogRecord( &nbsp; &nbsp; &nbsp; &nbsp;success = \"\"\" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u521b\u5efa\u4f18\u60e0\u5238\uff1a{{#requestParam.name}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u4f18\u60e0\u5bf9\u8c61\uff1a{COMMON_ENUM_PARSE{'DiscountTargetEnum' + '_' + #requestParam.target}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u4f18\u60e0\u7c7b\u578b\uff1a{COMMON_ENUM_PARSE{'DiscountTypeEnum' + '_' + #requestParam.type}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u5e93\u5b58\u6570\u91cf\uff1a{{#requestParam.stock}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a{{#requestParam.goods}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1a{{#requestParam.validStartTime}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1a{{#requestParam.validEndTime}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u9886\u53d6\u89c4\u5219\uff1a{{#requestParam.receiveRule}}\uff0c \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u6d88\u8017\u89c4\u5219\uff1a{{#requestParam.consumeRule}}; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\"\", &nbsp; &nbsp; &nbsp; &nbsp;type = \"CouponTemplate\", &nbsp; &nbsp; &nbsp; &nbsp;bizNo = \"{{#bizNo}}\", &nbsp; &nbsp; &nbsp; &nbsp;extra = \"{{#requestParam.toString()}}\" ) @Override public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;\/\/ ...... &nbsp; &nbsp;\/\/ \u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93 &nbsp; &nbsp;CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class); &nbsp; &nbsp;couponTemplateDO.setStatus(CouponTemplateStatusEnum.ACTIVE.getStatus()); &nbsp; &nbsp;couponTemplateDO.setShopNumber(UserContext.getShopNumber()); &nbsp; &nbsp;couponTemplateMapper.insert(couponTemplateDO); &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u56e0\u4e3a\u6a21\u677f ID \u662f\u8fd0\u884c\u4e2d\u751f\u6210\u7684\uff0c@LogRecord \u9ed8\u8ba4\u62ff\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u624b\u52a8\u8bbe\u7f6e &nbsp; &nbsp;LogRecordContext.putVariable(\"bizNo\", couponTemplateDO.getId()); }<\/code><\/p>\n\n\n\n<p>\u8fd9\u6837\u6211\u4eec\u5728 bizNo \u5b57\u6bb5\u4e2d\u53ef\u4ee5\u901a\u8fc7 SpEL \u8868\u8fbe\u5f0f\u83b7\u53d6\u5bf9\u5e94\u7684\u503c\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>LogRecordContext \u4f1a\u5728\u65b9\u6cd5\u7ed3\u675f\u540e\u81ea\u52a8 Remove\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u6211\u4eec\u624b\u52a8\u64cd\u4f5c\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<p>\u65e5\u5fd7\u6253\u5370\u5982\u4e0b\uff0c\u53ef\u4ee5\u770b\u5230 bizNo \u5df2\u7ecf\u6709\u5177\u4f53\u7684\u503c\u4e86\u3002<\/p>\n\n\n\n<p><code>2024-08-17T00:06:05.691+08:00 &nbsp;INFO 16978 --- [io-10010-exec-2] c.m.l.s.i.DefaultLogRecordServiceImpl &nbsp; : \u3010logRecord\u3011log=LogRecord(id=null, tenant=MerchantAdmin, type=CouponTemplate, subType=, bizNo=1824477740594647042, operator=111, action=\u521b\u5efa\u4f18\u60e0\u5238\uff1a\u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0\uff0c \u4f18\u60e0\u5bf9\u8c61\uff1a\u5168\u5e97\u901a\u7528\u4f18\u60e0\uff0c \u4f18\u60e0\u7c7b\u578b\uff1a\u7acb\u51cf\u5238\uff0c \u5e93\u5b58\u6570\u91cf\uff1a20990\uff0c \u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a\uff0c \u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1aMon Jul 08 12:00:00 CST 2024\uff0c \u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1aTue Jul 08 12:00:00 CST 2025\uff0c \u9886\u53d6\u89c4\u5219\uff1a{\"limitPerPerson\":10,\"usageInstructions\":\"3\"}\uff0c \u6d88\u8017\u89c4\u5219\uff1a{\"termsOfUse\":10,\"maximumDiscountAmount\":3,\"explanationOfUnmetConditions\":\"3\",\"validityPeriod\":\"48\"}; , fail=false, createTime=Sat Aug 17 00:06:05 CST 2024, extra={\"consumeRule\":\"{\\\"termsOfUse\\\":10,\\\"maximumDiscountAmount\\\":3,\\\"explanationOfUnmetConditions\\\":\\\"3\\\",\\\"validityPeriod\\\":\\\"48\\\"}\",\"goods\":\"\",\"name\":\"\u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0\",\"receiveRule\":\"{\\\"limitPerPerson\\\":10,\\\"usageInstructions\\\":\\\"3\\\"}\",\"source\":0,\"stock\":20990,\"target\":1,\"type\":0,\"validEndTime\":\"2025-07-08 12:00:00\",\"validStartTime\":\"2024-07-08 12:00:00\"}, codeVariable={ClassName=class com.nageoffer.onecoupon.merchant.admin.service.impl.CouponTemplateServiceImpl, MethodName=createCouponTemplate})<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-6\">3.6 \u4fdd\u5b58\u6570\u636e\u5e93<\/h4>\n\n\n\n<p>biz-log \u4e2d\u4e3a\u6211\u4eec\u9884\u7559\u4e86\u6269\u5c55\u63a5\u53e3\uff0c\u5b9e\u73b0 <code>ILogRecordService<\/code> \u63a5\u53e3\u5c31\u53ef\u4ee5\u81ea\u5b9a\u4e49\u4fdd\u5b58\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/**\n * \u4fdd\u5b58\u64cd\u4f5c\u65e5\u5fd7\u65b0\u589e\u5230\u6570\u636e\u5e93\n * &lt;p&gt;\n * \u4f5c\u8005\uff1a\u9a6c\u4e01\n * \u52a0\u9879\u76ee\u7fa4\uff1a\u65e9\u52a0\u5165\u5c31\u662f\u4f18\u52bf\uff01500\u4eba\u5185\u90e8\u9879\u76ee\u7fa4\uff0c\u5206\u4eab\u7684\u77e5\u8bc6\u603b\u6709\u4f60\u9700\u8981\u7684 &lt;a href=\"https:\/\/t.zsxq.com\/cw7b9\" \/&gt;\n * \u5f00\u53d1\u65f6\u95f4\uff1a2024-07-09\n *\/\n@Slf4j\n@Service\n@RequiredArgsConstructor\npublic class DBLogRecordServiceImpl implements ILogRecordService {\n\n    private final CouponTemplateLogMapper couponTemplateLogMapper;\n\n    @Override\n    public void record(LogRecord logRecord) {\n        try {\n            switch (logRecord.getType()) {\n                case \"CouponTemplate\": {\n                    CouponTemplateLogDO couponTemplateLogDO = CouponTemplateLogDO.builder()\n                            .couponTemplateId(logRecord.getBizNo())\n                            .shopNumber(UserContext.getShopNumber())\n                            .operatorId(UserContext.getUserId())\n                            .operationLog(logRecord.getAction())\n                            .originalData(Optional.ofNullable(LogRecordContext.getVariable(\"originalData\")).map(Object::toString).orElse(null))\n                            .modifiedData(StrUtil.isBlank(logRecord.getExtra()) ? null : logRecord.getExtra())\n                            .build();\n                    couponTemplateLogMapper.insert(couponTemplateLogDO);\n                }\n            }\n        } catch (Exception ex) {\n            log.error(\"\u8bb0\u5f55&#91;{}]\u64cd\u4f5c\u65e5\u5fd7\u5931\u8d25\", logRecord.getType(), ex);\n        }\n    }\n\n    @Override\n    public List&lt;LogRecord&gt; queryLog(String bizNo, String type) {\n        return List.of();\n    }\n\n    @Override\n    public List&lt;LogRecord&gt; queryLogByBizNo(String bizNo, String type, String subType) {\n        return List.of();\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u81f3\u6b64\uff0c\u6211\u4eec\u7684\u64cd\u4f5c\u65e5\u5fd7\u5373\u5b8c\u6210\uff0c\u540e\u7eed\u5546\u5bb6\u6709\u95ee\u9898\u6216\u8005\u8bf4\u5e73\u53f0\u81ea\u67e5\u4f18\u60e0\u5238\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u90fd\u53ef\u4ee5\u901a\u8fc7\u64cd\u4f5c\u65e5\u5fd7\u7559\u75d5\u6392\u67e5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5e38\u89c1\u95ee\u9898\u7b54\u7591<\/h2>\n\n\n\n<p>Q\uff1a\u64cd\u4f5c\u65e5\u5fd7\u5931\u8d25\uff0c\u9700\u8981\u56de\u6eda\u6574\u4e2a\u4f18\u60e0\u5238\u64cd\u4f5c\u4e48\uff1f<\/p>\n\n\n\n<p>A\uff1a\u4e0d\u5efa\u8bae\uff0c\u6211\u4eec\u662f\u6ca1\u6709\u56de\u6eda\u7684\u3002\u5982\u679c\u8bf4\u64cd\u4f5c\u8bb0\u5f55\u4fdd\u5b58\u5931\u8d25\uff0c\u5e94\u8be5\u6253\u5370\u5f02\u5e38\u65e5\u5fd7\u4ee5\u53ca\u62a5\u8b66\u3002\u5982\u679c\u8bf4\u5bf9\u64cd\u4f5c\u65e5\u5fd7\u96f6\u5bb9\u5fcd\uff0c\u53ef\u4ee5\u9009\u62e9\u4e8b\u52a1\u3002<\/p>\n\n\n\n<p>Q\uff1a\u64cd\u4f5c\u65e5\u5fd7\u53ef\u4ee5\u5f02\u6b65\u4e48\uff1f<\/p>\n\n\n\n<p>A\uff1a\u89c6\u60c5\u51b5\u800c\u5b9a\uff0c\u5982\u679c\u8bf4\u5e76\u53d1\u91cf\u6bd4\u8f83\u5c0f\uff0c\u53ef\u4ee5\u540c\u6b65\u6267\u884c\u3002\u5982\u679c\u5e76\u53d1\u91cf\u6bd4\u8f83\u5927\uff0c\u5efa\u8bae\u5728 <code>DBLogRecordServiceImpl#record<\/code> \u65b9\u6cd5\u4e2d\u8c03\u7528\u6d88\u606f\u961f\u5217\u5f02\u6b65\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u25aa\u7b2c09\u5c0f\u8282\uff1a\u57fa\u4e8e\u6ce8\u89e3\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u9632\u91cd\u590d\u63d0\u4ea4<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e1a\u52a1\u80cc\u666f<\/h2>\n\n\n\n<p>\u5546\u5bb6\u7528\u6237\u5728\u4f18\u60e0\u5238\u7ba1\u7406\u7cfb\u7edf\u4e2d\uff0c\u70b9\u51fb\u201c\u521b\u5efa\u4f18\u60e0\u5238\u201d\u6309\u94ae\u6765\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u4f18\u60e0\u5238\u3002\u8fd9\u4e2a\u64cd\u4f5c\u901a\u5e38\u662f\u5728\u4e00\u4e2a\u8868\u5355\u63d0\u4ea4\u9875\u9762\u4e0a\u5b8c\u6210\u7684\u3002\u5546\u5bb6\u586b\u5199\u4e86\u5fc5\u8981\u7684\u4fe1\u606f\uff08\u5982\u4f18\u60e0\u5238\u540d\u79f0\u3001\u91d1\u989d\u3001\u6709\u6548\u671f\u7b49\uff09\uff0c\u7136\u540e\u70b9\u51fb\u4e86\u521b\u5efa\u6309\u94ae\uff0c\u540e\u7aef\u7cfb\u7edf\u80fd\u591f\u751f\u6210\u5e76\u4fdd\u5b58\u8fd9\u4e2a\u4f18\u60e0\u5238\u3002<\/p>\n\n\n\n<p>\u5728\u7528\u6237\u70b9\u51fb\u201c\u521b\u5efa\u4f18\u60e0\u5238\u201d\u6309\u94ae\u540e\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u91cd\u590d\u63d0\u4ea4\u7684\u95ee\u9898\u3002\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7f51\u7edc\u5ef6\u8fdf<\/strong>\uff1a\u7528\u6237\u7684\u7f51\u7edc\u8fde\u63a5\u53ef\u80fd\u6709\u5ef6\u8fdf\uff0c\u6216\u8005\u7528\u6237\u65e0\u610f\u4e2d\u5237\u65b0\u4e86\u9875\u9762\uff0c\u5bfc\u81f4\u6309\u94ae\u88ab\u70b9\u51fb\u591a\u6b21\uff0c\u7cfb\u7edf\u63a5\u6536\u5230\u591a\u4e2a\u76f8\u540c\u7684\u8bf7\u6c42\u3002<\/li>\n\n\n\n<li><strong>\u6309\u94ae\u672a\u7981\u7528<\/strong>\uff1a\u524d\u7aef\u9875\u9762\u4e2d\u7684\u6309\u94ae\u5728\u7528\u6237\u70b9\u51fb\u540e\u6ca1\u6709\u53ca\u65f6\u7981\u7528\uff0c\u5bfc\u81f4\u7528\u6237\u53ef\u4ee5\u591a\u6b21\u70b9\u51fb\uff0c\u4ece\u800c\u53d1\u8d77\u591a\u4e2a\u521b\u5efa\u8bf7\u6c42\u3002<\/li>\n\n\n\n<li><strong>\u7cfb\u7edf\u5904\u7406\u5ef6\u8fdf<\/strong>\uff1a\u7cfb\u7edf\u5728\u5904\u7406\u8bf7\u6c42\u65f6\u53ef\u80fd\u51fa\u73b0\u5ef6\u8fdf\uff0c\u7528\u6237\u8bef\u4ee5\u4e3a\u8bf7\u6c42\u6ca1\u6709\u6210\u529f\uff0c\u4ece\u800c\u91cd\u590d\u63d0\u4ea4\u76f8\u540c\u7684\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"375\" width=\"1030\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/0b5da9e8c12cd26079409867e7fa8bc3.png\" alt=\"\"><\/p>\n\n\n\n<p>\u4e3a\u6b64\uff0c\u6211\u4eec\u9700\u8981\u5728\u540e\u7aef\u7cfb\u7edf\u4e2d\u9632\u91cd\u590d\u63d0\u4ea4\u7684\u903b\u8f91\u89e3\u51b3\u53ef\u80fd\u51fa\u73b0\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u4ece\u4ea4\u4e92\u4e0a\u6765\u8bf4\uff0c\u53ef\u4ee5\u628a\u524d\u7aef\u6309\u94ae\u7981\u7528\u5148\u5b8c\u6210\uff0c\u7136\u540e\u624d\u662f\u540e\u7aef\u5de5\u7a0b\u7f16\u7801\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"git\">Git \u5206\u652f<\/h2>\n\n\n\n<p>20240817_dev_no-duplicate-submit_lock_ding.ma<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u901a\u8fc7\u5206\u5e03\u5f0f\u9501\u9632\u91cd\u590d\u63d0\u4ea4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u80fd\u4e0d\u80fd\u7528\u672c\u5730\u9501\uff1f<\/h3>\n\n\n\n<p>\u5e38\u89c1\u7684\u672c\u5730\u9501\u6709\u4e24\u79cd\uff1a<code>synchronized<\/code> \u548c <code>ReentrantLock<\/code>\u3002<\/p>\n\n\n\n<p><code>synchronized<\/code> \u662f Java \u4e2d\u7684\u4e00\u79cd\u5185\u7f6e\u9501\u673a\u5236\uff0c\u7528\u4e8e\u5728\u4ee3\u7801\u5757\u6216\u65b9\u6cd5\u4e0a\u5b9e\u73b0\u7ebf\u7a0b\u540c\u6b65\u3002<\/p>\n\n\n\n<p><code>public synchronized void synchronizedMethod() { &nbsp; &nbsp;\/\/ \u7ebf\u7a0b\u5b89\u5168\u7684\u4ee3\u7801 }<\/code><\/p>\n\n\n\n<p><code>ReentrantLock<\/code> \u662f <code>java.util.concurrent.locks<\/code> \u5305\u4e0b\u7684\u9501\u5b9e\u73b0\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u63a7\u5236\u548c\u7075\u6d3b\u6027\u3002<\/p>\n\n\n\n<p><code>private final ReentrantLock lock = new ReentrantLock(); \u200b public void method() { &nbsp; &nbsp;lock.lock(); \/\/ \u52a0\u9501 &nbsp; &nbsp;try { &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u7ebf\u7a0b\u5b89\u5168\u7684\u4ee3\u7801 &nbsp; } finally { &nbsp; &nbsp; &nbsp; &nbsp;lock.unlock(); \/\/ \u89e3\u9501\uff0c\u786e\u4fdd\u5728\u6700\u7ec8\u5757\u4e2d\u91ca\u653e\u9501 &nbsp; } }<\/code><\/p>\n\n\n\n<p>\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528\u672c\u5730\u9501\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8303\u56f4\u6709\u9650<\/strong>\uff1a\u672c\u5730\u9501\u4ec5\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5355\u4e2a\u5b9e\u4f8b\u4e2d\u6709\u6548\u3002\u5982\u679c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u5728\u591a\u53f0\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\uff08\u5373\u5206\u5e03\u5f0f\u73af\u5883\uff09\uff0c\u6bcf\u4e2a\u5b9e\u4f8b\u7684\u672c\u5730\u9501\u76f8\u4e92\u72ec\u7acb\uff0c\u65e0\u6cd5\u5728\u96c6\u7fa4\u4e2d\u5171\u4eab\u9501\u72b6\u6001\u3002<\/li>\n\n\n\n<li><strong>\u7ade\u4e89\u6761\u4ef6<\/strong>\uff1a\u4e0d\u540c\u5b9e\u4f8b\u4e0a\u7684\u672c\u5730\u9501\u65e0\u6cd5\u76f8\u4e92\u611f\u77e5\uff0c\u8fd9\u610f\u5473\u7740\u591a\u4e2a\u5b9e\u4f8b\u53ef\u80fd\u540c\u65f6\u8ba4\u4e3a\u81ea\u5df1\u83b7\u5f97\u4e86\u9501\uff0c\u4ece\u800c\u5bfc\u81f4\u5e76\u53d1\u51b2\u7a81\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u800c\u4e14\uff0c\u4e0a\u9762\u9501\u5b9a\u7684\u8bdd\uff0c\u5355\u4e2a\u5b9e\u4f8b\u91cc\u7684\u903b\u8f91\u5c31\u53d8\u6210\u4e32\u884c\u4e86\u3002\u5982\u679c\u60f3\u8ba9\u4e0d\u540c\u7684\u7528\u6237\u3001\u4e0d\u540c\u7684\u53c2\u6570\u5e76\u884c\u6267\u884c\uff0c\u8fd8\u9700\u8981\u989d\u5916\u4ee3\u7801\u63a7\u5236\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u4ec0\u4e48\u662f\u5206\u5e03\u5f0f\u9501\uff1f<\/h3>\n\n\n\n<p>\u5206\u5e03\u5f0f\u9501\u662f\u4e00\u79cd\u7528\u4e8e\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u534f\u8c03\u591a\u4e2a\u8282\u70b9\u5bf9\u5171\u4eab\u8d44\u6e90\u7684\u8bbf\u95ee\u7684\u673a\u5236\u3002\u5b83\u786e\u4fdd\u5728\u591a\u4e2a\u8282\u70b9\u5e76\u53d1\u8bbf\u95ee\u65f6\uff0c\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\u53ef\u4ee5\u5728\u67d0\u4e2a\u65f6\u523b\u62e5\u6709\u7279\u5b9a\u8d44\u6e90\u7684\u8bbf\u95ee\u6743\uff0c\u4ece\u800c\u907f\u514d\u6570\u636e\u4e0d\u4e00\u81f4\u3001\u7ade\u4e89\u6761\u4ef6\u6216\u8d44\u6e90\u51b2\u7a81\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u76ee\u524d\u5e02\u573a\u4e3b\u8981\u662f\u4ee5 Redis \u5b9e\u73b0\u7684\u5206\u5e03\u5f0f\u9501\u4e3a\u4e3b\uff0c\u5176\u4e2d Redisson \u8fd9\u4e2a\u5de5\u5177\u5305\u4e2d\u7684\u5206\u5e03\u5f0f\u9501\u529f\u80fd\u7528\u7684\u8f83\u591a\u3002<\/p>\n\n\n\n<p>\u5206\u5e03\u5f0f\u9501\u6bd4\u8f83\u5173\u952e\u7684\u4e00\u4e2a\u6982\u5ff5\u5c31\u662f\u5206\u5e03\u5f0f\u9501 Key\uff0c\u8fd9\u4e2a\u5e94\u8be5\u5982\u4f55\u5b9a\u4e49\uff1f\u6211\u4eec\u7531\u4ee5\u4e0b\u51e0\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5206\u5e03\u5f0f\u9501\u524d\u7f00\u3002<\/li>\n\n\n\n<li>\u8bf7\u6c42\u8def\u5f84\u3002<\/li>\n\n\n\n<li>\u5f53\u524d\u8bbf\u95ee\u7528\u6237\u3002<\/li>\n\n\n\n<li>\u53c2\u6570 MD5\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p><code>private final RedissonClient redissonClient; \u200b @Override public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;\/\/ \u83b7\u53d6\u5206\u5e03\u5f0f\u9501\u6807\u8bc6 &nbsp; &nbsp;String lockKey = String.format(\"no-duplicate-submit:path:%s:currentUserId:%s:md5:%s\", getServletPath(), getCurrentUserId(), calcArgsMD5(requestParam)); &nbsp; &nbsp;RLock lock = redissonClient.getLock(lockKey); \u200b &nbsp; &nbsp;\/\/ \u5c1d\u8bd5\u83b7\u53d6\u9501\uff0c\u83b7\u53d6\u9501\u5931\u8d25\u5c31\u610f\u5473\u7740\u5df2\u7ecf\u91cd\u590d\u63d0\u4ea4\uff0c\u76f4\u63a5\u629b\u51fa\u5f02\u5e38 &nbsp; &nbsp;if (!lock.tryLock()) { &nbsp; &nbsp; &nbsp; &nbsp;throw new ClientException(\"\u8bf7\u52ff\u77ed\u65f6\u95f4\u5185\u91cd\u590d\u63d0\u4ea4\u4f18\u60e0\u5238\u6a21\u677f\"); &nbsp; } \u200b &nbsp; &nbsp;try { &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u6267\u884c\u5e38\u89c4\u4e1a\u52a1\u4ee3\u7801 &nbsp; &nbsp; &nbsp; &nbsp;\/\/ ...... &nbsp; } finally { &nbsp; &nbsp; &nbsp; &nbsp;lock.unlock(); &nbsp; } } \u200b \/** * @return \u83b7\u53d6\u5f53\u524d\u7ebf\u7a0b\u4e0a\u4e0b\u6587 ServletPath *\/ private String getServletPath() { &nbsp; &nbsp;ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); &nbsp; &nbsp;return sra.getRequest().getServletPath(); } \u200b \/** * @return \u5f53\u524d\u64cd\u4f5c\u7528\u6237 ID *\/ private String getCurrentUserId() { &nbsp; &nbsp;\/\/ \u7528\u6237\u5c5e\u4e8e\u975e\u6838\u5fc3\u529f\u80fd\uff0c\u8fd9\u91cc\u5148\u901a\u8fc7\u6a21\u62df\u7684\u5f62\u5f0f\u4ee3\u66ff\u3002\u540e\u7eed\u5982\u679c\u9700\u8981\u540e\u7ba1\u5c55\u793a\uff0c\u4f1a\u91cd\u6784\u8be5\u4ee3\u7801 &nbsp; &nbsp;return \"1810518709471555585\"; } \u200b \/** * @return joinPoint md5 *\/ private String calcArgsMD5(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;return DigestUtil.md5Hex(JSON.toJSONBytes(requestParam)); }<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-jmeter\">3. Jmeter \u538b\u529b\u6d4b\u8bd5<\/h3>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 Jmeter \u538b\u6d4b\u4e0b\u8bd5\u8bd5\u770b\u80fd\u4e0d\u80fd\u9632\u6b62\u91cd\u590d\u63d0\u4ea4\u5462\uff1f<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u6ce8\u610f\u4e0d\u8981\u7528 Chrome \u5f00\u591a\u4e2a\u9875\u9762\u8bbf\u95ee\uff0cChrome \u8bbf\u95ee\u662f\u5355\u7ebf\u7a0b\u7684\uff0c\u4e0a\u4e00\u4e2a\u8bf7\u6c42\u4e0d\u8fd4\u56de\uff0c\u4e0b\u4e00\u4e2a\u4e0d\u6267\u884c\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<p>\u56e0\u4e3a\u6267\u884c\u903b\u8f91\u592a\u5feb\u4e86\uff0c\u53ef\u80fd\u538b\u529b\u6d4b\u8bd5\u6ca1\u529e\u6cd5\u987a\u65f6\u89e6\u53d1\uff0c\u6211\u4eec\u53ef\u4ee5\u6dfb\u52a0\u7761\u7720\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p><code>@Override public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;\/\/ \u83b7\u53d6\u5206\u5e03\u5f0f\u9501\u6807\u8bc6 &nbsp; &nbsp;String lockKey = String.format(\"no-duplicate-submit:path:%s:currentUserId:%s:md5:%s\", getServletPath(), getCurrentUserId(), calcArgsMD5(requestParam)); &nbsp; &nbsp;RLock lock = redissonClient.getLock(lockKey); \u200b &nbsp; &nbsp;\/\/ \u5c1d\u8bd5\u83b7\u53d6\u9501\uff0c\u83b7\u53d6\u9501\u5931\u8d25\u5c31\u610f\u5473\u7740\u5df2\u7ecf\u91cd\u590d\u63d0\u4ea4\uff0c\u76f4\u63a5\u629b\u51fa\u5f02\u5e38 &nbsp; &nbsp;if (!lock.tryLock()) { &nbsp; &nbsp; &nbsp; &nbsp;throw new ClientException(\"\u8bf7\u52ff\u77ed\u65f6\u95f4\u5185\u91cd\u590d\u63d0\u4ea4\u4f18\u60e0\u5238\u6a21\u677f\"); &nbsp; } \u200b &nbsp; &nbsp;try { &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u7761\u7720 2 \u79d2 &nbsp; &nbsp; &nbsp; &nbsp;Thread.sleep(2000); &nbsp; } catch (InterruptedException e) { &nbsp; &nbsp; &nbsp; &nbsp;throw new RuntimeException(e); &nbsp; } \u200b &nbsp; &nbsp;try { &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u6267\u884c\u5e38\u89c4\u4e1a\u52a1\u4ee3\u7801 &nbsp; &nbsp; &nbsp; &nbsp;\/\/ ...... &nbsp; } finally { &nbsp; &nbsp; &nbsp; &nbsp;lock.unlock(); &nbsp; } }<\/code><\/p>\n\n\n\n<p>\u540c\u65f6\u542f\u52a8 20 \u4e2a\u7ebf\u7a0b\u6267\u884c\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\u63a5\u53e3\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"292\" width=\"616\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/230723cbbb42fadbbf514c687057825f.png\" alt=\"\"><\/p>\n\n\n\n<p>\u901a\u8fc7 Jmeter \u538b\u6d4b\u5f97\u77e5\uff1a<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1786\" width=\"2764\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/6bcd4372071965d4e87c6163fd14f85f.png\" alt=\"\"><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u4e3a\u4ec0\u4e48\u9519\u8bef\u7684\u8bf7\u6c42\u524d\u9762\u56fe\u6807\u8fd8\u662f\u7eff\u7684\uff1f\u56e0\u4e3a HTTP \u8fd4\u56de\u7801\u662f 200\uff0c\u53ea\u662f\u5728\u8fd4\u56de\u4f53\u91cc\u505a\u4e86\u5f02\u5e38\u6807\u8bc6\u3002<\/em><\/p>\n<\/blockquote>\n\n\n\n<p>\u901a\u8fc7\u8fd9\u4e2a\u4ee3\u7801\u53ef\u4ee5\u89e3\u51b3\u6211\u4eec\u7684\u4f18\u60e0\u5238\u9632\u91cd\u590d\u63d0\u4ea4\u95ee\u9898\u3002\u867d\u7136\u4e1a\u52a1\u95ee\u9898\u89e3\u51b3\u4e86\uff0c\u4f46\u662f\u9047\u5230\u4e86\u548c\u4e0a\u4e00\u8282\u64cd\u4f5c\u65e5\u5fd7\u8bb0\u5f55\u4e00\u6837\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f53\u4e1a\u52a1\u53d8\u5f97\u590d\u6742\u540e\uff0c\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7\u653e\u5728\u4e1a\u52a1\u4ee3\u7801\u4e2d\u4f1a\u5bfc\u81f4\u4e1a\u52a1\u7684\u903b\u8f91\u6bd4\u8f83\u7e41\u7410\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u6765\u8bf4\u662f\u4e00\u4e2a\u707e\u96be\uff0c\u56e0\u4e3a\u4e0d\u6b62\u8fd9\u4e00\u5904\u4f7f\u7528\uff0c\u5b58\u5728\u5927\u91cf\u7684\u5197\u4f59\u4ee3\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4e0a\u4e00\u8282\u4f7f\u7528 SpringAOP\u3001SpEL \u4ee5\u53ca\u73b0\u6210\u6846\u67b6\u89e3\u51b3\u7684\u4f18\u96c5\u8bb0\u5f55\u64cd\u4f5c\u65e5\u5fd7\uff0c\u8fd9\u6b21\u6211\u4eec\u81ea\u5df1\u901a\u8fc7 SpringAOP\u3001\u6ce8\u89e3\u548c\u5206\u5e03\u5f0f\u9501\u5b9e\u73b0\u4e00\u4e2a\u901a\u7528\u7ec4\u4ef6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5e93<\/h2>\n\n\n\n<p>\u5982\u679c\u5e38\u89c4\u6765\u8bf4\uff0c\u6211\u4eec\u4f1a\u6309\u7167 12306 \u7684\u7ec4\u4ef6\u5b9a\u4e49\u683c\u5f0f\uff0c\u6bcf\u4e2a\u529f\u80fd\u5b9e\u73b0\u4e00\u4e2a\u7ec4\u4ef6\u5e93\uff0c\u4e3a\u4e86\u907f\u514d\u5927\u5bb6\u4ece\u96f6\u5230\u4e00\u5b9e\u73b0\u7684\u7f16\u7801\u56f0\u96be\u5ea6\uff0c\u9009\u62e9\u5199\u5165 <code>framework<\/code> \u6a21\u5757\u4e2d\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1428\" width=\"2480\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/d15f00795d37164d5c3d2dbd4bd22676.png\" alt=\"\"><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>12306 \u5b66\u4e60\u5730\u5740\uff1a<a href=\"https:\/\/gitee.com\/nageoffer\/12306\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/gitee.com\/nageoffer\/12306<\/a><\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1\">1. \u81ea\u5b9a\u4e49\u6ce8\u89e3<\/h3>\n\n\n\n<p>\u5f88\u591a\u540c\u5b66\u6ca1\u6709\u521b\u5efa\u8fc7\u6ce8\u89e3\uff0c\u548c\u5e73\u5e38\u521b\u5efa\u7c7b\u4e00\u76f4\uff0c\u9009\u62e9 <code>Annotation<\/code> \u5373\u53ef\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"408\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/303d9b0c6dabf73caf4506bbdda59f9c.png\" width=\"746\">\u200b<img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:https:\/\/eve2333.top\/413c6846-79fc-402d-adab-a2cf7e6b9a4f\" width=\"15\">\u7f16\u8f91<\/p>\n\n\n\n<p>\u81ea\u5b9a\u4e49 Java \u6ce8\u89e3\uff0c\u6211\u4eec\u53d6\u540d <code>@NoDuplicateSubmit<\/code> \u9632\u6b62\u91cd\u590d\u63d0\u4ea4\u3002<\/p>\n\n\n\n<p><code>package com.nageoffer.onecoupon.framework.idempotent; \u200b import java.lang.annotation.ElementType; import java.lang.annotation.Target; \u200b \/** * \u5e42\u7b49\u6ce8\u89e3\uff0c\u9632\u6b62\u7528\u6237\u91cd\u590d\u63d0\u4ea4\u8868\u5355\u4fe1\u606f * &lt;p&gt; * \u4f5c\u8005\uff1a\u9a6c\u4e01 * \u52a0\u9879\u76ee\u7fa4\uff1a\u65e9\u52a0\u5165\u5c31\u662f\u4f18\u52bf\uff01500\u4eba\u5185\u90e8\u9879\u76ee\u7fa4\uff0c\u5206\u4eab\u7684\u77e5\u8bc6\u603b\u6709\u4f60\u9700\u8981\u7684 &lt;a href=\"https:\/\/t.zsxq.com\/cw7b9\" \/&gt; * \u5f00\u53d1\u65f6\u95f4\uff1a2024-07-10 *\/ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface NoDuplicateSubmit { \u200b &nbsp; &nbsp;\/** &nbsp; &nbsp; * \u89e6\u53d1\u5e42\u7b49\u5931\u8d25\u903b\u8f91\u65f6\uff0c\u8fd4\u56de\u7684\u9519\u8bef\u63d0\u793a\u4fe1\u606f &nbsp; &nbsp; *\/ &nbsp; &nbsp;String message() default \"\u60a8\u64cd\u4f5c\u592a\u5feb\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\"; }<\/code><\/p>\n\n\n\n<p>\u81ea\u5b9a\u4e49\u6ce8\u89e3\u4e0a\u8fd8\u6709\u4e24\u4e2a\u6ce8\u89e3\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>@Target(ElementType.METHOD) \u610f\u5473\u7740\u53ea\u80fd\u5728\u65b9\u6cd5\u4e0a\u4f7f\u7528\u3002<\/li>\n\n\n\n<li>@Retention(RetentionPolicy.RUNTIME) \u610f\u5473\u7740\u53ef\u4ee5\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u6ce8\u89e3\u5185\u7684\u4fe1\u606f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5b9a\u4e49\u7684 message \u5c5e\u6027\u53ef\u4ee5\u8ba9\u5927\u5bb6\u5728\u4f7f\u7528\u7684\u65f6\u5019\u81ea\u5b9a\u4e49\u9519\u8bef\u63d0\u793a\u4fe1\u606f\uff0c\u4e00\u4e2a\u5c0f\u4f18\u5316\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-spring-aop\">2. \u81ea\u5b9a\u4e49 SpringAOP \u5207\u9762<\/h3>\n\n\n\n<p>\u901a\u8fc7 SpringAOP \u73af\u7ed5\u901a\u77e5\u5bf9\u65b9\u6cd5\u589e\u5f3a\uff0c\u64cd\u4f5c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"427\" width=\"579\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/507bf9bc782ef0f821a7c48d616cec9f.png\" alt=\"\"><\/p>\n\n\n\n<p><code>framework<\/code> \u6a21\u5757 Pom.xml \u6587\u4ef6\u6dfb\u52a0 AOP \u7684\u4f9d\u8d56\u914d\u7f6e\u3002<\/p>\n\n\n\n<p><code>&lt;dependency&gt; &nbsp; &nbsp;&lt;groupId&gt;org.aspectj&lt;\/groupId&gt; &nbsp; &nbsp;&lt;artifactId&gt;aspectjweaver&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/p>\n\n\n\n<p>\u9632\u91cd\u590d\u63d0\u4ea4 AOP \u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n@Aspect\n@RequiredArgsConstructor\npublic final class NoDuplicateSubmitAspect {\n\n    private final RedissonClient redissonClient;\n\n    \/**\n     * \u589e\u5f3a\u65b9\u6cd5\u6807\u8bb0 {@link NoDuplicateSubmit} \u6ce8\u89e3\u903b\u8f91\n     *\/\n    @Around(\"@annotation(com.nageoffer.onecoupon.framework.idempotent.NoDuplicateSubmit)\")\n    public Object noDuplicateSubmit(ProceedingJoinPoint joinPoint) throws Throwable {\n        NoDuplicateSubmit noDuplicateSubmit = getNoDuplicateSubmitAnnotation(joinPoint);\n        \/\/ \u83b7\u53d6\u5206\u5e03\u5f0f\u9501\u6807\u8bc6\n        String lockKey = String.format(\"no-duplicate-submit:path:%s:currentUserId:%s:md5:%s\", getServletPath(), getCurrentUserId(), calcArgsMD5(joinPoint));\n        RLock lock = redissonClient.getLock(lockKey);\n        \/\/ \u5c1d\u8bd5\u83b7\u53d6\u9501\uff0c\u83b7\u53d6\u9501\u5931\u8d25\u5c31\u610f\u5473\u7740\u5df2\u7ecf\u91cd\u590d\u63d0\u4ea4\uff0c\u76f4\u63a5\u629b\u51fa\u5f02\u5e38\n        if (!lock.tryLock()) {\n            throw new ClientException(noDuplicateSubmit.message());\n        }\n        Object result;\n        try {\n            \/\/ \u6267\u884c\u6807\u8bb0\u4e86\u9632\u91cd\u590d\u63d0\u4ea4\u6ce8\u89e3\u7684\u65b9\u6cd5\u539f\u903b\u8f91\n            result = joinPoint.proceed();\n        } finally {\n            lock.unlock();\n        }\n        return result;\n    }\n\n    \/**\n     * @return \u8fd4\u56de\u81ea\u5b9a\u4e49\u9632\u91cd\u590d\u63d0\u4ea4\u6ce8\u89e3\n     *\/\n    public static NoDuplicateSubmit getNoDuplicateSubmitAnnotation(ProceedingJoinPoint joinPoint) throws NoSuchMethodException {\n        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();\n        Method targetMethod = joinPoint.getTarget().getClass().getDeclaredMethod(methodSignature.getName(), methodSignature.getMethod().getParameterTypes());\n        return targetMethod.getAnnotation(NoDuplicateSubmit.class);\n    }\n\n    \/**\n     * @return \u83b7\u53d6\u5f53\u524d\u7ebf\u7a0b\u4e0a\u4e0b\u6587 ServletPath\n     *\/\n    private String getServletPath() {\n        ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();\n        return sra.getRequest().getServletPath();\n    }\n\n    \/**\n     * @return \u5f53\u524d\u64cd\u4f5c\u7528\u6237 ID\n     *\/\n    private String getCurrentUserId() {\n        \/\/ \u7528\u6237\u5c5e\u4e8e\u975e\u6838\u5fc3\u529f\u80fd\uff0c\u8fd9\u91cc\u5148\u901a\u8fc7\u6a21\u62df\u7684\u5f62\u5f0f\u4ee3\u66ff\u3002\u540e\u7eed\u5982\u679c\u9700\u8981\u540e\u7ba1\u5c55\u793a\uff0c\u4f1a\u91cd\u6784\u8be5\u4ee3\u7801\n        return \"1810518709471555585\";\n    }\n\n    \/**\n     * @return joinPoint md5\n     *\/\n    private String calcArgsMD5(ProceedingJoinPoint joinPoint) {\n        return DigestUtil.md5Hex(JSON.toJSONBytes(joinPoint.getArgs()));\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u5e42\u7b49\u81ea\u52a8\u88c5\u914d\u7c7b<\/h3>\n\n\n\n<p>\u4e4b\u524d\u8bb2\u8fc7\uff0cStarter \u7ec4\u4ef6\u5e93\u91cc\u4e0d\u80fd\u901a\u8fc7\u7c7b\u4e0a\u52a0\u6ce8\u89e3\u6210\u4e3a Bean\uff0c\u6211\u4eec\u521b\u5efa\u5e42\u7b49\u81ea\u52a8\u88c5\u914d\u7c7b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.nageoffer.onecoupon.framework.config;\n\nimport com.nageoffer.onecoupon.framework.idempotent.NoDuplicateSubmitAspect;\nimport org.redisson.api.RedissonClient;\nimport org.springframework.context.annotation.Bean;\n\n\/**\n * \u5e42\u7b49\u7ec4\u4ef6\u76f8\u5173\u914d\u7f6e\u7c7b\n *\/\npublic class IdempotentConfiguration {\n\n    \/**\n     * \u9632\u6b62\u7528\u6237\u91cd\u590d\u63d0\u4ea4\u8868\u5355\u4fe1\u606f\u5207\u9762\u63a7\u5236\u5668\n     *\/\n    @Bean\n    public NoDuplicateSubmitAspect noDuplicateSubmitAspect(RedissonClient redissonClient) {\n        return new NoDuplicateSubmitAspect(redissonClient);\n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4\">4. \u914d\u7f6e\u81ea\u52a8\u53d1\u73b0<\/h3>\n\n\n\n<p>\u5728 <code>META-INF\/spring\/org.springframework.boot.autoconfigure.AutoConfiguration.imports<\/code> \u8ffd\u52a0\u5e42\u7b49\u81ea\u52a8\u88c5\u914d\u5168\u9650\u5b9a\u8def\u5f84\u3002<\/p>\n\n\n\n<p><code>com.nageoffer.onecoupon.framework.config.WebAutoConfiguration com.nageoffer.onecoupon.framework.config.IdempotentConfiguration<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5\">5. \u63a7\u5236\u5c42\u5f15\u5165\u6ce8\u89e3<\/h3>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u628a Service \u4e1a\u52a1\u65b9\u6cd5\u91cc\u7684\u5206\u5e03\u5f0f\u9501\u7b49\u548c\u4e1a\u52a1\u65e0\u5173\u7684\u4ee3\u7801\u5168\u90e8\u5220\u9664\uff0c\u4ec5\u5728 Controller \u4e0a\u6dfb\u52a0 <code>@NoDuplicateSubmit<\/code> \u6ce8\u89e3\u5373\u53ef\u5b8c\u6210\u9632\u91cd\u590d\u63d0\u4ea4\u529f\u80fd\u3002<\/p>\n\n\n\n<p><code>@NoDuplicateSubmit @Operation(summary = \"\u5546\u5bb6\u521b\u5efa\u4f18\u60e0\u5238\u6a21\u677f\") @PostMapping(\"\/api\/merchant-admin\/coupon-template\/create\") public Result&lt;Void&gt; createCouponTemplate(@RequestBody CouponTemplateSaveReqDTO requestParam) { &nbsp; &nbsp;couponTemplateService.createCouponTemplate(requestParam); &nbsp; &nbsp;return Results.success(); }<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5e76\u53d1\u5355\u5143\u6d4b\u8bd5<\/h2>\n\n\n\n<p>\u6211\u4eec\u901a\u8fc7\u5e76\u53d1\u7f16\u7a0b\u5355\u5143\u6d4b\u8bd5\u6a21\u62df\u7528\u6237\u9632\u91cd\u590d\u63d0\u4ea4\u6d41\u7a0b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.nageoffer.onecoupon.merchant.admin.template.lock;\u200b\nimport com.alibaba.fastjson2.JSON;\nimport com.nageoffer.onecoupon.merchant.admin.controller.CouponTemplateController;\nimport com.nageoffer.onecoupon.merchant.admin.dto.req.CouponTemplateSaveReqDTO;\nimport lombok.SneakyThrows;\nimport lombok.extern.slf4j.Slf4j;\nimport org.junit.jupiter.api.Test;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.test.context.SpringBootTest;\nimport org.springframework.mock.web.MockHttpServletRequest;\nimport org.springframework.web.context.request.RequestContextHolder;\nimport org.springframework.web.context.request.ServletRequestAttributes;\u200b\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\u200b \/** * \u4f18\u60e0\u5238\u6a21\u677f\u9632\u91cd\u590d\u63d0\u4ea4\u6d4b\u8bd5 *\/\n@Slf4j @SpringBootTest public class CouponTemplateCreateDuplicateSubmitTests {\n    \u200b\n    @Autowired private CouponTemplateController couponTemplateController;\u200b\n    @SneakyThrows @Test public void testDuplicateSubmit() {\n            ExecutorService executorService = Executors.newFixedThreadPool(10);\n            String paramJSONStr = \"\"\n            \" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            name \": \"\n            \u7528\u6237\u4e0b\u5355\u6ee110\u51cf3\u7279\u5927\u4f18\u60e0 \", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            source \": 0, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            target \": 1, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            goods \": \"\n            \", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            type \": 0, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            validStartTime \": \"\n            2024 - 07 - 08 12: 00: 00 \", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            validEndTime \": \"\n            2024 - 08 - 17 12: 00: 00 \", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            stock \": 20990, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            receiveRule \": \" {\n                \\\\\n                \"limitPerPerson\\\\\": 10,\n                \\\\\"usageInstructions\\\\\": \\\\ \"3\\\\\"\n            }\n            \", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            consumeRule \": \" {\n                \\\\\n                \"termsOfUse\\\\\": 10,\n                \\\\\"maximumDiscountAmount\\\\\": 3,\n                \\\\\"explanationOfUnmetConditions\\\\\": \\\\ \"3\\\\\",\n                \\\\\"validityPeriod\\\\\": \\\\ \"48\\\\\"\n            }\n            \" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\n            \"\";\u200b\n            MockHttpServletRequest request = new MockHttpServletRequest();\n            ServletRequestAttributes attributes = new ServletRequestAttributes(request);\u200b\n            for (int i = 0; i &lt; 10; i++) {\n                executorService.execute(() -&gt; {\n                            RequestContextHolder.setRequestAttributes(attributes); \/\/ \u5c06 ServletRequestAttributes \u7ed1\u5b9a\u5230\u5f53\u524d\u7ebf\u7a0b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;couponTemplateController.createCouponTemplate(JSON.parseObject(paramJSONStr, CouponTemplateSaveReqDTO.class)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception ex) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;log.error(\"\u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u5f02\u5e38\", ex); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } finally { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RequestContextHolder.resetRequestAttributes(); \/\/ \u786e\u4fdd\u5f53\u524d\u7ebf\u7a0b\u4e2d\u7684 RequestAttributes \u88ab\u6e05\u9664 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp;executorService.shutdown(); &nbsp; &nbsp; &nbsp; &nbsp;while (!executorService.isTerminated()) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Thread.sleep(1000); &nbsp; &nbsp; &nbsp; } &nbsp; } }<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u4f7f\u7528\u4e86\u661f\u7403\u516c\u6709\u4e91\u4e2d\u95f4\u4ef6\uff0c\u5927\u5bb6\u76f4\u63a5\u542f\u52a8\u4e0a\u9762\u7684\u7a0b\u5e8f\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a\u6d4b\u8bd5\u7528\u4f8b\u6ca1\u529e\u6cd5\u76f4\u63a5\u5173\u8054\u4e91\u4e2d\u95f4\u4ef6\u5730\u5740\uff0c\u800c\u662f\u8981\u5355\u72ec\u628a\u76f8\u5173 VM \u914d\u7f6e\u518d\u590d\u5236\u4e00\u4efd\u5230 <code>-ea<\/code> \u7684\u540e\u9762\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1518\" width=\"2178\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/82bc2f8c53a856d20a8a22eb8989b113.png\" alt=\"image-20250607110731832.png\"><\/p>\n\n\n\n<p>\u4e0d\u8d1f\u4f17\u671b\uff0c\u6700\u7ec8\u8fd8\u662f\u62a5\u9519\u4e86\uff0c\u54c8\u54c8\u3002<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"1940\" width=\"3266\" src=\"https:\/\/i-blog.csdnimg.cn\/img_convert\/3f817a6b9879dbc745e421bc31005262.png\" alt=\"\"><\/p>\n\n\n\n<p>\u5b8c\u7ed3\uff0c\u6492\u82b1 \ud83c\udf89\u3002 \u200b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> \nimport static com.nageoffer.onecoupon.merchant.admin.common.enums.ChainBizMarkEnum.MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY;\n\n\/**\n * \u4f18\u60e0\u5238\u6a21\u677f\u4e1a\u52a1\u903b\u8f91\u5b9e\u73b0\u5c42\n * &lt;p&gt;\n * \u4f5c\u8005\uff1a\u9a6c\u4e01\n * \u52a0\u9879\u76ee\u7fa4\uff1a\u65e9\u52a0\u5165\u5c31\u662f\u4f18\u52bf\uff01500\u4eba\u5185\u90e8\u9879\u76ee\u7fa4\uff0c\u5206\u4eab\u7684\u77e5\u8bc6\u603b\u6709\u4f60\u9700\u8981\u7684 &lt;a href=\"https:\/\/t.zsxq.com\/cw7b9\" \/&gt;\n * \u5f00\u53d1\u65f6\u95f4\uff1a2024-07-08\n *\/\n@Service\n@RequiredArgsConstructor\npublic class CouponTemplateServiceImpl extends ServiceImpl&lt;CouponTemplateMapper, CouponTemplateDO&gt; implements CouponTemplateService {\n\n    private final CouponTemplateMapper couponTemplateMapper;\n    private final MerchantAdminChainContext merchantAdminChainContext;\n    private final StringRedisTemplate stringRedisTemplate;\n\n    @LogRecord(\n            success = \"\"\"\n                    \u521b\u5efa\u4f18\u60e0\u5238\uff1a{{#requestParam.name}}\uff0c \\\n                    \u4f18\u60e0\u5bf9\u8c61\uff1a{COMMON_ENUM_PARSE{'DiscountTargetEnum' + '_' + #requestParam.target}}\uff0c \\\n                    \u4f18\u60e0\u7c7b\u578b\uff1a{COMMON_ENUM_PARSE{'DiscountTypeEnum' + '_' + #requestParam.type}}\uff0c \\\n                    \u5e93\u5b58\u6570\u91cf\uff1a{{#requestParam.stock}}\uff0c \\\n                    \u4f18\u60e0\u5546\u54c1\u7f16\u7801\uff1a{{#requestParam.goods}}\uff0c \\\n                    \u6709\u6548\u671f\u5f00\u59cb\u65f6\u95f4\uff1a{{#requestParam.validStartTime}}\uff0c \\\n                    \u6709\u6548\u671f\u7ed3\u675f\u65f6\u95f4\uff1a{{#requestParam.validEndTime}}\uff0c \\\n                    \u9886\u53d6\u89c4\u5219\uff1a{{#requestParam.receiveRule}}\uff0c \\\n                    \u6d88\u8017\u89c4\u5219\uff1a{{#requestParam.consumeRule}};\n                    \"\"\",\n            type = \"CouponTemplate\",\n            bizNo = \"{{#bizNo}}\",\n            extra = \"{{#requestParam.toString()}}\"\n    )\n    @Override\n    public void createCouponTemplate(CouponTemplateSaveReqDTO requestParam) {\n        \/\/ \u901a\u8fc7\u8d23\u4efb\u94fe\u9a8c\u8bc1\u8bf7\u6c42\u53c2\u6570\u662f\u5426\u6b63\u786e\n        merchantAdminChainContext.handler(MERCHANT_ADMIN_CREATE_COUPON_TEMPLATE_KEY.name(), requestParam);\n\n        \/\/ \u65b0\u589e\u4f18\u60e0\u5238\u6a21\u677f\u4fe1\u606f\u5230\u6570\u636e\u5e93\n        CouponTemplateDO couponTemplateDO = BeanUtil.toBean(requestParam, CouponTemplateDO.class);\n        couponTemplateDO.setStatus(CouponTemplateStatusEnum.ACTIVE.getStatus());\n        couponTemplateDO.setShopNumber(UserContext.getShopNumber());\n        couponTemplateMapper.insert(couponTemplateDO);\n\n        \/\/ \u56e0\u4e3a\u6a21\u677f ID \u662f\u8fd0\u884c\u4e2d\u751f\u6210\u7684\uff0c@LogRecord \u9ed8\u8ba4\u62ff\u4e0d\u5230\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\n        LogRecordContext.putVariable(\"bizNo\", couponTemplateDO.getId());\n\n        \/\/ \u7f13\u5b58\u9884\u70ed\uff1a\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u7684\u8bb0\u5f55\u5e8f\u5217\u5316\u6210 JSON \u5b57\u7b26\u4e32\u653e\u5165 Redis \u7f13\u5b58\n        CouponTemplateQueryRespDTO actualRespDTO = BeanUtil.toBean(couponTemplateDO, CouponTemplateQueryRespDTO.class);\n        Map&lt;String, Object&gt; cacheTargetMap = BeanUtil.beanToMap(actualRespDTO, false, true);\n        Map&lt;String, String&gt; actualCacheTargetMap = cacheTargetMap.entrySet().stream()\n                .collect(Collectors.toMap(\n                        Map.Entry::getKey,\n                        entry -&gt; entry.getValue() != null ? entry.getValue().toString() : \"\"\n                ));\n        String couponTemplateCacheKey = String.format(MerchantAdminRedisConstant.COUPON_TEMPLATE_KEY, couponTemplateDO.getId());\n\n        \/\/ \u901a\u8fc7 LUA \u811a\u672c\u6267\u884c\u8bbe\u7f6e Hash \u6570\u636e\u4ee5\u53ca\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\n        String luaScript = \"redis.call('HMSET', KEYS&#91;1], unpack(ARGV, 1, #ARGV - 1)) \" +\n                \"redis.call('EXPIREAT', KEYS&#91;1], ARGV&#91;#ARGV])\";\n\n        List&lt;String&gt; keys = Collections.singletonList(couponTemplateCacheKey);\n        List&lt;String&gt; args = new ArrayList&lt;&gt;(actualCacheTargetMap.size() * 2 + 1);\n        actualCacheTargetMap.forEach((key, value) -&gt; {\n            args.add(key);\n            args.add(value);\n        });\n\n        \/\/ \u4f18\u60e0\u5238\u6d3b\u52a8\u8fc7\u671f\u65f6\u95f4\u8f6c\u6362\u4e3a\u79d2\u7ea7\u522b\u7684 Unix \u65f6\u95f4\u6233\n        args.add(String.valueOf(couponTemplateDO.getValidEndTime().getTime() \/ 1000));\n\n        \/\/ \u6267\u884c LUA \u811a\u672c\n        stringRedisTemplate.execute(\n                new DefaultRedisScript&lt;&gt;(luaScript, Long.class),\n                keys,\n                args.toArray()\n        );\n    }\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/**\n * \u5e42\u7b49\u6ce8\u89e3\uff0c\u9632\u6b62\u7528\u6237\u91cd\u590d\u63d0\u4ea4\u8868\u5355\u4fe1\u606f\n *\/\n@Target(ElementType.METHOD)\n@Retention(RetentionPolicy.RUNTIME)\npublic @interface NoDuplicateSubmit {\n\n    \/**\n     * \u89e6\u53d1\u5e42\u7b49\u5931\u8d25\u903b\u8f91\u65f6\uff0c\u8fd4\u56de\u7684\u9519\u8bef\u63d0\u793a\u4fe1\u606f\n     *\/\n    String message() default \"\u60a8\u64cd\u4f5c\u592a\u5feb\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\";\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;\u25aa\u7b2c05\u5c0f\u8282\uff1a\u4ece\u96f6\u5230\u4e00\u521b\u5efaSpringBoot\u9879\u76ee&amp;\u521d\u59cb\u5316\u901a\u7528\u914d\u7f6e \u300a\u725b\u5238oneCoupon\u4f18\u60e0\u7cfb\u7edf\u89c6\u9891\u6559\u5b66\u300b &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[3],"tags":[16,20],"class_list":["post-1228","post","type-post","status-publish","format-standard","hentry","category-3","tag-sql","tag-20"],"_links":{"self":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/1228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1228"}],"version-history":[{"count":10,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/1228\/revisions"}],"predecessor-version":[{"id":1288,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/1228\/revisions\/1288"}],"wp:attachment":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}