generated from root/miduo_server
Merge branch 'master_jieling' of http://60.1.1.230/mashiyu/delivery-server into master_jieling
commit
1c903ab9fe
|
@ -0,0 +1,102 @@
|
||||||
|
package com.jmfy.controller;
|
||||||
|
|
||||||
|
import com.jmfy.paramBean.PaySdkEnum;
|
||||||
|
import com.jmfy.util.DuoyouUtils;
|
||||||
|
import com.jmfy.util.JsonUtil;
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爱玩游戏支付
|
||||||
|
* @author hj
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class AiWanRechargeController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayLogic payLogic;
|
||||||
|
|
||||||
|
private static final String APP_ID = "lbqitk9b39vk9ee5";
|
||||||
|
private static final String PAY_KEY = "qLFjFcmylTdgzzScwTmVGQkgLTvLRBQS";
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AiWanRechargeController.class);
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Web/aiwanCallback")
|
||||||
|
public String aiwanCallback(HttpServletRequest request) throws Exception {
|
||||||
|
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap2(request);
|
||||||
|
if (parameterMap.isEmpty()) {
|
||||||
|
LOGGER.info("aiwanGameCallback data is null");
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
|
||||||
|
String do1 = request.getParameter("do"); //操作方法:suc 发货通知
|
||||||
|
String site_uid = request.getParameter("site_uid"); //平台uid(爱玩SDK客户端返回account参数值)
|
||||||
|
String order_no = request.getParameter("order_no"); //游戏厂商订单号
|
||||||
|
String app_id = request.getParameter("app_id"); //应用ID
|
||||||
|
String channel = request.getParameter("channel"); //渠道ID,431 微信App支付,265 支付宝App支付
|
||||||
|
String amount = request.getParameter("amount"); //下单金额(原币),1单位是元
|
||||||
|
String amount_unit = request.getParameter("amount_unit"); //货币单位 CNY
|
||||||
|
String amount_rate = request.getParameter("amount_rate"); //兑换美金的汇率值
|
||||||
|
String amount_usd = request.getParameter("amount_usd"); //美金值
|
||||||
|
String amount_change = request.getParameter("amount_change"); //下单金额,付款金额是有变动。1有变动,0无变动
|
||||||
|
String ext = request.getParameter("ext"); //透传参数
|
||||||
|
String out_trade_no = request.getParameter("out_trade_no"); //游戏方订单号
|
||||||
|
String item_id = request.getParameter("item_id"); //商品ID
|
||||||
|
String create_time = request.getParameter("create_time"); //创建时间,10位Unix时间戳(秒)
|
||||||
|
String pay_time = request.getParameter("pay_time"); //付款时间,10位Unix时间戳(秒)
|
||||||
|
String time = request.getParameter("time"); //请求时间,10位Unix时间戳(秒)
|
||||||
|
String sign = request.getParameter("sign"); //签名
|
||||||
|
|
||||||
|
|
||||||
|
LOGGER.info("aiwan======》{}", parameterMap);
|
||||||
|
|
||||||
|
SortedMap<String, String> map = new TreeMap<>();
|
||||||
|
map.put("do",do1);
|
||||||
|
map.put("site_uid",site_uid);
|
||||||
|
map.put("order_no",order_no);
|
||||||
|
map.put("app_id",app_id);
|
||||||
|
map.put("channel",channel);
|
||||||
|
map.put("amount",amount);
|
||||||
|
map.put("amount_unit",amount_unit);
|
||||||
|
map.put("amount_rate",amount_rate);
|
||||||
|
map.put("amount_usd",amount_usd);
|
||||||
|
map.put("amount_change",amount_change);
|
||||||
|
map.put("ext",ext);
|
||||||
|
map.put("out_trade_no",out_trade_no);
|
||||||
|
map.put("item_id",item_id);
|
||||||
|
map.put("create_time",create_time);
|
||||||
|
map.put("pay_time",pay_time);
|
||||||
|
map.put("time",time);
|
||||||
|
|
||||||
|
boolean valid = verifySign(map, sign);
|
||||||
|
if (!valid) {
|
||||||
|
LOGGER.info("callback==>extra={},sin verify fail", ext);
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
|
||||||
|
int rmb = Integer.parseInt(amount) * 100;
|
||||||
|
return payLogic.initOrder(ext,out_trade_no,String.valueOf(rmb),new Date(),site_uid, PaySdkEnum.AIWAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean verifySign(Map<String, String> map, String sign){
|
||||||
|
if (map == null || map.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
|
builder.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||||
|
}
|
||||||
|
String substring = builder.substring(0, builder.length() - 1);
|
||||||
|
LOGGER.info("AiWan参数拼装sign(未加密):" + substring + PAY_KEY);
|
||||||
|
String md5Hex = DigestUtils.md5Hex(substring + PAY_KEY);
|
||||||
|
LOGGER.info("AiWan参数拼装sign(加密后):" + md5Hex);
|
||||||
|
return md5Hex.equals(sign);
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,10 @@ public class PayLogic {
|
||||||
private PayLogic() {
|
private PayLogic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String initOrder(String collBackInfo, String orderId, String amount, Date time, String openId, PaySdkEnum sdk){
|
||||||
|
return initOrder(collBackInfo,orderId,amount,time,openId,sdk,"");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param collBackInfo 回调参数
|
* @param collBackInfo 回调参数
|
||||||
|
@ -46,7 +50,7 @@ public class PayLogic {
|
||||||
* @param sdk sdk,支付渠道标识
|
* @param sdk sdk,支付渠道标识
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String initOrder(String collBackInfo, String orderId, String amount, Date time, String openId, PaySdkEnum sdk){
|
public String initOrder(String collBackInfo, String orderId, String amount, Date time, String openId, PaySdkEnum sdk, String ext){
|
||||||
try {
|
try {
|
||||||
// 角色id_物品id_ccId_平台
|
// 角色id_物品id_ccId_平台
|
||||||
String[] collback = collBackInfo.split("_");
|
String[] collback = collBackInfo.split("_");
|
||||||
|
|
|
@ -15,6 +15,7 @@ public enum PaySdkEnum {
|
||||||
YX(5,"YX"),
|
YX(5,"YX"),
|
||||||
DY(6,"DY"),
|
DY(6,"DY"),
|
||||||
DUOYOU(7,"DUOYOU"),
|
DUOYOU(7,"DUOYOU"),
|
||||||
|
AIWAN(8,"AIWAN"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
Loading…
Reference in New Issue