Browse Source

优化积余订餐推送的代码

longmeizhen@avic-s.com 2 năm trước cách đây
mục cha
commit
927b642e52

+ 10 - 0
src/main/java/com/palmnest/model/estateserve/AppUser.java

@@ -94,6 +94,16 @@ public class AppUser implements java.io.Serializable {
 	private String bindOpenid;
 	private String bindDevelopid;
 
+	private String isPushState;
+
+	public String getIsPushState() {
+		return isPushState;
+	}
+
+	public void setIsPushState(String isPushState) {
+		this.isPushState = isPushState;
+	}
+
 	@Column(name = "bind_openid")
 	public String getBindOpenid() {
 		return bindOpenid;

+ 29 - 26
src/main/java/com/palmnest/service/dinner/service/impl/ConsumerUserServiceImpl.java

@@ -165,6 +165,7 @@ public class ConsumerUserServiceImpl implements ConsumerUserService {
 			user.setUserType("0");
 			user.setStatus("1");//后台添加默认已审核
 			user.setVirPermId(appUserInputDto.getVirPermId());
+			user.setIsPushState(appUserInputDto.getPushState());
 		} else {
 			// 修改操作
 			user = appUserManager.get(Integer.parseInt(appUserInputDto.getId()));
@@ -212,6 +213,7 @@ public class ConsumerUserServiceImpl implements ConsumerUserService {
 					user.setIsBinding(0);
 				}
 				user.setUserMobile(appUserInputDto.getMobilePhone());
+				user.setIsPushState(appUserInputDto.getPushState());
 			}
 		}
 
@@ -285,7 +287,7 @@ public class ConsumerUserServiceImpl implements ConsumerUserService {
 			if (appUserInputDto != null && StringUtils.isBlank(appUserInputDto.getId())) {
 				// 新增操作
 				Integer usId = appUserManager.saveOrUpdateAppUser(user);
-				setPushState(usId,appUserInputDto.getPushState());
+//				setPushState(usId,appUserInputDto.getPushState());
 				//需要记录该积分流转(充值记录)
 				if (appUserInputDto.getIntegral() != null && appUserInputDto.getIntegral() >= 0) {
 					if (appUserManager.exists(usId)) {
@@ -321,7 +323,7 @@ public class ConsumerUserServiceImpl implements ConsumerUserService {
 					try {
 						Integer usId = appUserManager.saveOrUpdateAppUser(user);
 
-						setPushState(usId,appUserInputDto.getPushState());
+//						setPushState(usId,appUserInputDto.getPushState());
 						//C端认证后 修改企业 修改绑定的企业账号
 						if (null != user.getWxUserId()) {
 							if (scWxuserManager.exists(user.getWxUserId())) {
@@ -355,24 +357,24 @@ public class ConsumerUserServiceImpl implements ConsumerUserService {
 		return "fail";
 	}
 
-	private void setPushState(Integer userId,String pushState){
-		if(null == userId){
-			return;
-		}
-		if(StringUtils.isEmpty(pushState)){
-			pushState = "1";
-		}
-		OrderDinnerSet set = orderDinnerSetManager.findByUserId(userId);
-		if(null == set){
-			set = new OrderDinnerSet();
-			set.setUserId(userId);
-			set.setStatus(pushState);
-			orderDinnerSetManager.saveModel(set);
-		}else{
-			set.setStatus(pushState);
-			orderDinnerSetManager.updateModel(set);
-		}
-	}
+//	private void setPushState(Integer userId,String pushState){
+//		if(null == userId){
+//			return;
+//		}
+//		if(StringUtils.isEmpty(pushState)){
+//			pushState = "1";
+//		}
+//		OrderDinnerSet set = orderDinnerSetManager.findByUserId(userId);
+//		if(null == set){
+//			set = new OrderDinnerSet();
+//			set.setUserId(userId);
+//			set.setStatus(pushState);
+//			orderDinnerSetManager.saveModel(set);
+//		}else{
+//			set.setStatus(pushState);
+//			orderDinnerSetManager.updateModel(set);
+//		}
+//	}
 
 	@Override
 	public String setFaceImage(AppUser user, String addimgUrls, String imageUrlids, String removeUrlids) {
@@ -904,12 +906,13 @@ public class ConsumerUserServiceImpl implements ConsumerUserService {
 					dto.setPermName(config.getName());
 					dto.setPermId(config.getId());
 				}
-				OrderDinnerSet set = orderDinnerSetManager.findByUserId(id);
-				if(null != set && "0".equals(set.getStatus())){
-					dto.setPushState("0");
-				}else{
-					dto.setPushState("1");
-				}
+//				OrderDinnerSet set = orderDinnerSetManager.findByUserId(id);
+//				if(null != set && "0".equals(set.getStatus())){
+//					dto.setPushState("0");
+//				}else{
+//					dto.setPushState("1");
+//				}
+				dto.setPushState(cons.getIsPushState());
 				return AppResultUtil.createSuccesDto(dto);
 			}
 		}

+ 10 - 14
src/main/java/com/palmnest/service/dinner/service/impl/PlaceAnOrderServiceImpl.java

@@ -1009,12 +1009,13 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 
 	@Override
 	public AppResultDto getPushSetByUserId(Integer userId) {
-		OrderDinnerSet set = orderDinnerSetManager.findByUserId(userId);
-		if(null == set){
-			set = new OrderDinnerSet();
+		AppUser user = appUserManager.get(userId);
+		OrderDinnerSet set = new OrderDinnerSet();
+		set.setUserId(userId);
+		if(null == user || null == user.getIsPushState()){
 			set.setStatus("1");
-			set.setUserId(userId);
-			return AppResultUtil.createSuccesDto(set);
+		}else{
+			set.setStatus(user.getIsPushState());
 		}
 		return AppResultUtil.createSuccesDto(set);
 	}
@@ -1076,15 +1077,10 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 					orderDinnerSetManager.updateModel(set);
 				}
 			}else if(null != reSetDto.getUserId()){
-				OrderDinnerSet set = orderDinnerSetManager.findByUserId(reSetDto.getUserId());
-				if(null == set){
-					set = new OrderDinnerSet();
-					set.setUserId(reSetDto.getUserId());
-					set.setStatus(reSetDto.getStatus());
-					orderDinnerSetManager.save(set);
-				}else{
-					set.setStatus(reSetDto.getStatus());
-					orderDinnerSetManager.updateModel(set);
+				AppUser user = appUserManager.get(reSetDto.getUserId());
+				if(null != user){
+					user.setIsPushState(reSetDto.getStatus());
+					appUserManager.updateModel(user);
 				}
 			}
 			return AppResultUtil.createSuccesDto();