Quellcode durchsuchen

Merge branch 'master' of http://git.dayaedu.com/yonge/collect_fee

孙镇亮 vor 6 Jahren
Ursprung
Commit
5e48896ce6

+ 3 - 0
src/main/java/com/ym/mec/collectfee/CollectFeeServerApplication.java

@@ -9,6 +9,8 @@ import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
+import java.util.TimeZone;
+
 @SpringBootApplication
 @MapperScan("com.ym.mec.collectfee.dao")
 @ComponentScan(basePackages="com.ym.mec.collectfee")
@@ -20,6 +22,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 public class CollectFeeServerApplication {
 
 	public static void main(String[] args) {
+		TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
 		SpringApplication.run(CollectFeeServerApplication.class, args);
 	}
 	

+ 13 - 5
src/main/java/com/ym/mec/collectfee/controller/YqPayController.java

@@ -122,7 +122,7 @@ public class YqPayController extends BaseController {
 
         School school = schoolService.get(order.getClassId());
         String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
-        String returnUrl = "http://pay.dayaedu.com/login?schoolId=" + school.getId() + "&classId=" + order.getClassId() + "&cityId=" + school.getCityId();//支付后返回页面
+        String returnUrl = "http://pay.dayaedu.com/#/login?schoolId=" + school.getId() + "&classId=" + order.getClassId() + "&cityId=" + school.getCityId();//支付后返回页面
         String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付跳转页
         String payChannels = "{\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"fastpayXy\":true,\"aliPayMobile\":false,\"balancePay\":false}";//支付方式配置
 
@@ -220,9 +220,12 @@ public class YqPayController extends BaseController {
 
         //classType 小课1 大课2
         Integer buyCount = mecCourse4json.getBuyCount();
+        if (buyCount <= 0) {
+            return failed("购买次数不能小于1");
+        }
         BigDecimal amount = new BigDecimal("0"); //课程总价
         String remark = "";
-        List<MecCourse> pickCourses = null;
+        List<MecCourse> pickCourses = new ArrayList<>();
         for (int i = 0; i < courses.size(); i++) {
             MecCourse course = courses.get(i);
             if (mecCourse4json.getCourseId().equals(course.getCourseId().intValue())) {
@@ -240,8 +243,11 @@ public class YqPayController extends BaseController {
         }
 
         School school = schoolService.get(pickCourses.get(0).getClassId());
+        if (school == null) {
+            return failed("报名学校不存在");
+        }
         String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
-        String returnUrl = "http://pay.dayaedu.com/login?schoolId=" + school.getId() + "&classId=" + pickCourses.get(0).getClassId() + "&cityId=" + school.getCityId();//支付后返回页面
+        String returnUrl = "http://pay.dayaedu.com/#/login?schoolId=" + school.getId() + "&classId=" + pickCourses.get(0).getClassId() + "&cityId=" + school.getCityId();//支付后返回页面
         String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付跳转页
         String payChannels = "{\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"fastpayXy\":true,\"aliPayMobile\":false,\"balancePay\":false}";//支付方式配置
 
@@ -270,13 +276,15 @@ public class YqPayController extends BaseController {
         List<Map> tempRoutingList = new ArrayList();
         tempRoutingList.add(routingList);
 
-        renewalsService.addRenewalsOrder(renewals, amount, orderNo, pickCourses, routingMerNo,account.getId(), remark);
+        renewalsService.addRenewalsOrder(renewals, amount, orderNo, pickCourses, routingMerNo, account.getId(), remark);
 
         /*订单信息*/
         String orderBody = "大雅乐盟培训课程";
         /*订单标题*/
         String orderSubject = "培训订单";
 
+        //测试用
+        amount = new BigDecimal("2");
         Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
         resultMap.put("sellerNo", "0021677"); //收款商户号
         resultMap.put("payChannels", payChannels); //支付方式
@@ -416,7 +424,7 @@ public class YqPayController extends BaseController {
      */
     @PostMapping("/notify")
     public Msg notify(@ModelAttribute Msg msg) throws Exception {
-//        log.info(msg.toString());
+//        log.info(msg.toString());K
         Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
         rqMap.put("code", msg.getCode());
         rqMap.put("msg", msg.getMsg());

+ 25 - 2
src/main/java/com/ym/mec/collectfee/entity/ApplyInfo.java

@@ -290,7 +290,30 @@ public class ApplyInfo {
 
 	@Override
 	public String toString() {
-		return ToStringBuilder.reflectionToString(this);
+		return "ApplyInfo{" +
+				"id=" + id +
+				", userId=" + userId +
+				", mobile='" + mobile + '\'' +
+				", name='" + name + '\'' +
+				", realName='" + realName + '\'' +
+				", classId=" + classId +
+				", branchId=" + branchId +
+				", sex=" + sex +
+				", birthday=" + birthday +
+				", city='" + city + '\'' +
+				", schoolId=" + schoolId +
+				", grade='" + grade + '\'' +
+				", gClass='" + gClass + '\'' +
+				", subId=" + subId +
+				", isAdjust=" + isAdjust +
+				", patriarchPhone='" + patriarchPhone + '\'' +
+				", patriarchName='" + patriarchName + '\'' +
+				", patriarchUnit='" + patriarchUnit + '\'' +
+				", status=" + status +
+				", pushStatus=" + pushStatus +
+				", updateTime=" + updateTime +
+				", createTime=" + createTime +
+				", courseId=" + courseId +
+				'}';
 	}
-
 }

+ 13 - 1
src/main/java/com/ym/mec/collectfee/service/impl/ApplyInfoServiceImpl.java

@@ -11,6 +11,7 @@ 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 lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -22,6 +23,7 @@ import java.io.Writer;
 import java.util.*;
 
 @Service
+@Slf4j
 public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> implements ApplyInfoService {
 	
 	@Autowired
@@ -63,6 +65,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 			if(applyInfo != null && applyInfo.getStatus() == 1 && applyInfo.getPushStatus() != 1){
 				//组装请求
 				applyInfo.setRealName(applyInfo.getName());
+				String gClass = applyInfo.getgClass();
 				applyInfo.setgClass(applyInfo.getGrade() + applyInfo.getgClass());
 				applyInfo.setMobile(applyInfo.getPatriarchPhone());
 				XStream xs = new XStream();
@@ -71,6 +74,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);
 				body = getBody(body,121301);
 				Date date = new Date();
 				try {
@@ -78,14 +82,17 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 					ResponseUserInfo userInfo = parseRegisterInfo(body);
 					applyInfo.setUserId(userInfo.getUserId());
 					applyInfo.setPushStatus(1);
+					applyInfo.setGClass(gClass);
 					RequestMecApplyClass applyClass = getApplyClass(applyInfo,orderId);
 					body = xs.toXML(applyClass);
 					body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
 					//推送mec用户缴费
+					log.info("推送到用户数据到mec缴费 body: " + body);
 					getBody(body,125218);
 					applyInfoDao.update(applyInfo);
 					return true;
 				}catch (Exception e){
+					e.printStackTrace();
 					applyInfo.setPushStatus(2);
 					applyInfoDao.update(applyInfo);
 				}
@@ -109,7 +116,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 			//<classId>课程班(乐团)编号</classId>
 			applyClass.setClassId(applyInfo.getClassId());
 			//<subName>学员专业名称</subName>
-			CourseGroupInfo groupInfo = courseGroupInfoDao.get(applyInfo.getSubId());
+			CourseGroupInfo groupInfo = courseGroupInfoDao.get(applyInfo.getCourseId());
 			applyClass.setSubName(groupInfo.getSubName());
 			//<remark>备注</remark>
 			applyClass.setRemark(order.getRemark());
@@ -256,6 +263,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);
 				body = getBody(body, 121313);
 				if(!StringUtils.isEmpty(body)){
 					body = new String(Base64.getDecoder().decode(body));
@@ -278,6 +286,7 @@ 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);
 			body = CDesECB.encode(key,body);
 			RequestParamBean requestParamBean = new RequestParamBean();
 			requestParamBean.setBody(body);
@@ -288,6 +297,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);
 			body = body.substring(body.indexOf("<errCode>") + 9, body.indexOf("</errCode>"));
 //			body = new String(CDesECB.decode(key,body.getBytes()));
 //			body = CDesECB.decodeValue(key,body);
@@ -314,6 +324,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);
 			body = getBody(body, 120431);
 			body = new String(Base64.getDecoder().decode(body));
 			if(StringUtils.isEmpty(body)){
@@ -351,6 +362,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);
 		return body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
 	}
 

+ 4 - 1
src/main/resources/application.yml

@@ -4,10 +4,13 @@ server:
     contextPath: /api
 
 spring:
+  jackson:
+    time-zone: Asia/Shanghai
+    date-format: yyyy-MM-dd HH:mm:ss
+
   application:
     name: collect_fee
 
-    
   datasource:
     name: test
     url: jdbc:mysql://47.99.212.176:3306/mec_pay?useUnicode=true&characterEncoding=UTF8&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai

+ 32 - 3
src/main/resources/config/mybatis/ApplyInfoMapper.xml

@@ -148,7 +148,7 @@
 	<sql id="studentsPage">
 		<where>
 			<if test="musicTeamId != null">
-				ai.class_id_ = #{musicTeamId}
+				AND ai.class_id_ = #{musicTeamId}
 			</if>
 			<if test="name != null and name != ''">
 				AND ai.name_ = #{name}
@@ -185,7 +185,22 @@
 	<select id="queryUserPage" resultMap="ApplyInfoPage" parameterType="map">
 		SELECT ao.*,cgi.sub_name_ sub_name_ FROM (SELECT ai.*,o.amount amount_ FROM apply_info ai
 		LEFT JOIN `order` o ON ai.id_ = o.user_id
-		<include refid="studentsPage"/>) ao LEFT JOIN course_group_info cgi ON ao.course_id_ = cgi.id_
+		<where>
+			o.tui_fee IS NOT NULL AND o.`status` = 2
+			<if test="musicTeamId != null">
+				AND ai.class_id_ = #{musicTeamId}
+			</if>
+			<if test="name != null and name != ''">
+				AND ai.name_ = #{name}
+			</if>
+			<if test="status != null">
+				AND ai.status_ = #{status}
+			</if>
+			<if test="subId != null">
+				AND ai.sub_id_ = #{subId}
+			</if>
+		</where>
+		) ao LEFT JOIN course_group_info cgi ON ao.course_id_ = cgi.id_
 		ORDER BY ao.update_time_ DESC
 		<include refid="global.limit"/>
 	</select>
@@ -194,7 +209,21 @@
 		SELECT count(DISTINCT ai.id_) FROM apply_info ai
 		LEFT JOIN course_group_info cgi ON ai.sub_id_ = cgi.sub_id_
 		LEFT JOIN `order` o ON ai.id_ = o.user_id
-		<include refid="studentsPage"/>
+		<where>
+			AND o.tui_fee IS NOT NULL AND o.`status` = 2
+			<if test="musicTeamId != null">
+				AND ai.class_id_ = #{musicTeamId}
+			</if>
+			<if test="name != null and name != ''">
+				AND ai.name_ = #{name}
+			</if>
+			<if test="status != null">
+				AND ai.status_ = #{status}
+			</if>
+			<if test="subId != null">
+				AND ai.sub_id_ = #{subId}
+			</if>
+		</where>
 	</select>
 
 	<select id="findByUserId" resultMap="ApplyInfo">