zoujiajian 3 rokov pred
rodič
commit
35e9e73968

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/coupon/impl/CouponFontServiceImpl.java

@@ -128,6 +128,9 @@ public class CouponFontServiceImpl implements CouponFontService {
 		Long goodsId = null;
 		//实物还是虚物
 		GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getSkuId, skuId).op(Operator.Equal).build());
+		if (goodsDonSkuView == null) {
+			return new Page<>();
+		}
 		BigDecimal skuMoney = goodsDonSkuView.getMoney();
 		if (goodsDonSkuView.getType() == 2) {
 			goodsId = goodsDonSkuView.getGoodsId();

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/market/task/BindTaskService.java

@@ -33,4 +33,9 @@ public interface BindTaskService {
 	void checkPhoneCode(String phone, String inputCode);
 
 	void checkEmailCode(String email, String inputCode);
+
+	/**
+	 * 更换登录手机号
+	 */
+	void changeBindAccount(UserBindInfoReq request);
 }

+ 65 - 0
netflix-service/src/main/java/com/cyksj/service/market/task/impl/BindTaskServiceImpl.java

@@ -390,4 +390,69 @@ public class BindTaskServiceImpl implements BindTaskService {
 			throw BusinessRuntimeException.getInstance("邮箱验证码错误,请重新输入");
 		}
 	}
+
+	@Override
+	public void changeBindAccount(UserBindInfoReq request) {
+		Long userId = request.getUserId();
+		User user = userMapper.selectById(userId);
+		if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
+		String account = request.getAccount();
+		String code = request.getCode();
+		Integer type = request.getType();
+		if (type == 1) {
+			//是否已注册
+			User changeUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
+					.eq(User::getLoginPhone, account).last("limit 1"));
+			if (changeUser != null) {
+				throw BusinessRuntimeException.getInstance("您更换的手机号已注册,无法更换");
+			}
+			//是否已绑定
+			UserBindDetail changeUserBindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
+					.eq(UserBindDetail::getPhone, account).last("limit 1"));
+			if (changeUserBindDetail != null) {
+				throw BusinessRuntimeException.getInstance("您更换的手机号已被绑定,无法更换");
+			}
+			//校验手机号
+			checkPhoneCode(account, code);
+			String loginPhone = user.getLoginPhone();
+			User phoneUser = user;
+			Long phoneUserId = phoneUser.getId();
+			//手机用户
+			if (StrUtil.isNotBlank(loginPhone)) {
+				UserBindDetail userBindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
+						.eq(UserBindDetail::getPhone, loginPhone).last("limit 1"));
+				if (userBindDetail != null) {
+					userBindDetail.setPhone(account);
+					userBindDetail.setPhoneUserId(phoneUserId);
+					userBindDetailMapper.updateById(userBindDetail);
+				}
+				user.setLoginPhone(account);
+				userMapper.updateById(user);
+				return;
+			}
+			//非手机用户
+			UserBindDetail userBindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
+					.and(qr -> qr.eq(UserBindDetail::getUserId, userId)
+							.or().eq(UserBindDetail::getEmailUserId, userId))
+					.last("limit 1"));
+			if (userBindDetail == null) {
+				throw BusinessRuntimeException.getInstance("你未有绑定其他账号");
+			}
+			if (StrUtil.isEmpty(userBindDetail.getPhone())) {
+				throw BusinessRuntimeException.getInstance("您未绑定手机号,无法更换");
+			}
+			String phone = userBindDetail.getPhone();
+			phoneUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
+					.eq(User::getLoginPhone, phone).last("limit 1"));
+			if (phoneUser == null) throw BusinessRuntimeException.getInstance("你绑定的手机号未注册");
+			phoneUserId = phoneUser.getId();
+			userBindDetail.setPhone(account);
+			userBindDetail.setPhoneUserId(phoneUserId);
+			userBindDetailMapper.updateById(userBindDetail);
+
+			phoneUser.setLoginPhone(account);
+			userMapper.updateById(phoneUser);
+			return;
+		}
+	}
 }

+ 6 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/statistics/StatisticsDataController.java

@@ -102,6 +102,9 @@ public class StatisticsDataController {
 	@GetMapping("/export")
 	@SaCheckPermission("statics:export")
 	public void exportStatisticsData(Integer type, Long startTime, Long endTime, HttpServletResponse response) {
+		if (startTime == null || endTime == null) {
+			throw BusinessRuntimeException.getInstance("请选择导出的时间");
+		}
 		List<ExcelSheetAndData> excelSheetDataList = statisticsDataService.exportStatisticsDataByType(type, startTime, endTime);
 		excelSheetDataList = excelSheetDataList.stream().sorted(Comparator.comparing(ExcelSheetAndData::getSort)).collect(Collectors.toList());
 		EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, excelSheetDataList, "订单统计数据", ExcelTypeEnum.XLSX, null);
@@ -112,6 +115,9 @@ public class StatisticsDataController {
 	 */
 	@GetMapping("/export/monthly/data")
 	public void exportMonthlyData(Long startTime, Long endTime, HttpServletResponse response) {
+		if (startTime == null || endTime == null) {
+			throw BusinessRuntimeException.getInstance("请选择导出的时间");
+		}
 		List<ExcelSheetAndData> excelSheetDataList = statisticsDataService.exportMonthlyData(startTime, endTime);
 		excelSheetDataList = excelSheetDataList.stream().sorted(Comparator.comparing(ExcelSheetAndData::getSort)).collect(Collectors.toList());
 		EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, excelSheetDataList, String.format("%s月业务数据", DateUtil.month(DateTime.of(startTime)) + 1), ExcelTypeEnum.XLSX, null);

+ 14 - 0
netflix-web/src/main/java/com/cyksj/web/controller/market/TaskFrontController.java

@@ -12,6 +12,7 @@ import com.cyksj.model.request.UserBindInfoReq;
 import com.cyksj.model.views.TaskFrontView;
 import com.cyksj.service.market.MarketFrontService;
 import com.cyksj.service.market.task.BindTaskService;
+import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.service.user.UserService;
 import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
@@ -45,6 +46,8 @@ public class TaskFrontController {
 
 	private final UserService userService;
 
+	private final UserBindRelationService userBindRelationService;
+
 	/**
 	 * 任务列表
 	 */
@@ -131,6 +134,17 @@ public class TaskFrontController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	/**
+	 * 更换登录账号
+	 */
+	@PutMapping("/change/bind/account")
+	public Result<String> changeBindAccount(@RequestBody @Validated UserBindInfoReq request) {
+		long userId = StpUserUtil.getLoginIdAsLong();
+		request.setUserId(userId);
+		bindTaskService.changeBindAccount(request);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
 	/**
 	 * 绑定微信信息回调
 	 */