anderx 7 anni fa
parent
commit
65ce1c6245

+ 22 - 17
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -280,25 +280,30 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	public void saveVoucher(User us) {
 		if (StringUtils.isNotBlank(us.getBeInviteCode())) {
 			List<String> ids=voucherService.getSourceVoucher(VoucherSourceType.BYQGR.getCode());
-			for (String s : ids) {
-				JtVoucherDetail j=new JtVoucherDetail();
-				j.setId(jDBCIdGenerator.generateId().toString());
-				j.setReceiveTime(new Date());
-				j.setVoucherId(s);
-				j.setUseUid(us.getId());
-				j.setStatus(0);
-				voucherDetailService.saveVoucherDetail(j);
+			if (ids !=null && ids.size()>0) {
+				for (String s : ids) {
+					JtVoucherDetail j=new JtVoucherDetail();
+					j.setId(jDBCIdGenerator.generateId().toString());
+					j.setReceiveTime(new Date());
+					j.setVoucherId(s);
+					j.setUseUid(us.getId());
+					j.setStatus(0);
+					voucherDetailService.saveVoucherDetail(j);
+				}
 			}
 			User toUser=userMapper.getToInviteCode(us.getBeInviteCode());
-			List<String> ids2=voucherService.getSourceVoucher(VoucherSourceType.YQGR.getCode());
-			for (String string : ids2) {
-				JtVoucherDetail j=new JtVoucherDetail();
-				j.setId(jDBCIdGenerator.generateId().toString());
-				j.setReceiveTime(new Date());
-				j.setVoucherId(string);
-				j.setUseUid(toUser.getId());
-				j.setStatus(0);
-				voucherDetailService.saveVoucherDetail(j);
+			if (toUser !=null) {
+				List<String> ids2=voucherService.getSourceVoucher(VoucherSourceType.YQGR.getCode());
+				for (String string : ids2) {
+					JtVoucherDetail j=new JtVoucherDetail();
+					j.setId(jDBCIdGenerator.generateId().toString());
+					j.setReceiveTime(new Date());
+					j.setVoucherId(string);
+					j.setUseUid(toUser.getId());
+					j.setStatus(0);
+					voucherDetailService.saveVoucherDetail(j);
+			}
+			
 			}
 		}
 	}