generated from root/miduo_server
68 lines
2.5 KiB
Java
68 lines
2.5 KiB
Java
package com.jmfy.controller;
|
||
|
||
import com.jmfy.paramBean.PaySdkEnum;
|
||
import com.jmfy.util.DuoyouUtils;
|
||
import com.jmfy.util.JsonUtil;
|
||
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.Date;
|
||
import java.util.HashMap;
|
||
import java.util.SortedMap;
|
||
import java.util.TreeMap;
|
||
|
||
/**
|
||
* 多游游戏支付
|
||
*/
|
||
@RestController
|
||
public class DuoYouRechargeController {
|
||
|
||
@Resource
|
||
private PayLogic payLogic;
|
||
|
||
private static final String APP_ID = "531340CB459ACA5BD680DAF51215B56F";
|
||
private static final String APP_KEY = "31cc6cf98488f154d564153ecd93953e";
|
||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(DuoYouRechargeController.class);
|
||
|
||
@RequestMapping(value = "/Web/duoyouCallback")
|
||
public String duoyouCallback(HttpServletRequest request) throws Exception {
|
||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap2(request);
|
||
if (parameterMap.isEmpty()) {
|
||
LOGGER.info("duoyouGameCallback data is null");
|
||
return "FAIL";
|
||
}
|
||
|
||
String app_id = request.getParameter("app_id"); //多游分配的 appId
|
||
String transaction_id = request.getParameter("transaction_id"); //多游订单号
|
||
String out_trade_no = request.getParameter("out_trade_no"); //游戏厂商订单号
|
||
String total_fee = request.getParameter("total_fee"); //订单金额(分)
|
||
String payType = request.getParameter("payType"); //支付类型, Wx:微信支付 Ali:支付宝
|
||
String extra = request.getParameter("extra"); //额外参数
|
||
String sign = request.getParameter("sign"); //签名
|
||
|
||
LOGGER.info("duoyou======》{}", parameterMap);
|
||
|
||
SortedMap<String, String> map = new TreeMap<>();
|
||
map.put("app_id",app_id);
|
||
map.put("transaction_id",transaction_id);
|
||
map.put("out_trade_no",out_trade_no);
|
||
map.put("total_fee",total_fee);
|
||
map.put("payType",payType);
|
||
map.put("extra",extra);
|
||
map.put(DuoyouUtils.FIELD_SIGN,sign);
|
||
|
||
boolean valid = DuoyouUtils.isSignatureValid(map, APP_ID, APP_KEY);
|
||
if (!valid) {
|
||
LOGGER.info("callback==>extra={},sin verify fail", extra);
|
||
return "FAIL";
|
||
}
|
||
|
||
return payLogic.initOrder(extra,out_trade_no,total_fee,new Date(),app_id, PaySdkEnum.DUOYOU);
|
||
}
|
||
}
|