From 96b4bb0ce6a02617e440c3bdcb6691de865eace3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 26 Feb 2024 22:15:28 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E8=B7=B3=E8=BD=AC=E5=A4=A7?= =?UTF-8?q?=E8=BD=AC=E7=9B=98=E6=A6=82=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Integral/LuckyService.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs new file mode 100644 index 00000000..832e582f --- /dev/null +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs @@ -0,0 +1,56 @@ +using System; +using Microsoft.AspNetCore.Authorization; +using Volo.Abp.Application.Services; +using Volo.Abp.EventBus.Local; +using Yi.Framework.Bbs.Domain.Shared.Etos; + +namespace Yi.Framework.Bbs.Application.Services.Integral +{ + public class LuckyService : ApplicationService + { + private ILocalEventBus _localEventBus; + public LuckyService(ILocalEventBus localEventBus) { _localEventBus = localEventBus; } + + /// + /// 大转盘 + /// + /// + [Authorize] + public async Task PostWheel() + { + int[] values=new int[10] { 0,10,30,50,80,100,150,200,300,666}; + var index = GetWheelIndex(); + var value = values[index]-50; + + //修改钱钱,如果钱钱不足,直接会丢出去,那本次抽奖将无效 + await _localEventBus.PublishAsync(new MoneyChangeEventArgs { UserId = CurrentUser.Id!.Value, Number = value }, false); + + return index; + } + + private int GetWheelIndex() + { + int[] probabilities = { 10, 20, 30, 20, 5, 5, 4, 3, 2, 1 }; + + int total = 0; + foreach (var prob in probabilities) + { + total += prob; + } + + int randomNum = new Random().Next(1, total + 1); + + int cumulativeProb = 0; + for (int i = 0; i < probabilities.Length; i++) + { + cumulativeProb += probabilities[i]; + if (randomNum <= cumulativeProb) + { + return i; + } + } + var value = probabilities.Length - 1; + return value; + } + } +} From 01aa699462a674063ddc4ea3507d6fb8a8b0fa52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 26 Feb 2024 22:23:07 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=A6=82?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Integral/LuckyService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs index 832e582f..3c70252f 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs @@ -30,7 +30,7 @@ namespace Yi.Framework.Bbs.Application.Services.Integral private int GetWheelIndex() { - int[] probabilities = { 10, 20, 30, 20, 5, 5, 4, 3, 2, 1 }; + int[] probabilities = { 20, 20, 30, 30, 5, 3, 2, 2, 2, 1 }; int total = 0; foreach (var prob in probabilities) From de48c64bc9caf77e0aebe2e112792829f8c1e808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 26 Feb 2024 22:28:38 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=B9=B3?= =?UTF-8?q?=E8=A1=A1=E6=A6=82=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Integral/LuckyService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs index 3c70252f..e08728f0 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs @@ -18,7 +18,7 @@ namespace Yi.Framework.Bbs.Application.Services.Integral [Authorize] public async Task PostWheel() { - int[] values=new int[10] { 0,10,30,50,80,100,150,200,300,666}; + int[] values=new int[10] { 0,10,30,50,60,80,90,100,200,666}; var index = GetWheelIndex(); var value = values[index]-50; From 5f4ee6cc6837631b5b81f6cd28facaad5bc22faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 26 Feb 2024 22:28:48 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E6=A6=82?= =?UTF-8?q?=E7=8E=872?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Bbs.Vue3/src/views/lucky/Index.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Yi.Bbs.Vue3/src/views/lucky/Index.vue b/Yi.Bbs.Vue3/src/views/lucky/Index.vue index 42b4daa3..524cc447 100644 --- a/Yi.Bbs.Vue3/src/views/lucky/Index.vue +++ b/Yi.Bbs.Vue3/src/views/lucky/Index.vue @@ -32,11 +32,11 @@ const prizes = [ { fonts: [{ text: '10', top: '10%' }], background: '#b8c5f2' }, { fonts: [{ text: '30', top: '10%' }], background: '#e9e8fe' }, { fonts: [{ text: '50', top: '10%' }], background: '#b8c5f2' }, - { fonts: [{ text: '80', top: '10%' }], background: '#e9e8fe' }, + { fonts: [{ text: '60', top: '10%' }], background: '#e9e8fe' }, + { fonts: [{ text: '80', top: '10%' }], background: '#b8c5f2' }, + { fonts: [{ text: '90', top: '10%' }], background: '#e9e8fe' }, { fonts: [{ text: '100', top: '10%' }], background: '#b8c5f2' }, - { fonts: [{ text: '150', top: '10%' }], background: '#e9e8fe' }, - { fonts: [{ text: '200', top: '10%' }], background: '#b8c5f2' }, - { fonts: [{ text: '300', top: '10%' }], background: '#e9e8fe' }, + { fonts: [{ text: '200', top: '10%' }], background: '#e9e8fe' }, { fonts: [{ text: '666', top: '10%' }], background: '#FAD400' } ]; const buttons = [{ From 8ff472042cdd2d0ce428fb211da5360d785c0ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 26 Feb 2024 22:49:12 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20=E5=B9=B3=E8=A1=A1=E6=A6=82?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Integral/LuckyService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs index e08728f0..778d3132 100644 --- a/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs +++ b/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Application/Services/Integral/LuckyService.cs @@ -30,7 +30,7 @@ namespace Yi.Framework.Bbs.Application.Services.Integral private int GetWheelIndex() { - int[] probabilities = { 20, 20, 30, 30, 5, 3, 2, 2, 2, 1 }; + int[] probabilities = { 30, 40, 30, 20, 5, 3, 2, 2, 2, 1 }; int total = 0; foreach (var prob in probabilities)