|
@@ -5,19 +5,21 @@ import com.thoughtworks.xstream.XStream;
|
|
|
import com.ym.mec.collectfee.common.dao.BaseDAO;
|
|
|
import com.ym.mec.collectfee.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.collectfee.dao.OrderDao;
|
|
|
-import com.ym.mec.collectfee.entity.Order;
|
|
|
-import com.ym.mec.collectfee.entity.Orders;
|
|
|
-import com.ym.mec.collectfee.entity.RequestParamBean;
|
|
|
-import com.ym.mec.collectfee.entity.RequestHead;
|
|
|
+import com.ym.mec.collectfee.entity.*;
|
|
|
import com.ym.mec.collectfee.service.OrderService;
|
|
|
+import com.ym.mec.collectfee.utils.HttpUtil;
|
|
|
import com.ym.mec.collectfee.utils.XStreamUtil;
|
|
|
+import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.io.StringWriter;
|
|
|
import java.io.Writer;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
|
|
|
@Service
|
|
|
public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements OrderService {
|
|
@@ -28,6 +30,8 @@ public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements
|
|
|
//公共密钥
|
|
|
private String publicKey = "e99a18c428cb38d5f260853678922e03";
|
|
|
|
|
|
+ private String url = "http://101.200.2.249:9001/api/sys";
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Integer, Order> getDAO() {
|
|
|
return orderDao;
|
|
@@ -53,11 +57,10 @@ public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements
|
|
|
xs.toXML(orders,writer);
|
|
|
String body = writer.toString();
|
|
|
body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
-// String body = "<id>1</id><oid>123456</oid><userId>100018</userId><amount>1000.00</amount><pay>1000.00</pay><bank>301</bank><account>2342345</account><uAccount>123423452</uAccount><payId>234562354234</payId><payTime>2019-08-19 16:33:42.0 UTC</payTime><remark>test</remark><classId>1</classId><status>0</status><createTime>2019-08-19 16:34:12.0 UTC</createTime><poName>er而为人</poName><voicyPart>阿道夫</voicyPart><balance>500.00</balance><batchNum>23452345</batchNum>";
|
|
|
|
|
|
body = Base64.getEncoder().encodeToString(body.getBytes());
|
|
|
requestParamBean.setBody(body);
|
|
|
- requestParamBean.setHead(getOrdersHead(orderList,body));
|
|
|
+ requestParamBean.setHead(getOrdersHead(body,121512));
|
|
|
|
|
|
xs.autodetectAnnotations(true);
|
|
|
writer = new StringWriter();
|
|
@@ -70,10 +73,10 @@ public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private RequestHead getOrdersHead(List<Order> orders,String body){
|
|
|
- Order order = orders.get(0);
|
|
|
+ private RequestHead getOrdersHead(String body,Integer cmd){
|
|
|
RequestHead head = new RequestHead();
|
|
|
- head.setMsgId(order.getBatchNum());
|
|
|
+ head.setMsgId(getRandom(7));
|
|
|
+ head.setCmd(cmd);
|
|
|
head.setSign(getSign(head, body, publicKey));
|
|
|
return head;
|
|
|
}
|
|
@@ -90,4 +93,42 @@ public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements
|
|
|
public int countOrder(String poName, String voicePort) {
|
|
|
return orderDao.countOrder(poName,voicePort);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getSchoolDetail(Integer schoolId,Integer clazzId) {
|
|
|
+ try {
|
|
|
+ RequestParamBean requestParamBean = new RequestParamBean();
|
|
|
+ String body = "<schoolId>" + schoolId + "</schoolId><classId>" + clazzId + "</classId>";
|
|
|
+ body = Base64.getEncoder().encodeToString(body.getBytes());
|
|
|
+ requestParamBean.setBody(body);
|
|
|
+ requestParamBean.setHead(getOrdersHead(body,124005));
|
|
|
+ XStream xs = new XStream();
|
|
|
+ xs.autodetectAnnotations(true);
|
|
|
+ Writer writer = new StringWriter();
|
|
|
+ writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
|
|
+ xs.toXML(requestParamBean,writer);
|
|
|
+ String parseBody = parseBody(HttpUtil.postXmlData(writer.toString(), url));
|
|
|
+ ResponseCourseEntity xmlToObject = XStreamUtil.xmlToObject("body", ResponseCourseEntity.class, parseBody);
|
|
|
+ return xmlToObject;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String parseBody(String body){
|
|
|
+ body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
+ return "<body><courses>" + new String(Base64.getDecoder().decode(body)) + "</courses></body>";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getRandom(int length) {
|
|
|
+ String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
+ Random random = new Random();
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
+ int number = random.nextInt(base.length());
|
|
|
+ sb.append(base.charAt(number));
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
}
|