From 4de614508a39a62ef2ac0ff4b8cc4ae014c6817e Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 24 Apr 2024 20:27:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?update=20=E6=B4=BB=E8=B7=83=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E8=87=AA=E5=8A=A8=E5=85=91=E6=8D=A2=E6=88=90=E7=BB=BF?= =?UTF-8?q?=E8=89=B2=E8=83=BD=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md/mq.go | 6 +- ...ctivity_coin_auto_exchange_green_energy.go | 151 +++--------------- 2 files changed, 23 insertions(+), 134 deletions(-) diff --git a/md/mq.go b/md/mq.go index c1934aa..ff97bf4 100644 --- a/md/mq.go +++ b/md/mq.go @@ -17,8 +17,10 @@ type OneCirclesStructForSignIn struct { } type OneCirclesStructForAutoExchangeGreenEnergy struct { - MasterId string `json:"master_id"` - Uid int `json:"uid"` + MasterId string `json:"master_id"` + Uid int `json:"uid"` + CoinId int `json:"coin_id"` + AutoExchangeNumsAmount string `json:"auto_exchange_nums_amount"` } type OneCirclesStructForStarLevelDividends struct { MasterId string `json:"master_id"` diff --git a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go index ff15117..c62e9bf 100644 --- a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go +++ b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go @@ -19,13 +19,13 @@ import ( // ActivityCoinAutoExchangeGreenEnergyNew 活跃积分自动兑换成绿色能量 func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string, ch *rabbit.Channel) (err error) { //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 - oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - return - } + //oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ + // "key": "is_open", + // "value": 1, + //}) + //if err != nil { + // return + //} oneCirclesPublicPlatoonBasicSetting, err := db.OneCirclesPublicPlatoonBasicSettingGetOneByParams(engine, map[string]interface{}{ "key": "is_open", @@ -84,142 +84,29 @@ func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string session.Begin() for _, v := range list1 { + autoExchangeNumsByPersonValue, _ := decimal.NewFromString(v.Amount) + autoExchangeNumsByPersonAmount := autoExchangeNumsByPersonValue.Div(personActivePointsCoinExchangeRatioValue).String() //TODO::推入rabbitmq 异步处理 ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ - MasterId: masterId, - Uid: v.Uid, + MasterId: masterId, + Uid: v.Uid, + CoinId: coin1.Id, + AutoExchangeNumsAmount: autoExchangeNumsByPersonAmount, }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToPerson) } for _, v := range list2 { + autoExchangeNumsByTeamValue, _ := decimal.NewFromString(v.Amount) + autoExchangeNumsByTeamAmount := autoExchangeNumsByTeamValue.Div(teamActivePointsCoinExchangeRatioValue).String() //TODO::推入rabbitmq 异步处理 ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ - MasterId: masterId, - Uid: v.Uid, + MasterId: masterId, + Uid: v.Uid, + CoinId: coin1.Id, + AutoExchangeNumsAmount: autoExchangeNumsByTeamAmount, }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToTeam) } - //4、处理"个人活跃积分"兑换 - for _, v := range list1 { - autoExchangeNumsByPersonValue, _ := decimal.NewFromString(v.Amount) - autoExchangeNumsByPersonAmount := autoExchangeNumsByPersonValue.Div(personActivePointsCoinExchangeRatioValue).String() - //4.1计算涨价公式 - err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByPersonAmount, oneCirclesGreenEnergyBasicSetting) - if err1 != nil { - _ = session.Rollback() - return err1 - } - - //4.2给相应的用户加上个人的绿色积分(可用数量) - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "add", - Mid: masterId, - Title: md.OneCirclesPersonalActiveCoinExchangeGreenEnergy, - TransferType: md.OneCirclesPersonalActiveCoinExchangeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesGreenEnergyBasicSetting.PersonGreenEnergyCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(values), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::33333", err) - return err - } - - //4.3给相应的用户减去个人活跃积分 - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "sub", - Mid: masterId, - Title: md.OneCirclesPersonalActiveCoinExchangeToBeGreenEnergy, - TransferType: md.OneCirclesPersonalActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(v.Amount), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::33333", err) - return err - } - - //4.4 减少“原始数量”中的绿色能量 - err = DealAvailableGreenEnergyCoin(session, int(enum.PersonalActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), zhios_order_relate_utils.StrToFloat64(autoExchangeNumsByPersonAmount), enum.PersonalActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::44444", err) - return err - } - } - - //5、处理"团队活跃积分"兑换 - for _, v := range list2 { - autoExchangeNumsByTeamValue, _ := decimal.NewFromString(v.Amount) - autoExchangeNumsByTeamAmount := autoExchangeNumsByTeamValue.Div(teamActivePointsCoinExchangeRatioValue).String() - //5.1计算涨价公式 - err1, values, _, afterPriceValue := NewCalcPriceIncreaseFormula(autoExchangeNumsByTeamAmount, oneCirclesGreenEnergyBasicSetting) - if err1 != nil { - _ = session.Rollback() - return err1 - } - - //5.2给相应的用户加上个人的绿色积分(结算数量) - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "add", - Mid: masterId, - Title: md.OneCirclesTeamActiveCoinExchangeGreenEnergy, - TransferType: md.OneCirclesTeamActiveCoinExchangeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(values), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::33333", err) - return err - } - - //5.3给相应的用户减去个人团队积分 - err = DealUserCoin(session, md.DealUserCoinReq{ - Kind: "sub", - Mid: masterId, - Title: md.OneCirclesTeamActiveCoinExchangeToBeGreenEnergy, - TransferType: md.OneCirclesTeamActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow, - OrdId: "", - CoinId: oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId, - Uid: v.Uid, - Amount: zhios_order_relate_utils.StrToFloat64(v.Amount), - }) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::66666", err) - return err - } - - //5.4 减少“原始数量”中的绿色能量 - err = DealAvailableGreenEnergyCoin(session, int(enum.TeamActivePointRedemption), zhios_order_relate_utils.StrToFloat64(values), zhios_order_relate_utils.StrToFloat64(autoExchangeNumsByTeamAmount), enum.TeamActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::44444", err) - return err - } - } - - //6、修改 one_circles_green_energy_basic_setting 的 now_price - _, err = db.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting) - if err != nil { - _ = session.Rollback() - fmt.Println("err:::::77777", err) - return err - } - - err = session.Commit() - if err != nil { - _ = session.Rollback() - return errors.New("事务提交失败") - } return } From 77732d50825a426c7c4db9c8d9288dbf9d41ca06 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 24 Apr 2024 20:40:33 +0800 Subject: [PATCH 2/4] update --- hs_err_pid10832.log | 244 ++++++++++++++++++ md/mq.go | 4 +- ...ctivity_coin_auto_exchange_green_energy.go | 8 +- 3 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 hs_err_pid10832.log diff --git a/hs_err_pid10832.log b/hs_err_pid10832.log new file mode 100644 index 0000000..1d021e2 --- /dev/null +++ b/hs_err_pid10832.log @@ -0,0 +1,244 @@ +# +# There is insufficient memory for the Java Runtime Environment to continue. +# Native memory allocation (mmap) failed to map 536870912 bytes for G1 virtual space +# Possible reasons: +# The system is out of physical RAM or swap space +# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap +# Possible solutions: +# Reduce memory load on the system +# Increase physical memory or swap space +# Check if swap backing store is full +# Decrease Java heap size (-Xmx/-Xms) +# Decrease number of Java threads +# Decrease Java thread stack sizes (-Xss) +# Set larger code cache with -XX:ReservedCodeCacheSize= +# JVM is running with Zero Based Compressed Oops mode in which the Java heap is +# placed in the first 32GB address space. The Java Heap base address is the +# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress +# to set the Java Heap base and to place the Java Heap above 32GB virtual address. +# This output file may be truncated or incomplete. +# +# Out of Memory Error (os_windows.cpp:3825), pid=10832, tid=3432 +# +# JRE version: (17.0.10+8) (build ) +# Java VM: OpenJDK 64-Bit Server VM (17.0.10+8-b1207.12, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) +# No core dump will be written. Minidumps are not enabled by default on client versions of Windows +# + +--------------- S U M M A R Y ------------ + +Command Line: git4idea.http.GitAskPassApp Username for 'https://code.fnuoos.com': + +Host: Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz, 6 cores, 31G, Windows 10 , 64 bit Build 19041 (10.0.19041.789) +Time: Mon Apr 22 15:44:25 2024 Windows 10 , 64 bit Build 19041 (10.0.19041.789) elapsed time: 0.017051 seconds (0d 0h 0m 0s) + +--------------- T H R E A D --------------- + +Current thread (0x0000028c37db93c0): JavaThread "Unknown thread" [_thread_in_vm, id=3432, stack(0x000000ecb8900000,0x000000ecb8a00000)] + +Stack: [0x000000ecb8900000,0x000000ecb8a00000] +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +V [jvm.dll+0x687989] +V [jvm.dll+0x84116a] +V [jvm.dll+0x842dae] +V [jvm.dll+0x843413] +V [jvm.dll+0x249ccf] +V [jvm.dll+0x684759] +V [jvm.dll+0x67900a] +V [jvm.dll+0x30ab0b] +V [jvm.dll+0x311fb6] +V [jvm.dll+0x361d5e] +V [jvm.dll+0x361f8f] +V [jvm.dll+0x2e07f8] +V [jvm.dll+0x2e1764] +V [jvm.dll+0x811c31] +V [jvm.dll+0x36fc11] +V [jvm.dll+0x7f0666] +V [jvm.dll+0x3f3daf] +V [jvm.dll+0x3f5a41] +C [jli.dll+0x528f] +C [ucrtbase.dll+0x21bb2] +C [KERNEL32.DLL+0x17034] +C [ntdll.dll+0x4d241] + + +--------------- P R O C E S S --------------- + +Threads class SMR info: +_java_thread_list=0x00007ffd6991df58, length=0, elements={ +} + +Java Threads: ( => current thread ) + +Other Threads: + 0x0000028c37e672d0 GCTaskThread "GC Thread#0" [stack: 0x000000ecb8a00000,0x000000ecb8b00000] [id=29584] + 0x0000028c37e78130 ConcurrentGCThread "G1 Main Marker" [stack: 0x000000ecb8b00000,0x000000ecb8c00000] [id=37508] + 0x0000028c37e78b50 ConcurrentGCThread "G1 Conc#0" [stack: 0x000000ecb8c00000,0x000000ecb8d00000] [id=34580] + +[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffd690d13c7] + +VM state: not at safepoint (not fully initialized) + +VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) +[0x0000028c37db4290] Heap_lock - owner thread: 0x0000028c37db93c0 + +Heap address: 0x0000000601c00000, size: 8164 MB, Compressed Oops mode: Zero based, Oop shift amount: 3 + +CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 1. +Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0 + +GC Precious Log: + + +Heap: + garbage-first heap total 0K, used 0K [0x0000000601c00000, 0x0000000800000000) + region size 4096K, 0 young (0K), 0 survivors (0K) + Metaspace used 0K, committed 0K, reserved 0K + class space used 0K, committed 0K, reserved 0K + +Heap Regions: E=young(eden), S=young(survivor), O=old, HS=humongous(starts), HC=humongous(continues), CS=collection set, F=free, OA=open archive, CA=closed archive, TAMS=top-at-mark-start (previous, next) + +Card table byte_map: [0x0000028c4b650000,0x0000028c4c650000] _byte_map_base: 0x0000028c48642000 + +Marking Bits (Prev, Next): (CMBitMap*) 0x0000028c37e678f0, (CMBitMap*) 0x0000028c37e67930 + Prev Bits: [0x0000028c4d650000, 0x0000028c555e0000) + Next Bits: [0x0000028c555e0000, 0x0000028c5d570000) + +GC Heap History (0 events): +No events + +Dll operation events (1 events): +Event: 0.011 Loaded shared library D:\GoLand 2024.1\jbr\bin\java.dll + +Deoptimization events (0 events): +No events + +Classes unloaded (0 events): +No events + +Classes redefined (0 events): +No events + +Internal exceptions (0 events): +No events + +VM Operations (0 events): +No events + +Events (0 events): +No events + + +Dynamic libraries: +0x00007ff6cdda0000 - 0x00007ff6cddaa000 D:\GoLand 2024.1\jbr\bin\java.exe +0x00007ffddd6b0000 - 0x00007ffddd8a6000 C:\Windows\SYSTEM32\ntdll.dll +0x00007ffddbc60000 - 0x00007ffddbd1d000 C:\Windows\System32\KERNEL32.DLL +0x00007ffddb390000 - 0x00007ffddb659000 C:\Windows\System32\KERNELBASE.dll +0x00007ffddafb0000 - 0x00007ffddb0b0000 C:\Windows\System32\ucrtbase.dll +0x00007ffdd6950000 - 0x00007ffdd6967000 D:\GoLand 2024.1\jbr\bin\jli.dll +0x00007ffdb7130000 - 0x00007ffdb714b000 D:\GoLand 2024.1\jbr\bin\VCRUNTIME140.dll +0x00007ffddbac0000 - 0x00007ffddbc60000 C:\Windows\System32\USER32.dll +0x00007ffddb360000 - 0x00007ffddb382000 C:\Windows\System32\win32u.dll +0x00007ffddc470000 - 0x00007ffddc49a000 C:\Windows\System32\GDI32.dll +0x00007ffddaea0000 - 0x00007ffddafab000 C:\Windows\System32\gdi32full.dll +0x00007ffdc9650000 - 0x00007ffdc98eb000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.746_none_ca02b4b61b8320a4\COMCTL32.dll +0x00007ffddb260000 - 0x00007ffddb2fd000 C:\Windows\System32\msvcp_win.dll +0x00007ffddc870000 - 0x00007ffddc90e000 C:\Windows\System32\msvcrt.dll +0x00007ffddcd90000 - 0x00007ffddcdc0000 C:\Windows\System32\IMM32.DLL +0x00007ffdc4740000 - 0x00007ffdc474c000 D:\GoLand 2024.1\jbr\bin\vcruntime140_1.dll +0x00007ffdabee0000 - 0x00007ffdabf6d000 D:\GoLand 2024.1\jbr\bin\msvcp140.dll +0x00007ffd68de0000 - 0x00007ffd69a62000 D:\GoLand 2024.1\jbr\bin\server\jvm.dll +0x00007ffddd4f0000 - 0x00007ffddd59c000 C:\Windows\System32\ADVAPI32.dll +0x00007ffddd5b0000 - 0x00007ffddd64c000 C:\Windows\System32\sechost.dll +0x00007ffddcdc0000 - 0x00007ffddceeb000 C:\Windows\System32\RPCRT4.dll +0x00007ffdc0690000 - 0x00007ffdc0699000 C:\Windows\SYSTEM32\WSOCK32.dll +0x00007ffdcc4d0000 - 0x00007ffdcc4f7000 C:\Windows\SYSTEM32\WINMM.dll +0x00007ffddaba0000 - 0x00007ffddabeb000 C:\Windows\SYSTEM32\POWRPROF.dll +0x00007ffddd3c0000 - 0x00007ffddd42b000 C:\Windows\System32\WS2_32.dll +0x00007ffdd5760000 - 0x00007ffdd576a000 C:\Windows\SYSTEM32\VERSION.dll +0x00007ffddab80000 - 0x00007ffddab92000 C:\Windows\SYSTEM32\UMPDC.dll +0x00007ffdd8d60000 - 0x00007ffdd8d72000 C:\Windows\SYSTEM32\kernel.appcore.dll +0x00007ffdd6a30000 - 0x00007ffdd6a3a000 D:\GoLand 2024.1\jbr\bin\jimage.dll +0x00007ffdca2f0000 - 0x00007ffdca4d4000 C:\Windows\SYSTEM32\DBGHELP.DLL +0x00007ffdc7e00000 - 0x00007ffdc7e2c000 C:\Windows\SYSTEM32\dbgcore.DLL +0x00007ffddae20000 - 0x00007ffddaea0000 C:\Windows\System32\bcryptPrimitives.dll +0x00007ffdcb5e0000 - 0x00007ffdcb605000 D:\GoLand 2024.1\jbr\bin\java.dll + +dbghelp: loaded successfully - version: 4.0.5 - missing functions: none +symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;D:\GoLand 2024.1\jbr\bin;C:\Windows\SYSTEM32;C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.746_none_ca02b4b61b8320a4;D:\GoLand 2024.1\jbr\bin\server + +VM Arguments: +java_command: git4idea.http.GitAskPassApp Username for 'https://code.fnuoos.com': +java_class_path (initial): D:/GoLand 2024.1/plugins/vcs-git/lib/git4idea-rt.jar;D:/GoLand 2024.1/lib/externalProcess-rt.jar +Launcher Type: SUN_STANDARD + +[Global flags] + intx CICompilerCount = 3 {product} {ergonomic} + uint ConcGCThreads = 2 {product} {ergonomic} + uint G1ConcRefinementThreads = 6 {product} {ergonomic} + size_t G1HeapRegionSize = 4194304 {product} {ergonomic} + uintx GCDrainStackTargetSize = 64 {product} {ergonomic} + size_t InitialHeapSize = 536870912 {product} {ergonomic} + size_t MarkStackSize = 4194304 {product} {ergonomic} + size_t MaxHeapSize = 8560574464 {product} {ergonomic} + size_t MinHeapDeltaBytes = 4194304 {product} {ergonomic} + size_t MinHeapSize = 8388608 {product} {ergonomic} + uintx NonNMethodCodeHeapSize = 5832780 {pd product} {ergonomic} + uintx NonProfiledCodeHeapSize = 122912730 {pd product} {ergonomic} + uintx ProfiledCodeHeapSize = 122912730 {pd product} {ergonomic} + uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic} + bool SegmentedCodeCache = true {product} {ergonomic} + size_t SoftMaxHeapSize = 8560574464 {manageable} {ergonomic} + bool UseCompressedClassPointers = true {product lp64_product} {ergonomic} + bool UseCompressedOops = true {product lp64_product} {ergonomic} + bool UseG1GC = true {product} {ergonomic} + bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic} + +Logging: +Log output configuration: + #0: stdout all=warning uptime,level,tags + #1: stderr all=off uptime,level,tags + +Environment Variables: +PATH=D:\Program Files\Git\mingw64\libexec\git-core;D:\Program Files\Git\mingw64\libexec\git-core;D:\Program Files\Git\mingw64\bin;D:\Program Files\Git\usr\bin;C:\Users\Administrator\bin;E:\xshell\Xlpd 6;E:\xshell\Xshell 6;E:\xshell\Xmanager 6;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;D:\Dev\bin\gowin\bin;D:\Program Files\Git\usr\bin;D:\Dev\bin\Python\Scripts;D:\Dev\bin\Python;D:\Dev\bin\node;D:\Dev\bin\flutter\bin;C:\Program Files\nodejs;C:\Program Files\Git\cmd;D:\\mingw64\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\TortoiseGit\bin;D:\\Redis;D:\phpstudy_pro\Extensions\php\php7.4.3nts;C:\ProgramData\ComposerSetup\bin;E:\rabbitMq\erl-24.0\bin;D:\Dev\bin\go\bin;E:\Graphviz\bin;E:\Mysql\mysql-8.0.31-winx64\bin;D:\Dev\go\path\Bin;C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts;C:\Users\Administrator\AppData\Local\Programs\Python\Python38;C:\Program Files\MySQL\MySQL Shell 8.0\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm;D:\Microsoft VS Code\bin;C:\Users\Administrator\AppData\Roaming\Composer\vendor\bin;E:\PhpStorm\PhpStorm 2021.2.3\bin;C:\Program Files\JetBrains\GoLand 2022.1.1\bin;C:\Users\Administrator\go\bin;C:\Users\Administrator\AppData\Local\Programs\Fiddler +USERNAME=Administrator +DISPLAY=:0.0 +LC_ALL=en_US.UTF-8 +TERM=cygwin +TMPDIR=C:\Users\Administrator\AppData\Local\Temp +OS=Windows_NT +PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel +TMP=C:\Users\Administrator\AppData\Local\Temp +TEMP=C:\Users\Administrator\AppData\Local\Temp + + + +Periodic native trim disabled + +JNI global refs: +JNI global refs: 0, weak refs: 0 + +JNI global refs memory usage: 0, weak refs: 0 + +OOME stack traces (most recent first): +Classloader memory used: + + +--------------- S Y S T E M --------------- + +OS: + Windows 10 , 64 bit Build 19041 (10.0.19041.789) +OS uptime: 12 days 19:33 hours + +CPU: total 6 (initial active 6) (6 cores per cpu, 1 threads per core) family 6 model 158 stepping 10 microcode 0xca, cx8, cmov, fxsr, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, adx, fma, vzeroupper, clflush, clflushopt +Processor Information for all 6 processors : + Max Mhz: 2904, Current Mhz: 2904, Mhz Limit: 2904 + +Memory: 4k page, system-wide physical 32640M (12417M free) +TotalPageFile size 43320M (AvailPageFile size 395M) +current process WorkingSet (physical memory assigned to process): 10M, peak: 10M +current process commit charge ("private bytes"): 56M, peak: 568M + +vm_info: OpenJDK 64-Bit Server VM (17.0.10+8-b1207.12) for windows-amd64 JRE (17.0.10+8-b1207.12), built on 2024-03-15 by "builduser" with MS VC++ 16.10 / 16.11 (VS2019) + +END. diff --git a/md/mq.go b/md/mq.go index ff97bf4..322f663 100644 --- a/md/mq.go +++ b/md/mq.go @@ -19,7 +19,9 @@ type OneCirclesStructForSignIn struct { type OneCirclesStructForAutoExchangeGreenEnergy struct { MasterId string `json:"master_id"` Uid int `json:"uid"` - CoinId int `json:"coin_id"` + Amount string `json:"amount"` + CoinId1 int `json:"coin_id_1"` + CoinId2 int `json:"coin_id_2"` AutoExchangeNumsAmount string `json:"auto_exchange_nums_amount"` } type OneCirclesStructForStarLevelDividends struct { diff --git a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go index c62e9bf..9ed9560 100644 --- a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go +++ b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go @@ -90,7 +90,9 @@ func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ MasterId: masterId, Uid: v.Uid, - CoinId: coin1.Id, + Amount: v.Amount, + CoinId1: coin1.Id, + CoinId2: coin2.Id, AutoExchangeNumsAmount: autoExchangeNumsByPersonAmount, }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToPerson) } @@ -102,7 +104,9 @@ func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ MasterId: masterId, Uid: v.Uid, - CoinId: coin1.Id, + Amount: v.Amount, + CoinId1: coin1.Id, + CoinId2: coin2.Id, AutoExchangeNumsAmount: autoExchangeNumsByTeamAmount, }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToTeam) } From 5cf091d0397380c2506ac0894cb97844f1778db2 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 24 Apr 2024 21:02:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?update=20=E4=B8=80=E4=B8=AA=E5=9C=88?= =?UTF-8?q?=E5=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md/mq.go | 3 +- ...ctivity_coin_auto_exchange_green_energy.go | 144 +++++++++++++++++- svc/svc_redis_mutex_lock.go | 2 +- 3 files changed, 138 insertions(+), 11 deletions(-) diff --git a/md/mq.go b/md/mq.go index 322f663..d9ef773 100644 --- a/md/mq.go +++ b/md/mq.go @@ -20,8 +20,7 @@ type OneCirclesStructForAutoExchangeGreenEnergy struct { MasterId string `json:"master_id"` Uid int `json:"uid"` Amount string `json:"amount"` - CoinId1 int `json:"coin_id_1"` - CoinId2 int `json:"coin_id_2"` + CoinId int `json:"coin_id"` AutoExchangeNumsAmount string `json:"auto_exchange_nums_amount"` } type OneCirclesStructForStarLevelDividends struct { diff --git a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go index 9ed9560..942b3e0 100644 --- a/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go +++ b/rule/one_circles/one_circles_activity_coin_auto_exchange_green_energy.go @@ -91,8 +91,7 @@ func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string MasterId: masterId, Uid: v.Uid, Amount: v.Amount, - CoinId1: coin1.Id, - CoinId2: coin2.Id, + CoinId: coin1.Id, AutoExchangeNumsAmount: autoExchangeNumsByPersonAmount, }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToPerson) } @@ -105,8 +104,7 @@ func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string MasterId: masterId, Uid: v.Uid, Amount: v.Amount, - CoinId1: coin1.Id, - CoinId2: coin2.Id, + CoinId: coin2.Id, AutoExchangeNumsAmount: autoExchangeNumsByTeamAmount, }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToTeam) } @@ -114,8 +112,8 @@ func ActivityCoinAutoExchangeGreenEnergyNew(engine *xorm.Engine, masterId string return } -// ActivityCoinAutoExchangeGreenEnergy 活跃积分自动兑换成绿色能量 -func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err error) { +// OldActivityCoinAutoExchangeGreenEnergy 活跃积分自动兑换成绿色能量 +func OldActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err error) { //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ "key": "is_open", @@ -243,8 +241,8 @@ func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string) ( return } -// ActivityCoinAutoExchangeGreenEnergyForTeam 活跃积分自动兑换成绿色能量 -func ActivityCoinAutoExchangeGreenEnergyForTeam(engine *xorm.Engine, masterId string) (err error) { +// OldActivityCoinAutoExchangeGreenEnergyForTeam 活跃积分自动兑换成绿色能量 +func OldActivityCoinAutoExchangeGreenEnergyForTeam(engine *xorm.Engine, masterId string) (err error) { //1、查找 `one_circles_green_energy_basic_setting` 基础设置 && `one_circles_public_platoon_basic_setting` 基础设置 oneCirclesGreenEnergyBasicSetting, err := db.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{ "key": "is_open", @@ -371,3 +369,133 @@ func ActivityCoinAutoExchangeGreenEnergyForTeam(engine *xorm.Engine, masterId st } return } + +// ActivityCoinAutoExchangeGreenEnergy 活跃积分自动兑换成绿色能量(个人) +func ActivityCoinAutoExchangeGreenEnergy(engine *xorm.Engine, masterId string, ch *rabbit.Channel) (err error) { + //1、查找`one_circles_public_platoon_basic_setting` 基础设置 + oneCirclesPublicPlatoonBasicSetting, err := db.OneCirclesPublicPlatoonBasicSettingGetOneByParams(engine, map[string]interface{}{ + "key": "is_open", + "value": 1, + }) + if err != nil { + return + } + if oneCirclesPublicPlatoonBasicSetting.ExchangeRules == "" { + err = errors.New("自动兑换未设置!") + return + } + var exchangeRulesStruct *md2.ExchangeRulesStruct + err = json.Unmarshal([]byte(oneCirclesPublicPlatoonBasicSetting.ExchangeRules), &exchangeRulesStruct) + if err != nil { + return + } + var autoExchangeNumsByPerson = zhios_order_relate_utils.StrToFloat64(exchangeRulesStruct.AutoExchangeNumsByPerson) //个人活跃积分X个自动兑换 + fmt.Println("autoExchangeNumsByPerson>>>>>>>>>>>>", autoExchangeNumsByPerson) + + //2、获取"个人活跃积分" && 获取"团队活跃积分" + var coin1, coin2 model.VirtualCoin + _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId).Get(&coin1) + if err != nil { + return err + } + _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).Get(&coin2) + if err != nil { + return err + } + personActivePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin1.ExchangeRatio) + + //3、当前 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据 + var list1 []model.UserVirtualAmount + err = engine.Where("coin_id = ?", oneCirclesPublicPlatoonBasicSetting.PersonActivePointsCoinId).And("amount >=?", autoExchangeNumsByPerson).Find(&list1) + if err != nil { + fmt.Println("err:::::1111", err) + return + } + + session := engine.NewSession() + defer func() { + session.Close() + if err := recover(); err != nil { + _ = zhios_order_relate_logx.Error(err) + } + }() + session.Begin() + + for _, v := range list1 { + autoExchangeNumsByPersonValue, _ := decimal.NewFromString(v.Amount) + autoExchangeNumsByPersonAmount := autoExchangeNumsByPersonValue.Div(personActivePointsCoinExchangeRatioValue).String() + //TODO::推入rabbitmq 异步处理 + ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ + MasterId: masterId, + Uid: v.Uid, + Amount: v.Amount, + CoinId: coin1.Id, + AutoExchangeNumsAmount: autoExchangeNumsByPersonAmount, + }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToPerson) + } + + return +} + +// ActivityCoinAutoExchangeGreenEnergyForTeam 活跃积分自动兑换成绿色能量(团队) +func ActivityCoinAutoExchangeGreenEnergyForTeam(engine *xorm.Engine, masterId string, ch *rabbit.Channel) (err error) { + //1、查找`one_circles_public_platoon_basic_setting` 基础设置 + oneCirclesPublicPlatoonBasicSetting, err := db.OneCirclesPublicPlatoonBasicSettingGetOneByParams(engine, map[string]interface{}{ + "key": "is_open", + "value": 1, + }) + if err != nil { + return + } + if oneCirclesPublicPlatoonBasicSetting.ExchangeRules == "" { + err = errors.New("自动兑换未设置!") + return + } + var exchangeRulesStruct *md2.ExchangeRulesStruct + err = json.Unmarshal([]byte(oneCirclesPublicPlatoonBasicSetting.ExchangeRules), &exchangeRulesStruct) + if err != nil { + return + } + var autoExchangeNumsByTeam = zhios_order_relate_utils.StrToFloat64(exchangeRulesStruct.AutoExchangeNumsByTeam) //团队活跃积分X个自动兑换 + fmt.Println("autoExchangeNumsByTeam>>>>>>>>>>>>", autoExchangeNumsByTeam) + + //2、获取"个人活跃积分" && 获取"团队活跃积分" + var coin2 model.VirtualCoin + _, err = engine.Where("id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).Get(&coin2) + if err != nil { + return err + } + teamActivePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin2.ExchangeRatio) + + //3、当前 "个人活跃积分"可以自动兑换的用户数据 && "团队活跃积分"可以自动兑换的用户数据 + var list2 []model.UserVirtualAmount + err = engine.Where("coin_id = ?", oneCirclesPublicPlatoonBasicSetting.TeamActivePointsCoinId).And("amount >=?", autoExchangeNumsByTeam).Find(&list2) + if err != nil { + fmt.Println("err:::::2222", err) + return + } + + session := engine.NewSession() + defer func() { + session.Close() + if err := recover(); err != nil { + _ = zhios_order_relate_logx.Error(err) + } + }() + session.Begin() + + for _, v := range list2 { + autoExchangeNumsByTeamValue, _ := decimal.NewFromString(v.Amount) + autoExchangeNumsByTeamAmount := autoExchangeNumsByTeamValue.Div(teamActivePointsCoinExchangeRatioValue).String() + //TODO::推入rabbitmq 异步处理 + ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForAutoExchangeGreenEnergy{ + MasterId: masterId, + Uid: v.Uid, + Amount: v.Amount, + CoinId: coin2.Id, + AutoExchangeNumsAmount: autoExchangeNumsByTeamAmount, + }, md.OneCirclesRoutKeyForAutoExchangeGreenEnergyToTeam) + } + + return +} diff --git a/svc/svc_redis_mutex_lock.go b/svc/svc_redis_mutex_lock.go index 92cf77e..98bbfce 100644 --- a/svc/svc_redis_mutex_lock.go +++ b/svc/svc_redis_mutex_lock.go @@ -25,7 +25,7 @@ func TryGetDistributedLock(lockKey, requestId string, isNegative bool) bool { return true } // 尝试多次没获取成功 - if retry > 10 { + if retry > 50 { return false } time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) From 1834eada579091a7a696130766b6739526b6520a Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 24 Apr 2024 21:38:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?update=20=E4=B8=80=E4=B8=AA=E5=9C=88?= =?UTF-8?q?=E5=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one_circles_deal_available_green_energy_points.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rule/one_circles/one_circles_deal_available_green_energy_points.go b/rule/one_circles/one_circles_deal_available_green_energy_points.go index 4321c88..5b6341e 100644 --- a/rule/one_circles/one_circles_deal_available_green_energy_points.go +++ b/rule/one_circles/one_circles_deal_available_green_energy_points.go @@ -473,13 +473,13 @@ func DealAvailableGreenEnergyCoin(session *xorm.Session, kind int, amount, amoun } } else { oneCirclesGreenEnergyPrice.Price = nowPriceValue - updateAffected, err1 := db.OneCirclesGreenEnergyPriceUpdate(session, oneCirclesGreenEnergyPrice.Id, oneCirclesGreenEnergyPrice, "price") + _, err1 := db.OneCirclesGreenEnergyPriceUpdate(session, oneCirclesGreenEnergyPrice.Id, oneCirclesGreenEnergyPrice, "price") if err1 != nil { return err1 } - if updateAffected <= 0 { - return errors.New("更新 one_circles_green_energy_price 失败") - } + //if updateAffected <= 0 { + // return errors.New("更新 one_circles_green_energy_price 失败") + //} } } _, err := db.OneCirclesGreenEnergyBasicSettingUpdate(session, chain.Id, chain)