Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
064979ed
Commit
064979ed
authored
Aug 22, 2023
by
tangwei
Browse files
Options
Browse Files
Download
Plain Diff
解决冲突
parents
55767e5a
fc395672
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
403 additions
and
41 deletions
+403
-41
AccessTokenDto.java
...yeejoin/amos/boot/module/hygf/api/dto/AccessTokenDto.java
+18
-0
PeasantHouseholdDto.java
...in/amos/boot/module/hygf/api/dto/PeasantHouseholdDto.java
+3
-0
PreparationMoneyLogDto.java
...amos/boot/module/hygf/api/dto/PreparationMoneyLogDto.java
+0
-1
WechatQrCodeDTO.java
...eejoin/amos/boot/module/hygf/api/dto/WechatQrCodeDTO.java
+30
-0
PreparationMoneyLog.java
...amos/boot/module/hygf/api/entity/PreparationMoneyLog.java
+2
-2
PreparationMoneyLogMapper.java
...oot/module/hygf/api/mapper/PreparationMoneyLogMapper.java
+0
-1
IPreparationMoneyLogService.java
.../module/hygf/api/service/IPreparationMoneyLogService.java
+0
-1
IWxService.java
...yeejoin/amos/boot/module/hygf/api/service/IWxService.java
+121
-0
PeasantHouseholdWxController.java
...ule/hygf/biz/controller/PeasantHouseholdWxController.java
+4
-35
PeasantHouseholdServiceImpl.java
...le/hygf/biz/service/impl/PeasantHouseholdServiceImpl.java
+48
-0
WxServiceImpl.java
...amos/boot/module/hygf/biz/service/impl/WxServiceImpl.java
+177
-1
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/AccessTokenDto.java
0 → 100644
View file @
064979ed
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
dto
;
import
lombok.Data
;
/**
* TODO(一句话描述该类的功能)
*
* @author Provence
* @version v1.0
* @date 2023/8/22 12:58
*/
@Data
public
class
AccessTokenDto
{
private
String
access_token
;
private
Integer
expires_in
;
private
Integer
errcode
;
private
String
errmsg
;
}
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/PeasantHouseholdDto.java
View file @
064979ed
...
@@ -73,6 +73,9 @@ public class PeasantHouseholdDto extends BaseDto {
...
@@ -73,6 +73,9 @@ public class PeasantHouseholdDto extends BaseDto {
@ApiModelProperty
(
value
=
"勘察状态描述"
)
@ApiModelProperty
(
value
=
"勘察状态描述"
)
private
String
surveyOrNotText
;
private
String
surveyOrNotText
;
@ApiModelProperty
(
value
=
"证件类型"
)
private
String
idType
;
@ApiModelProperty
(
value
=
"身份证号"
)
@ApiModelProperty
(
value
=
"身份证号"
)
private
String
idCard
;
private
String
idCard
;
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/PreparationMoneyLogDto.java
View file @
064979ed
...
@@ -17,7 +17,6 @@ import lombok.EqualsAndHashCode;
...
@@ -17,7 +17,6 @@ import lombok.EqualsAndHashCode;
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"PreparationMoneyLogDto"
,
description
=
"发货单追踪记录"
)
@ApiModel
(
value
=
"PreparationMoneyLogDto"
,
description
=
"发货单追踪记录"
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PreparationMoneyLogDto
extends
BaseDto
{
public
class
PreparationMoneyLogDto
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/WechatQrCodeDTO.java
0 → 100644
View file @
064979ed
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
dto
;
import
lombok.Data
;
/**
* TODO(一句话描述该类的功能)
*
* @author Provence
* @version v1.0
* @date 2023/8/22 13:05
*/
@Data
public
class
WechatQrCodeDTO
{
/**
* 数据类型 (MIME Type)
*/
private
String
contentType
;
/**
* byte数据 微信生成的二维码
*/
private
byte
[]
buffer
;
/**
* 错误码
*/
private
Integer
errCode
;
/**
* 错误信息
*/
private
String
errMsg
;
}
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/entity/PreparationMoneyLog.java
View file @
064979ed
...
@@ -2,7 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.api.entity;
...
@@ -2,7 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.api.entity;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.
dto.BaseDto
;
import
com.yeejoin.amos.boot.biz.common.
entity.BaseEntity
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
...
@@ -17,7 +17,7 @@ import lombok.experimental.Accessors;
...
@@ -17,7 +17,7 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
value
=
"hygf_preparation_money_log"
)
@TableName
(
value
=
"hygf_preparation_money_log"
)
public
class
PreparationMoneyLog
extends
Base
Dto
{
public
class
PreparationMoneyLog
extends
Base
Entity
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/mapper/PreparationMoneyLogMapper.java
View file @
064979ed
...
@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.hygf.api.mapper;
...
@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.hygf.api.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoneyLog
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoneyLog
;
/**
/**
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/service/IPreparationMoneyLogService.java
View file @
064979ed
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
service
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
service
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto
;
/**
/**
* 发货单接口类
* 发货单接口类
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/service/IWxService.java
0 → 100644
View file @
064979ed
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
api
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
javax.servlet.http.HttpServletResponse
;
/**
*
* @author Provence
* @version v1.0
* @date 2023/8/22 12:53
*/
public
interface
IWxService
{
/**
* 统一提供小程序Token
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
*
* @return
*/
String
getAccessToken
();
/**
* 统一产生第三方页面二维码
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
*
* @param access_token 接口调用凭证
* @param scene 传递的参数
* 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
String
getSmallProQrCode
(
String
access_token
,
String
scene
,
String
page
,
Long
width
,
Boolean
auto_color
,
JSONObject
line_color
,
Boolean
is_hyaline
);
/**
* 统一产生第三方页面二维码
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
*
* @param access_token 接口调用凭证
* @param scene 传递的参数
* 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
byte
[]
getSmallProQrCodeByte
(
String
access_token
,
String
scene
,
String
page
,
Long
width
,
Boolean
auto_color
,
JSONObject
line_color
,
Boolean
is_hyaline
);
/**
* 小程序二维码请求-文件流
*
* @param access_token
* @param scene
* @param page
* @param width
* @param auto_color
* @param line_color
* @param is_hyaline
* @param response
* @param fileName
* @param fileType
*/
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
);
/**
* code转session
*
* @param code
* @return
*/
JSONObject
getCode2Session
(
String
code
);
/**
* 获取sessionKey
*
* @param code
* @return
*/
String
getSessionKey
(
String
code
);
/**
* 获取openId
*
* @param code
* @return
*/
String
getOpenId
(
String
code
);
/**
* 获取电话号码
* @param session_key
* @param encryptedData
* @param iv
* @return
*/
String
getPhoneNumber
(
String
session_key
,
String
encryptedData
,
String
iv
);
/* *//**
* 微信消息通知推送
* @param
*//*
void sendWeChatUpcomingMessage(List<String> openIds, String template, List<String> message) ;*/
String
getName
();
}
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/PeasantHouseholdWxController.java
View file @
064979ed
...
@@ -121,10 +121,10 @@ public class PeasantHouseholdWxController extends BaseController {
...
@@ -121,10 +121,10 @@ public class PeasantHouseholdWxController extends BaseController {
if
(
null
==
mobileLoginParam
.
getPeasantHouseholdDto
())
{
if
(
null
==
mobileLoginParam
.
getPeasantHouseholdDto
())
{
throw
new
BadRequest
(
"农户信息不能为空"
);
throw
new
BadRequest
(
"农户信息不能为空"
);
}
}
AgencyUserModel
userInfo
=
getUserInfo
();
PeasantHouseholdDto
model
=
mobileLoginParam
.
getPeasantHouseholdDto
();
PeasantHouseholdDto
model
=
mobileLoginParam
.
getPeasantHouseholdDto
();
SurveyInformationDto
surveyInformationDto
=
new
SurveyInformationDto
();
AgencyUserModel
userInfo
=
getUserInfo
();
surveyInformationServiceImpl
.
createWithModel
(
surveyInformationDto
);
model
.
setUserId
(
userInfo
.
getUserId
());
// 绑定平台userId
JSONArray
regionName
=
getRegionName
();
JSONArray
regionName
=
getRegionName
();
List
<
RegionModel
>
list
=
JSONArray
.
parseArray
(
regionName
.
toJSONString
(),
RegionModel
.
class
);
List
<
RegionModel
>
list
=
JSONArray
.
parseArray
(
regionName
.
toJSONString
(),
RegionModel
.
class
);
// 处理项目地址
// 处理项目地址
...
@@ -155,38 +155,7 @@ public class PeasantHouseholdWxController extends BaseController {
...
@@ -155,38 +155,7 @@ public class PeasantHouseholdWxController extends BaseController {
}
}
}
}
}
}
return
ResponseHelper
.
buildResponse
(
peasantHouseholdServiceImpl
.
savePeasantHousehold
(
model
));
model
.
setSurveyInformationId
(
surveyInformationDto
.
getSequenceNbr
());
model
.
setSurveyOrNot
(
0
);
model
.
setReview
(
0
);
if
(
model
.
getCreationTime
()
==
null
)
{
model
.
setCreationTime
(
new
Date
());
}
model
.
setPeasantHouseholdNo
(
peasantHouseholdServiceImpl
.
getPeasantHouseholdNo
());
model
.
setIsCertified
(
model
.
getIsCertified
()
==
null
?
0
:
model
.
getIsCertified
());
// 未认证
model
.
setUserId
(
userInfo
.
getUserId
());
// 绑定平台userId
PeasantHouseholdDto
peasantHousehold
=
peasantHouseholdServiceImpl
.
createWithModel
(
model
);
//生成合同
HouseholdContract
householdContract
=
new
HouseholdContract
();
householdContract
.
setPartyA
(
peasantHousehold
.
getOwnersName
());
householdContract
.
setPeasantHouseholdNumber
(
peasantHousehold
.
getPeasantHouseholdNo
());
householdContract
.
setPeasantHouseholdCard
(
peasantHousehold
.
getIdCard
());
householdContract
.
setDealerId
(
peasantHousehold
.
getDeveloperId
());
householdContract
.
setDealerCode
(
peasantHousehold
.
getDeveloperCode
());
householdContract
.
setDealerName
(
peasantHousehold
.
getDeveloperName
());
householdContract
.
setPeasantHouseholdId
(
peasantHousehold
.
getSequenceNbr
());
householdContract
.
setRegionalCompaniesCode
(
peasantHousehold
.
getRegionalCompaniesCode
());
householdContract
.
setRegionalCompaniesName
(
peasantHousehold
.
getRegionalCompaniesName
());
householdContract
.
setRegionalCompaniesSeq
(
peasantHousehold
.
getRegionalCompaniesSeq
());
householdContract
.
setPeasantHouseholdPhone
(
peasantHousehold
.
getTelephone
());
householdContract
.
setProjectAddressDetail
(
peasantHousehold
.
getProjectAddressDetail
());
householdContract
.
setProjectAddressName
(
peasantHousehold
.
getProjectAddressName
());
householdContract
.
setPermanentAddressDetail
(
peasantHousehold
.
getPermanentAddressDetail
());
householdContract
.
setPermanentAddressName
(
peasantHousehold
.
getPermanentAddressName
());
householdContractServiceImpl
.
addHouseholdContract
(
householdContract
);
return
ResponseHelper
.
buildResponse
(
peasantHousehold
);
}
}
public
JSONArray
getRegionName
()
{
public
JSONArray
getRegionName
()
{
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/PeasantHouseholdServiceImpl.java
View file @
064979ed
...
@@ -6,8 +6,10 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
...
@@ -6,8 +6,10 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.boot.module.hygf.api.Enum.PhoneRegisterTypeEum
;
import
com.yeejoin.amos.boot.module.hygf.api.Enum.PhoneRegisterTypeEum
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.MobileLoginParamDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.MobileLoginParamDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdWxDto
;
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.Commercial
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.Commercial
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.ExtendedInformation
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.ExtendedInformation
;
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.Information
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold
;
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.SurveyDetails
;
...
@@ -23,12 +25,14 @@ import com.yeejoin.amos.feign.privilege.model.LoginInfoModel;
...
@@ -23,12 +25,14 @@ import com.yeejoin.amos.feign.privilege.model.LoginInfoModel;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
import
com.yeejoin.amos.feign.privilege.model.VerifyCodeAuthModel
;
import
com.yeejoin.amos.feign.privilege.model.VerifyCodeAuthModel
;
import
com.yeejoin.amos.feign.privilege.util.DesUtil
;
import
com.yeejoin.amos.feign.privilege.util.DesUtil
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
import
lombok.Data
;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
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.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
...
@@ -119,6 +123,50 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
...
@@ -119,6 +123,50 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
@Autowired
@Autowired
CommercialServiceImpl
commercialService
;
CommercialServiceImpl
commercialService
;
@Autowired
SurveyInformationServiceImpl
surveyInformationServiceImpl
;
@Autowired
HouseholdContractServiceImpl
householdContractServiceImpl
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
PeasantHouseholdDto
savePeasantHousehold
(
PeasantHouseholdDto
model
)
{
SurveyInformationDto
surveyInformationDto
=
new
SurveyInformationDto
();
surveyInformationServiceImpl
.
createWithModel
(
surveyInformationDto
);
model
.
setSurveyInformationId
(
surveyInformationDto
.
getSequenceNbr
());
model
.
setSurveyOrNot
(
0
);
model
.
setReview
(
0
);
if
(
model
.
getCreationTime
()
==
null
)
{
model
.
setCreationTime
(
new
Date
());
}
model
.
setPeasantHouseholdNo
(
this
.
getPeasantHouseholdNo
());
model
.
setIsCertified
(
model
.
getIsCertified
()
==
null
?
0
:
model
.
getIsCertified
());
// 未认证
PeasantHouseholdDto
peasantHousehold
=
this
.
createWithModel
(
model
);
//生成合同
HouseholdContract
householdContract
=
new
HouseholdContract
();
householdContract
.
setPartyA
(
peasantHousehold
.
getOwnersName
());
householdContract
.
setPeasantHouseholdNumber
(
peasantHousehold
.
getPeasantHouseholdNo
());
householdContract
.
setPeasantHouseholdCard
(
peasantHousehold
.
getIdCard
());
householdContract
.
setDealerId
(
peasantHousehold
.
getDeveloperId
());
householdContract
.
setDealerCode
(
peasantHousehold
.
getDeveloperCode
());
householdContract
.
setDealerName
(
peasantHousehold
.
getDeveloperName
());
householdContract
.
setPeasantHouseholdId
(
peasantHousehold
.
getSequenceNbr
());
householdContract
.
setRegionalCompaniesCode
(
peasantHousehold
.
getRegionalCompaniesCode
());
householdContract
.
setRegionalCompaniesName
(
peasantHousehold
.
getRegionalCompaniesName
());
householdContract
.
setRegionalCompaniesSeq
(
peasantHousehold
.
getRegionalCompaniesSeq
());
householdContract
.
setPeasantHouseholdPhone
(
peasantHousehold
.
getTelephone
());
householdContract
.
setProjectAddressDetail
(
peasantHousehold
.
getProjectAddressDetail
());
householdContract
.
setProjectAddressName
(
peasantHousehold
.
getProjectAddressName
());
householdContract
.
setPermanentAddressDetail
(
peasantHousehold
.
getPermanentAddressDetail
());
householdContract
.
setPermanentAddressName
(
peasantHousehold
.
getPermanentAddressName
());
householdContractServiceImpl
.
addHouseholdContract
(
householdContract
);
return
peasantHousehold
;
}
public
boolean
deletePeasantHouseholdBySequenceNbr
(
Long
sequenceNbr
){
public
boolean
deletePeasantHouseholdBySequenceNbr
(
Long
sequenceNbr
){
PeasantHouseholdDto
peasantHouseholdDto
=
this
.
queryBySeq
(
sequenceNbr
);
PeasantHouseholdDto
peasantHouseholdDto
=
this
.
queryBySeq
(
sequenceNbr
);
Long
surveyInformationId
=
peasantHouseholdDto
.
getSurveyInformationId
();
Long
surveyInformationId
=
peasantHouseholdDto
.
getSurveyInformationId
();
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/WxServiceImpl.java
View file @
064979ed
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
hygf
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.biz.common.utils.HttpUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.AccessTokenDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.WechatQrCodeDTO
;
import
com.yeejoin.amos.boot.module.hygf.api.service.IWxService
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.HttpUtil
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.HttpUtil
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
/**
/**
* 农户微信小程序
* 农户微信小程序
...
@@ -21,8 +35,30 @@ import java.io.InputStream;
...
@@ -21,8 +35,30 @@ import java.io.InputStream;
*/
*/
@Slf4j
@Slf4j
@Component
@Component
public
class
WxServiceImpl
{
public
class
WxServiceImpl
implements
IWxService
{
private
final
String
SMALL_PRO_TOKEN_URL
=
"https://api.weixin.qq.com/cgi-bin/token?"
;
private
final
String
SMALL_PRO_TOKEN
=
"wxToken"
;
private
final
String
SMALL_PRO_QRCODE_URL
=
"https://api.weixin.qq.com/wxa/getwxacodeunlimit?"
;
@Autowired
private
RedisUtils
redisUtil
;
private
static
final
String
grant_type
=
"client_credential"
;
private
static
final
String
smallPrograName
=
"amos\\u5E73\\u53F0"
;
/**
* 公众号appid
*/
private
static
final
String
publicAppId
=
"wxf6f295ce82aa4aab"
;
/**
* 公众号secret
*/
private
static
final
String
publicSecret
=
"8df0d4c5968d0d65cba2a398eedfd1e8"
;
@Value
(
"${hygfProgram.appid}"
)
@Value
(
"${hygfProgram.appid}"
)
private
String
appId
;
private
String
appId
;
...
@@ -38,6 +74,135 @@ public class WxServiceImpl {
...
@@ -38,6 +74,135 @@ public class WxServiceImpl {
return
sessionKey
;
return
sessionKey
;
}
}
@Override
public
String
getAccessToken
()
{
// 坑,redis取出来的值 微信说失效了 现在解决方案 是改小失效时间
String
redisKey
=
SMALL_PRO_TOKEN
+
":"
+
appId
;
if
(
redisUtil
.
hasKey
(
redisKey
))
{
return
redisUtil
.
get
(
redisKey
).
toString
();
}
AccessTokenDto
accessToken
=
buildTokenParam
(
SMALL_PRO_TOKEN_URL
,
grant_type
,
appId
,
secret
);
if
(
accessToken
.
getErrcode
()
==
null
)
{
redisUtil
.
set
(
redisKey
,
accessToken
.
getAccess_token
(),
accessToken
.
getExpires_in
()
-
5
);
}
return
accessToken
.
getAccess_token
();
}
private
AccessTokenDto
buildTokenParam
(
String
url
,
String
grant_type
,
String
appid
,
String
secret
)
{
StringBuffer
buildUrl
=
new
StringBuffer
();
buildUrl
.
append
(
url
).
append
(
"grant_type="
+
grant_type
).
append
(
"&appid="
+
appid
).
append
(
"&secret="
+
secret
);
try
{
String
resultStr
=
HttpUtils
.
doGet
(
buildUrl
.
toString
());
AccessTokenDto
accessToken
=
JSON
.
parseObject
(
resultStr
,
AccessTokenDto
.
class
);
if
(
0
!=
accessToken
.
getErrcode
())
{
throw
new
RuntimeException
(
accessToken
.
getErrmsg
());
}
return
accessToken
;
}
catch
(
Exception
e
)
{
log
.
error
(
"getSmallPro token is error url:{}"
,
buildUrl
.
toString
());
throw
new
RuntimeException
(
e
.
getMessage
());
}
}
/**
* @param url
* @param access_token 接口调用凭证
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
private
WechatQrCodeDTO
buildQrParam
(
String
url
,
String
access_token
,
String
scene
,
String
page
,
Long
width
,
Boolean
auto_color
,
JSONObject
line_color
,
Boolean
is_hyaline
)
{
WechatQrCodeDTO
smallProQrCodeVo
=
new
WechatQrCodeDTO
();
StringBuffer
buildUrl
=
new
StringBuffer
();
buildUrl
.
append
(
url
).
append
(
"access_token="
+
access_token
);
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"scene"
,
scene
);
param
.
put
(
"page"
,
page
);
param
.
put
(
"width"
,
width
);
param
.
put
(
"auto_color"
,
auto_color
);
param
.
put
(
"line_color"
,
line_color
);
param
.
put
(
"is_hyaline"
,
is_hyaline
);
try
{
RestTemplate
rest
=
new
RestTemplate
();
log
.
info
(
"request wxQrCode start....."
);
ResponseEntity
<
Resource
>
entity
=
rest
.
postForEntity
(
buildUrl
.
toString
(),
param
.
toJSONString
(),
Resource
.
class
);
log
.
info
(
"get wxQrCode entity:{}"
,
entity
.
toString
());
InputStream
in
=
entity
.
getBody
().
getInputStream
();
smallProQrCodeVo
.
setBuffer
(
inputStream2byte
(
in
));
}
catch
(
Exception
e
)
{
log
.
error
(
"getSmallProQrCode is error url:{} param:{}"
,
buildUrl
.
toString
(),
JSON
.
toJSON
(
param
));
throw
new
BadRequest
(
e
.
getMessage
());
}
return
smallProQrCodeVo
;
}
/**
* 功能描述:
*
* @param inputStream 输入流
* @return byte[] 数组
* @author sqy
* @date 2019/3/28 16:03
* @version 1.0
*/
public
static
byte
[]
inputStream2byte
(
InputStream
inputStream
)
throws
IOException
{
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
byte
[]
buff
=
new
byte
[
100
];
int
rc
=
0
;
while
((
rc
=
inputStream
.
read
(
buff
,
0
,
100
))
>
0
)
{
byteArrayOutputStream
.
write
(
buff
,
0
,
rc
);
}
return
byteArrayOutputStream
.
toByteArray
();
}
@Override
public
String
getSmallProQrCode
(
String
access_token
,
String
scene
,
String
page
,
Long
width
,
Boolean
auto_color
,
JSONObject
line_color
,
Boolean
is_hyaline
)
{
WechatQrCodeDTO
smallProQrCodeVo
=
buildQrParam
(
SMALL_PRO_QRCODE_URL
,
access_token
,
scene
,
page
,
width
,
auto_color
,
line_color
,
is_hyaline
);
// 小程序二维码
byte
[]
buffer
=
smallProQrCodeVo
.
getBuffer
();
return
JSON
.
toJSONString
(
buffer
);
}
@Override
public
byte
[]
getSmallProQrCodeByte
(
String
access_token
,
String
scene
,
String
page
,
Long
width
,
Boolean
auto_color
,
JSONObject
line_color
,
Boolean
is_hyaline
)
{
WechatQrCodeDTO
smallProQrCodeVo
=
buildQrParam
(
SMALL_PRO_QRCODE_URL
,
access_token
,
scene
,
page
,
width
,
auto_color
,
line_color
,
is_hyaline
);
// 小程序二维码 byte
return
smallProQrCodeVo
.
getBuffer
();
}
@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
)
{
WechatQrCodeDTO
smallProQrCodeVo
=
buildQrParam
(
SMALL_PRO_QRCODE_URL
,
access_token
,
scene
,
page
,
width
,
auto_color
,
line_color
,
is_hyaline
);
byte
[]
smallProQrCode
=
smallProQrCodeVo
.
getBuffer
();
response
.
setContentType
(
"image/"
+
fileType
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
+
"."
+
fileType
);
response
.
addHeader
(
"Access-Control-Allow-Headers"
,
"Content-Disposition"
);
response
.
addHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
OutputStream
os
;
try
{
os
=
response
.
getOutputStream
();
os
.
write
(
smallProQrCode
);
os
.
flush
();
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
JSONObject
getCode2Session
(
String
code
)
{
public
JSONObject
getCode2Session
(
String
code
)
{
String
url
=
buildOpenIdUrl
(
appId
,
secret
,
code
);
String
url
=
buildOpenIdUrl
(
appId
,
secret
,
code
);
String
resultStr
=
HttpUtil
.
sendHttpGet
(
url
);
String
resultStr
=
HttpUtil
.
sendHttpGet
(
url
);
...
@@ -65,6 +230,7 @@ public class WxServiceImpl {
...
@@ -65,6 +230,7 @@ public class WxServiceImpl {
InputStream
inputStream
;
InputStream
inputStream
;
}
}
@Override
public
String
getOpenId
(
String
code
)
{
public
String
getOpenId
(
String
code
)
{
JSONObject
jsonObject
=
getCode2Session
(
code
);
JSONObject
jsonObject
=
getCode2Session
(
code
);
String
openId
=
null
;
String
openId
=
null
;
...
@@ -73,4 +239,14 @@ public class WxServiceImpl {
...
@@ -73,4 +239,14 @@ public class WxServiceImpl {
}
}
return
openId
;
return
openId
;
}
}
@Override
public
String
getPhoneNumber
(
String
session_key
,
String
encryptedData
,
String
iv
)
{
return
null
;
}
@Override
public
String
getName
()
{
return
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment