ducnt 3 weeks ago
commit
c7022e8525
100 changed files with 3230 additions and 0 deletions
  1. 147 0
      .gitignore
  2. BIN
      HappyFootballProcess/HappyFootballProcess/lib/CollaborationAgent-2.2.jar
  3. BIN
      HappyFootballProcess/HappyFootballProcess/lib/LogWriter-v2.1-yc14.jar
  4. BIN
      HappyFootballProcess/HappyFootballProcess/lib/PMLib_1.0.jar
  5. BIN
      HappyFootballProcess/HappyFootballProcess/lib/PropertiesUtils.jar
  6. BIN
      HappyFootballProcess/HappyFootballProcess/lib/VAS_FW_Process_v2.0.jar
  7. BIN
      HappyFootballProcess/HappyFootballProcess/lib/VasgwFW.jar
  8. BIN
      HappyFootballProcess/HappyFootballProcess/lib/bcprov-jdk16-141.jar
  9. BIN
      HappyFootballProcess/HappyFootballProcess/lib/c3p0-0.9.2.1.jar
  10. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-beanutils-1.7.0.jar
  11. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-beanutils-bean-collections.jar
  12. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-beanutils-core.jar
  13. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-codec-1.3.jar
  14. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-collections-3.2.1.jar
  15. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-collections-3.2.jar
  16. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-dbcp-1.2.2.jar
  17. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-digester-1.8.jar
  18. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-discovery-0.2.jar
  19. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-httpclient-3.1.jar
  20. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-lang-2.4.jar
  21. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-logging-1.1.1.jar
  22. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-net-3.6.jar
  23. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons-pool-1.3.jar
  24. BIN
      HappyFootballProcess/HappyFootballProcess/lib/commons.jar
  25. BIN
      HappyFootballProcess/HappyFootballProcess/lib/hibernate3.jar
  26. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/aopalliance-repackaged-2.6.1.jar
  27. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/connection-pool-2.4.4.jar
  28. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-framework-2.4.4.jar
  29. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-2.4.4.jar
  30. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-client-1.16.jar
  31. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-server-2.4.4.jar
  32. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-servlet-2.4.4.jar
  33. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-websockets-2.4.4.jar
  34. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/hk2-api-2.6.1.jar
  35. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/hk2-locator-2.6.1.jar
  36. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/hk2-utils-2.6.1.jar
  37. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-annotations-2.9.9.jar
  38. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-core-2.9.9.jar
  39. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-databind-2.9.9.jar
  40. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-jaxrs-base-2.9.9.jar
  41. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-jaxrs-json-provider-2.9.9.jar
  42. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-module-jaxb-annotations-2.9.9.jar
  43. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.annotation-api-1.3.5.jar
  44. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.inject-2.6.1.jar
  45. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.servlet-api-4.0.3.jar
  46. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.validation-api-2.0.2.jar
  47. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.ws.rs-api-2.1.6.jar
  48. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/javassist-3.22.0-CR2.jar
  49. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-client-2.29.1.jar
  50. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-common-2.29.1.jar
  51. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-grizzly2-http-2.29.1.jar
  52. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-grizzly2-servlet-2.29.1.jar
  53. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-servlet-2.29.1.jar
  54. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-servlet-core-2.29.1.jar
  55. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-entity-filtering-2.29.1.jar
  56. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-grizzly-connector-2.29.1.jar
  57. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-hk2-2.29.1.jar
  58. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-media-jaxb-2.29.1.jar
  59. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-media-json-jackson-2.29.1.jar
  60. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-server-2.29.1.jar
  61. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/json-jackson-2.29.1.jar
  62. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/json.jar
  63. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/osgi-resource-locator-1.0.3.jar
  64. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jar_files/slf4j-api-1.7.12.jar
  65. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jep.jar
  66. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jgroups-2.10.0.GA.jar
  67. BIN
      HappyFootballProcess/HappyFootballProcess/lib/jsch-0.1.55.jar
  68. BIN
      HappyFootballProcess/HappyFootballProcess/lib/log4j-1.2.15-ext.jar
  69. BIN
      HappyFootballProcess/HappyFootballProcess/lib/log4j-simon-ext-1.0.jar
  70. BIN
      HappyFootballProcess/HappyFootballProcess/lib/mchange-commons-java-0.2.3.4.jar
  71. BIN
      HappyFootballProcess/HappyFootballProcess/lib/mina-core-2.0.0-M5.jar
  72. BIN
      HappyFootballProcess/HappyFootballProcess/lib/mmserver-3.2.jar
  73. BIN
      HappyFootballProcess/HappyFootballProcess/lib/ojdbc6.jar
  74. BIN
      HappyFootballProcess/HappyFootballProcess/lib/org-openide-util.jar
  75. BIN
      HappyFootballProcess/HappyFootballProcess/lib/sendmtv1.2.0.jar
  76. BIN
      HappyFootballProcess/HappyFootballProcess/lib/slf4j-api-1.5.6.jar
  77. BIN
      HappyFootballProcess/HappyFootballProcess/lib/slf4j-jdk14-1.5.6.jar
  78. BIN
      HappyFootballProcess/HappyFootballProcess/lib/utils.jar
  79. BIN
      HappyFootballProcess/HappyFootballProcess/lib/viettel-lib-2.0.jar
  80. BIN
      HappyFootballProcess/HappyFootballProcess/lib/viettelsecurity.2.0.jar
  81. BIN
      HappyFootballProcess/HappyFootballProcess/lib/vsa3-vpclient-ws-1.0.jar
  82. BIN
      HappyFootballProcess/HappyFootballProcess/lib/vsa3-vptoken-1.0.jar
  83. 1 0
      HappyFootballProcess/HappyFootballProcess/src/.svn/entries
  84. 1 0
      HappyFootballProcess/HappyFootballProcess/src/.svn/format
  85. BIN
      HappyFootballProcess/HappyFootballProcess/src/.svn/wc.db
  86. 0 0
      HappyFootballProcess/HappyFootballProcess/src/.svn/wc.db-journal
  87. 232 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/CdrGetFtp.java
  88. 264 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/ImportSignal.java
  89. 183 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/RenewSpinTimes.java
  90. 374 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/SignalProcess.java
  91. 252 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/SignalProcessBk.java
  92. 207 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/CdrRecharge.java
  93. 238 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/CdrRechargeSftpCard.java
  94. 126 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/Disable.java
  95. 204 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/ExecutePrize.java
  96. 115 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/Help.java
  97. 182 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/PrepairDailyPrize.java
  98. 203 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/PrizeProcess.java
  99. 395 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/PrizeProcessOnline.java
  100. 106 0
      HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/SendMt.java

+ 147 - 0
.gitignore

@@ -0,0 +1,147 @@
+*.swp
+*.*~
+project.lock.json
+.DS_Store
+*.pyc
+nupkg/
+
+# Visual Studio Code
+.vscode/
+
+# Rider
+.idea/
+
+# Visual Studio
+.vs/
+
+# Fleet
+.fleet/
+
+# Code Rush
+.cr/
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+build/
+bld/
+[Bb]in/
+[Oo]bj/
+[Oo]ut/
+msbuild.log
+msbuild.err
+msbuild.wrn
+
+
+##############################
+## Java
+##############################
+.mtj.tmp/
+*.class
+#*.jar
+*.war
+*.ear
+*.nar
+hs_err_pid*
+replay_pid*
+
+##############################
+## Maven
+##############################
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+pom.xml.bak
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+
+##############################
+## Gradle
+##############################
+bin/
+build/
+.gradle
+.gradletasknamecache
+gradle-app.setting
+!gradle-wrapper.jar
+
+##############################
+## IntelliJ
+##############################
+out/
+.idea/
+.idea_modules/
+*.iml
+*.ipr
+*.iws
+
+##############################
+## Eclipse
+##############################
+.settings/
+bin/
+tmp/
+.metadata
+.classpath
+.project
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.loadpath
+.factorypath
+
+##############################
+## NetBeans
+##############################
+nbproject/
+build/
+nbbuild/
+dist/
+nbdist/
+nbactions.xml
+nb-configuration.xml
+build.xml
+manifest.mf
+
+##############################
+## Visual Studio Code
+##############################
+.vscode/
+.code-workspace
+
+##############################
+## OS X
+##############################
+.DS_Store
+
+##############################
+## Miscellaneous
+##############################
+*.log
+
+**/nbproject/private/
+**/nbproject/Makefile-*.mk
+**/nbproject/Package-*.bash
+build/
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/
+/HappyFootballProcess/HappyFootballProcess/build

BIN
HappyFootballProcess/HappyFootballProcess/lib/CollaborationAgent-2.2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/LogWriter-v2.1-yc14.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/PMLib_1.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/PropertiesUtils.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/VAS_FW_Process_v2.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/VasgwFW.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/bcprov-jdk16-141.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/c3p0-0.9.2.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-beanutils-1.7.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-beanutils-bean-collections.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-beanutils-core.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-codec-1.3.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-collections-3.2.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-collections-3.2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-dbcp-1.2.2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-digester-1.8.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-discovery-0.2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-httpclient-3.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-lang-2.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-logging-1.1.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-net-3.6.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons-pool-1.3.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/commons.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/hibernate3.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/aopalliance-repackaged-2.6.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/connection-pool-2.4.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-framework-2.4.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-2.4.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-client-1.16.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-server-2.4.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-http-servlet-2.4.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/grizzly-websockets-2.4.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/hk2-api-2.6.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/hk2-locator-2.6.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/hk2-utils-2.6.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-annotations-2.9.9.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-core-2.9.9.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-databind-2.9.9.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-jaxrs-base-2.9.9.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-jaxrs-json-provider-2.9.9.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jackson-module-jaxb-annotations-2.9.9.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.annotation-api-1.3.5.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.inject-2.6.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.servlet-api-4.0.3.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.validation-api-2.0.2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jakarta.ws.rs-api-2.1.6.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/javassist-3.22.0-CR2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-client-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-common-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-grizzly2-http-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-grizzly2-servlet-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-servlet-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-container-servlet-core-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-entity-filtering-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-grizzly-connector-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-hk2-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-media-jaxb-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-media-json-jackson-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/jersey-server-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/json-jackson-2.29.1.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/json.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/osgi-resource-locator-1.0.3.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jar_files/slf4j-api-1.7.12.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jep.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jgroups-2.10.0.GA.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/jsch-0.1.55.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/log4j-1.2.15-ext.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/log4j-simon-ext-1.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/mchange-commons-java-0.2.3.4.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/mina-core-2.0.0-M5.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/mmserver-3.2.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/ojdbc6.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/org-openide-util.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/sendmtv1.2.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/slf4j-api-1.5.6.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/slf4j-jdk14-1.5.6.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/utils.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/viettel-lib-2.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/viettelsecurity.2.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/vsa3-vpclient-ws-1.0.jar


BIN
HappyFootballProcess/HappyFootballProcess/lib/vsa3-vptoken-1.0.jar


+ 1 - 0
HappyFootballProcess/HappyFootballProcess/src/.svn/entries

@@ -0,0 +1 @@
+12

+ 1 - 0
HappyFootballProcess/HappyFootballProcess/src/.svn/format

@@ -0,0 +1 @@
+12

BIN
HappyFootballProcess/HappyFootballProcess/src/.svn/wc.db


+ 0 - 0
HappyFootballProcess/HappyFootballProcess/src/.svn/wc.db-journal


+ 232 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/CdrGetFtp.java

@@ -0,0 +1,232 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.luckycall.process;
+
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.ChargeLog;
+import com.vas.portal.utils.object.MtRecord;
+//import com.vas.portal.utils.object.Mt;
+import com.vas.portal.utils.object.ProcessedDate;
+import com.vas.portal.utils.service.WSProcessor;
+//import com.vas.portal.utils.object.SpinGift;
+//import com.vas.portal.utils.object.SpinRecharge;
+import com.viettel.cluster.agent.integration.Record;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class CdrGetFtp extends ProcessRecordAbstract {
+
+    private WSProcessor ws;
+    private DbProcessor db;
+//    private DbExtend dbExtend;
+    private StringBuilder br = new StringBuilder();
+    private SimpleDateFormat sdfCdr = new SimpleDateFormat("yyyyMM");
+    private SimpleDateFormat sdfCdrLocal = new SimpleDateFormat("yyyyMMdd");
+    private SimpleDateFormat sdfTime = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //11/09/2020 00:00:07
+
+    public CdrGetFtp() {
+        super();
+        logger = Logger.getLogger(CdrGetFtp.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.listProduct = db.iLoadPackage();
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            //
+            Common.listSpinLevel = db.getSpinCallLevel();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+
+        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+        List<MtRecord> listMt = new ArrayList();
+        List<ChargeLog> listChargeLog = new ArrayList();
+
+        FTPClient ftpClient = new FTPClient();
+        try {
+//            Date today = new Date();
+//            String todayStr = sdfCdr.format(today);
+//            String todayStrLocal = sdfCdrLocal.format(today);
+            ftpClient.connect(Common.FTP_RECHARGE_ADDRESS, 21);
+            logger.debug("Connected to FTP");
+            ftpClient.login(Common.FTP_RECHARGE_ACCOUNT, Common.FTP_RECHARGE_PASS);
+            logger.debug("Logged in to FTP");
+            ftpClient.enterLocalPassiveMode();
+            ftpClient.setConnectTimeout(120000);
+            ftpClient.setControlKeepAliveTimeout(60000);
+            ftpClient.setDataTimeout(120000);
+            ftpClient.setSoTimeout(120000);
+            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+
+            String clientFolder = Common.FTP_RECHARGE_DOWNLOADED_PATH;
+            String processFolder = Common.FILE_PATH_CALL_SIGNAL;
+            logger.debug("Client folder CDR: " + clientFolder);
+            File clientDir = new File(clientFolder);
+            if (!clientDir.exists()) {
+                logger.info("Make new client folder CDR");
+                clientDir.mkdir();
+            }
+            long newLastValue = processedDate.getLastValue();
+//            logger.debug("Working directory: " + ftpClient.printWorkingDirectory());
+//            logger.debug("Change directory: " + Common.FTP_RECHARGE_PATH);
+            String[] listPath = Common.FTP_RECHARGE_PATH.split(";");
+            for (String path : listPath) {
+                if (path == null || path.trim().isEmpty()) {
+                    continue;
+                }
+                ftpClient.changeWorkingDirectory(path);
+                logger.debug("Last value: " + newLastValue + ", new working directory: " + ftpClient.printWorkingDirectory());
+                FTPFile[] listFile = ftpClient.listFiles();
+                for (FTPFile file : listFile) {
+                    try {
+                        // check last file 
+                        long lastModified = file.getTimestamp().getTimeInMillis();
+//                        logger.info("Last modified: " + lastModified + ", " + sdfTime.format(lastModified) + ", file: " + file.getName());
+                        //only get new file                    
+//                        if (lastModified > processedDate.getLastValue()) {
+                        if (lastModified > newLastValue) {
+                            newLastValue = lastModified;
+                        }
+                        logger.info("File: " + file.getName());
+                        logger.info("Start download cdr file: " + file.getName());
+                        String clientPath = clientFolder + "/" + file.getName();
+                        File downloadFile1 = new File(clientPath);
+                        OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
+                        ftpClient.retrieveFile(file.getName(), outputStream1);
+                        outputStream1.close();
+                        logger.info("Delete file " + path + "/" + file.getName());
+                        if (!ftpClient.deleteFile(path + "/" + file.getName())) {
+                            throw new IOException("Failed to remove file " + file.getName() + " due to " + ftpClient.getReplyString());
+                        }
+                        // move to process folder
+                        downloadFile1.renameTo(new File(processFolder + "/" + file.getName()));
+//                        }
+                    } catch (Exception ex1) {
+                        logger.error("Error when process ftp file", ex1);
+                    }
+                }
+            }
+
+            // charge log
+            if (!listChargeLog.isEmpty()) {
+                db.insertChargeLog(listChargeLog);
+                listChargeLog.clear();
+            }
+
+            if (!listMt.isEmpty()) {
+                db.insertMt(listMt);
+                listMt.clear();
+            }
+
+            // set new last value
+            processedDate.setLastValue(newLastValue);
+        } catch (Exception ex) {
+            logger.error("Error with ftp connection", ex);
+        } finally {
+            try {
+                if (ftpClient.isConnected()) {
+                    ftpClient.logout();
+                    ftpClient.disconnect();
+                }
+            } catch (Exception ex) {
+            }
+        }
+
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tLAST_PROCESS\t\t").
+                append("|\tTYPE\t\t\r\n");
+        for (Record record : listRecord) {
+            ProcessedDate resultObj = (ProcessedDate) record;
+            br.append("|\t").
+                    append(resultObj.getLastProcess()).
+                    append("\t|\t").
+                    append(resultObj.getTypeProcess()).
+                    append("\t|\r\n");
+        }
+        logger.info(br);
+    }
+
+    private String validateMsisdn(String input) {
+        if (input != null) {
+            if (input.startsWith(Common.COUNTRY_CODE)) {
+                return input;
+            } else {
+                return Common.COUNTRY_CODE + input;
+            }
+        }
+        return Common.COUNTRY_CODE;
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    private String formatNumber(double num) {
+        if (num == Math.ceil(num)) {
+            return String.format("%.0f", num);
+        } else {
+            return String.format("%.1f", num);
+        }
+    }
+}

+ 264 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/ImportSignal.java

@@ -0,0 +1,264 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.luckycall.process;
+
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.CallSignalObj;
+//import com.vas.portal.utils.object.Mt;
+import com.vas.portal.utils.object.ProcessedDate;
+import com.vas.portal.utils.service.WSProcessor;
+//import com.vas.portal.utils.object.SpinGift;
+//import com.vas.portal.utils.object.SpinRecharge;
+import com.viettel.cluster.agent.integration.Record;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class ImportSignal extends ProcessRecordAbstract {
+
+    private WSProcessor ws;
+    private DbProcessor db;
+//    private DbExtend dbExtend;
+    private final StringBuilder br = new StringBuilder();
+    private final SimpleDateFormat sdfCdr = new SimpleDateFormat("yyyyMMdd");
+    private final SimpleDateFormat sdfCdrLocal = new SimpleDateFormat("yyyyMMddHHmmss");
+    private final SimpleDateFormat sdfTime = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //11/09/2020 00:00:07
+    private final Random ran = new Random();
+
+    public ImportSignal() {
+        super();
+        logger = Logger.getLogger(ImportSignal.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.listProduct = db.iLoadPackage();
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            //
+            Common.listSpinLevel = db.getSpinCallLevel();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+
+        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+
+        long lastValue = processedDate.getLastValue();
+        try {
+            Date today = new Date();
+            String todayStr = "";
+            File directory = new File(Common.FILE_PATH_CALL_SIGNAL);
+            File backupFolder = new File(Common.FILE_PATH_CALL_SIGNAL_BACKUP);
+            File[] files = directory.listFiles(File::isFile);
+            for (File _file : files) {
+                try {
+//                    if (processedDate.getLastValue() < _file.lastModified()) {
+                    logger.info("Import file: " + _file.getName());
+                    // run import to DB
+                    importDb(_file);
+                    if (lastValue < _file.lastModified()) {
+                        lastValue = _file.lastModified();
+                    }
+                    try {
+                        todayStr = _file.getName().split("_")[6].substring(0, 8);
+                    } catch (Exception ex) {
+                        todayStr = sdfCdr.format(today);
+                    }
+                    logger.info("Backup file: " + _file.getName());
+                    Files.createDirectories(Paths.get(backupFolder + "/" + todayStr));
+                    _file.renameTo(new File(backupFolder + "/" + todayStr + "/" + _file.getName()));
+//                    }
+                } catch (Exception ex1) {
+                    logger.error("Error read file " + _file.getName(), ex1);
+                }
+            }
+            // set new last value
+            processedDate.setLastValue(lastValue);
+
+        } catch (Exception ex) {
+            logger.error("Error with ftp connection", ex);
+        } finally {
+
+        }
+
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+//        br.setLength(0);
+//        br.append("\r\n").
+//                append("|\tLAST_PROCESS\t\t").
+//                append("|\tTYPE\t\t\r\n");
+//        for (Record record : listRecord) {
+//            ProcessedDate resultObj = (ProcessedDate) record;
+//            br.append("|\t").
+//                    append(resultObj.getLastProcess()).
+//                    append("\t|\t").
+//                    append(resultObj.getTypeProcess()).
+//                    append("\t|\r\n");
+//        }
+//        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    private long importDb(File _file) {
+
+        RandomAccessFile raf = null;
+        List<CallSignalObj> listSignal = new ArrayList();
+        String line = null;
+        try {
+            raf = new RandomAccessFile(_file, "r");
+//            raf.seek(0);
+
+            // count cdr in day
+            int allow = db.checkCdr();
+            logger.info("Check allow = " + allow);
+            // check in active time
+            if (betweenFrameHour(Common.SCAN_SIGNAL_TIME)) {
+                while ((line = raf.readLine()) != null) {
+                    if (!line.isEmpty() && line.split("\\|").length > 7) {
+                        String[] values = line.split("\\|");
+                        String calling = values[0];
+                        String called = values[1];
+                        String beginTime = values[2];
+                        String duration = values[3];
+                        String type = values[4];
+                        String money1 = values[19];
+                        String money3 = values[25];
+
+                        if (calling != null && !calling.trim().isEmpty() && "1".equals(type)
+                                && (!"0".equals(money1) || !"0".equals(money3))) {
+                            if (Common.LIST_TEST_MSISDN == null || Common.LIST_TEST_MSISDN.contains(calling)) {
+                                if (Common.blacklistVip == null || !Common.blacklistVip.contains(calling)) {
+                                    CallSignalObj signal = new CallSignalObj();
+                                    signal.setCallingNumber(formatMsisdn(calling));
+                                    signal.setCalledNumber(formatMsisdn(called));
+                                    signal.setStartTime(new Timestamp(sdfCdrLocal.parse(beginTime).getTime()));
+                                    signal.setCallDuration(Integer.parseInt(duration));
+                                    double moneyPaid = Double.parseDouble(money1) + Double.parseDouble(money3);
+                                    String balanceId = ("0".equals(money1) ? "" : "1") + "," + ("0".equals(money3) ? "" : "3");
+                                    signal.setMoneyPaid((int) (moneyPaid));
+                                    signal.setBalanceId(balanceId);
+//                                    signal.setEndTime(new Timestamp(Long.parseLong(end)));
+                                    signal.setMessageType(Integer.parseInt(type));
+                                    listSignal.add(signal);
+                                }
+                            }
+                        }
+                    }
+                }
+                if (!listSignal.isEmpty()) {
+                    db.insertCallSignal(listSignal, allow);
+                    listSignal.clear();
+                }
+            } else {
+                logger.info("Not in frame signal call");
+            }
+            return raf.getFilePointer();
+        } catch (Exception ex) {
+            logger.error("Error import DB: " + line, ex);
+        } finally {
+            try {
+                if (raf != null) {
+                    raf.close();
+                }
+            } catch (Exception ex) {
+            }
+        }
+        return _file.length();
+    }
+
+    private String formatMsisdn(String msisdn) {
+        if (msisdn == null || msisdn.trim().isEmpty()) {
+            return "";
+        }
+        msisdn = msisdn.trim();
+        if (msisdn.startsWith(Common.COUNTRY_CODE)) {
+            return msisdn;
+        } else if (msisdn.startsWith("0")) {
+            return Common.COUNTRY_CODE + msisdn.substring(1);
+        }
+        return Common.COUNTRY_CODE + msisdn;
+    }
+
+    public static void main(String[] args) throws ParseException {
+        String line = "Call|03e953f07005000008|67076476602|67076074277|501|10|1641884551019|0";
+        SimpleDateFormat sdfCdr = new SimpleDateFormat("yyyyMMdd");
+        SimpleDateFormat sdfCdr2 = new SimpleDateFormat("yyyyMMddHHmmss");
+        Date d = sdfCdr.parse("20230524102547");
+        System.out.println(sdfCdr2.format(d));
+    }
+
+    private boolean betweenFrameHour(List<String[]> listFrame) {
+        if (listFrame == null || listFrame.isEmpty()) {
+            return false;
+        }
+        for (String[] times : listFrame) {
+            String[] timeStart = times[0].split(":");
+            String[] timeEnd = times[1].split(":");
+
+            Date now = new Date();
+            Date begin = new Date(now.getYear(), now.getMonth(), now.getDate(),
+                    Integer.parseInt(timeStart[0].trim()), Integer.parseInt(timeStart[1].trim()));
+            Date end = new Date(now.getYear(), now.getMonth(), now.getDate(),
+                    Integer.parseInt(timeEnd[0].trim()), Integer.parseInt(timeEnd[1].trim()));
+
+            if (now.after(begin) && now.before(end)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 183 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/RenewSpinTimes.java

@@ -0,0 +1,183 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.luckycall.process;
+
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.LuckyCallUtils;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.LuckySpinObj;
+import com.vas.portal.utils.object.MtExtend;
+import com.vas.portal.utils.object.ProductInfo;
+import com.vas.portal.utils.object.RegisterInfo;
+import com.viettel.cluster.agent.integration.Record;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class RenewSpinTimes extends ProcessRecordAbstract {
+
+//    private String loggerLabel = ExtendResult.class.getSimpleName() + ": ";
+    private DbProcessor db;
+//    private WSProcessor ws;
+//    private DbExtend db;
+    private StringBuilder br = new StringBuilder();
+
+    public RenewSpinTimes() {
+        super();
+        logger = Logger.getLogger(RenewSpinTimes.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+
+            Common.listProduct = db.iLoadPackage();
+
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            // level spin added
+            Common.listSpinLevel = db.getSpinCallLevel();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+        List<MtExtend> listMtExtend = new ArrayList();
+        for (Record record : listMo) {
+
+            RegisterInfo regInfo = (RegisterInfo) record;
+            ProductInfo productInfo = getProductByName(regInfo.getProductName());
+            try {
+                sendLuckySpin(regInfo.getMsisdn(), productInfo);
+//                logger.error("Renew spin success " + regInfo.getMsisdn() + ", remain: " + remain);
+//                regInfo.setNumberAdded(productInfo.getNumberAdded());
+//                regInfo.setNumberPlayed(0);
+                // always success
+//                String message = MessageResponse.get(
+//                        Common.Message.RENEW_SPIN_SUCCESS + "_" + regInfo.getProductName(), Common.Message.RENEW_SPIN_SUCCESS, logger);
+//                message = message.replaceAll("%fee%", productInfo.getFee() + "");
+//                message = message.replaceAll("%spin%", productInfo.getNumberSpin() + "");
+//                MtExtend mtRecord = new MtExtend();
+//                mtRecord.setChannel(Common.CHANNEL);
+//                mtRecord.setMsisdn(regInfo.getMsisdn());
+//                mtRecord.setMessage(message);
+//                listMtExtend.add(mtRecord);
+            } catch (Exception ex) {
+                logger.error("Exception : ", ex);
+            }
+        }
+
+        if (listMtExtend.size() > 0) {
+            db.insertMtExtend(listMtExtend);
+            listMtExtend.clear();
+        }
+
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+//        StringBuilder br = new StringBuilder();
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tACCOUNT_ID\t\t").
+                append("|\tMSISDN\t\t").
+                append("|\tEXPIRE_TIME\t\t\r\n");
+        for (Record record : listRecord) {
+            RegisterInfo resultObj = (RegisterInfo) record;
+            br.append("|\t").
+                    append(resultObj.getRegisterId()).
+                    append("\t|\t").
+                    append(resultObj.getMsisdn()).
+                    append("\t|\t").
+                    append(resultObj.getExpireTime()).
+                    append("\t|\r\n");
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    protected ProductInfo getProductByName(String packName) {
+        for (ProductInfo product : Common.listProduct) {
+            if (product.getProductName().equalsIgnoreCase(packName)) {
+                return product;
+            }
+        }
+        return null;
+    }
+
+    protected void sendLuckySpin(String msisdn, ProductInfo productInfo) {
+        int numSpin = productInfo.getNumberSpin() / productInfo.getExpireDays();
+
+        logger.info("Add lucky spin for weekly: " + msisdn + ", num spin: " + numSpin);
+        LuckySpinObj lc = new LuckySpinObj();
+        lc.setMsisdn(msisdn);
+        lc.setExpireTime(getExpireSpin());
+        lc.setAdded(numSpin);
+        lc.setUsed(0);
+        lc.setChannelAdd(LuckyCallUtils.Channel.SUB + " " + productInfo.getProductName());
+
+        if (db.insertLuckySpin1(lc)) {
+//            String message;
+//            message = MessageResponse.get(Common.Message.REGISTER_GET_SPIN,
+//                    Common.Message.REGISTER_GET_SPIN + "_" + productInfo.getProductName(), logger);
+//            message = message.replace("%spin%", numSpin + "");
+//            message = message.replaceAll("%expire%", df.format(lc.getExpireTime()));
+//            SmsMtObj mt = new SmsMtObj();
+//            mt.setMsisdn(msisdn);
+//            mt.setChannel(Common.CHANNEL);
+//            mt.setMessage(message);
+//            db.insertMt(mt);
+            logger.info("Add spin success: " + msisdn + ", spin: " + numSpin);
+        }
+    }
+
+    protected Timestamp getExpireSpin() {
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 23);
+        cal.set(Calendar.MINUTE, 59);
+        cal.set(Calendar.SECOND, 59);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, Common.EXPIRE_DAYS_SPIN);
+        return new Timestamp(cal.getTimeInMillis());
+    }
+}

+ 374 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/SignalProcess.java

@@ -0,0 +1,374 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.luckycall.process;
+
+import com.viettel.cluster.agent.integration.Record;
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.CallSignalObj;
+import com.vas.portal.utils.object.InvitationObj;
+import com.vas.portal.utils.common.LuckyCallUtils;
+import com.vas.portal.utils.object.LuckySpinObj;
+import com.vas.portal.utils.object.MtExtend;
+import com.vas.portal.utils.object.MtRecord;
+import com.vas.portal.utils.object.SvAdv;
+import com.vas.portal.utils.object.SvAdvScheduler;
+import com.vas.portal.utils.service.WSProcessor;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+//import java.time.LocalDateTime;
+//import java.time.LocalTime;
+//import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+//import java.util.Random;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class SignalProcess extends ProcessRecordAbstract {
+
+    private WSProcessor ws;
+    private DbProcessor db;
+    private final StringBuilder br = new StringBuilder();
+    private final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+//    private final Random ran = new Random();
+
+    public SignalProcess() {
+        super();
+        logger = Logger.getLogger(SignalProcess.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.listProduct = db.iLoadPackage();
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            // level spin added
+            Common.listSpinLevel = db.getSpinCallLevel();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listRecord) throws Exception {
+        int codeType = LuckyCallUtils.CodeType.LUCKY_CARD;
+        List<MtExtend> listMtExtend = new ArrayList();
+        List<MtRecord> listMt = new ArrayList();
+        List<LuckySpinObj> listLuckySpin = new ArrayList();
+
+        // load service schedule broadcast
+        List<SvAdvScheduler> listSchedule = db.loadListSvAdvSchedule(codeType);
+        List<SvAdv> listAdv = new ArrayList();
+        for (SvAdvScheduler schedule : listSchedule) {
+            for (int i = 0; i < schedule.getPercent(); i++) {
+                listAdv.add(schedule.getSvAdv());
+            }
+        }
+
+        if (listAdv.size() < 100) {
+            int paddingSize = 100 - listAdv.size();
+            for (int i = 0; i < paddingSize; i++) {
+                listAdv.add(null);
+            }
+        }
+        HashMap<Integer, Integer> mCount = new HashMap();
+        int allow = db.checkCdr();
+        logger.info("Check allow = " + allow);
+
+        for (Record record : listRecord) {
+            CallSignalObj signalObj = (CallSignalObj) record;
+            String msisdn = signalObj.getCallingNumber();
+            boolean isSub = false;
+            boolean invited = false;
+            try {
+                // check invite
+                List<InvitationObj> listInvitation = db.getInvitation(msisdn);
+                if (listInvitation == null) {
+                    logger.error("Error check invitation: " + msisdn);
+                    continue;
+                }
+                InvitationObj invitation = null;
+                if (!listInvitation.isEmpty()) {
+                    invitation = listInvitation.get(0);
+                    if (invitation.getLastInvite().getTime() > atStartOfDay()) {
+                        // already invited
+                        logger.info("Already invited in day: " + msisdn);
+                        //continue;
+                        invited = true;
+                    }
+                }
+
+//                if (spinAdded > 0) {
+                // insert/update invite
+//                if (!invited) {
+//                    if (invitation != null) {
+//                        invitation.setMessageType(signalObj.getMessageType());
+//                        db.updateInvitation(invitation);
+//                    } else {
+//                        invitation = new InvitationObj();
+//                        invitation.setMsisdn(msisdn);
+//                        invitation.setMessageType(signalObj.getMessageType());
+//                        db.insertInvitation(invitation);
+//                    }
+//                }
+//                }
+                // check sub/unsub
+                Boolean checkReg = db.checkRegisterInfo(msisdn);
+                if (checkReg != null && checkReg) {
+                    // already registered
+                    logger.info("Already registered: " + msisdn);
+                    isSub = true;
+//                    continue;
+                } else {
+                    logger.info("Not registered: " + msisdn);
+                    isSub = false;
+//                    continue;
+                }
+
+                SvAdv svAdv = listAdv.get((int) (signalObj.getId() % listAdv.size()));
+
+                // add spin
+                int spinAdded = LuckyCallUtils.getSpinLevel(signalObj.getCallDuration());
+
+                LuckySpinObj lc = new LuckySpinObj();
+                lc.setMsisdn(msisdn);
+                lc.setExpireTime(getExpireSpin());
+                lc.setAdded(spinAdded);
+                lc.setUsed(0);
+                lc.setChannelAdd(LuckyCallUtils.Channel.CALL);
+                if (spinAdded > 0 && isSub) {
+                    listLuckySpin.add(lc);
+                }
+
+                if (!invited) {
+                    if (spinAdded > 0 && (svAdv == null || db.checkBlackListCall(msisdn) || allow == 0)) {
+                        String message;
+                        if (isSub) {
+                            // addd spin to customer
+                            message = MessageResponse.getMessage(Common.Message.MSG_GOT_LUCKY_SPIN_CALL, logger);
+                            message = message.replaceAll("%spin%", spinAdded + "");
+                            message = message.replaceAll("%expire%", sdf.format(lc.getExpireTime()));
+                            MtRecord mtRecord = new MtRecord();
+                            mtRecord.setChannel(Common.CHANNEL);
+                            mtRecord.setMsisdn(msisdn);
+                            mtRecord.setMessage(message);
+                            listMt.add(mtRecord);
+
+                            // increate counter
+                            if (mCount.containsKey(0)) {
+                                mCount.put(0, mCount.get(0) + 1);
+                            } else {
+                                mCount.put(0, 1);
+                            }
+
+                            // update invite
+                            if (invitation != null) {
+                                invitation.setMessageType(signalObj.getMessageType());
+                                db.updateInvitation(invitation);
+                            } else {
+                                invitation = new InvitationObj();
+                                invitation.setMsisdn(msisdn);
+                                invitation.setMessageType(signalObj.getMessageType());
+                                db.insertInvitation(invitation);
+                            }
+                        } else {
+                            // not sub: invite register -> not invite now
+//                        message = MessageResponse.getMessage(Common.Message.INVITE_REGISTER_CALL, logger);
+                        }
+
+                    } else if (allow == 1) {
+                        // other services
+                        long duration = signalObj.getCallDuration();
+                        if (svAdv != null && duration > svAdv.getFromMoney()) {
+                            if (invitation != null && invitation.getLastInvite() != null
+                                    && invitation.getLastInvite().getTime() > atStartOfDay(2)) {
+                                // already invited in n-1
+                                logger.info("Already invited in day n-1: " + msisdn);
+                            } else {
+                                // send sms
+                                String msgAdv = svAdv.getMsgAdv();
+                                msgAdv = msgAdv.replace("%money%", (duration) + "");
+                                MtExtend mt = new MtExtend();
+                                mt.setMsisdn(msisdn);
+                                mt.setChannel(svAdv.getChannelAdv());
+                                mt.setMessage(msgAdv);
+                                mt.setSendTime(signalObj.getEndTime());
+                                mt.setMessageType(svAdv.getMessageType());
+                                listMtExtend.add(mt);
+
+                                // increate counter
+                                if (mCount.containsKey(svAdv.getScheduleDetailId())) {
+                                    mCount.put(svAdv.getScheduleDetailId(), mCount.get(svAdv.getScheduleDetailId()) + 1);
+                                } else {
+                                    mCount.put(svAdv.getScheduleDetailId(), 1);
+                                }
+
+                                // update invite
+                                if (invitation != null) {
+                                    invitation.setMessageType(signalObj.getMessageType());
+                                    db.updateInvitation(invitation);
+                                } else {
+                                    invitation = new InvitationObj();
+                                    invitation.setMsisdn(msisdn);
+                                    invitation.setMessageType(signalObj.getMessageType());
+                                    db.insertInvitation(invitation);
+                                }
+                            }
+                        }
+                    }
+                }
+
+            } catch (Exception ex) {
+                logger.error("Error processing: " + msisdn, ex);
+            }
+        }
+
+        // insert code
+        if (listLuckySpin.size() > 0) {
+            db.insertLuckySpin(listLuckySpin);
+            listLuckySpin.clear();
+        }
+
+        // insert MT
+        if (!listMt.isEmpty()) {
+            db.insertMt(listMt);
+            listMt.clear();
+        }
+
+        if (listMtExtend.size() > 0) {
+            db.insertMtExtend(listMtExtend);
+            listMtExtend.clear();
+        }
+
+        if (mCount.size() > 0) {
+            for (Integer detailId : mCount.keySet()) {
+                db.updateCdrCounter(detailId, mCount.get(detailId), codeType);
+            }
+            mCount.clear();
+        }
+
+        return listRecord;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tID\t\t").
+                append("|\tMSISDN\t").
+                append("|\tDURATION\t").
+                append("|\tSTART TIME\r\n");
+        for (Record record : listRecord) {
+            CallSignalObj resultObj = (CallSignalObj) record;
+            br.append("|\t").
+                    append(resultObj.getId()).
+                    append("\t|\t").
+                    append(resultObj.getCallingNumber()).
+                    append("\t|\t").
+                    append(resultObj.getCallDuration()).
+                    append("\t|\t").
+                    append(sdf.format(resultObj.getStartTime())).
+                    append("\t|\r\n");
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    private String validateMsisdn(String input) {
+        if (input != null) {
+            if (input.startsWith(Common.COUNTRY_CODE)) {
+                return input;
+            } else {
+                return Common.COUNTRY_CODE + input;
+            }
+        }
+        return Common.COUNTRY_CODE;
+    }
+
+//    private ProductInfo getProductByName(String productName) {
+//        for (ProductInfo packInfo : Common.listProduct) {
+//            if (packInfo.getProductName().equalsIgnoreCase(productName)) {
+//                return packInfo;
+//            }
+//        }
+//        return Common.listProduct.get(0);
+//    }
+    private long atStartOfDay() {
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, 0);
+        return cal.getTimeInMillis();
+    }
+
+    private long atStartOfDay(int days) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, -days);
+        return cal.getTimeInMillis();
+    }
+
+    private Timestamp getExpireSpin() {
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 23);
+        cal.set(Calendar.MINUTE, 59);
+        cal.set(Calendar.SECOND, 59);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, Common.EXPIRE_DAYS_SPIN);
+        return new Timestamp(cal.getTimeInMillis());
+    }
+
+    public static void main(String[] args) {
+        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+        Calendar cal = Calendar.getInstance();
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, 0);
+        System.out.println(sdf.format(cal.getTimeInMillis()));
+    }
+}

+ 252 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/luckycall/process/SignalProcessBk.java

@@ -0,0 +1,252 @@
+///*
+// * To change this template, choose Tools | Templates
+// * and open the template in the editor.
+// */
+//package com.vas.luckycall.process;
+//
+//import com.viettel.cluster.agent.integration.Record;
+//import com.vas.portal.utils.common.Common;
+//import com.vas.portal.utils.common.MessageResponse;
+//import com.vas.portal.utils.database.DbProcessor;
+//import com.vas.portal.utils.object.CallSignalObj;
+//import com.vas.portal.utils.object.InvitationObj;
+//import com.vas.portal.utils.object.LuckyCode;
+//import com.vas.portal.utils.common.LuckyCallUtils;
+//import com.vas.portal.utils.object.MtRecord;
+//import com.vas.portal.utils.object.RegisterInfo;
+//import com.vas.portal.utils.service.WSProcessor;
+//import com.viettel.smsfw.process.ProcessRecordAbstract;
+//import java.sql.Timestamp;
+//import java.text.SimpleDateFormat;
+////import java.time.LocalDateTime;
+////import java.time.LocalTime;
+////import java.time.ZoneId;
+//import java.util.ArrayList;
+//import java.util.Calendar;
+//import java.util.HashMap;
+//import java.util.List;
+////import java.util.Random;
+//import org.apache.log4j.Logger;
+//
+///**
+// *
+// * @author
+// */
+//public class SignalProcessBk extends ProcessRecordAbstract {
+//
+//    private WSProcessor ws;
+//    private DbProcessor db;
+//    private final StringBuilder br = new StringBuilder();
+//    private final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+////    private final Random ran = new Random();
+//
+//    public SignalProcessBk() {
+//        super();
+//        logger = Logger.getLogger(SignalProcessBk.class);
+//    }
+//
+//    @Override
+//    public void initBeforeStart() throws Exception {
+//        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+//        db = new DbProcessor(dbName, logger);
+//        if (!MessageResponse.init) {
+//            HashMap listMsg = db.getListConfig("PROCESS");
+//            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+//            MessageResponse.setMessage(listMsg);
+//        }
+//
+//        if (Common.iLoadConfig) {
+//            Common.mapPrize = db.loadPrize(0);
+//            logger.info("List prize: " + Common.mapPrize);
+//            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+//            Common.mapMpsConfig = db.loadMpsConfig();
+//            //
+//            Common.blacklistVip = db.loadBlackListVip();
+//        }
+//    }
+//
+//    @Override
+//    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+//
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public List<Record> processListRecord(List<Record> listRecord) throws Exception {
+//
+//        List<MtRecord> listMt = new ArrayList();
+//        List<LuckyCode> listLuckyCode = new ArrayList();
+//        for (Record record : listRecord) {
+//            CallSignalObj signalObj = (CallSignalObj) record;
+//            String msisdn = signalObj.getCallingNumber();
+//
+//            try {
+//                // check invite
+//                List<InvitationObj> listInvitation = db.getInvitation(msisdn);
+//                if (listInvitation == null) {
+//                    logger.error("Error check invitation: " + msisdn);
+//                    continue;
+//                }
+//                InvitationObj invitation = null;
+//                if (!listInvitation.isEmpty()) {
+//                    invitation = listInvitation.get(0);
+//                    if (invitation.getLastInvite().getTime() > atStartOfDay()) {
+//                        // already invited
+//                        logger.info("Already invited in day: " + msisdn);
+//                        continue;
+//                    }
+//                }
+//
+//                // check sub/unsub
+//                List<RegisterInfo> listReg = db.getRegisterInfo(msisdn, Common.ServiceCode.LUCKY_CALL);
+//                if (listReg != null && !listReg.isEmpty()) {
+//                    // already registered
+//                    logger.info("Already registered: " + msisdn);
+//                    continue;
+//                }
+//
+//                // insert/update invite
+//                if (invitation != null) {
+//                    invitation.setMessageType(signalObj.getMessageType());
+//                    db.updateInvitation(invitation);
+//                } else {
+//                    invitation = new InvitationObj();
+//                    invitation.setMsisdn(msisdn);
+//                    invitation.setMessageType(signalObj.getMessageType());
+//                    db.insertInvitation(invitation);
+//                }
+//
+//                // create lucky code
+//                String codeId = String.format("%08d", signalObj.getId());
+//                String code = codeId.substring(codeId.length() - 8);
+//                LuckyCode lc = new LuckyCode();
+//                lc.setMsisdn(msisdn);
+//                lc.setPeriod(LuckyCallUtils.Period.DAILY);
+//                lc.setCode(code);
+//                lc.setExpireTime(getExpireCode(LuckyCallUtils.Period.DAILY));
+//                lc.setStatus(LuckyCallUtils.Status.NOT_REDEEM);
+//                lc.setCodeType(LuckyCallUtils.CodeType.LUCKY_CALL);
+//                listLuckyCode.add(lc);
+//
+//                String key = Common.Message.MSG_GOT_LUCKY_SPIN_CALL;
+//                // return message
+//                String message = MessageResponse.getMessage(key, logger);
+//                message = message.replaceAll("%code%", code);
+//                message = message.replaceAll("%expire%", sdf.format(lc.getExpireTime()));
+//
+//                MtRecord mtRecord = new MtRecord();
+//                mtRecord.setChannel(Common.CHANNEL);
+//                mtRecord.setMsisdn(msisdn);
+//                mtRecord.setMessage(message);
+//                listMt.add(mtRecord);
+//
+//            } catch (Exception ex) {
+//                logger.error("Error processing: " + msisdn, ex);
+//            }
+//        }
+//
+//        // insert code
+//        if (listLuckyCode.size() > 0) {
+//            db.insertLuckyCode(listLuckyCode);
+//            listLuckyCode.clear();
+//        }
+//
+//        // insert MT
+//        if (!listMt.isEmpty()) {
+//            db.insertMt(listMt);
+//            listMt.clear();
+//        }
+//
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public void printListRecord(List<Record> listRecord) throws Exception {
+//        br.setLength(0);
+//        br.append("\r\n").
+//                append("|\tID\t\t").
+//                append("|\tMSISDN\t").
+//                append("|\tSTART TIME\r\n");
+//        for (Record record : listRecord) {
+//            CallSignalObj resultObj = (CallSignalObj) record;
+//            br.append("|\t").
+//                    append(resultObj.getId()).
+//                    append("\t|\t").
+//                    append(resultObj.getCallingNumber()).
+//                    append("\t|\t").
+//                    append(sdf.format(resultObj.getStartTime())).
+//                    append("\t|\r\n");
+//        }
+//        logger.info(br);
+//    }
+//
+//    @Override
+//    public List<Record> processException(List<Record> listRecord) {
+//        logger.error("Exception when processing....");
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public boolean startProcessRecord() {
+//        return true;
+//    }
+//
+//    private String validateMsisdn(String input) {
+//        if (input != null) {
+//            if (input.startsWith(Common.COUNTRY_CODE)) {
+//                return input;
+//            } else {
+//                return Common.COUNTRY_CODE + input;
+//            }
+//        }
+//        return Common.COUNTRY_CODE;
+//    }
+//
+////    private ProductInfo getProductByName(String productName) {
+////        for (ProductInfo packInfo : Common.listProduct) {
+////            if (packInfo.getProductName().equalsIgnoreCase(productName)) {
+////                return packInfo;
+////            }
+////        }
+////        return Common.listProduct.get(0);
+////    }
+//    private long atStartOfDay() {
+//        Calendar cal = Calendar.getInstance();
+//        cal.set(Calendar.HOUR_OF_DAY, 0);
+//        cal.set(Calendar.MINUTE, 0);
+//        cal.set(Calendar.SECOND, 0);
+//        cal.set(Calendar.MILLISECOND, 0);
+//        cal.add(Calendar.DAY_OF_MONTH, -1);
+//        return cal.getTimeInMillis();
+//    }
+//
+//    private Timestamp getExpireCode(int type) {
+//        Calendar cal = Calendar.getInstance();
+//        cal.set(Calendar.HOUR_OF_DAY, 23);
+//        cal.set(Calendar.MINUTE, 59);
+//        cal.set(Calendar.SECOND, 59);
+//        cal.set(Calendar.MILLISECOND, 0);
+//        if (type == LuckyCallUtils.Period.WEEKLY) {
+//            cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+//            if (cal.getTimeInMillis() < System.currentTimeMillis()) {
+//                cal.add(Calendar.DAY_OF_MONTH, 7);
+//            }
+//        } else if (type == LuckyCallUtils.Period.MONTHLY) {
+//            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+//        }
+//        return new Timestamp(cal.getTimeInMillis());
+//    }
+//
+//    public static void main(String[] args) {
+//        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+//        Calendar cal = Calendar.getInstance();
+//        cal.set(Calendar.DAY_OF_MONTH, 1);
+//        cal.set(Calendar.HOUR_OF_DAY, 0);
+//        cal.set(Calendar.MINUTE, 0);
+//        cal.set(Calendar.SECOND, 0);
+//        cal.set(Calendar.MILLISECOND, 0);
+//        cal.add(Calendar.DAY_OF_MONTH, -1);
+//        System.out.println(sdf.format(cal.getTime()));
+//    }
+//}

+ 207 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/CdrRecharge.java

@@ -0,0 +1,207 @@
+///*
+// * To change this template, choose Tools | Templates
+// * and open the template in the editor.
+// */
+//package com.vas.portal.process;
+//
+//import com.vas.portal.utils.common.Common;
+//import com.vas.portal.utils.common.MessageResponse;
+//import com.vas.portal.utils.database.DbProcessor;
+//import com.vas.portal.utils.object.CdrRechargeObj;
+//import com.vas.portal.utils.object.ProcessedDate;
+//import com.viettel.cluster.agent.integration.Record;
+//import com.viettel.smsfw.process.ProcessRecordAbstract;
+//import java.io.BufferedOutputStream;
+//import java.io.BufferedReader;
+//import java.io.File;
+//import java.io.FileOutputStream;
+//import java.io.FileReader;
+//import java.io.OutputStream;
+//import java.sql.Timestamp;
+//import java.text.SimpleDateFormat;
+//import java.util.ArrayList;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import org.apache.commons.net.ftp.FTP;
+//import org.apache.commons.net.ftp.FTPClient;
+//import org.apache.commons.net.ftp.FTPFile;
+//import org.apache.log4j.Logger;
+//
+///**
+// *
+// * @author
+// */
+//public class CdrRecharge extends ProcessRecordAbstract {
+//
+////    private WSProcessor ws;
+//    private DbProcessor db;
+////    private DbExtend dbExtend;
+//    private StringBuilder br = new StringBuilder();
+//    private SimpleDateFormat sdfCdr = new SimpleDateFormat("yyyyMMdd");
+//    private SimpleDateFormat sdfTime = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //11/09/2020 00:00:07
+//
+//    public CdrRecharge() {
+//        super();
+//        logger = Logger.getLogger(CdrRecharge.class);
+//    }
+//
+//    @Override
+//    public void initBeforeStart() throws Exception {
+////        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+//        db = new DbProcessor(dbName, logger);
+////        dbExtend = new DbExtend(dbName, logger);
+//        if (!MessageResponse.init) {
+//            HashMap listMsg = db.getListConfig("PROCESS");
+//            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+//            MessageResponse.setMessage(listMsg);
+//        }
+//
+//        if (Common.iLoadConfig) {
+//            Common.mapPrize = db.loadPrize(0);
+//            logger.info("List prize: " + Common.mapPrize);
+//            Common.loadConfig(logger);
+////            logger.info("Map group prize: " + Common.mapGroupPrize);
+//            Common.mapMpsConfig = db.loadMpsConfig();
+//        }
+//    }
+//
+//    @Override
+//    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+//
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+//
+//        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+//        List<CdrRechargeObj> listCdrRecharge = new ArrayList();
+//        FTPClient ftpClient = new FTPClient();
+//        try {
+//            String todayStr = sdfCdr.format(new Date());
+//            ftpClient.connect(Common.FTP_RECHARGE_ADDRESS, 21);
+//            ftpClient.login(Common.FTP_RECHARGE_ACCOUNT, Common.FTP_RECHARGE_PASS);
+//            ftpClient.enterLocalPassiveMode();
+//            ftpClient.setConnectTimeout(120000);
+////            ftpClient.setControlKeepAliveTimeout(60000);
+//            ftpClient.setDataTimeout(120000);
+//            ftpClient.setSoTimeout(120000);
+//            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+//
+//            String clientFolder = Common.FTP_RECHARGE_DOWNLOADED_PATH + "/" + todayStr;
+//            File clientDir = new File(clientFolder);
+//            if (!clientDir.exists()) {
+//                clientDir.mkdir();
+//            }
+//            long newLastValue = processedDate.getLastValue();
+//            logger.info("Last value: " + newLastValue);
+//            ftpClient.changeWorkingDirectory(Common.FTP_RECHARGE_PATH);
+//            logger.debug("Changed directory to " + Common.FTP_RECHARGE_PATH);
+////            FTPFile[] listFile = ftpClient.listFiles("RC*" + todayStr + "*.DAT");
+//            FTPFile[] listFile = ftpClient.listFiles("*RC*.DAT");
+//            for (FTPFile file : listFile) {
+//                try {
+//                    // check last file
+//                    String fileName = file.getName();
+//                    logger.debug("file " + fileName);
+////                    int beginIdx = 2;
+////                    if (fileName.contains("_")) {
+////                        beginIdx = fileName.lastIndexOf("_") + 1;
+////                    }
+////                    long valueIdx = Long.parseLong(fileName.substring(beginIdx, beginIdx + 14));//fileName.length() - 4));
+//                    long lastModified = file.getTimestamp().getTimeInMillis();
+////                    logger.info("Last modified: " + lastModified + ", file: " + fileName);
+//                    //only get new file                    
+//                    if (lastModified > processedDate.getLastValue()) {
+//                        if (lastModified > newLastValue) {
+//                            newLastValue = lastModified;
+//                        }
+//                        logger.info("Start download cdr file: " + file.getName());
+//                        String clientPath = clientFolder + "/" + file.getName();
+//                        File downloadFile1 = new File(clientPath);
+//                        OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
+//                        ftpClient.retrieveFile(file.getName(), outputStream1);
+////                        logger.info("Delete file " + Common.FTP_RECHARGE_PATH + "/" + file.getName());
+//                        boolean resultDelete = ftpClient.deleteFile(Common.FTP_RECHARGE_PATH + "/" + file.getName());
+//                        logger.info(resultDelete + " Delete file " + Common.FTP_RECHARGE_PATH + "/" + file.getName());
+//                        outputStream1.close();
+//
+//                        // read downloaded file
+//                        BufferedReader input = new BufferedReader(new FileReader(downloadFile1));
+//                        try {
+//                            String line = null;
+//                            while ((line = input.readLine()) != null) {
+//                                // get field
+//                                String msisdn = line.split("\\|")[8];
+//                                String date = line.split("\\|")[1];
+//                                String money = line.split("\\|")[6];
+//
+//                                // insert db 
+//                                CdrRechargeObj cdr = new CdrRechargeObj();
+//                                cdr.setMsisdn(msisdn);
+//                                cdr.setRechargeTime(new Timestamp(sdfTime.parse(date).getTime()));
+//                                cdr.setMoney(Long.parseLong(money));
+//                                listCdrRecharge.add(cdr);
+//                            }
+//                        } finally {
+//                            input.close();
+//                        }
+//
+//                    }
+//                } catch (Exception ex1) {
+//                    logger.error("Error when process ftp file", ex1);
+//                }
+//            }
+//
+//            // insert cdr
+//            if (listCdrRecharge.size() > 0) {
+//                db.insertCdrRecharge(listCdrRecharge);
+//                listCdrRecharge.clear();
+//            }
+//
+//            // set new last value
+//            processedDate.setLastValue(newLastValue);
+//        } catch (Exception ex) {
+//            logger.error("Error with ftp connection", ex);
+//        } finally {
+//            try {
+//                if (ftpClient.isConnected()) {
+//                    ftpClient.logout();
+//                    ftpClient.disconnect();
+//                }
+//            } catch (Exception ex) {
+//            }
+//        }
+//
+//        return listMo;
+//    }
+//
+//    @Override
+//    public void printListRecord(List<Record> listRecord) throws Exception {
+//        br.setLength(0);
+//        br.append("\r\n").
+//                append("|\tLAST_PROCESS\t\t").
+//                append("|\tTYPE\t\t\r\n");
+//        for (Record record : listRecord) {
+//            ProcessedDate resultObj = (ProcessedDate) record;
+//            br.append("|\t").
+//                    append(resultObj.getLastProcess()).
+//                    append("\t|\t").
+//                    append(resultObj.getTypeProcess()).
+//                    append("\t|\r\n");
+//        }
+//        logger.info(br);
+//    }
+//
+//    @Override
+//    public List<Record> processException(List<Record> listRecord) {
+//        logger.error("Exception when processing....");
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public boolean startProcessRecord() {
+//        return true;
+//    }
+//}

+ 238 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/CdrRechargeSftpCard.java

@@ -0,0 +1,238 @@
+///*
+// * To change this template, choose Tools | Templates
+// * and open the template in the editor.
+// */
+//package com.vas.portal.process;
+//
+//import com.jcraft.jsch.Channel;
+//import com.jcraft.jsch.ChannelSftp;
+//import com.jcraft.jsch.JSch;
+//import com.jcraft.jsch.Session;
+//import com.vas.portal.utils.common.Common;
+//import com.vas.portal.utils.common.MessageResponse;
+//import com.vas.portal.utils.database.DbProcessor;
+//import com.vas.portal.utils.object.CdrRechargeObj;
+//import com.vas.portal.utils.object.ProcessedDate;
+//import com.viettel.cluster.agent.integration.Record;
+//import com.viettel.smsfw.process.ProcessRecordAbstract;
+//import java.io.BufferedOutputStream;
+//import java.io.BufferedReader;
+//import java.io.File;
+//import java.io.FileOutputStream;
+//import java.io.FileReader;
+//import java.io.OutputStream;
+//import java.sql.Timestamp;
+//import java.text.ParseException;
+//import java.text.SimpleDateFormat;
+//import java.util.ArrayList;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Vector;
+//import org.apache.log4j.Logger;
+//
+///**
+// *
+// * @author
+// */
+//public class CdrRechargeSftpCard extends ProcessRecordAbstract {
+//
+////    private WSProcessor ws;
+//    private DbProcessor db;
+////    private DbExtend dbExtend;
+//    private StringBuilder br = new StringBuilder();
+//    private SimpleDateFormat sdfCdr = new SimpleDateFormat("yyyyMMdd");
+//    private SimpleDateFormat sdfTime = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
+//
+//    public CdrRechargeSftpCard() {
+//        super();
+//        logger = Logger.getLogger(CdrRechargeSftpCard.class);
+//    }
+//
+//    @Override
+//    public void initBeforeStart() throws Exception {
+////        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+//        db = new DbProcessor(dbName, logger);
+////        dbExtend = new DbExtend(dbName, logger);
+//        if (!MessageResponse.init) {
+//            HashMap listMsg = db.getListConfig("PROCESS");
+//            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+//            MessageResponse.setMessage(listMsg);
+//        }
+//
+//        if (Common.iLoadConfig) {
+//            Common.mapPrize = db.loadPrize(0);
+//            logger.info("List prize: " + Common.mapPrize);
+//            Common.loadConfig(logger);
+////            logger.info("Map group prize: " + Common.mapGroupPrize);
+//            Common.mapMpsConfig = db.loadMpsConfig();
+//        }
+//    }
+//
+//    @Override
+//    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+//
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+//
+//        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+//        List<CdrRechargeObj> listCdrRecharge = new ArrayList();
+//
+//        JSch jsch = new JSch();
+//        Channel channel = null;
+//        Session session = null;
+//        try {
+//            String todayStr = sdfCdr.format(new Date());
+//            String clientFolder = Common.FTP_RECHARGE_DOWNLOADED_PATH + "/" + todayStr;
+//            File clientDir = new File(clientFolder);
+//            if (!clientDir.exists()) {
+//                clientDir.mkdir();
+//            }
+//            String serverFolder = Common.FTP_RECHARGE_PATH;// + "/" + todayStr + "/"; //+"*RC*.DAT";
+//
+//            session = jsch.getSession(Common.FTP_RECHARGE_ACCOUNT, Common.FTP_RECHARGE_ADDRESS, 21);
+//
+//            java.util.Properties config = new java.util.Properties();
+//            config.put("StrictHostKeyChecking", "no");
+//            session.setConfig(config);
+//
+//            //UserInfo ui = new MyUserInfo();
+//            session.setPassword(Common.FTP_RECHARGE_PASS);
+//            logger.info("Connect to server...");
+//            session.connect();
+//
+//            logger.info("Open channel...");
+//            channel = session.openChannel("sftp");
+//            channel.connect();
+//            ChannelSftp c = (ChannelSftp) channel;
+//
+//            logger.info("Get list file...");
+//            c.cd(serverFolder);
+//            Vector listFile = c.ls("*RC*.DAT");
+//            long newLastValue = processedDate.getLastValue();
+//            for (int i = 0; i < listFile.size(); i++) {
+//                try {
+//                    ChannelSftp.LsEntry lsEntry = (ChannelSftp.LsEntry) listFile.get(i);
+//                    String fileName = lsEntry.getFilename();
+//                    // check last file
+////                    String fileName = file.getName();
+//                    int beginIdx = 2;
+//                    if (fileName.contains("_")) {
+//                        beginIdx = fileName.lastIndexOf("_") + 3;
+//                    }
+//                    long valueIdx = Long.parseLong(fileName.substring(beginIdx, fileName.length() - 4));
+//                    //only get new file
+//                    if (valueIdx > processedDate.getLastValue()) {
+//                        if (valueIdx > newLastValue) {
+//                            newLastValue = valueIdx;
+//                        }
+//                        logger.info("Start download cdr file: " + fileName);
+//                        String clientPath = clientFolder + "/" + fileName;
+//                        File downloadFile1 = new File(clientPath);
+//                        OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
+//                        c.get(fileName, outputStream1);
+//
+//                        // delete
+////                        logger.info("Delete file " + Common.FTP_RECHARGE_PATH + "/" + fileName);
+////                        c.rm(Common.FTP_RECHARGE_PATH + "/" + fileName);
+//                        outputStream1.close();
+//
+//                        // read downloaded file
+//                        BufferedReader input = new BufferedReader(new FileReader(downloadFile1));
+//                        try {
+//                            String line = null;
+//                            while ((line = input.readLine()) != null) {
+//                                // get field
+//                                String msisdn = line.split("\\|")[8];
+//                                String date = line.split("\\|")[1];
+//                                String money = line.split("\\|")[6];
+//
+//                                // insert db 
+//                                CdrRechargeObj cdr = new CdrRechargeObj();
+//                                cdr.setMsisdn(msisdn);
+//                                cdr.setRechargeTime(new Timestamp(sdfTime.parse(date).getTime()));
+//                                cdr.setMoney(Long.parseLong(money));
+//                                listCdrRecharge.add(cdr);
+//                            }
+//                        } finally {
+//                            input.close();
+//                        }
+//                    }
+//
+//                } catch (Exception ex1) {
+//                    logger.error("Error when process ftp file", ex1);
+//                }
+//            }
+//            // insert cdr
+//            if (listCdrRecharge.size() > 0) {
+//                db.insertCdrRecharge(listCdrRecharge);
+//                listCdrRecharge.clear();
+//            }
+//
+//            // set new last value
+//            processedDate.setLastValue(newLastValue);
+//            //
+//        } catch (Exception ex) {
+//            logger.error("Error with sftp connection", ex);
+//        } finally {
+//            try {
+//                if (session != null) {
+//                    session.disconnect();
+//                }
+//                if (channel != null) {
+//                    channel.disconnect();
+//                }
+//            } catch (Exception ex) {
+//            }
+//        }
+//
+//        return listMo;
+//    }
+//
+//    @Override
+//    public void printListRecord(List<Record> listRecord) throws Exception {
+//        br.setLength(0);
+//        br.append("\r\n").
+//                append("|\tLAST_PROCESS\t\t").
+//                append("|\tTYPE\t\t\r\n");
+//        for (Record record : listRecord) {
+//            ProcessedDate resultObj = (ProcessedDate) record;
+//            br.append("|\t").
+//                    append(resultObj.getLastProcess()).
+//                    append("\t|\t").
+//                    append(resultObj.getTypeProcess()).
+//                    append("\t|\r\n");
+//        }
+//        logger.info(br);
+//    }
+//
+//    @Override
+//    public List<Record> processException(List<Record> listRecord) {
+//        logger.error("Exception when processing....");
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public boolean startProcessRecord() {
+//        return true;
+//    }
+//
+//    public static void main(String[] args) throws ParseException {
+////        String line
+////                = "VC12051941268766421|10/20/2020 12:09:53 PM|V|C|17457251|1516753251194#10551947256|1000000|0|67075140274|-450888|-1450888|01/18/2021 12:00:00 AM|01/18/2021 12:09:53 PM|5002|0|03/16/2020 09:04:05 AM|120||0";
+////
+////        SimpleDateFormat sdfTime = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
+////        String msisdn = line.split("\\|")[8];
+////        String date = line.split("\\|")[1];
+////        String money = line.split("\\|")[6];
+////        Date ddd = sdfTime.parse(date);
+////        System.out.println(msisdn + ", " + ddd + ", " + money);
+//        System.out.println(System.currentTimeMillis());
+//        Date n = new Date();
+//        n.setHours(6);
+//        System.out.println(n.getTime());
+//    }
+//}

+ 126 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/Disable.java

@@ -0,0 +1,126 @@
+//    /*
+// * To change this template, choose Tools | Templates
+// * and open the template in the editor.
+// */
+//package com.vas.portal.process;
+//
+//import com.vas.portal.utils.common.Common;
+//import com.vas.portal.utils.common.MessageResponse;
+//import com.vas.portal.utils.database.DbProcessor;
+//import com.vas.portal.utils.object.RegisterInfo;
+//import com.vas.portal.utils.service.WSProcessor;
+//import com.viettel.cluster.agent.integration.Record;
+//import com.viettel.smsfw.process.ProcessRecordAbstract;
+//import com.viettel.smsfw.utils.MoRecord;
+//import java.text.SimpleDateFormat;
+//import java.util.HashMap;
+//import java.util.List;
+//import org.apache.log4j.Logger;
+//
+///**
+// *
+// * @author
+// */
+//public class Disable extends ProcessRecordAbstract {
+//
+////    private String loggerLabel = ExtendResult.class.getSimpleName() + ": ";
+////    private DbProcessor db;
+//    private WSProcessor ws;
+//    private DbProcessor db;
+////    private DbExtend dbExtend;
+//    private StringBuilder br = new StringBuilder();
+//    private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
+//
+//    public Disable() {
+//        super();
+//        logger = Logger.getLogger(Disable.class);
+//    }
+//
+//    @Override
+//    public void initBeforeStart() throws Exception {
+//        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+//        db = new DbProcessor(dbName, logger);
+////        dbExtend = new DbExtend(dbName, logger);
+//        if (!MessageResponse.init) {
+//            HashMap listMsg = db.getListConfig("PROCESS");
+//            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+//            MessageResponse.setMessage(listMsg);
+//        }
+//
+//        if (Common.iLoadConfig) {
+//            Common.loadConfig(logger);
+//        }
+//    }
+//
+//    @Override
+//    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+//
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+//        for (Record record : listMo) {
+//
+//            MoRecord moRecord = (MoRecord) record;
+//            String msisdn = moRecord.getMsisdn();
+//            try {
+//                //Check register and update times to play in day 
+//                List<RegisterInfo> listRegisterInfo = db.getRegisterInfo(msisdn);
+//                if (listRegisterInfo == null || listRegisterInfo.isEmpty()) {
+//                    moRecord.setErrCode(Common.ErrCode.NOT_REGISTER);
+//                    String message = MessageResponse.getMessage(Common.Message.NOT_REGISTERED, logger);
+//                    moRecord.setMessage(message);
+//                    continue;
+//                }
+//
+//                ws.cancelService(msisdn, "CANCEL");
+//                db.iCancelService(listRegisterInfo.get(0).getRegisterId());
+//
+//                String message = MessageResponse.getMessage(Common.Message.DESTROY_ACCOUNT_SUCCESS, logger);
+//                moRecord.setErrCode(Common.ErrCode.SUCCESS);
+//                moRecord.setMessage(message);
+//
+//            } catch (Exception ex) {
+//                logger.error("Exception : ", ex);
+//            }
+//        }
+//
+//        return listMo;
+//    }
+//
+//    @Override
+//    public void printListRecord(List<Record> listRecord) throws Exception {
+////        StringBuilder br = new StringBuilder();
+//        br.setLength(0);
+//        br.append("\r\n").
+//                append("|\tID\t\t").
+//                append("|\tMSISDN\t\t").
+//                append("|\tCOMMAND\t\t\r\n");
+//        for (Record record : listRecord) {
+//            MoRecord moRecord = (MoRecord) record;
+//            br.append("|\t").
+//                    append(moRecord.getId()).
+//                    append("\t|\t").
+//                    append(moRecord.getMsisdn()).
+//                    append("\t|\t").
+//                    append(moRecord.getCommand()).
+//                    append("\t|\r\n");
+//            moRecord.setNodeName(holder.getNodeName());
+//            moRecord.setClusterName(holder.getClusterName());
+//        }
+//        logger.info(br);
+//    }
+//
+//    @Override
+//    public List<Record> processException(List<Record> listRecord) {
+//        logger.error("Exception when processing....");
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public boolean startProcessRecord() {
+//        return true;
+//    }
+//
+//}

+ 204 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/ExecutePrize.java

@@ -0,0 +1,204 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.portal.process;
+
+import com.viettel.cluster.agent.integration.Record;
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.ExecutePrizeObj;
+import com.vas.portal.utils.object.MtRecord;
+import com.vas.portal.utils.object.PrizeObj;
+import com.vas.portal.utils.object.PrizeWinner;
+import com.vas.portal.utils.service.WSProcessor;
+import com.viettel.smsfw.manager.AppManager;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import com.viettel.smsfw.utils.TransactionLog;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class ExecutePrize extends ProcessRecordAbstract {
+
+    private WSProcessor ws;
+    private DbProcessor db;
+    private StringBuilder br = new StringBuilder();
+
+    public ExecutePrize() {
+        super();
+        logger = Logger.getLogger(ExecutePrize.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.listProduct = db.iLoadPackage();
+
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            // level spin added
+            Common.listSpinLevel = db.getSpinCallLevel();
+            WSProcessor.USER_AUTHEN_LOYALTY = AppManager.getProperty("USER_AUTHEN_LOYALTY");
+            WSProcessor.KEY_LOYALTY = AppManager.getProperty("KEY_LOYALTY");
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+
+        List<MtRecord> listMt = new ArrayList();
+//        List<PrizeWinner> listWinner = new ArrayList();
+//        ObjectMapper mapper = new ObjectMapper();
+        for (Record record : listMo) {
+            ExecutePrizeObj executeObj = (ExecutePrizeObj) record;
+            executeObj.setStatus(Common.ErrCode.DB_ERROR);
+            PrizeObj prizeObj = Common.mapPrize.get(executeObj.getPrizeId());
+            try {
+                // check prize winner id
+                List<PrizeWinner> listWinnerCheck = db.getPrizeWinnerById(executeObj.getPrizeWinnerId());
+                if (listWinnerCheck == null) {
+                    logger.error("Error check prize winner again: " + executeObj.getMsisdn() + ", prizeWinnerId: " + executeObj.getPrizeId());
+                    continue;
+                }
+                if (listWinnerCheck.isEmpty()) {
+                    logger.warn("Not found prize winner: " + executeObj.getMsisdn() + ", prizeWinnerId: " + executeObj.getPrizeId());
+                    continue;
+                }
+                PrizeWinner prizeWinner = listWinnerCheck.get(0);
+                if (prizeWinner.getProcessTime() != null) {
+                    logger.warn("Prize already processed: " + executeObj.getMsisdn() + ", prizeWinnerId: " + executeObj.getPrizeId());
+                    continue;
+                }
+                // update prize winner processed
+                if (db.updatePrizeWinnerProcessed(executeObj.getPrizeWinnerId(), holder.getNodeName())) {
+                    String rsWs = Common.ErrCode.SUCCESS;
+                    // run command
+                    if (prizeObj.getActionType().equals("MPS")) {
+                        rsWs = ws.executeCmd(executeObj.getMsisdn(), prizeObj.getActionCode());
+                    } else if (prizeObj.getActionType().equals("ADD_COIN")) {
+                        if (db.addCoin(executeObj.getMsisdn()) == null) {
+                            rsWs = Common.ErrCode.DB_ERROR;
+                        }
+                    } else if (prizeObj.getActionType().equals("LOYALTY")) {
+                        // loyalty point, minute, data...
+                        String refTransId = System.currentTimeMillis() + "-" + executeObj.getId() + "-" + executeObj.getMsisdn() + "-" + prizeObj.getActionCode();
+                        TransactionLog response = ws.sendAddLoyalty(executeObj.getMsisdn(), prizeObj.getActionCode(), refTransId);
+
+                        //cusBonus.setResponseContent(response);
+                        if (response != null && response.getErrorCode().equals("SUCCESS")) {
+                            logger.info("Add prize success: " + executeObj.getMsisdn() + ", " + prizeObj.getActionCode());
+                            rsWs = Common.ErrCode.SUCCESS;
+//                           // insert MT
+//                           String message = MessageResponse.get(Common.Message.ADD_BONUS_LOYALTY_SUCCESS, logger, cusBonus.getLang());
+//                           ReqSendMt reqSendMt = new ReqSendMt(cusBonus.getMsisdn(), message);
+//                           ws.sendMt(reqSendMt);
+                        } else {
+                            rsWs = Common.ErrCode.PRO_ERROR;
+                            logger.info("Add prize failed: " + executeObj.getMsisdn() + ", " + prizeObj.getActionCode());
+                        }
+                    } else {
+                        logger.error("Not config prize execution: " + executeObj.getMsisdn() + ", " + prizeObj.getActionCode());
+                        rsWs = "1";
+                    }
+
+                    executeObj.setStatus(rsWs);
+                    if ("0".equals(rsWs)) {
+                        logger.info("Execute success: " + executeObj.getMsisdn() + ", " + prizeObj.getActionCode());
+                        // send mt 
+                        String key = Common.Message.MSG_PRIZE_WINNER;
+                        String message = MessageResponse.get(key + "_" + prizeObj.getActionCode(), key, logger);
+                        message = message.replaceAll("%prize%", prizeObj.getDescription());
+
+                        MtRecord mtRecord = new MtRecord();
+                        mtRecord.setChannel(Common.CHANNEL);
+                        mtRecord.setMsisdn(executeObj.getMsisdn());
+                        mtRecord.setMessage(message);
+                        listMt.add(mtRecord);
+                    } else {
+                        logger.error("Execute failed: " + executeObj.getMsisdn() + ", " + prizeObj.getActionCode());
+                    }
+                } else {
+                    logger.error("Error update processed winner: " + executeObj.getMsisdn() + ", Id: " + executeObj.getPrizeWinnerId());
+                }
+
+            } catch (Exception ex) {
+                logger.error("Execute failed: " + executeObj.getMsisdn() + ", " + prizeObj.getActionCode(), ex);
+            }
+        }
+
+        if (listMt.size() > 0) {
+            db.insertMt(listMt);
+            listMt.clear();
+        }
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tID\t\t").
+                append("|\tMSISDN\t\t").
+                append("|\tPRIZE ID\r\n");
+        for (Record record : listRecord) {
+            ExecutePrizeObj resultObj = (ExecutePrizeObj) record;
+            br.append("|\t").
+                    append(resultObj.getId()).
+                    append("\t|\t").
+                    append(resultObj.getMsisdn()).
+                    append("\t|\t").
+                    append(resultObj.getPrizeId()).
+                    append("\t|\r\n");
+
+            resultObj.setNodeProcess(holder.getNodeName());
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    private String validateMsisdn(String input) {
+        if (input != null) {
+            if (input.startsWith(Common.COUNTRY_CODE)) {
+                return input;
+            } else {
+                return Common.COUNTRY_CODE + input;
+            }
+        }
+        return Common.COUNTRY_CODE;
+    }
+}

+ 115 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/Help.java

@@ -0,0 +1,115 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.portal.process;
+
+import com.viettel.cluster.agent.integration.Record;
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import com.viettel.smsfw.utils.MoRecord;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class Help extends ProcessRecordAbstract {
+
+//    private String loggerLabel = ExtendResult.class.getSimpleName() + ": ";
+//    private DbProcessor db;
+//    private WSProcessor ws;
+    private DbProcessor db;
+    private StringBuilder br = new StringBuilder();
+
+    public Help() {
+        super();
+        logger = Logger.getLogger(Help.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+//        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+//        dbExtend = new DbExtend(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+
+        for (Record record : listMo) {
+
+            MoRecord moRecord = (MoRecord) record;
+//            String msisdn = moRecord.getMsisdn();
+//            ProductInfo productInfo = getProductBySyntax(moRecord.getCommand().toUpperCase());
+            try {
+                String message = MessageResponse.get(Common.Message.INTRODUCE_MESSAGE + "_" + moRecord.getParam(), Common.Message.INTRODUCE_MESSAGE, logger);
+                moRecord.setErrCode(Common.ErrCode.SUCCESS);
+                moRecord.setMessage(message);
+
+            } catch (Exception ex) {
+                logger.error("Exception : ", ex);
+            }
+        }
+
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+//        StringBuilder br = new StringBuilder();
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tID\t\t").
+                append("|\tMSISDN\t\t").
+                append("|\tCOMMAND\t\t\r\n");
+        for (Record record : listRecord) {
+            MoRecord moRecord = (MoRecord) record;
+            br.append("|\t").
+                    append(moRecord.getId()).
+                    append("\t|\t").
+                    append(moRecord.getMsisdn()).
+                    append("\t|\t").
+                    append(moRecord.getCommand()).
+                    append("\t|\r\n");
+            moRecord.setNodeName(holder.getNodeName());
+            moRecord.setClusterName(holder.getClusterName());
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+}

+ 182 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/PrepairDailyPrize.java

@@ -0,0 +1,182 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.portal.process;
+
+import com.viettel.cluster.agent.integration.Record;
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.common.LuckyCallUtils;
+import com.vas.portal.utils.object.DailyPrizeObj;
+import com.vas.portal.utils.object.PrizeObj;
+import com.vas.portal.utils.object.ProcessedDate;
+import com.vas.portal.utils.object.ReportPreviousObj;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class PrepairDailyPrize extends ProcessRecordAbstract {
+
+//    private WSProcessor ws;
+    private DbProcessor db;
+    private StringBuilder br = new StringBuilder();
+
+    public PrepairDailyPrize() {
+        super();
+        logger = Logger.getLogger(PrepairDailyPrize.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+//        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.listProduct = db.iLoadPackage();
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            // level spin added
+            Common.listSpinLevel = db.getSpinCallLevel();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+
+        List<DailyPrizeObj> listDailyPrize = new ArrayList();
+        List<Long> listNumberWin = new ArrayList();
+        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+        if (processedDate.getLastProcess().getDay() != (new Date()).getDay()) {
+            LuckyCallUtils.counterCdr.set(0);
+        }
+
+        // insert previous
+        db.insertReportPrevious();
+
+        // check previous
+        ReportPreviousObj reportPre;
+        List<ReportPreviousObj> listReport = db.getReportPrevious();
+        if (listReport != null && !listReport.isEmpty()) {
+            reportPre = listReport.get(0);
+            if (reportPre.getNumRequest() < Common.DEFAULT_NUM_REQUEST) {
+                reportPre.setNumRequest(Common.DEFAULT_NUM_REQUEST);
+            }
+            if (reportPre.getRevenue() < Common.DEFAULT_REVENUE) {
+                reportPre.setRevenue(Common.DEFAULT_REVENUE);
+            }
+        } else {
+            reportPre = new ReportPreviousObj();
+            reportPre.setNumRequest(Common.DEFAULT_NUM_REQUEST);
+            reportPre.setRevenue(Common.DEFAULT_REVENUE);
+        }
+
+        // loop prize 
+        for (PrizeObj prizeSub : Common.mapPrize.values()) {
+            if (prizeSub.getPeriod() == LuckyCallUtils.Period.DAILY) {
+                // total prize by last revenue
+                int numberPrize = 0;
+                if (prizeSub.getMoneyConverted() > 0) {
+                    numberPrize = (int) (reportPre.getRevenue() * prizeSub.getPercentRatio() / prizeSub.getMoneyConverted() / 100);
+                } else {
+                    numberPrize = (int) (reportPre.getNumRequest() * prizeSub.getPercentRatio() / 100);
+                    // limit 500 prize ticket
+                    if (numberPrize > 500) {
+                        numberPrize = 500;
+                    }
+                }
+                logger.info("Number prize " + prizeSub.getPrizeName() + ": " + numberPrize);
+                if (numberPrize > 0) {
+                    int winEvery = (int) Math.floor(reportPre.getNumRequest() / numberPrize);
+                    // check total request
+                    for (int i = 0; i < numberPrize; i++) {
+                        DailyPrizeObj dailyPrize = new DailyPrizeObj();
+                        dailyPrize.setPrizeId(prizeSub.getId());
+                        Long numWin = (long) (i + 1) * winEvery;
+                        numWin = getValidNumberWin(listNumberWin, numWin);
+                        dailyPrize.setNumberWin(numWin);
+                        //
+                        listDailyPrize.add(dailyPrize);
+                        listNumberWin.add(numWin);
+                    }
+                }
+            }
+        }
+
+        logger.info("ListDailyPrize: " + listDailyPrize);
+//        // padding
+//        if (listDailyPrize.size() < 100) {
+//            int len = 100 - listDailyPrize.size();
+//            for (int i = 0; i < len; i++) {
+//                listDailyPrize.add(new PrizeObj());
+//            }
+//        }
+//        Collections.shuffle(listDailyPrize);
+
+        db.removeDailyPrizeUsed();
+        db.insertDailyPrize(listDailyPrize, LuckyCallUtils.CodeType.LUCKY_CARD);
+        listDailyPrize.clear();
+
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tLAST_PROCESS\t\t").
+                append("|\tTYPE\t\t\r\n");
+        for (Record record : listRecord) {
+            ProcessedDate resultObj = (ProcessedDate) record;
+            br.append("|\t").
+                    append(resultObj.getLastProcess()).
+                    append("\t|\t").
+                    append(resultObj.getTypeProcess()).
+                    append("\t|\r\n");
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    private long getValidNumberWin(List<Long> listDailyPrize, Long numberWin) {
+        while (listDailyPrize.contains(numberWin)) {
+            logger.warn("Duplicated number win, check increase: " + numberWin);
+            numberWin++;
+        }
+        return numberWin;
+    }
+}

+ 203 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/PrizeProcess.java

@@ -0,0 +1,203 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.portal.process;
+
+import com.viettel.cluster.agent.integration.Record;
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.LuckyCallUtils;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.PrizeObj;
+import com.vas.portal.utils.object.ProcessedDate;
+import com.vas.portal.utils.object.ReportPreviousObj;
+import com.vas.portal.utils.service.WSProcessor;
+import com.viettel.smsfw.manager.AppManager;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class PrizeProcess extends ProcessRecordAbstract {
+
+//    private WSProcessor ws;
+    private DbProcessor db;
+    private StringBuilder br = new StringBuilder();
+
+    public PrizeProcess() {
+        super();
+        logger = Logger.getLogger(PrizeProcess.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+
+            Common.listProduct = db.iLoadPackage();
+
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+            //
+            Common.blacklistVip = db.loadBlackListVip();
+            // level spin added
+            Common.listSpinLevel = db.getSpinCallLevel();
+            WSProcessor.USER_AUTHEN_LOYALTY = AppManager.getProperty("USER_AUTHEN_LOYALTY");
+            WSProcessor.KEY_LOYALTY = AppManager.getProperty("KEY_LOYALTY");
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+
+        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+
+        ReportPreviousObj reportPre;
+        List<ReportPreviousObj> listReport = db.getRevenueWeek();
+        if (listReport != null && !listReport.isEmpty()) {
+            reportPre = listReport.get(0);
+        } else {
+            reportPre = new ReportPreviousObj();
+            reportPre.setNumRequest(Common.DEFAULT_NUM_REQUEST * 7);
+            reportPre.setRevenue(Common.DEFAULT_REVENUE * 7);
+        }
+        // get random winner
+        List<String> listWinner = db.getRandomWinner();
+        int lenTotal = listWinner.size();
+        int countWinner = 0;
+        // loop prize
+        for (PrizeObj prizeSub : Common.mapPrize.values()) {
+            if (prizeSub.getPeriod() == LuckyCallUtils.Period.WEEKLY) {
+                try {
+                    logger.info("prizeInfo: " + prizeSub);
+                    // total prize by last revenue
+                    int numberPrize = (int) (reportPre.getRevenue() * prizeSub.getPercentRatio() / prizeSub.getMoneyConverted() / 100);
+                    logger.info("Number prize " + prizeSub.getPrizeName() + ": " + numberPrize);
+                    if (numberPrize > 0) {
+                        for (int i = 0; i < numberPrize; i++) {
+                            // round again if no more user in listWinner
+                            if (i + countWinner >= lenTotal) {
+                                countWinner = 0;
+                            }
+                            // get winner
+                            if (i + countWinner < lenTotal) {
+                                String msisdn = listWinner.get(i + countWinner);
+                                if (db.addPrize(msisdn, prizeSub.getId())) {
+                                    logger.info("Add prize success: " + msisdn + ", prize:" + prizeSub.getPrizeName());
+                                } else {
+                                    logger.error("Add prize failed: " + msisdn + ", prize:" + prizeSub.getPrizeName());
+                                }
+
+//                            //return message
+//                            String key = Common.Message.MSG_PRIZE_WINNER;
+//                            String message = MessageResponse.get(key + "_" + prizeObj.getChannel() + "_" + prizeObj.getId(),
+//                                    key + "_" + prizeObj.getId(), logger);
+//                            message = message.replaceAll("%prize%", prizeObj.getDescription());
+//                            message = message.replaceAll("%code%", lc.getCode());
+//
+//                            MtRecord mtRecord = new MtRecord();
+//                            mtRecord.setChannel(Common.CHANNEL);
+//                            mtRecord.setMsisdn(lc.getMsisdn());
+//                            mtRecord.setMessage(message);
+//                            listMt.add(mtRecord);
+                            } else {
+                                logger.warn("Winner out of range total spin: " + (i + countWinner) + ", total: " + lenTotal);
+                            }
+                        }
+
+                        // add counter winner
+                        countWinner += numberPrize;
+                    }
+                } catch (Exception ex) {
+                    logger.error("Error execute prize weekly: " + ex.getMessage(), ex);
+                }
+            }
+        }
+//        }
+
+//        if (listMt.size() > 0) {
+//            db.insertMt(listMt);
+//            listMt.clear();
+//        }
+//        if (listChargeLog.size() > 0) {
+//            db.insertChargeLog(listChargeLog);
+//            listChargeLog.clear();
+//        }
+//
+//        if (listCmd.size() > 0) {
+//            db.insertExecutePrize(listCmd);
+//            listCmd.clear();
+//        }
+//        if (listWinner.size() > 0) {
+//            db.insertPrizeWinner(listWinner);
+//            listWinner.clear();
+//        }
+        // delete lucky code all expired
+//        db.insertLuckyCodeHis();
+//        db.deleteLuckyCode();
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tLAST_PROCESS\t\t").
+                append("|\tTYPE\t\t\r\n");
+        for (Record record : listRecord) {
+            ProcessedDate resultObj = (ProcessedDate) record;
+            br.append("|\t").
+                    append(resultObj.getLastProcess()).
+                    append("\t|\t").
+                    append(resultObj.getTypeProcess()).
+                    append("\t|\r\n");
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+
+    private String validateMsisdn(String input) {
+        if (input != null) {
+            if (input.startsWith(Common.COUNTRY_CODE)) {
+                return input;
+            } else {
+                return Common.COUNTRY_CODE + input;
+            }
+        }
+        return Common.COUNTRY_CODE;
+    }
+
+    public static void main(String[] args) {
+        System.out.println(3 * 35 / 100);
+    }
+}

+ 395 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/PrizeProcessOnline.java

@@ -0,0 +1,395 @@
+///*
+// * To change this template, choose Tools | Templates
+// * and open the template in the editor.
+// */
+//package com.vas.portal.process;
+//
+//import com.viettel.cluster.agent.integration.Record;
+//import com.vas.portal.utils.common.Common;
+//import com.vas.portal.utils.common.MessageResponse;
+//import com.vas.portal.utils.database.DbProcessor;
+//import com.vas.portal.utils.object.ChargeLog;
+//import com.vas.portal.utils.object.ExecutePrizeObj;
+//import com.vas.portal.utils.object.LuckyCode;
+//import com.vas.portal.utils.common.LuckyCallUtils;
+//import com.vas.portal.utils.object.MtRecord;
+//import com.vas.portal.utils.object.PrizeObj;
+//import com.vas.portal.utils.object.PrizeWinner;
+//import com.vas.portal.utils.object.ProcessedDate;
+//import com.viettel.smsfw.process.ProcessRecordAbstract;
+//import java.sql.Timestamp;
+//import java.text.SimpleDateFormat;
+//import java.util.ArrayList;
+//import java.util.Calendar;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Random;
+//import org.apache.log4j.Logger;
+//
+///**
+// *
+// * @author
+// */
+//public class PrizeProcessOnline extends ProcessRecordAbstract {
+//
+////    private WSProcessor ws;
+//    private DbProcessor db;
+//    private StringBuilder br = new StringBuilder();
+//    private final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+//
+//    public PrizeProcessOnline() {
+//        super();
+//        logger = Logger.getLogger(PrizeProcessOnline.class);
+//    }
+//
+//    @Override
+//    public void initBeforeStart() throws Exception {
+////        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+//        db = new DbProcessor(dbName, logger);
+//        if (!MessageResponse.init) {
+//            HashMap listMsg = db.getListConfig("PROCESS");
+//            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+//            MessageResponse.setMessage(listMsg);
+//        }
+//
+//        if (Common.iLoadConfig) {
+//            Common.mapPrize = db.loadPrize(0);
+//            logger.info("List prize: " + Common.mapPrize);
+//            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+//            Common.mapMpsConfig = db.loadMpsConfig();
+//        }
+//    }
+//
+//    @Override
+//    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+//
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+//
+//        List<MtRecord> listMt = new ArrayList();
+//        List<ChargeLog> listChargeLog = new ArrayList();
+//        List<ExecutePrizeObj> listCmd = new ArrayList();
+//        List<PrizeWinner> listWinner = new ArrayList();
+//        List<LuckyCode> listLuckyCode = new ArrayList();
+//
+//        ProcessedDate processedDate = (ProcessedDate) listMo.get(0);
+//        if (processedDate.getLastProcess().getDay() != (new Date()).getDay()) {
+//            LuckyCallUtils.counterCdr.set(0);
+////            Common.mochaList = db.loadMochaUser();
+//        }
+//
+////        if (Common.mochaList == null || Common.mochaList.isEmpty()) {
+////            Common.mochaList = db.loadMochaUser();
+////        }
+//        int numPrize = 0;
+//        for (List<List<PrizeObj>> subGroups : Common.mapGroupPrize.values()) {
+//            for (List<PrizeObj> prizesInSub : subGroups) {
+//                PrizeObj prizeSub = prizesInSub.get(0);
+//                // total prize group
+//                int numberPrizeSubGroup = prizeSub.getNumberPrize();
+////                logger.info("Number prize in sub group " + prizesInSub.get(0).getSubGroupPrize() + ": " + numberPrizeSubGroup
+////                        + ", prize type: " + prizeSub.getNumberPrizeType());
+//                if (prizeSub.getNumberPrizeType() == LuckyCallUtils.NumberPrizeType.FIXED_TIMES
+//                        && prizeSub.getPeriod() == LuckyCallUtils.Period.DAILY) {
+//                    numPrize += numberPrizeSubGroup;
+//                }
+//            }
+//        }
+//
+//        for (int codeType = 0; codeType < 2; codeType++) {
+//            List<LuckyCode> listCodeWinner = db.getLuckyCodeDaily(codeType);
+//
+//            for (LuckyCode luckyCode : listCodeWinner) {
+////            boolean isPrized = false; 
+//                int confirmChannel = luckyCode.getConfirmChannel() == 1 ? 1 : 0;
+//                // loop prize
+//                for (List<List<PrizeObj>> subGroups : Common.mapGroupPrize.values()) {
+//
+//                    logger.info("Subgroups: " + subGroups);
+//                    // get total winner in group
+//                    PrizeObj temp = subGroups.get(0).get(0);
+//                    if ((temp.getChannel() == -1 || temp.getChannel() == confirmChannel)
+//                            && (temp.getPeriod() == luckyCode.getPeriod())
+//                            && (temp.getTimesPrize() == 0 || temp.getTimesPrize() == luckyCode.getCountTimes())) {
+//                        // check prize percent of fixed
+//                        //<editor-fold defaultstate="collapsed" desc="check prize">
+//                        if (temp.getNumberPrizeType() == LuckyCallUtils.NumberPrizeType.PERCENT) {
+//                            // get randome prize
+//                            //<editor-fold defaultstate="collapsed" desc="percent">
+//                            int numPrizePercent = temp.getNumberPrize();
+//                            Random ran = new Random();
+//                            int check = ran.nextInt(100);
+//                            if (check >= numPrizePercent) {
+//                                // no prize
+//                                processNoPrize(luckyCode, listMt);
+//                            } else {
+//                                //
+//                                ExecutePrizeObj cmd = new ExecutePrizeObj();
+//                                cmd.setMsisdn(luckyCode.getMsisdn());
+//                                cmd.setPrizeId(temp.getId());
+//                                cmd.setCodeType(codeType);
+//                                listCmd.add(cmd);
+//                                // add winner
+//                                PrizeWinner winner = new PrizeWinner();
+//                                winner.setMsisdn(luckyCode.getMsisdn());
+//                                winner.setPrizeId(temp.getId());
+//                                winner.setCode(luckyCode.getCode());
+//                                winner.setCodeTime(luckyCode.getConfirmTime());
+//                                winner.setCodeType(luckyCode.getCodeType());
+//                                listWinner.add(winner);
+//
+//                                //return message
+//                                String key = Common.Message.MSG_PRIZE_WINNER;
+//                                String message = MessageResponse.get(key + "_" + temp.getChannel() + "_" + temp.getId(),
+//                                        key + "_" + temp.getId(), logger);
+//                                message = message.replaceAll("%prize%", temp.getDescription());
+//                                message = message.replaceAll("%code%", luckyCode.getCode());
+//
+//                                MtRecord mtRecord = new MtRecord();
+//                                mtRecord.setChannel(Common.CHANNEL);
+//                                mtRecord.setMsisdn(luckyCode.getMsisdn());
+//                                mtRecord.setMessage(message);
+//                                listMt.add(mtRecord);
+//
+//                                // present 1 code for 1st redeem mocha lucky calll
+//                                if (codeType == LuckyCallUtils.CodeType.LUCKY_CALL
+//                                        && temp.getChannel() == LuckyCallUtils.Channel.MOCHA
+//                                        && temp.getTimesPrize() == LuckyCallUtils.PrizeTimes.FIRST_TIMES) {
+//                                    String codeId = String.format("%08d", db.getNextCode());
+//                                    String code = codeId.substring(codeId.length() - 8);
+//
+//                                    LuckyCode lc = new LuckyCode();
+//                                    lc.setMsisdn(luckyCode.getMsisdn());
+//                                    lc.setPeriod(LuckyCallUtils.Period.DAILY);
+//                                    lc.setCode(code);
+//                                    lc.setExpireTime(getExpireCode(LuckyCallUtils.Period.DAILY));
+//                                    lc.setStatus(LuckyCallUtils.Status.NOT_REDEEM);
+//                                    lc.setCodeType(LuckyCallUtils.CodeType.LUCKY_CALL);
+//                                    listLuckyCode.add(lc);
+//
+//                                    key = Common.Message.MSG_GOT_LUCKY_CODE_BONUS;
+//                                    // return message
+//                                    message = MessageResponse.getMessage(key, logger);
+//                                    message = message.replaceAll("%code%", code);
+//                                    message = message.replaceAll("%expire%", sdf.format(lc.getExpireTime()));
+//                                    mtRecord = new MtRecord();
+//                                    mtRecord.setChannel(Common.CHANNEL);
+//                                    mtRecord.setMsisdn(luckyCode.getMsisdn());
+//                                    mtRecord.setMessage(message);
+//                                    listMt.add(mtRecord);
+//                                }
+//                            }
+//                            //</editor-fold>
+//                        } else {
+//                            //<editor-fold defaultstate="collapsed" desc="fixed">
+//                            Random ran = new Random();
+//                            int check = ran.nextInt(120);
+//                            if (check >= numPrize) {
+//                                // no prize
+//                                processNoPrize(luckyCode, listMt);
+//                            } else {
+//                                // check remain in DB
+//                                PrizeObj nextPrize = db.getNextDailyPrize(temp.getChannel(), temp.getPeriod(), temp.getTimesPrize(), codeType);
+//                                if (nextPrize == null || nextPrize.getSubGroupPrize() == 0) {
+//                                    // no prize
+//                                    if (nextPrize != null) {
+//                                        // update prize used
+//                                        db.updateDailyPrizeUsed(nextPrize.getId(), luckyCode.getMsisdn());
+//                                    }
+//                                    processNoPrize(luckyCode, listMt);
+//                                } else {
+//                                    PrizeObj prizeObj = null;
+//                                    List<PrizeObj> listPrizeTmp = getPrizeInSubGroup(nextPrize.getSubGroupPrize());
+//                                    // get prize in subgroup
+//                                    if (listPrizeTmp.size() == 1) {
+//                                        prizeObj = listPrizeTmp.get(0);
+//                                    } else {
+//                                        for (PrizeObj pr : listPrizeTmp) {
+//                                            if (pr.getPrefixMsisdn() == null || pr.getPrefixMsisdn().isEmpty()) {
+//                                                prizeObj = pr;
+//                                                break;
+//                                            } else {
+//                                                for (String prefix : pr.getPrefixMsisdn()) {
+//                                                    if (luckyCode.getMsisdn().startsWith(prefix)) {
+//                                                        prizeObj = pr;
+//                                                        break;
+//                                                    }
+//                                                }
+//                                                if (prizeObj != null) {
+//                                                    break;
+//                                                }
+//                                            }
+//                                        }
+//                                    }
+//                                    if (prizeObj == null) {
+//                                        logger.warn("Not found prize valid: " + luckyCode.getMsisdn() + ", subgroup: " + temp.getSubGroupPrize());
+//                                    } else {
+//                                        // update prize used
+//                                        db.updateDailyPrizeUsed(nextPrize.getId(), luckyCode.getMsisdn());
+//
+//                                        // add cmd execute
+//                                        ExecutePrizeObj cmd = new ExecutePrizeObj();
+//                                        cmd.setMsisdn(luckyCode.getMsisdn());
+//                                        cmd.setPrizeId(prizeObj.getId());
+//                                        cmd.setCodeType(codeType);
+//                                        listCmd.add(cmd);
+//                                        // add winner
+//                                        PrizeWinner winner = new PrizeWinner();
+//                                        winner.setMsisdn(luckyCode.getMsisdn());
+//                                        winner.setPrizeId(prizeObj.getId());
+//                                        winner.setCode(luckyCode.getCode());
+//                                        winner.setCodeTime(luckyCode.getConfirmTime());
+//                                        winner.setCodeType(luckyCode.getCodeType());
+//                                        listWinner.add(winner);
+//
+//                                        //return message
+//                                        String key = Common.Message.MSG_PRIZE_WINNER;
+//                                        String message = MessageResponse.get(key + "_" + prizeObj.getChannel() + "_" + prizeObj.getId(),
+//                                                key + "_" + prizeObj.getId(), logger);
+//                                        message = message.replaceAll("%prize%", prizeObj.getDescription());
+//                                        message = message.replaceAll("%code%", luckyCode.getCode());
+//
+//                                        MtRecord mtRecord = new MtRecord();
+//                                        mtRecord.setChannel(Common.CHANNEL);
+//                                        mtRecord.setMsisdn(luckyCode.getMsisdn());
+//                                        mtRecord.setMessage(message);
+//                                        listMt.add(mtRecord);
+//                                    }
+//                                }
+//                            }
+//
+//                            //</editor-fold>
+//                        }
+//
+//                        //</editor-fold>
+//                        break;
+//                    }
+//                }
+//            }
+//
+//            // delete lucky code all expired
+//            if (listCodeWinner.size() > 0) {
+//                db.deleteLuckyCode(listCodeWinner);
+//                listCodeWinner.clear();
+//            }
+//        }
+//
+//        if (listMt.size() > 0) {
+//            db.insertMt(listMt);
+//            listMt.clear();
+//        }
+//
+//        if (listChargeLog.size() > 0) {
+//            db.insertChargeLog(listChargeLog);
+//            listChargeLog.clear();
+//        }
+//
+//        if (listCmd.size() > 0) {
+//            db.insertExecutePrize(listCmd);
+//            listCmd.clear();
+//        }
+//
+//        if (listWinner.size() > 0) {
+//            db.insertPrizeWinner(listWinner);
+//            listWinner.clear();
+//        }
+//
+//        if (listLuckyCode.size() > 0) {
+//            db.insertLuckyCode(listLuckyCode);
+//            listLuckyCode.clear();
+//        }
+//
+//        return listMo;
+//    }
+//
+//    private void processNoPrize(LuckyCode luckyCode, List<MtRecord> listMt) {
+//        // message code not win
+//        String key = Common.Message.MSG_CODE_NO_PRIZE;
+//        if (db.checkMochaUser(luckyCode.getMsisdn())) {
+//            key = Common.Message.MSG_CODE_NO_PRIZE_MOCHA;
+//        }
+//        String message = MessageResponse.getMessage(key, logger);
+//        message = message.replaceAll("%code%", luckyCode.getCode());
+//
+//        MtRecord mtRecord = new MtRecord();
+//        mtRecord.setChannel(Common.CHANNEL);
+//        mtRecord.setMsisdn(luckyCode.getMsisdn());
+//        mtRecord.setMessage(message);
+//        listMt.add(mtRecord);
+//    }
+//
+//    @Override
+//    public void printListRecord(List<Record> listRecord) throws Exception {
+//        br.setLength(0);
+//        br.append("\r\n").
+//                append("|\tLAST_PROCESS\t\t").
+//                append("|\tTYPE\t\t\r\n");
+//        for (Record record : listRecord) {
+//            ProcessedDate resultObj = (ProcessedDate) record;
+//            br.append("|\t").
+//                    append(resultObj.getLastProcess()).
+//                    append("\t|\t").
+//                    append(resultObj.getTypeProcess()).
+//                    append("\t|\r\n");
+//        }
+//        logger.info(br);
+//    }
+//
+//    @Override
+//    public List<Record> processException(List<Record> listRecord) {
+//        logger.error("Exception when processing....");
+//        return listRecord;
+//    }
+//
+//    @Override
+//    public boolean startProcessRecord() {
+//        return true;
+//    }
+//
+//    private String validateMsisdn(String input) {
+//        if (input != null) {
+//            if (input.startsWith(Common.COUNTRY_CODE)) {
+//                return input;
+//            } else {
+//                return Common.COUNTRY_CODE + input;
+//            }
+//        }
+//        return Common.COUNTRY_CODE;
+//    }
+//
+//    public static void main(String[] args) {
+//        System.out.println(3 * 35 / 100);
+//    }
+//
+//    private Timestamp getExpireCode(int type) {
+//        Calendar cal = Calendar.getInstance();
+//        cal.set(Calendar.HOUR_OF_DAY, 23);
+//        cal.set(Calendar.MINUTE, 59);
+//        cal.set(Calendar.SECOND, 59);
+//        cal.set(Calendar.MILLISECOND, 0);
+//        if (type == LuckyCallUtils.Period.WEEKLY) {
+//            cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+//            if (cal.getTimeInMillis() < System.currentTimeMillis()) {
+//                cal.add(Calendar.DAY_OF_MONTH, 7);
+//            }
+//        } else if (type == LuckyCallUtils.Period.MONTHLY) {
+//            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+//        }
+//        return new Timestamp(cal.getTimeInMillis());
+//    }
+//
+//    private List<PrizeObj> getPrizeInSubGroup(int subGroupId) {
+//        List<PrizeObj> listPrize = new ArrayList();
+//        for (PrizeObj prize : Common.mapPrize.values()) {
+//            if (prize.getSubGroupPrize() == subGroupId) {
+//                listPrize.add(prize);
+//            }
+//        }
+//        return listPrize;
+//    }
+//}

+ 106 - 0
HappyFootballProcess/HappyFootballProcess/src/com/vas/portal/process/SendMt.java

@@ -0,0 +1,106 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.vas.portal.process;
+
+import com.viettel.cluster.agent.integration.Record;
+import com.vas.portal.utils.common.Common;
+import com.vas.portal.utils.common.MessageResponse;
+import com.vas.portal.utils.database.DbProcessor;
+import com.vas.portal.utils.object.MtRecord;
+import com.vas.portal.utils.service.WSProcessor;
+import com.viettel.smsfw.process.ProcessRecordAbstract;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author
+ */
+public class SendMt extends ProcessRecordAbstract {
+
+    private WSProcessor ws;
+    private DbProcessor db;
+    private StringBuilder br = new StringBuilder();
+
+    public SendMt() {
+        super();
+        logger = Logger.getLogger(SendMt.class);
+    }
+
+    @Override
+    public void initBeforeStart() throws Exception {
+        ws = new WSProcessor(logger, "../etc/webservice.cfg");
+        db = new DbProcessor(dbName, logger);
+        if (!MessageResponse.init) {
+            HashMap listMsg = db.getListConfig("PROCESS");
+            logger.info("====> MESSAGE CONFIG:\n" + listMsg);
+            MessageResponse.setMessage(listMsg);
+        }
+
+        if (Common.iLoadConfig) {
+            Common.mapPrize = db.loadPrize(0);
+            logger.info("List prize: " + Common.mapPrize);
+            Common.loadConfig(logger);
+//            logger.info("Map group prize: " + Common.mapGroupPrize);
+            Common.mapMpsConfig = db.loadMpsConfig();
+        }
+    }
+
+    @Override
+    public List<Record> validateContraint(List<Record> listRecord) throws Exception {
+
+        return listRecord;
+    }
+
+    @Override
+    public List<Record> processListRecord(List<Record> listMo) throws Exception {
+        for (Record record : listMo) {
+            MtRecord mt = (MtRecord) record;
+            if (mt.getMessage() != null && mt.getMessage().trim().length() > 0) {
+                for (String msg : mt.getMessage().split("\\^")) {
+                    if (msg != null && msg.trim().length() > 0) {
+                        ws.sendSms(mt.getMsisdn(), msg, mt.getChannel());
+                    }
+                }
+            }
+        }
+
+        return listMo;
+    }
+
+    @Override
+    public void printListRecord(List<Record> listRecord) throws Exception {
+        br.setLength(0);
+        br.append("\r\n").
+                append("|\tMSISDN\t\t").
+                append("|CHANNEL\t").
+                append("|\tCONTENT\t\t\r\n");
+        for (Record record : listRecord) {
+            MtRecord mtRecord = (MtRecord) record;
+            br.append("|\t").
+                    append(mtRecord.getMsisdn()).
+                    append("\t|").
+                    append(mtRecord.getChannel()).
+                    append("\t|\t").
+                    append(mtRecord.getMessage()).
+                    append("\t|\r\n");
+            mtRecord.setNodeName(holder.getNodeName());
+            mtRecord.setClusterName(holder.getClusterName());
+        }
+        logger.info(br);
+    }
+
+    @Override
+    public List<Record> processException(List<Record> listRecord) {
+        logger.error("Exception when processing....");
+        return listRecord;
+    }
+
+    @Override
+    public boolean startProcessRecord() {
+        return true;
+    }
+}

Some files were not shown because too many files changed in this diff