Commit 0562463e by yanlveming

同步

parent 32323ba5
...@@ -217,7 +217,7 @@ public class MetfoneSentUtils { ...@@ -217,7 +217,7 @@ public class MetfoneSentUtils {
System.out.println(str);*/ System.out.println(str);*/
String str = checkMyMoneyPost("20010818431127","0979530750"); String str = checkMyMoneyPost("200108184311227","0979530750");
System.out.println(str); System.out.println(str);
} }
......
...@@ -11,8 +11,8 @@ import net.sf.json.JSONObject; ...@@ -11,8 +11,8 @@ import net.sf.json.JSONObject;
import org.apache.http.util.TextUtils; import org.apache.http.util.TextUtils;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap; import java.text.SimpleDateFormat;
import java.util.Map; import java.util.*;
public class SmartSentUtils { public class SmartSentUtils {
...@@ -175,9 +175,51 @@ public class SmartSentUtils { ...@@ -175,9 +175,51 @@ public class SmartSentUtils {
} }
public static void main222(String[] args) {
/**
* {
* "correlation_id": "Link Asia:87234159:20200109105959",
* "institution_id": "98198198",
* "subscriber_id": "tel:+85587234159",
* "amount": 100,
* "channel": "WEB",
* "instance_id": "0109110016004792"
* }
*/
String json = getToken();
/**
* {"access_token":"372b5f81-9662-3d75-abcf-639920880ce3","refresh_token":"d62d9da3-3730-35f7-9368-c82b43509db1","scope":"default","token_type":"Bearer","expires_in":3249}//
*/
System.out.println(json);
String tip="";
String tokenStr = "";
//判断是否成功获取到token
if (!TextUtils.isEmpty(json)) {
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = jsonParser.parse(json).getAsJsonObject();
tokenStr = jsonObject.get("access_token") == null ? "" : jsonObject.get("access_token").getAsString();
if (!TextUtils.isEmpty(tokenStr)) {
access_token = tokenStr;
refresh_token = jsonObject.get("refresh_token").getAsString();
token_type = jsonObject.get("token_type").getAsString();
expires_in = jsonObject.get("expires_in").getAsInt();
} else {
tip += " 返回结果:" + json;
}
} else {
tip += " 返回值为空";
}
String jsonQuery = queryRechargePhone("Link Asia:87234159:20200109105959");//发起校验
System.out.println(jsonQuery);
System.out.println(tip);
}
public static void main(String[] args) { public static void main(String[] args) {
String phone = "87234159"; String phone = "87234159";
ResultsModel resultsModel = sentTopUp(phone, 1, "99999912"); ResultsModel resultsModel = sentTopUp(phone, 1, getFormatedDateString(7));
System.out.println("充值是否成功:" + resultsModel.isSuccessful()); System.out.println("充值是否成功:" + resultsModel.isSuccessful());
System.out.println("充值日志:" + resultsModel.getTip()); System.out.println("充值日志:" + resultsModel.getTip());
...@@ -248,7 +290,7 @@ public class SmartSentUtils { ...@@ -248,7 +290,7 @@ public class SmartSentUtils {
//校验成功 //校验成功
tip += " 手机号码校验成功 !!!"; tip += " 手机号码校验成功 !!!";
String rechId = "58cam:" + phone + ":" + orderNum; String rechId = "LinkAsia:" + phone + ":" + orderNum;
int amount = topUpAmount * 100;//需要乘以100,文档写在至少100分美元,则1美元,以分为单位 int amount = topUpAmount * 100;//需要乘以100,文档写在至少100分美元,则1美元,以分为单位
String rechargeJson = rechargePhone(phone, String.valueOf(amount), rechId);//发起充值 String rechargeJson = rechargePhone(phone, String.valueOf(amount), rechId);//发起充值
System.out.println(rechargeJson); System.out.println(rechargeJson);
...@@ -266,7 +308,7 @@ public class SmartSentUtils { ...@@ -266,7 +308,7 @@ public class SmartSentUtils {
JsonParser jsonParserRecharge = new JsonParser(); JsonParser jsonParserRecharge = new JsonParser();
JsonObject jsonObjectRecharge = jsonParserRecharge.parse(rechargeJson).getAsJsonObject(); JsonObject jsonObjectRecharge = jsonParserRecharge.parse(rechargeJson).getAsJsonObject();
correlation_id = jsonObjectRecharge.get("correlation_id") == null ? "" : jsonObjectRecharge.get("correlation_id").getAsString();//不为空,则充值成功 correlation_id = jsonObjectRecharge.get("correlation_id") == null ? "" : jsonObjectRecharge.get("correlation_id").getAsString();//不为空,则充值成功
tip += " 充值发起成功!!!"; tip += " 充值发起请求成功!!!";
} else { } else {
tip += " 充值请求返回值为空;"; tip += " 充值请求返回值为空;";
} }
...@@ -318,4 +360,32 @@ public class SmartSentUtils { ...@@ -318,4 +360,32 @@ public class SmartSentUtils {
return resultsModel; return resultsModel;
} }
} }
/**
* 此函数非原创,从网上搜索而来,timeZoneOffset原为int类型,为班加罗尔调整成float类型
* timeZoneOffset表示时区,如中国一般使用东八区,因此timeZoneOffset就是8
*
* @param timeZoneOffset
* @return
*/
public static String getFormatedDateString(float timeZoneOffset) {
if (timeZoneOffset > 13 || timeZoneOffset < -12) {
timeZoneOffset = 0;
}
int newTime = (int) (timeZoneOffset * 60 * 60 * 1000);
TimeZone timeZone;
String[] ids = TimeZone.getAvailableIDs(newTime);
if (ids.length == 0) {
timeZone = TimeZone.getDefault();
} else {
timeZone = new SimpleTimeZone(newTime, ids[0]);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone(timeZone);
return sdf.format(new Date());
}
} }
...@@ -21,6 +21,7 @@ public class NameValue { ...@@ -21,6 +21,7 @@ public class NameValue {
public static String Table_order_log = "pre_dz_pay_order_log";//订单日志表 public static String Table_order_log = "pre_dz_pay_order_log";//订单日志表
public static String Table_order = "pre_dz_pay_order";//订单表 public static String Table_order = "pre_dz_pay_order";//订单表
public static String Table_pay_segment = "pre_dz_pay_segment";//订单表 public static String Table_pay_segment = "pre_dz_pay_segment";//订单表
public static String Table_pay_operator_balance = "pre_dz_pay_operator_balance";//运营商余额
......
...@@ -7,6 +7,7 @@ import com.library.TopUp.Http.HttpUtils; ...@@ -7,6 +7,7 @@ import com.library.TopUp.Http.HttpUtils;
import com.library.TopUp.Statel.HttpClientUtils; import com.library.TopUp.Statel.HttpClientUtils;
import com.library.TopUp.Statel.SeatelSentUtils; import com.library.TopUp.Statel.SeatelSentUtils;
import com.library.TopUp.cellcard.CellcardSentUtils; import com.library.TopUp.cellcard.CellcardSentUtils;
import com.library.TopUp.mefont.MetfoneSentUtils;
import com.library.TopUp.model.ResultsModel; import com.library.TopUp.model.ResultsModel;
import com.library.respcode.ServerResponse; import com.library.respcode.ServerResponse;
import com.library.service.AdminService; import com.library.service.AdminService;
...@@ -22,10 +23,7 @@ import javax.annotation.Resource; ...@@ -22,10 +23,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
/* /*
* @项目名: yunVpay * @项目名: yunVpay
...@@ -45,94 +43,47 @@ public class CommonController { ...@@ -45,94 +43,47 @@ public class CommonController {
@Resource @Resource
private HttpServletRequest request; private HttpServletRequest request;
//查询剩余的余额
@ResponseBody
@RequestMapping("checkMyMoney")
private ServerResponse checkMyMoney() {
return commService.checkMyMoney();
}
//保存邮箱
@ResponseBody
@RequestMapping("saveTheEmail")
private ServerResponse saveTheEmail() {
return commService.saveTheEmail();
}
//检查Seatel运营商的手机 //检查Seatel运营商的手机
@ResponseBody @ResponseBody
@RequestMapping("checkPhoneInSeatel") @RequestMapping("checkPhoneInSeatel")
private ServerResponse checkPhoneInSeatel() { private ServerResponse checkPhoneInSeatel() {
return commService.checkPhoneInSeatel();
}
String phone = request.getParameter("phone"); //查询Metfone手机号剩余的余额
String json = SeatelSentUtils.checkPhone2(phone); @ResponseBody
return ServerResponse.createBySuccess(json); @RequestMapping("checkMyMoneyInMetfone")
private ServerResponse checkMyMoneyInMetfone() {
return commService.checkMyMoneyInMetfone();
} }
//查询Seatel运营商剩余的余额 //查询Seatel运营商剩余的余额
@ResponseBody @ResponseBody
@RequestMapping("queryAgentFeeInSeatel") @RequestMapping("queryAgentFeeInSeatel")
private ServerResponse queryAgentFeeInSeatel() { private ServerResponse queryAgentFeeInSeatel() {
return commService.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 + "";
} else {
tip += "获取不到余额信息";
}
} else {
tip += "查询余额失败;结果为:" + feeJson;
}
}
return ServerResponse.createBySuccess(tip, myAmount);
} }
//查询Cellcard运营商剩余的余额 // 查询Cellcard运营商剩余的余额
@ResponseBody @ResponseBody
@RequestMapping("queryAgentFeeInCellcard") @RequestMapping("queryAgentFeeInCellcard")
private ServerResponse queryAgentFeeInCellcard() { private ServerResponse queryAgentFeeInCellcard() {
String feeJson = ""; return commService.queryAgentFeeInCellcard();
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 + "";
return ServerResponse.createByErrorCodeMessage(3002, tip);
} else {
tip += "获取不到余额信息;"+error_message;
}
} else {
tip += "查询余额失败;结果为:" + feeJson;
}
} else {
tip += "解析data为空";
}
} else {
tip += "请求的数据为空";
}
return ServerResponse.createByErrorCodeMessage(3001, tip);
} catch (Exception e) {
e.printStackTrace();
return ServerResponse.createByErrorCodeMessage(-1, feeJson);
}
} }
......
...@@ -79,5 +79,11 @@ public interface CommMapper { ...@@ -79,5 +79,11 @@ public interface CommMapper {
*/ */
public List<Map<String, Object>> findAllProducts(@Param("page") int page, @Param("number") int number); public List<Map<String, Object>> findAllProducts(@Param("page") int page, @Param("number") int number);
/**
* 更新余额
*
* @return
*/
public int updateTheBalance(@Param("map") Map<String,Object> map);
} }
...@@ -219,4 +219,33 @@ ...@@ -219,4 +219,33 @@
LIMIT #{page},#{number} LIMIT #{page},#{number}
</select> </select>
<update id="updateTheBalance" parameterType="map">
UPDATE pre_dz_pay_operator_balance
SET
<if test="map.statel != null">
statel = #{map.statel} ,
</if>
<if test="map.mefont != null">
mefont = #{map.mefont} ,
</if>
<if test="map.cellcard != null">
cellcard = #{map.cellcard} ,
</if>
<if test="map.smart != null">
smart = #{map.smart} ,
</if>
<if test="map.remark != null">
remark = #{map.remark} ,
</if>
<if test="map.email != null">
email = #{map.email} ,
</if>
<if test="map.lackbalance != null">
lackbalance = #{map.lackbalance} ,
</if>
update_time = now()
WHERE id = 1
</update>
</mapper> </mapper>
package com.library.model;
import java.sql.Timestamp;
public class OperatorBalanceModel {
public int id;
public String statel;
public String mefont;
public String cellcard;
public String smart;
public String remark;
public String email;
public String lackbalance;
public Timestamp update_time;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getStatel() {
return statel;
}
public void setStatel(String statel) {
this.statel = statel;
}
public String getMefont() {
return mefont;
}
public void setMefont(String mefont) {
this.mefont = mefont;
}
public String getCellcard() {
return cellcard;
}
public void setCellcard(String cellcard) {
this.cellcard = cellcard;
}
public String getSmart() {
return smart;
}
public void setSmart(String smart) {
this.smart = smart;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Timestamp getUpdate_time() {
return update_time;
}
public void setUpdate_time(Timestamp update_time) {
this.update_time = update_time;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLackbalance() {
return lackbalance;
}
public void setLackbalance(String lackbalance) {
this.lackbalance = lackbalance;
}
}
...@@ -21,4 +21,16 @@ public interface CommService { ...@@ -21,4 +21,16 @@ public interface CommService {
* @return * @return
*/ */
ServerResponse adminLogin(); ServerResponse adminLogin();
ServerResponse checkPhoneInSeatel();
ServerResponse queryAgentFeeInSeatel();
ServerResponse queryAgentFeeInCellcard();
ServerResponse checkMyMoneyInMetfone();
ServerResponse checkMyMoney();
ServerResponse saveTheEmail();
} }
...@@ -11,16 +11,16 @@ import javax.mail.internet.MimeMessage; ...@@ -11,16 +11,16 @@ import javax.mail.internet.MimeMessage;
public class SendEmailTools { public class SendEmailTools {
//用于给用户发送邮件的邮箱 //用于给用户发送邮件的邮箱
private static String from = "503781495@qq.com"; private static String from = "2142497421@qq.com";
//授权码 从QQ上获得 //授权码 从QQ上获得
private static String password = "gflhiysqjvwebgfb"; private static String password = "myxetjyyawzebbdi";
/* /*
主方法测试用 主方法测试用
*/ */
public static void main(String[] args) { public static void main(String[] args) {
SendMail("有新下的订单", "aohdoiajdfjasdjf;l", "503781495@qq.com"); SendMail("测试", "aohdoiajdfjasdjf;l", "yanlveming@aliyun.com");
} }
......
...@@ -2,7 +2,9 @@ package com.library.util; ...@@ -2,7 +2,9 @@ package com.library.util;
import java.util.Locale; import java.util.Locale;
import com.library.controller.CommonController;
import com.library.service.AutomaticCodeService; import com.library.service.AutomaticCodeService;
import com.library.service.CommService;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
...@@ -20,6 +22,8 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -20,6 +22,8 @@ public class SpringContextUtil implements ApplicationContextAware {
@Autowired @Autowired
private AutomaticCodeService automaticCodeService; private AutomaticCodeService automaticCodeService;
@Autowired
private CommService commService;
/* (non Javadoc) /* (non Javadoc)
* @Title: setApplicationContext * @Title: setApplicationContext
...@@ -33,6 +37,8 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -33,6 +37,8 @@ public class SpringContextUtil implements ApplicationContextAware {
throws BeansException { throws BeansException {
System.out.println("========充值系统-开始系统自检========="); System.out.println("========充值系统-开始系统自检=========");
new CheckSystem().start(); new CheckSystem().start();
new CheckOperatorBalance1().start();
new CheckOperatorBalance2().start();
context = applicationContext; context = applicationContext;
} }
...@@ -45,7 +51,7 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -45,7 +51,7 @@ public class SpringContextUtil implements ApplicationContextAware {
@Override @Override
public void run() { public void run() {
while (true){ while (true) {
System.out.println("========自检次数:" + i + "========="); System.out.println("========自检次数:" + i + "=========");
i++; i++;
automaticCodeService.automaticForTack(); automaticCodeService.automaticForTack();
...@@ -61,6 +67,60 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -61,6 +67,60 @@ public class SpringContextUtil implements ApplicationContextAware {
} }
/**
* 进行运营商余额自检
*/
class CheckOperatorBalance1 extends Thread {
int i = 0;
@Override
public void run() {
while (true) {
System.out.println("========进行运营商余额自检次数:" + i + "=========");
i++;
commService.queryAgentFeeInSeatel();
try {
sleep(1000 * 60 * 60 * 24);//24个小时更新一次
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* 进行运营商余额自检
*/
class CheckOperatorBalance2 extends Thread {
int i = 0;
@Override
public void run() {
while (true) {
System.out.println("========进行运营商余额自检次数:" + i + "=========");
i++;
commService.queryAgentFeeInCellcard();
try {
sleep(1000 * 60 * 60 * 24);//24个小时更新一次
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public static <T> T getBean(String beanName) { public static <T> T getBean(String beanName) {
return (T) context.getBean(beanName); return (T) context.getBean(beanName);
......
package com.library.util; package com.library.util;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -47,6 +50,21 @@ public class UrlInterceptor implements HandlerInterceptor{ ...@@ -47,6 +50,21 @@ public class UrlInterceptor implements HandlerInterceptor{
@Override @Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, public boolean preHandle(HttpServletRequest req, HttpServletResponse resp,
Object arg2) throws Exception { Object arg2) throws Exception {
/* // 设置允许多个域名请求
String[] allowDomains = {"http://www.toheart.xin","http://localhost:8080"};
Set allowOrigins = new HashSet(Arrays.asList(allowDomains));
// if (Arrays.asList(Constants.ALLOW_DOMAIN).contains(originHeader)) {
String originHeads = req.getHeader("Origin");
if(allowOrigins.contains(originHeads)){
//设置允许跨域的配置
// 这里填写你允许进行跨域的主机ip(正式上线时可以动态配置具体允许的域名和IP)
}*/
resp.setHeader("Access-Control-Allow-Origin", req.getHeader("Origin"));
String reqURL=req.getRequestURI(); String reqURL=req.getRequestURI();
System.out.println(Tools.format3.format(new Timestamp(System.currentTimeMillis()))+" IP("+req.getRemoteAddr()+")访问的地址:"+reqURL); System.out.println(Tools.format3.format(new Timestamp(System.currentTimeMillis()))+" IP("+req.getRemoteAddr()+")访问的地址:"+reqURL);
if(!CanVisit(reqURL, req, resp)){//判断管理员是否能访问 if(!CanVisit(reqURL, req, resp)){//判断管理员是否能访问
......
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