yonge 5 роки тому
батько
коміт
d73a6a9c2b

+ 34 - 41
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -2417,8 +2417,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			noCreateSuccessVipGroup.setStatus(VipGroupStatusEnum.CANCEL);
 			List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(noCreateSuccessVipGroup.getId().toString(),
 					OrderTypeEnum.SMALL_CLASS_TO_BUY, DealStatusEnum.SUCCESS);
-			//推送消息
-			stopVipPush(noCreateSuccessVipGroup.getId(),noCreateSuccessVipGroup.getName());
 
 			for (StudentPaymentOrder studentPaymentOrder:studentPaymentOrders){
 				//生成账户资金明细
@@ -2438,7 +2436,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(!CollectionUtils.isEmpty(userCashAccountDetails)){
 			sysUserCashAccountDetailDao.batchInsert(userCashAccountDetails);
 		}
-		vipGroupDao.batchUpdate(noCreateSuccessVipGroups);
+		if(noCreateSuccessVipGroups != null && noCreateSuccessVipGroups.size() > 0){
+			vipGroupDao.batchUpdate(noCreateSuccessVipGroups);
+			
+			for (VipGroup noCreateSuccessVipGroup : noCreateSuccessVipGroups) {
+				//推送消息
+				stopVipPush(noCreateSuccessVipGroup.getId(),noCreateSuccessVipGroup.getName());
+			}
+		}
 	}
 
 	@Override
@@ -2457,47 +2462,35 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if (!CollectionUtils.isEmpty(normalVipGroupList)){
             Date now = new Date();
             List<VipGroup> needUpdateVipGroups = new ArrayList<>();
-            for (VipGroup vipGroup : normalVipGroupList) {
-                try {
-                	if(Objects.isNull(vipGroup.getRegistrationStartTime())){
-                		continue;
+			for (VipGroup vipGroup : normalVipGroupList) {
+				try {
+					if (Objects.isNull(vipGroup.getRegistrationStartTime())) {
+						continue;
 					}
-                	if(vipGroup.getStatus().equals(VipGroupStatusEnum.PAUSE)){
-                		continue;
+					if (vipGroup.getStatus().equals(VipGroupStatusEnum.PAUSE) || vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)
+							|| vipGroup.getStatus().equals(VipGroupStatusEnum.FINISHED)) {
+						continue;
 					}
-                	if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){
-                		continue;
+					if (now.before(vipGroup.getRegistrationStartTime())) {
+						vipGroup.setStatus(VipGroupStatusEnum.NOT_START);
+					} else if (vipGroup.getRegistrationStartTime().before(now) && vipGroup.getPaymentExpireDate().after(now)) {
+						vipGroup.setStatus(VipGroupStatusEnum.APPLYING);
 					}
-                    if(now.before(vipGroup.getRegistrationStartTime())){
-                        if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
-							vipGroup.setStatus(VipGroupStatusEnum.NOT_START);
-						}
-                    }
-                    if(vipGroup.getRegistrationStartTime().before(now)&&vipGroup.getPaymentExpireDate().after(now)){
-                        if(vipGroup.getStatus().equals(VipGroupStatusEnum.NOT_START)){
-							vipGroup.setStatus(VipGroupStatusEnum.APPLYING);
-						}
-                    }
-                    if(vipGroup.getPaymentExpireDate().before(now)&&vipGroup.getCourseStartDate().after(now)){
-						if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)) {
-							vipGroup.setStatus(VipGroupStatusEnum.APPLYING_END);
-						}
-                    }
-                    if(vipGroup.getCourseStartDate().before(now)&&vipGroup.getCoursesExpireDate().after(now)){
-						if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING_END)){
-							vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
-						}
-                    }
-                    VipGroup vipGroup1 = new VipGroup();
-                    vipGroup1.setId(vipGroup.getId());
-                    vipGroup1.setStatus(vipGroup.getStatus());
-                    vipGroup1.setUpdateTime(now);
-                    vipGroup1.setTotalPrice(vipGroup.getTotalPrice());
-                    needUpdateVipGroups.add(vipGroup1);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
+					if (vipGroup.getPaymentExpireDate().before(now) && vipGroup.getCourseStartDate().after(now)) {
+						vipGroup.setStatus(VipGroupStatusEnum.APPLYING_END);
+					} else if (vipGroup.getCourseStartDate().before(now) && vipGroup.getCoursesExpireDate().after(now)) {
+						vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
+					}
+					VipGroup vipGroup1 = new VipGroup();
+					vipGroup1.setId(vipGroup.getId());
+					vipGroup1.setStatus(vipGroup.getStatus());
+					vipGroup1.setUpdateTime(now);
+					vipGroup1.setTotalPrice(vipGroup.getTotalPrice());
+					needUpdateVipGroups.add(vipGroup1);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
             vipGroupDao.batchUpdate(needUpdateVipGroups);
         }
 	}

+ 6 - 6
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPluginContext.java

@@ -21,13 +21,13 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 
 	public enum MessageSender {
 
-		JIGUANG("PUSH"), MOXINGTONG("SMS"), SHIYUAN("SMS"),YIMEI("SMS");
-		
+		JIGUANG("PUSH"), MOXINGTONG("SMS"), SHIYUAN("SMS"), YIMEI("SMS");
+
 		/**
 		 * 发送模式(SMS,PUSH,EMAIL)
 		 */
 		private String sendMode;
-		
+
 		private MessageSender(String sendMode) {
 			this.sendMode = sendMode;
 		}
@@ -70,7 +70,7 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 
 		messageSenderPlugin = getMessageSenderPlugin(messageSender);
 
-		return messageSenderPlugin.send(subject, content, receiver, url,jpushType);
+		return messageSenderPlugin.send(subject, content, receiver, url, jpushType);
 	}
 
 	/**
@@ -87,7 +87,7 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 
 		messageSenderPlugin = getMessageSenderPlugin(messageSender);
 
-		return messageSenderPlugin.batchSend(subject, content, receivers, url,jpushType);
+		return messageSenderPlugin.batchSend(subject, content, receivers, url, jpushType);
 	}
 
 	@Override
@@ -99,7 +99,7 @@ public class MessageSenderPluginContext implements ApplicationContextAware {
 		String beanId = mapper.get(StringUtils.lowerCase(messageSender.name()));
 
 		if (StringUtils.isBlank(beanId)) {
-			throw new ThirdpartyException("消息提供方不存在");
+			throw new ThirdpartyException("消息提供方:{}不存在", beanId);
 		}
 
 		return applicationContext.getBean(beanId, MessageSenderPlugin.class);

+ 5 - 11
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/provider/JiguangPushPlugin.java

@@ -5,12 +5,16 @@ import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.thirdparty.message.MessageSenderPlugin;
 import com.ym.mec.util.http.HttpUtil;
+
 import org.apache.commons.codec.binary.Base64;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.stream.Collectors;
 
 /**
  * 极光推送
@@ -188,7 +192,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 		JSONObject json = JSONObject.parseObject(result);
 		if (json.containsKey("error")) {
 			JSONObject jsonObject = json.getJSONObject("error");
-			throw new ThirdpartyException(jsonObject.get("message").toString());
+			throw new ThirdpartyException(jsonObject.get("message").toString()+"["+Arrays.stream(receivers).collect(Collectors.joining(","))+"]");
 		}
 		return true;
 	}
@@ -229,14 +233,4 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
 		this.reqURL = reqURL;
 	}
 
-	/*public static void main(String[] args) throws IOException {
-		
-		String str = "2094588";
-		
-		
-		JiguangPushPlugin plugin = new JiguangPushPlugin();
-		
-		plugin.batchSend("基础技能训练报名通知", "家长您好:经五路小学比赛团乐团基础技能训练已经开始缴费。请您在收到本通知后,点击http://mstuonline.dayaedu.com/#/smallRegister?musicGroupId=19121912014300001 进行缴费,若有疑问请咨询800-8208820", str.split(","), "5?http://mstudev.dayaedu.com/#/smallRegister?musicGroupId=19121912014300001");
-	}*/
-
 }

+ 21 - 0
mec-web/src/main/resources/logback-spring.xml

@@ -27,8 +27,29 @@
 		</encoder>
 	</appender>
 
+	<appender name="messagefile"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<FileNamePattern>/mdata/logs/message-%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
+			<MaxHistory>90</MaxHistory>
+			<TimeBasedFileNamingAndTriggeringPolicy
+				class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+				<MaxFileSize>20MB</MaxFileSize>
+			</TimeBasedFileNamingAndTriggeringPolicy>
+		</rollingPolicy>
+
+		<encoder>
+			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
+		</encoder>
+	</appender>
+
 	<logger name="com.ym.mec" level="INFO" />
 
+	<logger name="com.ym.mec.thirdparty" level="INFO"
+		additivity="false">
+		<appender-ref ref="messagefile" />
+	</logger>
+
 	<!--开发环境:打印控制台 -->
 	<springProfile name="dev">
 		<root level="INFO">