Commit 63d0f414 by giaogiao

2021年04月02日10:57:06 修复Metfone错误代码

parent 537848d4
package com.library.TopUp.mefont;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
import org.apache.commons.codec.binary.Base64;
package com.library.TopUp.mefont;
import javax.crypto.Cipher;
import java.io.FileInputStream;
import java.net.URLDecoder;
import java.security.KeyFactory;
......@@ -10,86 +12,68 @@ import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;
import org.apache.commons.codec.binary.Base64;
public class MetfoneRSAUtils {
static final String pripath = "/com/library/TopUp/mefont/keys/LASIA.pri";
static final String pubpath = "/com/library/TopUp/mefont/keys/LASIA.pub";
final static String pripath = "/com/library/TopUp/mefont/keys/ePayTest.pri";
final static String pubpath = "/com/library/TopUp/mefont/keys/ePayTest.pub";
public MetfoneRSAUtils() {
}
public static String encryptRSA(String plainData) {
try {
String path = MetfoneRSAUtils.class.getResource("/").toString();
path = path.substring(6, path.length() - 1);
path = URLDecoder.decode(path) + pubpath;
path = "/" + path.substring(6, path.length() - 1);
path = URLDecoder.decode(path) + "/com/library/TopUp/mefont/keys/LASIA.pub";
FileInputStream fis = new FileInputStream(path);
byte[] byteKeyFromFile = new byte[fis.available()];
fis.read(byteKeyFromFile);
fis.close();
X509EncodedKeySpec keySpec = new
X509EncodedKeySpec(byteKeyFromFile);
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(byteKeyFromFile);
KeyFactory factory = KeyFactory.getInstance("RSA");
PublicKey pubKey = factory.generatePublic(keySpec);
// Mã hoá dữ liệu
Cipher c = Cipher.getInstance("RSA/ECB/PKCS1Padding");
c.init(Cipher.ENCRYPT_MODE, pubKey);
byte encryptedByte[] = c.doFinal(plainData.getBytes());
c.init(1, pubKey);
byte[] encryptedByte = c.doFinal(plainData.getBytes());
String encrypted = Base64.encodeBase64String(encryptedByte);
return encrypted;
} catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
}
} catch (Exception var10) {
System.out.println(var10.getLocalizedMessage());
return null;
}
}
public static String decryptRSA(String encryptedData) {
try {
String path = MetfoneRSAUtils.class.getResource("/").toString();
path = path.substring(6, path.length() - 1);
path = URLDecoder.decode(path) + pripath;
path = "/" + path.substring(6, path.length() - 1);
path = URLDecoder.decode(path) + "/com/library/TopUp/mefont/keys/LASIA.pri";
FileInputStream fis = new FileInputStream(path);
byte[] byteKeyFromFile = new byte[fis.available()];
fis.read(byteKeyFromFile);
fis.close();
PKCS8EncodedKeySpec keySpec = new
PKCS8EncodedKeySpec(byteKeyFromFile);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(byteKeyFromFile);
KeyFactory factory = KeyFactory.getInstance("RSA");
PrivateKey priKey = factory.generatePrivate(keySpec);
// Giải mã dữ liệu
Cipher c2 = Cipher.getInstance("RSA/ECB/PKCS1Padding");
c2.init(Cipher.DECRYPT_MODE, priKey);
String decrypted = new
String(c2.doFinal(Base64.decodeBase64(encryptedData)));
c2.init(2, priKey);
String decrypted = new String(c2.doFinal(Base64.decodeBase64(encryptedData)));
return decrypted;
} catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
}
} catch (Exception var9) {
System.out.println(var9.getLocalizedMessage());
return null;
}
}
public static void main(String[] args) {
String token = "lF4inzg0SYpt7VekJEhCRYi/hLaPtxgGpflBo5ocWv7lZT09tD+zP8cqTICzTqT8R4raZ3USzv" +
"nyi6tBcE6hNtdoXa8Cq6ub8AZbyoMB0RMWyPbcaKvnbX34kLRnskUECjEKsBRNpYEVP1rNcSVc+" +
"xmDGC7PtcYV+kIRDp5Dmqhcb/7wOHkqyUemTbvhmgb6wgLXE4pdB6NyJZ7JAbfZ5DiIgyGQ7EK4" +
"7hdb4bGn1/15+M4C3OlpOcp7PuFzBuDO1HRkoLXeayFhMKoLHBj1s0wWaFHbPQIYxpCBFW6lzdO" +
"6rVVuhA1YoaoKNZOnYk9fVZ+vQUj5nY2i4yH8u4GJKw==";
String token = "NTKenRyiwOW5xaXnWm/2+HHuTsy4o4dA59J3uVs8bQM+C+Wt/KQM2jjeRHKlAi0UswHabwpRAn+/KBaZtI/MO/ysOa4eEtZCEFui5u5SsKC/iZPxFVA30xlriORaYd7vX3rXvr3I1wNkFromkyATxDWPg3JCUj+soakh9M2SRt54Qa4NxbgsNGgesAHJKQ1JWQglv5pklyVWN7THj1aMjcdq7aigEZgcPI01/+r5Wcwe1pvJx5hH0I3CYRZY+BVM/Jm1g6E17sd3bOT2f7G3ARmFA6i5mgDReZGZpLmx2TogVY+EAGUAZE3LrtBwlzkV5gLrnh+WIZ9nMG7GkTxNFA==";
String token2 = "iljUgme83Rj3dCvhFHwFdBB+DXkPpmxTjSFGlsjJJeXQRmQRP62lO9lNYGBkz827TPOjrycRg0BuPLH4I497iuMo7LUMt0mg3C7B3ejRkgcqWoiQxaSjB79mQa8lip/w6Q9S74Wwim/tDw/horrQ/a50+sTe+UYuHh1hjwnr61KQwieNDRFC3rYxeA5WkwpMCVQMHWfTqK3mPjXHqJgoMySUekg0NCbYQYmqWsgetakUuSlaKmrjpK90WfjOsnIeuTWEYHh+tlrI3VVIGF/Pknw6xzLOG+rTi1IZ7RkuHKh8nbiR4uLDkXpvGiiL1Hiq3H2Sz897MZKs1HeqWdrMng==";
// System.out.println(System.getProperty("user.dir"));
String str = decryptRSA(token2);
String encryptText = str + "|" + "298315";
String str = decryptRSA(token);
String encryptText = str + "|682504";
String retStr = encryptRSA(encryptText);
System.out.println("解密后的数据:" + str);
System.out.println("加上PIN加密的数据:" + retStr);
}
}
package com.library.TopUp.mefont;
import com.google.gson.Gson;
......@@ -12,168 +13,126 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
public class MetfoneSentUtils {
private static final String baseUrl = "https://payment.emoney.com.kh:8888/";
private static final String PIN = "682504";
private static final String MyAuthorization = "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300";
private final static String baseUrl = "https://36.37.242.116:8301/";
// private final static String baseUrl = "https://payment.emoney.com.kh:8888/";
private final static String PIN = "298315";
public MetfoneSentUtils() {
}
public static String initTel(String transAmount, String refId, String customerPhoneNumber) {
Map params = new HashMap();
params.put("serviceType", "TOPUP");
params.put("transAmount", transAmount);
params.put("currency", "USD");
params.put("refId", refId);
params.put("customerPhoneNumber", customerPhoneNumber);
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
String url = baseUrl + "ePayTest/telco/init";
// String urlTest="https://36.37.242.116:8301/ePayTest/telco/init";
String str = HttpUtils.post(url,
params, heardMap
, 3000, 3000, "UTF-8");
String url = "https://payment.emoney.com.kh:8888/LASIA/telco/init";
String str = HttpUtils.post(url, params, heardMap, 3000, 3000, "UTF-8");
return str;
}
public static String confirmTel(String txPaymentTokenId) {
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
Map params = new HashMap();
params.put("txPaymentTokenId", txPaymentTokenId);
String conURL = baseUrl + "ePayTest/telco/confirm";
String str = HttpUtils.post(conURL,
params, heardMap
, 3000, 3000, "UTF-8");
String conURL = "https://payment.emoney.com.kh:8888/LASIA/telco/confirm";
String str = HttpUtils.post(conURL, params, heardMap, 3000, 3000, "UTF-8");
return str;
}
public static String initTelPost(String transAmount, String refId, String customerPhoneNumber) {
try {
// Map params = new HashMap();
Map<String, String> params = new HashMap<>();
Map<String, String> params = new HashMap();
params.put("serviceType", "TOPUP");
params.put("transAmount", transAmount);
params.put("currency", "USD");
params.put("refId", refId);
params.put("customerPhoneNumber", customerPhoneNumber);
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
String requestUrl = baseUrl + "ePayTest/telco/init";
String str = HttpsTool.send(new Gson().toJson(params), heardMap, requestUrl, "utf-8",
"utf-8", 300 * 1000, 300 * 1000,
"application/json");// 大家最终只要使用这一句代码就可调用
String requestUrl = "https://payment.emoney.com.kh:8888/LASIA/telco/init";
String str = HttpsTool.send((new Gson()).toJson(params), heardMap, requestUrl, "utf-8", "utf-8", 300000, 300000, "application/json");
return str;
} catch (Exception e) {
e.getLocalizedMessage();
} catch (Exception var7) {
var7.getLocalizedMessage();
return null;
}
}
public static String confirmPost(String txPaymentTokenId) {
try {
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
Map params = new HashMap();
params.put("txPaymentTokenId", txPaymentTokenId);
String conURL = baseUrl + "ePayTest/telco/confirm";
String senc = HttpsTool.send(new Gson().toJson(params), heardMap, conURL, "utf-8",
"utf-8", 300 * 1000, 300 * 1000, "application/json");// 大家最终只要使用这一句代码就可调用
String conURL = "https://payment.emoney.com.kh:8888/LASIA/telco/confirm";
String senc = HttpsTool.send((new Gson()).toJson(params), heardMap, conURL, "utf-8", "utf-8", 300000, 300000, "application/json");
return senc;
} catch (Exception e) {
e.getLocalizedMessage();
} catch (Exception var5) {
var5.getLocalizedMessage();
return null;
}
}
public static String checkPayPost(String transDetailId, String refId) {
try {
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
Map params = new HashMap();
params.put("transDetailId", transDetailId);
params.put("refId", refId);
String conURL = baseUrl + "ePayTest/trans/check";
String senc = HttpsTool.send(new Gson().toJson(params), heardMap, conURL, "utf-8",
"utf-8", 300 * 1000, 300 * 1000, "application/json");// 大家最终只要使用这一句代码就可调用
String conURL = "https://payment.emoney.com.kh:8888/LASIA/trans/check";
String senc = HttpsTool.send((new Gson()).toJson(params), heardMap, conURL, "utf-8", "utf-8", 300000, 300000, "application/json");
return senc;
} catch (Exception e) {
e.getLocalizedMessage();
} catch (Exception var6) {
var6.getLocalizedMessage();
return null;
}
}
public static String billInfoPost(String paymentCode) {
try {
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
Map params = new HashMap();
params.put("paymentCode", paymentCode);
String conURL = baseUrl + "ePayTest/telco/metfone-bill/info";
String senc = HttpsTool.send(new Gson().toJson(params), heardMap, conURL, "utf-8",
"utf-8", 300 * 1000, 300 * 1000, "application/json");// 大家最终只要使用这一句代码就可调用
String conURL = "https://payment.emoney.com.kh:8888/LASIA/telco/metfone-bill/info";
String senc = HttpsTool.send((new Gson()).toJson(params), heardMap, conURL, "utf-8", "utf-8", 300000, 300000, "application/json");
return senc;
} catch (Exception e) {
e.getLocalizedMessage();
} catch (Exception var5) {
var5.getLocalizedMessage();
return null;
}
}
/**
* 查询系统我的账户余额
*
......@@ -182,55 +141,45 @@ public class MetfoneSentUtils {
* @return
*/
public static String checkMyMoneyPost(String refId, String msisdn) {
try {
Map<String, String> heardMap = new HashMap<>();
heardMap.put("Authorization", "epa 2478e27af578e11a6af86a8320562124240f5c972e8039cd9c564e53d643bb31");
Map<String, String> heardMap = new HashMap();
heardMap.put("Authorization", "epa 5b83407f62da2bef2f20a463ffc0b5d2fbf6fab388531a297d7f00627cce3300");
heardMap.put("e-language", "English");
heardMap.put("Content-Type", "application/json");
heardMap.put("Accept", "application/json");
String pin = PIN + "|" + msisdn + "|" + refId;
String pin = "682504|" + msisdn + "|" + refId;
Map params = new HashMap();
params.put("refId", refId);
params.put("serviceType", "TOPUP");
params.put("msisdn", msisdn);
params.put("pin", MetfoneRSAUtils.encryptRSA(pin));//encrypt the plain text in format "pin|msisdn|refId
String conURL = baseUrl + "ePayTest/account/balance";
String senc = HttpsTool.send(new Gson().toJson(params), heardMap, conURL, "utf-8",
"utf-8", 300 * 1000, 300 * 1000,
"application/json");// 大家最终只要使用这一句代码就可调用
params.put("pin", MetfoneRSAUtils.encryptRSA(pin));
String conURL = "https://payment.emoney.com.kh:8888/LASIA/account/balance";
String senc = HttpsTool.send((new Gson()).toJson(params), heardMap, conURL, "utf-8", "utf-8", 300000, 300000, "application/json");
return senc;
} catch (Exception e) {
e.getLocalizedMessage();
} catch (Exception var7) {
var7.getLocalizedMessage();
return null;
}
}
public static void main(String[] args) {
/* String str = checkMyMoneyPost("1200016", "0979530750");
//{"status":0,"code":"MSG_SUCCESS","message":"Success","msisdn":null,"accountName":null,"accountType":null,"balances":{"KHR":"498,983","USD":"5,135.60"}}
System.out.println(str);*/
// public static void main(String[] args) {
// String str = checkMyMoneyPost(getFormatedDateString(7.0F), "855886402606");
// System.out.println(str);
// }
String str = checkMyMoneyPost("200108184311227","0979530750");
System.out.println(str);
}
public static void main(String[] args) {
// String phone = "0977722887";
String phone = "0887038371";
public static void main222(String[] args) {
String phone = "0979530750";
SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
String hms = sdf.format(new Date());
ResultsModel resultsModel = sentTopUp(phone, 1, hms);
System.out.println("充值日志:" + resultsModel.getTip());
System.out.println("充值状态:" + resultsModel.isSuccessful());
System.out.println("拓展字段:" + resultsModel.getExpandText());
ResultsModel resultsModel=sentTopUp(phone, 1, hms);
System.out.println("充值日志:"+resultsModel.getTip());
System.out.println("充值状态:"+resultsModel.isSuccessful());
System.out.println("拓展字段:"+resultsModel.getExpandText());
int i=1;
}
/**
......@@ -242,47 +191,41 @@ public class MetfoneSentUtils {
* @return
*/
public static ResultsModel sentTopUp(String phone, int amount, String orderNum) {
String tip = "";
boolean topUpSuccess = false;
try {
String refId = orderNum;
String transDetailId = "";//可以用来复查充值订单数据
String json = initTelPost(String.valueOf(amount), refId, phone);
String json = initTelPost(String.valueOf(amount), orderNum, phone);
String tokenId = "";
String str;
if (!TextUtils.isEmpty(json)) {
JsonObject object = new JsonParser().parse(json).getAsJsonObject();
String status = object.get("status") == null ? "" : object.get("status").getAsString();
//请求是否成功
if (status.equals("0")) {
JsonObject object = (new JsonParser()).parse(json).getAsJsonObject();
str = object.get("status") == null ? "" : object.get("status").getAsString();
if (str.equals("0")) {
JsonObject txDetail = object.get("txDetail").getAsJsonObject();
if (txDetail != null) {
//获取需要解密的值
tokenId = txDetail.get("txPaymentTokenId").getAsString();
transDetailId = txDetail.get("transDetailId").getAsString();
} else {
tip += "返回值txDetail为空";
tip = tip + "返回值txDetail为空";
}
} else {
tip += "initTel返回结果:" + new Gson().toJson(object) + " \n";
tip = tip + "initTel返回结果:" + (new Gson()).toJson(object) + " \n";
}
} else {
tip += "返回值为空";
tip = tip + "返回值为空";
}
String conStr = "";
String status;
if (!TextUtils.isEmpty(tokenId)) {
String str = MetfoneRSAUtils.decryptRSA(tokenId);
String encryptText = str + "|" + PIN;
// tip += "解析的值:" + encryptText;
String retStr = MetfoneRSAUtils.encryptRSA(encryptText);
// tip += "\n" + "加密后的值:" + retStr;
//发起充值
str = MetfoneRSAUtils.decryptRSA(tokenId);
status = str + "|" + "682504";
tip = tip + "解析的值:" + status;
String retStr = MetfoneRSAUtils.encryptRSA(status);
tip = tip + "\n加密后的值:" + retStr + "\n";
conStr = confirmPost(retStr);
}
......@@ -291,24 +234,40 @@ public class MetfoneSentUtils {
//有结果返回
System.out.println(conStr);
JsonObject confirmObject = new JsonParser().parse(conStr).getAsJsonObject();
String status = confirmObject.get("status") == null ? "" : confirmObject.get("status").getAsString();
JsonObject confirmObject = (new JsonParser()).parse(conStr).getAsJsonObject();
status = confirmObject.get("status") == null ? "" : confirmObject.get("status").getAsString();
if (status.equals("0")) {
System.out.println("充值成功");
topUpSuccess = true;
tip += " 充值成功!!!";
tip = tip + " 充值成功!!!";
} else {
tip += "confirmTel返回结果:" + new Gson().toJson(confirmObject) + " \n";
tip = tip + "confirmTel返回结果:" + (new Gson()).toJson(confirmObject) + " \n";
}
}
// String checkStr = checkPayPost(transDetailId, refId);
// System.out.println(checkStr);
return new ResultsModel(topUpSuccess, tip, transDetailId);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var13) {
var13.printStackTrace();
return new ResultsModel(topUpSuccess, tip);
}
}
public static String getFormatedDateString(float timeZoneOffset) {
if (timeZoneOffset > 13.0F || timeZoneOffset < -12.0F) {
timeZoneOffset = 0.0F;
}
int newTime = (int) (timeZoneOffset * 60.0F * 60.0F * 1000.0F);
String[] ids = TimeZone.getAvailableIDs(newTime);
Object timeZone;
if (ids.length == 0) {
timeZone = TimeZone.getDefault();
} else {
timeZone = new SimpleTimeZone(newTime, ids[0]);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone((TimeZone) timeZone);
return sdf.format(new Date());
}
}
PRIVATE KEY:
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCVL1nXktHcEMHSTh7gQHd4p9eoBYU/630Hy4JNY5XoRvi3QQKq7RRtAGa2tHI7u8jfwdtdnoUWplBuTh/QWY/wlikYT6NHpZqkv1TsSaz67cXfckA4rInlHUZmgi4ACax7HMdCKYV9pjE2iPsziry2jt0lz8b5cXFjZgzS+pHoYUqh7GLHEqKfzEamCcbIC7lkR4aAg9VK9oSMFzFR3QIa1ocMqYnJO5Jht83VncWBUFEG+VzMntxjHE8Q5I6YyP/oxkALF/pNjsgP6U4SelrlP8rNTPVRgOupVzjzL72M5MSGrFmAEqKJyvDni4uvJMkc/wCj6kzD6MwUpv+WrlH9AgMBAAECggEARELFRglM8vfL59GM+SkmQVPzLlNQVB4JOJ7awVRWzFBlD1y0vsb5+KIdXW4VctWKpS+LkzusQ9/Xn5Epp2jDnt7mcNRHrsnMh6NwVSmk97ACQSqCzivMcMRDaTYZnDTQ8ggJ+HENPp/jlsN4xW2uyY13DQ0USyCoNEYGiibSylO8oZdtU3nfzatoo5eW1Kfcc1MhQaY1BXpSS6VB6XgrtsoqSh9rybNyWalLB8kxJlE9izHFQxj/+RI2v9bT7JtS7iARgFyvhFkv012RiOS04XH1tt6oFaVY1nT6Fy5vOEajUGWwbRFegQwr4KJAxKWucKY4AQJVWKJJrcEqN64pgQKBgQDnzfB7sUjk4IG619LAzo3zbeezoZEdMK8iSdEW1FXnuFnkcQ2TC0N41WFUhasGy8KeAUAAOPTreI7sxKcgKB/CAplLeb8OwEha16JhdNLzxeVELt2gMWVXfZdjMJELZKdPAzQCR2RDgippdsWAX3iG7FTf0JPZF0r0+kVYh3+InQKBgQCkwbs34WLTK6iSAw6l6e5Q6wg8wfGhFLoSf2cetcB+9+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newline at end of file
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn0dF9WwFY8Te4AEoGdTC34c9vStRegi9D9H4jXXNoOAMyRPH+e9I+ZTJfERpIs45j+Y+KezmI0bFJ/mk06ZK9Si9V81aeBsgtgy5Ul4reQYkH9KL0G7hboX1eePkmc95qCQFwGD3PEITKD6ei43YxYfOf8BltHFZ0Z+opkTTZHW5aOMAFUIRoaXTpaVD+I7rx6gDJX+pZsPowLpfFjGAY2YRe2FJN1YXtyJFEDhRJDeqY4QakelyKGDK8gi5CFLxDtkUxpF3QWUk98WLJH/mkGJUmKAORksVR7ReaHbEWQkJUuDUxh0YUr9X7aXGZnbHAuDTbUqCP4L/wFBIhWWaOwIDAQAB
\ No newline at end of file
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhtV7fPkhM3KjzWt/S7mXDpBkPdHGyDUptS4tnFjdSL10C/XSeDWu2NC72owruRXTHnRfWUtxuygoUdQTccMpXmUv1BtYrQK9Cs09UA0mCKXuLxDxhVVXGcOmi/z2s9Njd2sknLYUhZG2b+xISlQNjeqRqnhG4pFgzRadm+DOwbfBQiBaSz9wP6JpaNOaPHI2ZGi0DoKjxCx3n5Nk4JF9X7v38kZis5sMoMoRyFQarwqVegOLZVCMWfgXcZPKko0WKLXtF5DBPxnmx8IkcBx/aimoGzjQZFerrpdgPf81W6nxD+Ui74PVwmny/hGMd3pLv70B9wgBVnkDtrxygkjywwIDAQAB
\ No newline at end of file
PRIVATE KEY:
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCVL1nXktHcEMHSTh7gQHd4p9eoBYU/630Hy4JNY5XoRvi3QQKq7RRtAGa2tHI7u8jfwdtdnoUWplBuTh/QWY/wlikYT6NHpZqkv1TsSaz67cXfckA4rInlHUZmgi4ACax7HMdCKYV9pjE2iPsziry2jt0lz8b5cXFjZgzS+pHoYUqh7GLHEqKfzEamCcbIC7lkR4aAg9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FXwqwR9IULH21Z4bkHmgeoa7i23rMkdnWz+4ZAMACtB+g3CP+YXbVlA4CJayPOhg2iOtDcu4MI38OxYKXaIubw8UVTwH6xe8abwuIR/cbit5VGQhxXst32ECgYEAmKMt8LDjtc+MXBbt5n8K4HAw6PO6jAfoSLgyBpchaYOQwlgPu3hIeamp3PtuaYuX0111Y18dW4Bum8oXX142dUma17zXONBiK/DEiYFZVleGim22GajVev7QD/nyLzrDL2z46hfkzoQjzfpqllgjQ6OvRv+uUJR2BgtCCnmMPAE=
PUBLIC KEY:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhtV7fPkhM3KjzWt/S7mXDpBkPdHGyDUptS4tnFjdSL10C/XSeDWu2NC72owruRXTHnRfWUtxuygoUdQTccMpXmUv1BtYrQK9Cs09UA0mCKXuLxDxhVVXGcOmi/z2s9Njd2sknLYUhZG2b+xISlQNjeqRqnhG4pFgzRadm+DOwbfBQiBaSz9wP6JpaNOaPHI2ZGi0DoKjxCx3n5Nk4JF9X7v38kZis5sMoMoRyFQarwqVegOLZVCMWfgXcZPKko0WKLXtF5DBPxnmx8IkcBx/aimoGzjQZFerrpdgPf81W6nxD+Ui74PVwmny/hGMd3pLv70B9wgBVnkDtrxygkjywwIDAQAB
\ No newline at end of file
......@@ -15,37 +15,31 @@ import com.library.model.SegmentModel;
import com.library.service.AutomaticCodeService;
import com.library.util.Paygo24Utils;
import com.library.util.TransformationTools;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by Administrator on 2018\11\22 0022.
*/
@Service
@Transactional
public class AutomaticCodeServiceImpl implements AutomaticCodeService {
@Resource
private AutomaticQueueMapper automaticQueueMapper;
@Resource
private CurrencyMapper currencyMapper;
private final static String SegmentType_Cellcard = "Cellcard";
private final static String SegmentType_Metfone = "Metfone";
private final static String SegmentType_Smart = "Smart";
private final static String SegmentType_Seatel = "Seatel";
private static String PREFIX_ZERO = "0";
public static String REGULARLY = "^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$";
private static final String PREFIX_ZERO = "0";
private static final String SegmentType_Cellcard = "Cellcard";
private static final String SegmentType_Metfone = "Metfone";
private static final String SegmentType_Smart = "Smart";
private static final String SegmentType_Seatel = "Seatel";
@Override
public boolean isChinaPhone(String phone) {
......@@ -73,8 +67,8 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
//自动处理状态说明
String desc = "";
AutomaticQueueModel automaticQueueModel = null;
String top_up_num = "";
try {
automaticQueueModel = (AutomaticQueueModel) TransformationTools.ToObjectOne(AutomaticQueueModel.class, map);
// 修改状态
......@@ -101,57 +95,63 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
desc = resultsModel.getTip();
success = resultsModel.isSuccessful();
top_up_num = resultsModel.getTopUpNum();
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var11) {
var11.printStackTrace();
desc = "System error.";
}
// 自动处理结果
this.automaticForTackResult(automaticQueueModel, success, desc, top_up_num);
}
}
private ResultsModel sentTopup(AutomaticQueueModel automaticQueueModel, String top_up_num) {
}
private ResultsModel sentTopup(AutomaticQueueModel automaticQueueModel, String top_up_datetime) {
ResultsModel resultsModel = null;
try {
//充值订单编号
String orderNumId = top_up_num;
// //充值订单编号
// String orderNumId = top_up_datetime;
//通过手机前三位获取到运营商
String phoneThree = automaticQueueModel.getOrder_phone().substring(0, 3);
Map<String, Object> map = automaticQueueMapper.selectSegment(phoneThree);
Map<String, Object> map = this.automaticQueueMapper.selectSegment(phoneThree);
//1.先判断这是哪个公司的充值订单,然后发起充值
SegmentModel segmentModel = (SegmentModel) TransformationTools.ToObjectOne(SegmentModel.class, map);
if (segmentModel.getOperator().equals(SegmentType_Cellcard)) {
SegmentModel segmentModel = (SegmentModel)TransformationTools.ToObjectOne(SegmentModel.class, map);
if (segmentModel.getOperator().equals("Cellcard")) {
//Cellcard的手机号,则选择Cellcard公司的api发起充值
resultsModel = CellcardSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), orderNumId, automaticQueueModel.getOrder_money().intValue());
resultsModel.setTopUpNum(orderNumId);
} else if (segmentModel.getOperator().equals(SegmentType_Metfone)) {
resultsModel = MetfoneSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), automaticQueueModel.getOrder_money().intValue(), orderNumId);
resultsModel.setTopUpNum(orderNumId);
} else if (segmentModel.getOperator().equals(SegmentType_Smart)) {
resultsModel = SmartSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), automaticQueueModel.getOrder_money().intValue(), orderNumId);
resultsModel.setTopUpNum(orderNumId);
} else if (segmentModel.getOperator().equals(SegmentType_Seatel)) {
resultsModel = CellcardSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), top_up_datetime, automaticQueueModel.getOrder_money().intValue());
resultsModel.setTopUpNum(top_up_datetime);
} else if (segmentModel.getOperator().equals("Metfone")) {
resultsModel = MetfoneSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), automaticQueueModel.getOrder_money().intValue(), top_up_datetime);
resultsModel.setTopUpNum(top_up_datetime);
} else if (segmentModel.getOperator().equals("Smart")) {
resultsModel = SmartSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), automaticQueueModel.getOrder_money().intValue(), top_up_datetime);
resultsModel.setTopUpNum(top_up_datetime);
} else if (segmentModel.getOperator().equals("Seatel")) {
resultsModel = SeatelSentUtils.sentTopUp(automaticQueueModel.getOrder_phone(), automaticQueueModel.getOrder_money().intValue());
//这个不用返回订单num,里面已经做了处理
} else {
Paygo24Utils paygo = new Paygo24Utils();
String result = paygo.payment(automaticQueueModel.getOrder_phone(), automaticQueueModel.getSegment_id(), automaticQueueModel.getOrder_money());
resultsModel = new ResultsModel();
resultsModel.setTip(result);//描述
resultsModel.setSuccessful(result.equals(Paygo24Utils.SUCCESS));
resultsModel.setTip(result);
if (result.equals("SUCCESS")) {
resultsModel.setSuccessful(true);
} else {
resultsModel.setSuccessful(false);
}
resultsModel.setTopUpNum(orderNumId);
resultsModel.setTopUpNum(top_up_datetime);
}
return resultsModel;
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var10) {
var10.printStackTrace();
return null;
}
}
......@@ -161,63 +161,58 @@ public class AutomaticCodeServiceImpl implements AutomaticCodeService {
@Override
public void automaticForTackResult(AutomaticQueueModel early, boolean success, String desc, String top_up_num) {
Timestamp newTime = new Timestamp(System.currentTimeMillis());
if (success) {//充值成功
Map mapOrder;
OrderModel orderModel;
OrderLogModel orderLogModel;
//充值成功
if (success) {
try {
Map<String, Object> mapOrder = automaticQueueMapper.selectOrderByNumber(early.getOrder_num());
OrderModel orderModel = (OrderModel) TransformationTools.ToObjectOne(OrderModel.class, mapOrder);
mapOrder = this.automaticQueueMapper.selectOrderByNumber(early.getOrder_num());
orderModel = (OrderModel)TransformationTools.ToObjectOne(OrderModel.class, mapOrder);
orderModel.setState(3);
orderModel.setPaygo_time(newTime);
orderModel.setPaygo_remark(desc);
orderModel.setTop_up_num(top_up_num);
//更新订单表的状态
currencyMapper.updateTableForMysql(TransformationTools.CreatUpdateMysql(orderModel, NameValue.Table_order, "id", null));
this.currencyMapper.updateTableForMysql(TransformationTools.CreatUpdateMysql(orderModel, NameValue.Table_order, "id", (List)null));
//发送短信通知用户
//添加订单日志
OrderLogModel orderLogModel = new OrderLogModel();
orderLogModel = new OrderLogModel();
orderLogModel.setLog_order_number(early.getOrder_num());
orderLogModel.setLog_type(3);
orderLogModel.setTime(newTime);
orderLogModel.setLog_content("自动充值-充值成功");
//添加订单操作日志
currencyMapper.AddTableForMysql(TransformationTools.CreatAddMysql(orderLogModel, NameValue.Table_order_log, "id", null));
} catch (Exception e) {
e.printStackTrace();
//添加订单操作日志
this.currencyMapper.AddTableForMysql(TransformationTools.CreatAddMysql(orderLogModel, NameValue.Table_order_log, "id", (List)null));
} catch (Exception var10) {
var10.printStackTrace();
}
} else {//充值失败,转入人工处理
} else {
//充值失败,转入人工处理
try {
Map<String, Object> mapOrder = automaticQueueMapper.selectOrderByNumber(early.getOrder_num());
OrderModel orderModel = (OrderModel) TransformationTools.ToObjectOne(OrderModel.class, mapOrder);
mapOrder = this.automaticQueueMapper.selectOrderByNumber(early.getOrder_num());
orderModel = (OrderModel)TransformationTools.ToObjectOne(OrderModel.class, mapOrder);
orderModel.setState(4);
orderModel.setPaygo_remark(desc + "-处理时间:" + newTime);
orderModel.setTop_up_num(top_up_num);
//更新订单表的状态
currencyMapper.updateTableForMysql(TransformationTools.CreatUpdateMysql(orderModel, NameValue.Table_order, "id", null));
//添加订单日志
OrderLogModel orderLogModel = new OrderLogModel();
//更新订单表的状态
this.currencyMapper.updateTableForMysql(TransformationTools.CreatUpdateMysql(orderModel, NameValue.Table_order, "id", (List)null));
orderLogModel = new OrderLogModel();
orderLogModel.setLog_order_number(early.getOrder_num());
orderLogModel.setLog_type(4);
orderLogModel.setTime(newTime);
orderLogModel.setLog_content("充值失败,转入人工处理-" + desc);
//添加订单操作日志
currencyMapper.AddTableForMysql(TransformationTools.CreatAddMysql(orderLogModel, NameValue.Table_order_log, "id", null));
// early.setStatus(-1);
// currencyMapper.updateTableForMysql(TransformationTools.CreatUpdateMysql(early,NameValue.Table_automatic_queue,"id",null));
} catch (Exception e) {
e.printStackTrace();
//添加订单日志
this.currencyMapper.AddTableForMysql(TransformationTools.CreatAddMysql(orderLogModel, NameValue.Table_order_log, "id", (List)null));
} catch (Exception var9) {
var9.printStackTrace();
}
}
//移除自动充值队列中
currencyMapper.DeleteDataById(NameValue.Table_automatic_queue, early.getId());
this.currencyMapper.DeleteDataById(NameValue.Table_automatic_queue, early.getId());
}
@Override
......
package com.library.service.Impl;
import com.google.gson.JsonObject;
......@@ -8,20 +9,9 @@ import com.library.TopUp.mefont.MetfoneSentUtils;
import com.library.config.NameValue;
import com.library.mapper.CommMapper;
import com.library.mapper.CurrencyMapper;
import com.library.model.AdminModel;
import com.library.model.UserModel;
import com.library.respcode.ServerResponse;
import com.library.service.AutomaticCodeService;
import com.library.service.CommService;
import com.library.util.MSMmethodUtil;
import com.library.util.Paygo24Utils;
import com.library.util.SendEmailTools;
import com.library.util.TransformationTools;
import com.wechat.pay.MD5Util;
import com.wechat.pay.WeChatManager;
import com.wechat.pay.WeChatManager.UserInfo;
import org.apache.http.util.TextUtils;
import org.springframework.stereotype.Service;
......@@ -29,13 +19,15 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
@Service
public class CommServiceImpl implements CommService {
@Resource
private HttpServletRequest request;
@Resource
......@@ -43,29 +35,26 @@ public class CommServiceImpl implements CommService {
@Resource
private CurrencyMapper currencyMapper;
@Resource
private AutomaticCodeService automaticCodeService;
public CommServiceImpl() {
}
@Override
public ServerResponse Recharge() {
try {
return ServerResponse.createByErrorCodeMessage(-1, "无此接口");
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var2) {
var2.printStackTrace();
return ServerResponse.createByError();
}
}
@Override
public ServerResponse adminLogin() {
return ServerResponse.createByErrorCodeMessage(-1, "无此接口");
}
@Override
public ServerResponse checkPhoneInSeatel() {
String phone = request.getParameter("phone");
String phone = this.request.getParameter("phone");
String json = SeatelSentUtils.checkPhone2(phone);
return ServerResponse.createBySuccess(json);
}
......@@ -73,34 +62,25 @@ public class CommServiceImpl implements CommService {
@Override
public ServerResponse queryAgentFeeInSeatel() {
String feeJson = SeatelSentUtils.queryAgentFee();
String tip = "";
String myAmount = "";
if (!TextUtils.isEmpty(feeJson)) {
JsonParser jsonParserFee = new JsonParser();
JsonObject jsonObjectFee = jsonParserFee.parse(feeJson).getAsJsonObject();
String codeCheck = jsonObjectFee.get("code") == null ? "" : jsonObjectFee.get("code").getAsString();
if (!TextUtils.isEmpty(codeCheck) && codeCheck.equals("0")) {
//接口查询成功,比较金额大小
if (jsonObjectFee.get("amount") != null) {
myAmount = jsonObjectFee.get("amount").getAsString();
tip += "您当前的余额为:$" + myAmount + "";
// if (!TextUtils.isEmpty(myAmount)) {
// Map<String, Object> map = new HashMap<>();
// map.put("statel", myAmount);
// commMapper.updateTheBalance(map);
// }
changeTheAmountLog(myAmount, "", "", "", "");
tip = tip + "您当前的余额为:$" + myAmount + "";
this.changeTheAmountLog(myAmount, "", "", "", "");
} else {
tip += "获取不到余额信息";
tip = tip + "获取不到余额信息";
}
} else {
tip += "查询余额失败;结果为:" + feeJson;
tip = tip + "查询余额失败;结果为:" + feeJson;
}
}
System.out.println(tip);
return ServerResponse.createBySuccess(tip, myAmount);
}
......@@ -108,56 +88,41 @@ public class CommServiceImpl implements CommService {
@Override
public ServerResponse queryAgentFeeInCellcard() {
String feeJson = "";
try {
try {
feeJson = CellcardSentUtils.checkBalance();
String tip = "";
String myAmount = "";
if (!TextUtils.isEmpty(feeJson)) {
JsonParser jsonParserFee = new JsonParser();
JsonObject jsonObjectFee = jsonParserFee.parse(feeJson).getAsJsonObject();
if (jsonObjectFee.get("data") != null) {
JsonObject data = jsonObjectFee.get("data").getAsJsonObject();
String error_message = data.get("error_message") == null ? "" : data.get("error_message").getAsString();
String error_code = data.get("error_code") == null ? "" : data.get("error_code").getAsString();
if (!TextUtils.isEmpty(error_code) && error_code.equals("0")) {
//接口查询成功,比较金额大小
if (data.get("distributor_balance") != null) {
myAmount = data.get("distributor_balance").getAsString();
tip += "您当前的余额为:$" + myAmount + "";
// if (!TextUtils.isEmpty(myAmount)) {
// Map<String, Object> map = new HashMap<>();
// map.put("cellcard", myAmount);
// commMapper.updateTheBalance(map);
// }
changeTheAmountLog("", "", myAmount, "", "");
tip = tip + "您当前的余额为:$" + myAmount + "";
this.changeTheAmountLog("", "", myAmount, "", "");
return ServerResponse.createBySuccess(tip, myAmount);
} else {
tip += "获取不到余额信息;" + error_message;
}
tip = tip + "获取不到余额信息;" + error_message;
} else {
tip += "查询余额失败;结果为:" + feeJson;
tip = tip + "查询余额失败;结果为:" + feeJson;
}
} else {
tip += "解析data为空";
tip = tip + "解析data为空";
}
} else {
tip += "请求的数据为空";
tip = tip + "请求的数据为空";
}
System.out.println(tip);
return ServerResponse.createByErrorCodeMessage(3001, tip);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var9) {
var9.printStackTrace();
return ServerResponse.createByErrorCodeMessage(-1, feeJson);
}
}
......@@ -165,133 +130,130 @@ public class CommServiceImpl implements CommService {
@Override
public ServerResponse checkMyMoneyInMetfone() {
String feeJson = "";
try {
String refId = getFormatedDateString(7);
String phone = request.getParameter("phone");
// {"status":0,"code":"MSG_SUCCESS","message":"Success","msisdn":null,"accountName":null,"accountType":null,"balances":{"KHR":"498,983","USD":"4,748.00"}}
try {
String refId = getFormatedDateString(7.0F);
String phone = "855886402606";
feeJson = MetfoneSentUtils.checkMyMoneyPost(refId, phone);
String tip = "";
JsonObject data = null;
if (!TextUtils.isEmpty(feeJson)) {
JsonParser jsonParserFee = new JsonParser();
JsonObject jsonObjectFee = jsonParserFee.parse(feeJson).getAsJsonObject();
String status = jsonObjectFee.get("status") == null ? "" : jsonObjectFee.get("status").getAsString();
if (status.equals("0")) {
String usd;
if (jsonObjectFee.get("balances") != null) {
data = jsonObjectFee.get("balances").getAsJsonObject();
if (data != null && data.get("USD") != null) {
usd = data.get("USD").getAsString();
this.changeTheAmountLog("", usd, "", "", "");
}
return ServerResponse.createBySuccess(data);
} else {
String message = jsonObjectFee.get("message") == null ? "" : jsonObjectFee.get("message").getAsString();
tip += "" + message;
}
usd = jsonObjectFee.get("message") == null ? "" : jsonObjectFee.get("message").getAsString();
tip = tip + "" + usd;
} else {
tip += "请求的数据为空";
tip = tip + "请求的数据为空";
}
} else {
tip += "请求的数据为空";
tip = tip + "请求的数据为空";
}
return ServerResponse.createByErrorCodeMessage(3001, tip);
} catch (Exception e) {
e.printStackTrace();
return ServerResponse.createByErrorCodeMessage(3001, tip);
} catch (Exception var10) {
var10.printStackTrace();
return ServerResponse.createByErrorCodeMessage(-1, feeJson);
}
}
@Override
public ServerResponse checkMyMoney() {
try {
Map<String, Object> map = currencyMapper.FindDataById(NameValue.Table_pay_operator_balance, 1);
Map<String, Object> map = this.currencyMapper.FindDataById(NameValue.Table_pay_operator_balance, 1);
return ServerResponse.createBySuccess(map);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var2) {
var2.printStackTrace();
return ServerResponse.createByError();
}
}
@Override
public ServerResponse saveTheEmail() {
try {
String email = request.getParameter("email");
String email = this.request.getParameter("email");
email = URLDecoder.decode(email, "UTF-8");
System.out.println(email);
Map<String, Object> mapUpdate = new HashMap<>();
Map<String, Object> mapUpdate = new HashMap();
mapUpdate.put("email", email);
int rest = commMapper.updateTheBalance(mapUpdate);
int rest = this.commMapper.updateTheBalance(mapUpdate);
return ServerResponse.createBySuccess(rest);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception var4) {
var4.printStackTrace();
return ServerResponse.createByError();
}
}
//修改运营商剩余余额记录
private void changeTheAmountLog(String statel, String mefont, String cellcard, String smart, String remark) {
try {
Map<String, Object> map = new HashMap<>();
Map<String, Object> map = new HashMap();
if (!TextUtils.isEmpty(statel)) {
map.put("statel", statel);
sentMail(statel, "statel");
this.sentMail(statel, "statel");
}
if (!TextUtils.isEmpty(mefont)) {
map.put("mefont", mefont);
sentMail(mefont, "mefont");
this.sentMail(mefont, "mefont");
}
if (!TextUtils.isEmpty(cellcard)) {
map.put("cellcard", cellcard);
sentMail(cellcard, "cellcard");
this.sentMail(cellcard, "cellcard");
}
if (!TextUtils.isEmpty(smart)) {
map.put("smart", smart);
sentMail(smart, "smart");
this.sentMail(smart, "smart");
}
if (!TextUtils.isEmpty(remark)) {
map.put("remark", remark);
}
commMapper.updateTheBalance(map);
} catch (Exception e) {
e.printStackTrace();
this.commMapper.updateTheBalance(map);
} catch (Exception var7) {
var7.printStackTrace();
}
}
private void sentMail(String money, String operation) {
try {
Map<String, Object> map = currencyMapper.FindDataById(NameValue.Table_pay_operator_balance, 1);
Map<String, Object> map = this.currencyMapper.FindDataById(NameValue.Table_pay_operator_balance, 1);
String email = map.get("email") == null ? "" : map.get("email").toString();
String lackbalance = map.get("lackbalance") == null ? "" : map.get("lackbalance").toString();
if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(lackbalance)) {
if (new BigDecimal(money).compareTo(new BigDecimal(lackbalance)) < 0) {
if (money.indexOf(",") != -1) {
money = money.replace(",", "");
}
if ((new BigDecimal(money)).compareTo(new BigDecimal(lackbalance)) < 0) {
String[] els = email.split(",");
for (int i = 0; i < els.length; i++) {
for (int i = 0; i < els.length; ++i) {
SendEmailTools.SendMail("充值系统-余额不足" + lackbalance + "美元", operation + "运营商当前剩余余额:" + money, els[i]);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception var8) {
var8.printStackTrace();
}
}
/**
* 此函数非原创,从网上搜索而来,timeZoneOffset原为int类型,为班加罗尔调整成float类型
......@@ -301,13 +263,13 @@ public class CommServiceImpl implements CommService {
* @return
*/
public static String getFormatedDateString(float timeZoneOffset) {
if (timeZoneOffset > 13 || timeZoneOffset < -12) {
timeZoneOffset = 0;
if (timeZoneOffset > 13.0F || timeZoneOffset < -12.0F) {
timeZoneOffset = 0.0F;
}
int newTime = (int) (timeZoneOffset * 60 * 60 * 1000);
TimeZone timeZone;
int newTime = (int) (timeZoneOffset * 60.0F * 60.0F * 1000.0F);
String[] ids = TimeZone.getAvailableIDs(newTime);
Object timeZone;
if (ids.length == 0) {
timeZone = TimeZone.getDefault();
} else {
......@@ -315,8 +277,7 @@ public class CommServiceImpl implements CommService {
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone(timeZone);
sdf.setTimeZone((TimeZone) timeZone);
return sdf.format(new Date());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment