提交代码

dev-discount
胡锐 3 years ago
parent cf36751ddc
commit b4e31c13cc
  1. 40
      hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java

@ -177,40 +177,30 @@ public class HighUserCardController {
@ResponseBody @ResponseBody
@ApiOperation(value = "根据手机号获取汇联通工会卡列表") @ApiOperation(value = "根据手机号获取汇联通工会卡列表")
public ResponseData getHuiLianTongCardByPhone(@RequestParam(name = "phone", required = true) String phone, public ResponseData getHuiLianTongCardByPhone(@RequestParam(name = "phone", required = true) String phone,
@RequestParam(name = "smsCode", required = true) String smsCode,
HttpServletRequest request) { HttpServletRequest request) {
try { try {
// 用户 // 用户
SessionObject sessionObject = userCenter.getSessionObject(request); SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
// 获取手机号验证码 // 验证码校验成功
String phoneSmsCode = (String) redisUtil.get(phone); // 根据手机号查询卡号
JSONObject jsonObject = HuiLianTongUnionCardConfig.queryCardByMobile(phone);
// 验证码校验 if(jsonObject.getString("respCode").equals("0000") && jsonObject.getString("respMessage").equals("ok")) {
if (StringUtils.isNotBlank(phoneSmsCode) && Objects.equals(phoneSmsCode,smsCode)) { JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"));
// 验证码校验成功 JSONArray cards = dataObject.getJSONArray("cards");
// 根据手机号查询卡号 for (Object cardObject : cards) {
JSONObject jsonObject = HuiLianTongUnionCardConfig.queryCardByMobile(phone); JSONObject card = (JSONObject)cardObject;
if(jsonObject.getString("respCode").equals("0000") && jsonObject.getString("respMessage").equals("ok")) { if (highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), card.getString("cardNo")) != null) {
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); card.put("bindStatus", true);
JSONArray cards = dataObject.getJSONArray("cards"); } else {
for (Object cardObject : cards) { card.put("bindStatus", false);
JSONObject card = (JSONObject)cardObject;
if (highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), card.getString("cardNo")) != null) {
card.put("bindStatus", true);
} else {
card.put("bindStatus", false);
}
} }
redisUtil.del(phone);
return ResponseMsgUtil.success(cards);
} else {
System.out.println(jsonObject);
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败");
} }
return ResponseMsgUtil.success(cards);
} }
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); System.out.println(jsonObject);
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败");
} catch (Exception e) { } catch (Exception e) {
log.error("HighUserCardController --> getHuiLianTongCardByPhone() error!", e); log.error("HighUserCardController --> getHuiLianTongCardByPhone() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

Loading…
Cancel
Save