|
@@ -10,7 +10,9 @@ import com.miaxis.common.core.controller.BaseController;
|
|
import com.miaxis.common.core.domain.Response;
|
|
import com.miaxis.common.core.domain.Response;
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
import com.miaxis.common.core.page.ResponsePageInfo;
|
|
import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
|
+import com.miaxis.common.sms.MD5Utils;
|
|
import com.miaxis.common.utils.SecurityUtils;
|
|
import com.miaxis.common.utils.SecurityUtils;
|
|
|
|
+import com.miaxis.common.utils.StringUtils;
|
|
import com.miaxis.customer.dto.AppletCustomerInfoDto;
|
|
import com.miaxis.customer.dto.AppletCustomerInfoDto;
|
|
import com.miaxis.customer.service.ICustomerInfoService;
|
|
import com.miaxis.customer.service.ICustomerInfoService;
|
|
import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
|
|
import com.miaxis.customer.vo.ExhibitionCustomerInfoVo;
|
|
@@ -35,10 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.TreeMap;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 【小程序-客户信息】Controller
|
|
* 【小程序-客户信息】Controller
|
|
@@ -58,6 +57,10 @@ public class FilmController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private WxpayConfig wxpayConfig;
|
|
private WxpayConfig wxpayConfig;
|
|
|
|
|
|
|
|
+ private static String appKey = "10000000000";
|
|
|
|
+
|
|
|
|
+ private static String appSecret = "25f9e794323b453885f5181f1b624d0b";
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 微信支付获取预订单id
|
|
* 微信支付获取预订单id
|
|
*/
|
|
*/
|
|
@@ -89,10 +92,6 @@ public class FilmController extends BaseController {
|
|
return Response.success(prepareOrderEntity);
|
|
return Response.success(prepareOrderEntity);
|
|
|
|
|
|
}
|
|
}
|
|
- @Data
|
|
|
|
- public static class PrepareOrderEntity{
|
|
|
|
- String prepay_id;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -103,13 +102,43 @@ public class FilmController extends BaseController {
|
|
* @return 服务器返回数据
|
|
* @return 服务器返回数据
|
|
*/
|
|
*/
|
|
@PostMapping(value = "/fileCommonApi")
|
|
@PostMapping(value = "/fileCommonApi")
|
|
- @ApiOperation("微信支付获取预订单id")
|
|
|
|
- public static String httpPostWithForm(FilmDTO filmDTO){
|
|
|
|
|
|
+ @ApiOperation("电影通用接口")
|
|
|
|
+ public Response<JSONObject> httpPostWithForm(@RequestBody FilmDTO filmDTO){
|
|
// 用于接收返回的结果
|
|
// 用于接收返回的结果
|
|
String resultData ="";
|
|
String resultData ="";
|
|
try {
|
|
try {
|
|
HttpPost post = new HttpPost("http://movieapi2-test.taototo.cn/"+filmDTO.getUrl());
|
|
HttpPost post = new HttpPost("http://movieapi2-test.taototo.cn/"+filmDTO.getUrl());
|
|
post.setHeader("Content-Type","application/x-www-form-urlencoded");
|
|
post.setHeader("Content-Type","application/x-www-form-urlencoded");
|
|
|
|
+ Map<String, Object> sortMap = new TreeMap<String, Object>();
|
|
|
|
+ String time = String.valueOf(System.currentTimeMillis()/1000);
|
|
|
|
+ Map<String,Object> param = new HashMap<String,Object>();
|
|
|
|
+ sortMap.put("appKey",appKey);
|
|
|
|
+ sortMap.put("time",time);
|
|
|
|
+ //1 将数据拆分成 treemap存储
|
|
|
|
+ if (!StringUtils.isEmpty(filmDTO.getParamData())){
|
|
|
|
+ String[] keyValueStr = filmDTO.getParamData().split("&");
|
|
|
|
+ for(String keyValue : keyValueStr){
|
|
|
|
+ String[] arr = keyValue.split("=");
|
|
|
|
+ sortMap.put(arr[0],arr[1]) ;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //2 读取treemap。按固定格式拼接,最后再拼接上 secret
|
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
|
+ for (Map.Entry<String, Object> s : sortMap.entrySet()) {
|
|
|
|
+ String k = s.getKey();
|
|
|
|
+ Object v = s.getValue();
|
|
|
|
+ builder.append(k).append("=").append(v).append("&");
|
|
|
|
+ }
|
|
|
|
+ //3 将最后拼接出来的sign传 md5加密
|
|
|
|
+ String sign = MD5Utils.MD5Encode(builder.append("appSecret="+appSecret).toString());
|
|
|
|
+ List<BasicNameValuePair> pairList = new ArrayList<BasicNameValuePair>();
|
|
|
|
+ // 迭代Map-->取出key,value放到BasicNameValuePair对象中-->添加到list中
|
|
|
|
+ for (Map.Entry entry : sortMap.entrySet()) {
|
|
|
|
+ pairList.add(new BasicNameValuePair(String.valueOf(entry.getKey()) ,String.valueOf(entry.getValue())));
|
|
|
|
+ }
|
|
|
|
+ pairList.add(new BasicNameValuePair("sign",sign));
|
|
|
|
+ UrlEncodedFormEntity uefe = new UrlEncodedFormEntity(pairList, "utf-8");
|
|
|
|
+ post.setEntity(uefe);
|
|
// 创建一个http客户端
|
|
// 创建一个http客户端
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
// 发送post请求
|
|
// 发送post请求
|
|
@@ -123,9 +152,10 @@ public class FilmController extends BaseController {
|
|
throw new RuntimeException("接口连接失败!");
|
|
throw new RuntimeException("接口连接失败!");
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
throw new RuntimeException("接口连接失败!");
|
|
throw new RuntimeException("接口连接失败!");
|
|
}
|
|
}
|
|
- return resultData;
|
|
|
|
|
|
+ return Response.success(JSONObject.parseObject(resultData));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -147,6 +177,12 @@ public class FilmController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @Data
|
|
|
|
+ public static class PrepareOrderEntity{
|
|
|
|
+ String prepay_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|