|
@@ -7,6 +7,7 @@ import com.ym.mec.collectfee.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.collectfee.dao.*;
|
|
|
import com.ym.mec.collectfee.entity.*;
|
|
|
import com.ym.mec.collectfee.service.ApplyInfoService;
|
|
|
+import com.ym.mec.collectfee.utils.DES;
|
|
|
import com.ym.mec.collectfee.utils.HttpUtil;
|
|
|
import com.ym.mec.collectfee.utils.MapUtil;
|
|
|
import com.ym.mec.collectfee.utils.XStreamUtil;
|
|
@@ -14,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import java.io.StringWriter;
|
|
|
import java.io.Writer;
|
|
|
import java.util.*;
|
|
@@ -24,6 +26,8 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
@Autowired
|
|
|
private ApplyInfoDao applyInfoDao;
|
|
|
@Autowired
|
|
|
+ private MecUserDao mecUserDao;
|
|
|
+ @Autowired
|
|
|
private OrderDao orderDao;
|
|
|
@Autowired
|
|
|
private CourseGroupInfoDao courseGroupInfoDao;
|
|
@@ -38,6 +42,9 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
@Value("${common.properties.mec-url}")
|
|
|
private String url;
|
|
|
|
|
|
+ @Value("${common.properties.key}")
|
|
|
+ private String key;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ApplyInfo> getDAO() {
|
|
|
return applyInfoDao;
|
|
@@ -63,7 +70,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
String body = xs.toXML(applyInfo);
|
|
|
body = body.substring(body.indexOf("<user>")+6,body.indexOf("</user>"));
|
|
|
//推送mec注册接口
|
|
|
- body = getBody(body,12301);
|
|
|
+ body = getBody(body,12301,null);
|
|
|
Date date = new Date();
|
|
|
try {
|
|
|
applyInfo.setUpdateTime(date);
|
|
@@ -74,7 +81,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
body = xs.toXML(applyClass);
|
|
|
body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
//推送mec用户缴费
|
|
|
- getBody(body,125218);
|
|
|
+ getBody(body,125218,null);
|
|
|
applyInfoDao.update(applyInfo);
|
|
|
return true;
|
|
|
}catch (Exception e){
|
|
@@ -139,7 +146,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
List<Branch> branchList = branchDao.findAll(null);
|
|
|
if(branchList == null || branchList.size() < 1){
|
|
|
String body = "<province>0</province>";
|
|
|
- body = getBody(body,121002);
|
|
|
+ body = getBody(body,121002,null);
|
|
|
body = "<body><branches>" + new String(Base64.getDecoder().decode(body)) + "</branches></body>";
|
|
|
ResponseBranchesBean branches = XStreamUtil.xmlToObject("body", ResponseBranchesBean.class, body);
|
|
|
branchDao.batchInsert(branches.getBranches());
|
|
@@ -152,19 +159,6 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private String getBody(String body,Integer cmd) throws Exception{
|
|
|
- body = Base64.getEncoder().encodeToString(body.getBytes());
|
|
|
- RequestParamBean requestParamBean = new RequestParamBean();
|
|
|
- requestParamBean.setBody(body);
|
|
|
- requestParamBean.setHead(XStreamUtil.getOrdersHead(body,cmd,publicKey));
|
|
|
- Writer writer = new StringWriter();
|
|
|
- writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
|
|
- XStream xs = new XStream();
|
|
|
- xs.toXML(requestParamBean,writer);
|
|
|
- body = HttpUtil.postXmlData(writer.toString(), url);
|
|
|
- return body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void saveSeminary() {
|
|
|
try {
|
|
@@ -175,7 +169,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
break;
|
|
|
}
|
|
|
String body = "<branchId>" + branch.getBranchId() + "</branchId>";
|
|
|
- body = getBody(body,121107);
|
|
|
+ body = getBody(body,121107,null);
|
|
|
body = "<body><schools>" + new String(Base64.getDecoder().decode(body)) + "</schools></body>";
|
|
|
ResponseSeminariesBean seminaries = XStreamUtil.xmlToObject("body", ResponseSeminariesBean.class, body);
|
|
|
if(seminaries.getSchools() == null || seminaries.getSchools().size() < 1){
|
|
@@ -197,11 +191,6 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
}else {
|
|
|
vIewDetail.put("isCopperPipe",false);
|
|
|
}
|
|
|
- /*if("圆号,上低音,长号,大号".contains(subName.split("\\.")[1])){
|
|
|
- vIewDetail.put("isCopperPipe",true);
|
|
|
- }else {
|
|
|
- vIewDetail.put("isCopperPipe",false);
|
|
|
- }*/
|
|
|
return vIewDetail;
|
|
|
}
|
|
|
|
|
@@ -225,6 +214,97 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
return pageInfo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Object queryUserCourse(Integer userId) {
|
|
|
+ try {
|
|
|
+ //获取学员信息
|
|
|
+ MecUser mecUser = mecUserDao.get(userId);
|
|
|
+ if(mecUser == null){
|
|
|
+ String body = "<body><userId>" + userId + "</userId></body>";
|
|
|
+ body = getBody(body, 121313,null);
|
|
|
+ if(!StringUtils.isEmpty(body)){
|
|
|
+ body = new String(Base64.getDecoder().decode(body));
|
|
|
+ mecUser = XStreamUtil.xmlToObject("student", MecUser.class, body);
|
|
|
+ //同步mec用户数据
|
|
|
+ mecUserDao.insert(mecUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取学员课程班数据
|
|
|
+ //1小课,2乐团
|
|
|
+ String body = "<body><userId>" + userId + "</userId><classType>1</classType></body>";
|
|
|
+ List<MecCourse> coursesMin = getCourses(body);
|
|
|
+ body = "<body><userId>" + userId + "</userId><classType>2</classType></body>";
|
|
|
+ List<MecCourse> coursesMax = getCourses(body);
|
|
|
+ if(coursesMin != null && coursesMin.size() > 0){
|
|
|
+ coursesMin.forEach( e -> {
|
|
|
+ e.setClassType(1);
|
|
|
+ } );
|
|
|
+ }else {
|
|
|
+ coursesMin = new ArrayList<>();
|
|
|
+ }
|
|
|
+ if(coursesMax != null && coursesMax.size() > 0){
|
|
|
+ coursesMax.forEach( e -> {
|
|
|
+ e.setClassType(2);
|
|
|
+ } );
|
|
|
+ }else {
|
|
|
+ coursesMax = new ArrayList<>();
|
|
|
+ }
|
|
|
+ coursesMin.addAll(coursesMax);
|
|
|
+ return coursesMin;
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean pushRenew(RenewBean renewBean) {
|
|
|
+ try {
|
|
|
+ XStream xs = new XStream();
|
|
|
+ xs.autodetectAnnotations(true);
|
|
|
+ String body = xs.toXML(renewBean);
|
|
|
+ body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
+// while (body.length()%8 != 0){
|
|
|
+// body = body+"0";
|
|
|
+// }
|
|
|
+ byte[] encrypt = DES.encrypt(body.getBytes(), key.getBytes());
|
|
|
+ body = getBody(new String(encrypt), 123255, 2);
|
|
|
+ body = new String(Base64.getDecoder().decode(body),"UTF-8");
|
|
|
+ if(StringUtils.isEmpty(body)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<MecCourse> getCourses(String body) throws Exception{
|
|
|
+ body = getBody(body,123031,null);
|
|
|
+ if(StringUtils.isEmpty(body)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ body = "<body><courses>" + new String(Base64.getDecoder().decode(body)) + "</courses></body>";
|
|
|
+ ParseMecCourse parseMecCourse = XStreamUtil.xmlToObject("body", ParseMecCourse.class, body);
|
|
|
+ return parseMecCourse.getCourses();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getBody(String body,Integer cmd,Integer uid) throws Exception{
|
|
|
+ body = Base64.getEncoder().encodeToString(body.getBytes());
|
|
|
+ RequestParamBean requestParamBean = new RequestParamBean();
|
|
|
+ requestParamBean.setBody(body);
|
|
|
+ requestParamBean.setHead(XStreamUtil.getOrdersHead(body,cmd,publicKey,uid));
|
|
|
+ Writer writer = new StringWriter();
|
|
|
+ writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
|
|
+ XStream xs = new XStream();
|
|
|
+ xs.autodetectAnnotations(true);
|
|
|
+ xs.toXML(requestParamBean,writer);
|
|
|
+ body = HttpUtil.postXmlData(writer.toString(), url);
|
|
|
+ return body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
+ }
|
|
|
+
|
|
|
private ResponseUserInfo parseRegisterInfo(String body){
|
|
|
body = "<body>" + new String(Base64.getDecoder().decode(body)) + "</body>";
|
|
|
ResponseUserInfo userInfo = XStreamUtil.xmlToObject("body", ResponseUserInfo.class, body);
|