Commit 7dc766a3 authored by 杨阳's avatar 杨阳

发货单

新增/编辑/详情接口 更新发货单状态接口
parent 7b82037b
......@@ -12,6 +12,12 @@ import lombok.Data;
@Data
public class MobileLoginParamDto {
@ApiModelProperty("用户userid")
private String userId;
@ApiModelProperty("二维码类型:region, personal")
private String qrCodeType;
/**
* 注册类型:1-微信授权快捷登录;2-手机验证登录
*/
......
......@@ -75,7 +75,7 @@ public interface IWxService {
* @param fileName
* @param fileType
*/
void getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color,
String getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline, HttpServletResponse response, String fileName, String fileType);
/**
......
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
......@@ -10,9 +11,12 @@ import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdWxDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.SurveyInformationDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.hygf.api.service.IWxService;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl;
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.ugp.api.entity.Project;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
......@@ -25,6 +29,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -43,6 +48,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -78,6 +84,11 @@ public class PeasantHouseholdWxController extends BaseController {
@Autowired
HouseholdContractServiceImpl householdContractServiceImpl;
@Autowired
private IWxService wxService;
@Value("${hygfProgram.loginPage:view/mine/minepage/LoginPhone}")
private String miniprogramLoginPage;
private static final String regionRedis = "app_region_redis";
......@@ -189,4 +200,43 @@ public class PeasantHouseholdWxController extends BaseController {
return jsonArray;
}
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping("/getRegionQrCode")
@ApiOperation (httpMethod = "GET", value = " 获取区域经销商二维码", notes = " 获取区域经销商二维码")
public ResponseModel<Map<String, Object>> getRegionQrCode(
@RequestParam (value = "fileType", required = false, defaultValue = "png") String fileType,
@RequestParam (value = "width", required = false, defaultValue = "350") String width,
HttpServletResponse response) {
AgencyUserModel userInfo = getUserInfo();
String accessToken = wxService.getAccessToken();
// 生成二维码
String page = miniprogramLoginPage;
String scene = "userId=" + userInfo.getUserId() + "&qrCodeType=region";
// 返回当前用户ID
String picStr = wxService.getSmallProQrCodeResponse(accessToken, scene, page, Long.valueOf(width), null, null, null, response,
"二维码_" + userInfo.getUserId(), fileType);
PeasantHouseholdDto peasantHouseholdDto = peasantHouseholdServiceImpl.buildDefaultPeasantHouseholdDto("region", userInfo);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("qrCodePic", picStr);
resultMap.put("peasantHousehold", peasantHouseholdDto);
return ResponseHelper.buildResponse(resultMap);
}
@GetMapping("/getPersonalQrCode")
@ApiOperation (httpMethod = "GET", value = " 获取个人经销商二维码", notes = " 获取个人经销商二维码")
public void getPersonalQrCode(
@RequestParam (value = "fileType", required = false, defaultValue = "png") String fileType,
@RequestParam (value = "width", required = false, defaultValue = "350") String width,
HttpServletResponse response) {
AgencyUserModel userInfo = getUserInfo();
String accessToken = wxService.getAccessToken();
String page = "view/mine/minepage/Login" + "?userId=" + userInfo.getUserId() + "&qrCodeType=personal";
wxService.getSmallProQrCodeResponse(accessToken, null, page, Long.valueOf(width), null, null, null, response,
page, fileType);
}
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.Enum.PhoneRegisterTypeEum;
......@@ -13,9 +14,12 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.HouseholdContract;
import com.yeejoin.amos.boot.module.hygf.api.entity.Information;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.entity.SurveyDetails;
import com.yeejoin.amos.boot.module.hygf.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PeasantHouseholdMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IPeasantHouseholdService;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.service.IUnitInfoService;
import com.yeejoin.amos.boot.module.hygf.api.service.IWxService;
import com.yeejoin.amos.boot.module.jxiop.api.util.HttpUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
......@@ -106,7 +110,7 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
private RedisUtils redisUtils;
@Autowired
private WxServiceImpl wxService;
private IWxService wxService;
@Autowired
SurveyInformationServiceImpl surveyInformationService;
......@@ -129,6 +133,9 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
@Autowired
HouseholdContractServiceImpl householdContractServiceImpl;
@Autowired
UnitInfoServiceImpl unitInfoServiceImpl;
@Transactional (rollbackFor = Exception.class)
public PeasantHouseholdDto savePeasantHousehold(PeasantHouseholdDto model) {
SurveyInformationDto surveyInformationDto = new SurveyInformationDto();
......@@ -244,8 +251,8 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
public PeasantHouseholdWxDto wxUserLogin(MobileLoginParamDto wxDTO) {
// 通过手机号和验证码调用平台接口进行验证
// String phoneNo = this.parsePhoneNo(wxDTO);
String phoneNo = "13022982292";
String phoneNo = this.parsePhoneNo(wxDTO);
//String phoneNo = "13022982292";
if (phoneNo == null) {
throw new BadRequest("获取手机号失败!");
}
......@@ -264,7 +271,7 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
// 没有注册过农户信息
if (null == peasantHousehold) {
PeasantHouseholdWxDto peasantHouseholdWxDto = new PeasantHouseholdWxDto();
PeasantHouseholdDto peasantHouseholdDto = buildDefaultPeasantHouseholdDto(phoneNo);
PeasantHouseholdDto peasantHouseholdDto = buildDefaultPeasantHouseholdDto(wxDTO.getUserId(), wxDTO.getQrCodeType(), phoneNo);
peasantHousehold = new PeasantHousehold();
BeanUtils.copyProperties(peasantHouseholdDto, peasantHousehold);
peasantHouseholdWxDto.setPeasantHousehold(peasantHousehold);
......@@ -385,20 +392,42 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
return peasantHouseholdWxDto;
}
private PeasantHouseholdDto buildDefaultPeasantHouseholdDto(String phoneNo) {
public PeasantHouseholdDto buildDefaultPeasantHouseholdDto(String qrCodeType, AgencyUserModel userInfo) {
Long sequenceNbr = userInfo.getCompanys().get(0).getSequenceNbr();
Integer companyOrgCode = userInfo.getCompanys().get(0).getCompanyOrgCode();
String companyName = userInfo.getCompanys().get(0).getCompanyName();
// unitInfoServiceImpl.createCompanyAndUser 创建经销商的时候绑定的平台用户
List<UnitInfo> unitInfos = unitInfoServiceImpl.list(new LambdaQueryWrapper<UnitInfo>().eq(UnitInfo::getAmosCompanySeq, sequenceNbr));
Long regionalCompaniesSeq = unitInfos.get(0).getRegionalCompaniesSeq();
String regionalCompaniesCode = unitInfos.get(0).getRegionalCompaniesCode();
String regionalCompaniesName = unitInfos.get(0).getRegionalCompaniesName();
PeasantHouseholdDto dto = new PeasantHouseholdDto();
dto.setPeasantHouseholdNo(this.getPeasantHouseholdNo());
dto.setIsCertified(0);// 未认证
dto.setSurveyOrNot(0);
dto.setReview(0);
// 先在后台创建一个角色和公司,微信农户新建的用户使用统一的
// 用户光伏-微信农户
dto.setDeveloperCode(orgCode);
dto.setDeveloperId(orgSequenceNbr);
dto.setDeveloperName(orgNamesWithoutRole);
dto.setDeveloper(phoneNo);
dto.setRegionalCompaniesSeq(orgSequenceNbr);
dto.setRegionalCompaniesCode(orgCode);
dto.setRegionalCompaniesName(orgNamesWithoutRole);
// 非扫码进入注册页面,默认
dto.setDeveloperCode(companyOrgCode.toString());// 开发方code
dto.setDeveloperId(sequenceNbr);// 开发方id
dto.setDeveloperName(companyName);// 开发方名称
dto.setDeveloper(userInfo.getRealName());// 开发人
dto.setRegionalCompaniesSeq(regionalCompaniesSeq);
dto.setRegionalCompaniesCode(regionalCompaniesCode);
dto.setRegionalCompaniesName(regionalCompaniesName);
return dto;
}
private PeasantHouseholdDto buildDefaultPeasantHouseholdDto(String userId, String qrCodeType, String phoneNo) {
// 获取区域
FeignClientResult<AgencyUserModel> userInfoResult = Privilege.agencyUserClient.queryByUserId(userId);// 获取用户
if (userInfoResult.getStatus() != 200) {
throw new BadRequest("userId错误");
}
AgencyUserModel userInfo = userInfoResult.getResult();
PeasantHouseholdDto dto = buildDefaultPeasantHouseholdDto(qrCodeType, userInfo);
dto.setTelephone(phoneNo);
return dto;
}
......@@ -457,6 +486,9 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
/*IdPasswordAuthModel authModel = new IdPasswordAuthModel();
authModel.setLoginId(platfromAccessLoginId);
authModel.setPassword(DesUtil.encode(,"qaz"));*/
/* IdPasswordAuthModel authModel = new IdPasswordAuthModel();
authModel.setLoginId(platfromAccessLoginId);
authModel.setPassword(platfromAccessPassword);*/
FeignClientResult<Map<String, String>> authResult = Privilege.authClient.idpassword(authModel);
......
......@@ -25,6 +25,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Base64;
/**
* 农户微信小程序
......@@ -94,7 +95,7 @@ public class WxServiceImpl implements IWxService {
try {
String resultStr = HttpUtils.doGet(buildUrl.toString());
AccessTokenDto accessToken = JSON.parseObject(resultStr, AccessTokenDto.class);
if (0 != accessToken.getErrcode()) {
if (accessToken.getErrcode() != null && 0 != accessToken.getErrcode()) {
throw new RuntimeException(accessToken.getErrmsg());
}
return accessToken;
......@@ -182,7 +183,7 @@ public class WxServiceImpl implements IWxService {
}
@Override
public void getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color, JSONObject line_color, Boolean is_hyaline, HttpServletResponse response, String fileName, String fileType) {
public String getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color, JSONObject line_color, Boolean is_hyaline, HttpServletResponse response, String fileName, String fileType) {
WechatQrCodeDTO smallProQrCodeVo = buildQrParam(SMALL_PRO_QRCODE_URL, access_token, scene, page, width,
auto_color, line_color, is_hyaline);
byte[] smallProQrCode = smallProQrCodeVo.getBuffer();
......@@ -191,15 +192,27 @@ public class WxServiceImpl implements IWxService {
response.addHeader("Access-Control-Allow-Headers", "Content-Disposition");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
OutputStream os;
String picStr = Base64.getEncoder().encodeToString(smallProQrCode);
return picStr;
/*OutputStream os = null;
try {
os = response.getOutputStream();
os.write(smallProQrCode);
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
} finally {
try {
if (os != null) os.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
if (os != null) os.close();
} catch (IOException e) {
e.printStackTrace();
}
}*/
}
@Override
......
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