|
@@ -1,57 +1,26 @@
|
|
|
package com.ym.mec.collectfee.service.impl;
|
|
|
|
|
|
-import java.io.StringWriter;
|
|
|
-import java.io.Writer;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Base64;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-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 org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
import com.thoughtworks.xstream.XStream;
|
|
|
import com.ym.mec.collectfee.common.dao.BaseDAO;
|
|
|
import com.ym.mec.collectfee.common.page.PageInfo;
|
|
|
import com.ym.mec.collectfee.common.service.impl.BaseServiceImpl;
|
|
|
-import com.ym.mec.collectfee.dao.ApplyInfoDao;
|
|
|
-import com.ym.mec.collectfee.dao.BranchDao;
|
|
|
-import com.ym.mec.collectfee.dao.CourseGroupInfoDao;
|
|
|
-import com.ym.mec.collectfee.dao.MecUserDao;
|
|
|
-import com.ym.mec.collectfee.dao.OrderDao;
|
|
|
-import com.ym.mec.collectfee.dao.SeminaryDao;
|
|
|
-import com.ym.mec.collectfee.entity.ApplyInfo;
|
|
|
-import com.ym.mec.collectfee.entity.ApplyInfoPage;
|
|
|
-import com.ym.mec.collectfee.entity.Branch;
|
|
|
-import com.ym.mec.collectfee.entity.Course;
|
|
|
-import com.ym.mec.collectfee.entity.CourseGroupInfo;
|
|
|
-import com.ym.mec.collectfee.entity.MecCourse;
|
|
|
-import com.ym.mec.collectfee.entity.MecUser;
|
|
|
-import com.ym.mec.collectfee.entity.MecUserInfo;
|
|
|
-import com.ym.mec.collectfee.entity.Order;
|
|
|
-import com.ym.mec.collectfee.entity.ParseMecCourse;
|
|
|
-import com.ym.mec.collectfee.entity.RenewBean;
|
|
|
-import com.ym.mec.collectfee.entity.RequestMecApplyClass;
|
|
|
-import com.ym.mec.collectfee.entity.RequestParamBean;
|
|
|
-import com.ym.mec.collectfee.entity.ResponseBranchesBean;
|
|
|
-import com.ym.mec.collectfee.entity.ResponseSeminariesBean;
|
|
|
-import com.ym.mec.collectfee.entity.ResponseUserInfo;
|
|
|
-import com.ym.mec.collectfee.entity.Seminary;
|
|
|
-import com.ym.mec.collectfee.entity.StudentsQueryInfo;
|
|
|
-import com.ym.mec.collectfee.entity.Sundry;
|
|
|
+import com.ym.mec.collectfee.common.sms.SmsExample;
|
|
|
+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.CDesECB;
|
|
|
-import com.ym.mec.collectfee.utils.HttpUtil;
|
|
|
-import com.ym.mec.collectfee.utils.MapUtil;
|
|
|
-import com.ym.mec.collectfee.utils.XStreamUtil;
|
|
|
-
|
|
|
+import com.ym.mec.collectfee.utils.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.RandomStringUtils;
|
|
|
+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 org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+import java.io.StringWriter;
|
|
|
+import java.io.Writer;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -78,9 +47,22 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
|
|
|
@Value("${common.properties.key}")
|
|
|
private String key;
|
|
|
-
|
|
|
- @Value("${common.properties.keyId}")
|
|
|
- private Integer keyId;
|
|
|
+ @Value("${common.properties.sms-appId}")
|
|
|
+ private String appId;
|
|
|
+ @Value("${common.properties.sms-secretKey}")
|
|
|
+ private String secretKey;
|
|
|
+ @Value("${common.properties.sms-host-dev}")
|
|
|
+ private String host;
|
|
|
+ @Value("${common.properties.sms-send-request-url}")
|
|
|
+ private String sendUrl;
|
|
|
+ // 加密算法
|
|
|
+ private String algorithm = "AES/ECB/PKCS5Padding";
|
|
|
+ // 编码
|
|
|
+ private String encode = "UTF-8";
|
|
|
+ // 是否压缩
|
|
|
+ private boolean isGizp = true;
|
|
|
+
|
|
|
+ private final String loginVerifyCodeKey = "loginVerifyCode:";
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ApplyInfo> getDAO() {
|
|
@@ -108,7 +90,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注册接口
|
|
|
-// log.info("推送到用户数据到mec注册 body: " + body);
|
|
|
+ log.info("推送到用户数据到mec注册 body: " + body);
|
|
|
body = getBody(body,121301);
|
|
|
Date date = new Date();
|
|
|
try {
|
|
@@ -121,7 +103,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
body = xs.toXML(applyClass);
|
|
|
body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
//推送mec用户缴费
|
|
|
-// log.info("推送到用户数据到mec缴费 body: " + body);
|
|
|
+ log.info("推送到用户数据到mec缴费 body: " + body);
|
|
|
getBody(body,125218);
|
|
|
applyInfoDao.update(applyInfo);
|
|
|
return true;
|
|
@@ -161,19 +143,15 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
courses.add(course);
|
|
|
applyClass.setCourses(courses);
|
|
|
//<amount>缴费总金额</amount>
|
|
|
-// applyClass.setAmount(order.getAmount());
|
|
|
- applyClass.setAmount(new BigDecimal(0));
|
|
|
+ applyClass.setAmount(order.getAmount());
|
|
|
//<tuiFee>学费金额</tuiFee>
|
|
|
-// applyClass.setTuiFee(order.getTuiFee());
|
|
|
- applyClass.setTuiFee(new BigDecimal(0));
|
|
|
+ applyClass.setTuiFee(order.getTuiFee());
|
|
|
//<goodsFee>乐器费用</goodsFee>
|
|
|
-// applyClass.setGoodsFee(order.getGoodsFee());
|
|
|
- applyClass.setGoodsFee(new BigDecimal(0));
|
|
|
+ applyClass.setGoodsFee(order.getGoodsFee());
|
|
|
//<sdName>杂费名称</sdName>
|
|
|
List<Sundry> sundries = new ArrayList<>();
|
|
|
Sundry sundry = new Sundry();
|
|
|
-// sundry.setSdFee(order.getSdFee());
|
|
|
- sundry.setSdFee(new BigDecimal(0));
|
|
|
+ sundry.setSdFee(order.getSdFee());
|
|
|
String sdName = order.getSdName();
|
|
|
if(StringUtils.isEmpty(sdName)){
|
|
|
sdName = order.getRemark();
|
|
@@ -233,7 +211,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
public Map<String, Object> getUserRegisterViewDetail(Integer stuId) {
|
|
|
Map<String, Object> vIewDetail = applyInfoDao.getUserRegisterVIewDetail(stuId);
|
|
|
String subName = vIewDetail.get("sub_name_").toString();
|
|
|
- if(subName.contains("圆号") || subName.contains("上低音") ||subName.contains("长号") ||subName.contains("大号") || subName.contains("次中音号")){
|
|
|
+ if(subName.contains("圆号") || subName.contains("上低音") ||subName.contains("长号") ||subName.contains("大号")){
|
|
|
vIewDetail.put("isCopperPipe",true);
|
|
|
}else {
|
|
|
vIewDetail.put("isCopperPipe",false);
|
|
@@ -301,7 +279,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
MecUser mecUser = mecUserDao.get(userId);
|
|
|
if(mecUser == null){
|
|
|
String body = "<body><userId>" + userId + "</userId></body>";
|
|
|
-// log.info("获取学员信息mec body: " + body);
|
|
|
+ log.info("获取学员信息mec body: " + body);
|
|
|
body = getBody(body, 121313);
|
|
|
if(!StringUtils.isEmpty(body)){
|
|
|
body = new String(Base64.getDecoder().decode(body));
|
|
@@ -324,18 +302,18 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
xs.autodetectAnnotations(true);
|
|
|
String body = xs.toXML(renewBean);
|
|
|
body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
-// log.info("推送续费数据到mec body: " + body);
|
|
|
+ log.info("推送续费数据到mec body: " + body);
|
|
|
body = CDesECB.encode(key,body);
|
|
|
RequestParamBean requestParamBean = new RequestParamBean();
|
|
|
requestParamBean.setBody(body);
|
|
|
- requestParamBean.setHead(XStreamUtil.getOrdersHead(body,123255,publicKey,keyId,4));
|
|
|
+ requestParamBean.setHead(XStreamUtil.getOrdersHead(body,123255,publicKey,2,4));
|
|
|
Writer writer = new StringWriter();
|
|
|
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
|
|
xs = new XStream();
|
|
|
xs.autodetectAnnotations(true);
|
|
|
xs.toXML(requestParamBean,writer);
|
|
|
body = HttpUtil.postXmlData(writer.toString(), url);
|
|
|
-// log.info("mec响应的续费数据 body: " + body);
|
|
|
+ log.info("mec响应的续费数据 body: " + body);
|
|
|
body = body.substring(body.indexOf("<errCode>") + 9, body.indexOf("</errCode>"));
|
|
|
// body = new String(CDesECB.decode(key,body.getBytes()));
|
|
|
// body = CDesECB.decodeValue(key,body);
|
|
@@ -362,7 +340,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
public boolean mecUserIsExist(String phone) {
|
|
|
try {
|
|
|
String body = "<body><uType>1</uType><uName>" + phone +"</uName></body>";
|
|
|
-// log.info("用户是否存在mec系统 body: " + body);
|
|
|
+ log.info("用户是否存在mec系统 body: " + body);
|
|
|
body = getBody(body, 120431);
|
|
|
body = new String(Base64.getDecoder().decode(body));
|
|
|
if(StringUtils.isEmpty(body)){
|
|
@@ -378,6 +356,26 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean sendValidCode(String mobile, HttpSession session) {
|
|
|
+ String code = RandomStringUtils.randomNumeric(6);
|
|
|
+ session.setMaxInactiveInterval(900);
|
|
|
+ session.setAttribute(loginVerifyCodeKey + mobile,code);
|
|
|
+ SmsExample.setSingleSms(appId,secretKey,host,algorithm,String.format(Constants.SEND_LOGIN_SME_MSG, code),null,null,mobile,isGizp,encode);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean verifySmsCode(String mobile,String smsCode,HttpSession session) {
|
|
|
+ Object attribute = session.getAttribute(loginVerifyCodeKey + mobile);
|
|
|
+ if(attribute != null){
|
|
|
+ if(StringUtils.isNotEmpty(attribute.toString()) && attribute.toString().equals(smsCode)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private List<MecCourse> getCourses(String body) throws Exception{
|
|
|
body = getBody(body,123031);
|
|
@@ -400,7 +398,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
|
|
|
xs.autodetectAnnotations(true);
|
|
|
xs.toXML(requestParamBean,writer);
|
|
|
body = HttpUtil.postXmlData(writer.toString(), url);
|
|
|
-// log.info("mec响应参数 body: " + body + " ,cmd: " + cmd);
|
|
|
+ log.info("mec响应参数 body: " + body + " ,cmd: " + cmd);
|
|
|
return body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
|
|
|
}
|
|
|
|