Commit 82536e02 authored by tangwei's avatar tangwei

解决冲突

parents 506afed7 30c76030
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.hygf.api.dto; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.hygf.api.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.Valid;
/** /**
* *
* @author Provence * @author Provence
...@@ -61,5 +63,5 @@ public class MobileLoginParamDto { ...@@ -61,5 +63,5 @@ public class MobileLoginParamDto {
private String verifyCode; private String verifyCode;
@ApiModelProperty("农户信息") @ApiModelProperty("农户信息")
private PeasantHouseholdDto peasantHouseholdDto; private @Valid PeasantHouseholdDto peasantHouseholdDto;
} }
...@@ -9,6 +9,9 @@ import lombok.Data; ...@@ -9,6 +9,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -39,13 +42,16 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -39,13 +42,16 @@ public class PeasantHouseholdDto extends BaseDto {
private String telephone; private String telephone;
@ApiModelProperty(value = "开发方名称") @ApiModelProperty(value = "开发方名称")
@NotBlank(message = "开发方名称不能为空")
private String developerName; private String developerName;
@ApiModelProperty(value = "开发方code") @ApiModelProperty(value = "开发方code")
@NotBlank(message = "开发方code不能为空")
private String developerCode; private String developerCode;
@ApiModelProperty(value = "开发方平台id") @ApiModelProperty(value = "开发方平台id")
@NotNull(message = "开发方平台id不能为空")
private Long developerId; private Long developerId;
@ApiModelProperty(value = "定金") @ApiModelProperty(value = "定金")
...@@ -90,7 +96,9 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -90,7 +96,9 @@ public class PeasantHouseholdDto extends BaseDto {
@ApiModelProperty(value = "常住详细地址") @ApiModelProperty(value = "常住详细地址")
private String permanentAddressDetail; private String permanentAddressDetail;
@ApiModelProperty(value = "开发人") @ApiModelProperty(value = "开发人")
@NotBlank(message = "开发人不能为空")
private String developer; private String developer;
@ApiModelProperty(value = "常住地址") @ApiModelProperty(value = "常住地址")
...@@ -108,20 +116,25 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -108,20 +116,25 @@ public class PeasantHouseholdDto extends BaseDto {
private List<String> permanentAddressText; private List<String> permanentAddressText;
@ApiModelProperty(value = "区域公司id") @ApiModelProperty(value = "区域公司id")
@NotNull(message = "区域公司id不能为空")
private Long regionalCompaniesSeq; private Long regionalCompaniesSeq;
@ApiModelProperty(value = "区域公司code") @ApiModelProperty(value = "区域公司code")
@NotBlank(message = "区域公司code不能为空")
private String regionalCompaniesCode; private String regionalCompaniesCode;
@ApiModelProperty(value = "区域公司名称") @ApiModelProperty(value = "区域公司名称")
@NotBlank(message = "区域公司名称不能为空")
private String regionalCompaniesName; private String regionalCompaniesName;
@ApiModelProperty(value = "身份证正面") @ApiModelProperty(value = "身份证正面")
@TableField(typeHandler = FastjsonTypeHandler.class) @TableField(typeHandler = FastjsonTypeHandler.class)
@NotEmpty(message = "身份证正面不能为空")
private List<Object> idCardFront; private List<Object> idCardFront;
@ApiModelProperty(value = "身份证反面") @ApiModelProperty(value = "身份证反面")
@TableField(typeHandler = FastjsonTypeHandler.class) @TableField(typeHandler = FastjsonTypeHandler.class)
@NotEmpty(message = "身份证反面不能为空")
private List<Object> idCardOpposite; private List<Object> idCardOpposite;
@ApiModelProperty(value = "微信唯一id") @ApiModelProperty(value = "微信唯一id")
......
...@@ -11,6 +11,8 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServi ...@@ -11,6 +11,8 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServi
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
...@@ -19,16 +21,17 @@ import io.swagger.annotations.Api; ...@@ -19,16 +21,17 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -41,6 +44,7 @@ import java.util.Collection; ...@@ -41,6 +44,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture;
/** /**
* 农户信息 * 农户信息
...@@ -75,6 +79,9 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -75,6 +79,9 @@ public class PeasantHouseholdWxController extends BaseController {
@Value("${hygfProgram.loginPage:view/mine/minepage/LoginPhone}") @Value("${hygfProgram.loginPage:view/mine/minepage/LoginPhone}")
private String miniprogramLoginPage; private String miniprogramLoginPage;
@Autowired
private AmosRequestContext requestContext;
private static final String regionRedis = "app_region_redis"; private static final String regionRedis = "app_region_redis";
/*@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false) /*@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
...@@ -105,11 +112,11 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -105,11 +112,11 @@ public class PeasantHouseholdWxController extends BaseController {
@RequestMapping (value = "/login", method = RequestMethod.POST) @RequestMapping (value = "/login", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信授权登陆", notes = "微信授权登陆") @ApiOperation (httpMethod = "POST", value = "微信授权登陆", notes = "微信授权登陆")
public ResponseModel<PeasantHouseholdWxDto> wxUserLogin(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) { public ResponseModel<PeasantHouseholdWxDto> wxUserLogin(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) {
log.info("微信授权登录入参 => {}", mobileLoginParam);
if (StringUtils.isBlank(mobileLoginParam.getAmosUserId())) { if (StringUtils.isBlank(mobileLoginParam.getAmosUserId())) {
// 扫码的userId为空, 则取默认值 // 扫码的userId为空, 则取默认值
mobileLoginParam.setAmosUserId(defaultUserId); mobileLoginParam.setAmosUserId(defaultUserId);
} }
//peasantHouseholdServiceImpl.setPlatFormAccess();
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.wxUserLogin(mobileLoginParam)); return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.wxUserLogin(mobileLoginParam));
} }
...@@ -117,12 +124,22 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -117,12 +124,22 @@ public class PeasantHouseholdWxController extends BaseController {
@RequestMapping (value = "/register", method = RequestMethod.POST) @RequestMapping (value = "/register", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信农户注册", notes = "微信农户注册") @ApiOperation (httpMethod = "POST", value = "微信农户注册", notes = "微信农户注册")
public ResponseModel<PeasantHouseholdDto> wxUserRegister(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) { public ResponseModel<PeasantHouseholdDto> wxUserRegister(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) {
// log.info("微信农户注册, 入参 => {}", JSONObject.toJSONString(mobileLoginParam)); log.info("微信农户注册, 入参 => {}", mobileLoginParam);
if (null == mobileLoginParam.getPeasantHouseholdDto()) {
throw new BadRequest("农户信息不能为空");
}
PeasantHouseholdDto model = mobileLoginParam.getPeasantHouseholdDto(); PeasantHouseholdDto model = mobileLoginParam.getPeasantHouseholdDto();
validatedPeasantHouseholdDto(model);
AgencyUserModel userInfo = getUserInfo(); AgencyUserModel userInfo = getUserInfo();
// 更新平台农户的真实姓名
CompletableFuture.supplyAsync(() -> {
// 机器人token
RequestContext.setAppKey("AMOS_STUDIO");
RequestContext.setProduct("AMOS_STUDIO_WEB");
RequestContext.setToken(requestContext.getToken());
userInfo.setRealName(model.getOwnersName());
Privilege.agencyUserClient.update(userInfo, userInfo.getUserId());
return null;
});
model.setAmosUserId(userInfo.getUserId());// 绑定平台userId model.setAmosUserId(userInfo.getUserId());// 绑定平台userId
model.setPeasantHouseholdNo(peasantHouseholdServiceImpl.getPeasantHouseholdNo()); model.setPeasantHouseholdNo(peasantHouseholdServiceImpl.getPeasantHouseholdNo());
model.setIsCertified(1);// 这里就实名认证 model.setIsCertified(1);// 这里就实名认证
...@@ -158,7 +175,8 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -158,7 +175,8 @@ public class PeasantHouseholdWxController extends BaseController {
} }
} }
} }
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.savePeasantHousehold(model)); PeasantHouseholdDto result = peasantHouseholdServiceImpl.savePeasantHousehold(model);
return ResponseHelper.buildResponse(result);
} }
public JSONArray getRegionName() { public JSONArray getRegionName() {
...@@ -219,17 +237,34 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -219,17 +237,34 @@ public class PeasantHouseholdWxController extends BaseController {
} }
@GetMapping("/getPersonalQrCode") private void validatedPeasantHouseholdDto(PeasantHouseholdDto model) {
@ApiOperation (httpMethod = "GET", value = " 获取个人经销商二维码", notes = " 获取个人经销商二维码") if (null == model) {
public void getPersonalQrCode( throw new BadRequest("农户信息不能为空");
@RequestParam (value = "fileType", required = false, defaultValue = "png") String fileType, }
@RequestParam (value = "width", required = false, defaultValue = "350") String width, if (StringUtils.isBlank(model.getOwnersName())) {
HttpServletResponse response) { throw new BadRequest("姓名不能为空");
AgencyUserModel userInfo = getUserInfo(); }
String accessToken = wxService.getAccessToken(); if (StringUtils.isBlank(model.getDeveloper())) {
String page = "view/mine/minepage/Login" + "?amosUserId=" + userInfo.getUserId() + "&qrCodeType=personal"; throw new BadRequest("开发人不能为空");
wxService.getSmallProQrCodeResponse(accessToken, null, page, Long.valueOf(width), null, null, null, response, }
page, fileType); if (StringUtils.isBlank(model.getDeveloperCode())) {
throw new BadRequest("开发方code不能为空");
}
if (StringUtils.isBlank(model.getDeveloperName())) {
throw new BadRequest("开发方名称不能为空");
}
if (null == model.getDeveloperId()) {
throw new BadRequest("开发方平台id不能为空");
}
if (null == model.getRegionalCompaniesSeq()) {
throw new BadRequest("区域公司id不能为空");
}
if (StringUtils.isBlank(model.getRegionalCompaniesCode())) {
throw new BadRequest("区域公司code不能为空");
}
if (StringUtils.isBlank(model.getRegionalCompaniesName())) {
throw new BadRequest("区域公司名称不能为空");
}
} }
} }
...@@ -249,12 +249,13 @@ public class WxServiceImpl implements IWxService { ...@@ -249,12 +249,13 @@ public class WxServiceImpl implements IWxService {
@Override @Override
public JSONObject getCode2Session(String code) { public JSONObject getCode2Session(String code) {
String url = buildOpenIdUrl(appId, secret, code); String url = buildOpenIdUrl(appId, secret, code);
log.info("微信 code2Session, code =>{}, 请求 => {}", code, url);
String resultStr = HttpUtil.sendHttpGet(url); String resultStr = HttpUtil.sendHttpGet(url);
// resultStr => {"session_key":"Mj5xbDhcZU73DtUduI1xKg==","openid":"oRraY5aYJkxkDJiG4rBaaw4MSmPA"} // resultStr => {"session_key":"Mj5xbDhcZU73DtUduI1xKg==","openid":"oRraY5aYJkxkDJiG4rBaaw4MSmPA"}
log.info("微信 Code2Session, code =>{}, 结果 => {}", code, resultStr); log.info("微信 code2Session, code =>{}, 结果 => {}", code, resultStr);
JSONObject jsonObject = JSONObject.parseObject(resultStr); JSONObject jsonObject = JSONObject.parseObject(resultStr);
if (jsonObject == null || jsonObject.getIntValue("errcode") != 0) { if (jsonObject == null || jsonObject.getIntValue("errcode") != 0) {
throw new BadRequest("微信授权失败, 请重新授权"); throw new RuntimeException("微信授权失败, 请重新授权");
} }
return jsonObject; return jsonObject;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment