优化小程序获取证书,机构增加运营商id

This commit is contained in:
yuyang 2022-02-08 15:59:35 +08:00
parent 913fc3ef62
commit 7e8c386880
13 changed files with 130 additions and 29 deletions

View File

@ -1,6 +1,5 @@
package com.xhpc.common.api;
import com.xhpc.common.api.factory.CardHistoryOrderFactory;
import com.xhpc.common.api.factory.SettingConfigFactory;
import com.xhpc.common.core.constant.ServiceNameConstants;
import com.xhpc.common.core.domain.R;

View File

@ -166,7 +166,8 @@ public class XhpcAppUserController extends BaseController {
R r = settingConfigService.settingConfig(1, tenantId);
if(r !=null && r.getCode()==200){
XhpcSettingConfig xhpcSettingConfig = (XhpcSettingConfig)r.getData();
String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+xhpcSettingConfig.getWxAppId()+"&secret="+xhpcSettingConfig.getWxAppSecret()+"&js_code="+ jsCode + "&grant_type=authorization_code";
Map<String, Object> mapConfig = (Map<String, Object>)r.getData();
String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+mapConfig.get("wxAppId").toString()+"&secret="+mapConfig.get("wxAppSecret").toString()+"&js_code="+ jsCode + "&grant_type=authorization_code";
String result = HttpUtils.get(url);
JSONObject json = JSON.parseObject(result);
if (null != json) {
@ -247,23 +248,23 @@ public class XhpcAppUserController extends BaseController {
if("".equals(tenantId) || null==tenantId){
tenantId="000000";
}
R r = settingConfigService.settingConfig(1, tenantId);
R r = settingConfigService.settingConfig(2, tenantId);
if(r !=null && r.getCode()==200){
XhpcSettingConfig xhpcSettingConfig = (XhpcSettingConfig)r.getData();
Map<String, Object> map = (Map<String, Object>)r.getData();
/** 初始化 **/
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
/** 支付宝网关 **/
certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");
/** 应用id如何获取请参考https://opensupport.alipay.com/support/helpcenter/190/201602493024 **/
certAlipayRequest.setAppId(xhpcSettingConfig.getZfbAppId());
certAlipayRequest.setAppId(map.get("zfbAppId").toString());
/** 应用私钥, 如何获取请参考https://opensupport.alipay.com/support/helpcenter/207/201602471154?ant_source=antsupport **/
certAlipayRequest.setPrivateKey(xhpcSettingConfig.getZfbPrivateKey());
certAlipayRequest.setPrivateKey(map.get("zfbPrivateKey").toString());
/** 应用公钥证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setCertPath(xhpcSettingConfig.getZfbAppCertPublicKey());
certAlipayRequest.setCertPath(map.get("zfbAppCertPublicKey").toString());
/** 支付宝公钥证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setAlipayPublicCertPath(xhpcSettingConfig.getZfbAppCertPublicKey());
certAlipayRequest.setAlipayPublicCertPath(map.get("zfbAlipayCertPublicKeyRsa").toString());
/** 支付宝根证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setRootCertPath(xhpcSettingConfig.getZfbAlipayRootCert());
certAlipayRequest.setRootCertPath(map.get("zfbAlipayRootCert").toString());
/** 设置签名类型 **/
certAlipayRequest.setSignType("RSA2");
/** 设置请求格式固定值json **/

View File

@ -43,8 +43,8 @@ public class XhpcCommunityController extends BaseController {
*/
@Log(title = "社区", businessType = BusinessType.INSERT)
@PostMapping(value = "/addCommunity")
public AjaxResult addCommunity(@RequestBody XhpcCommunity xhpcCommunity) {
return xhpcCommunityService.addCommunity(xhpcCommunity);
public AjaxResult addCommunity(HttpServletRequest request,@RequestBody XhpcCommunity xhpcCommunity) {
return xhpcCommunityService.addCommunity(request,xhpcCommunity);
}
/**
@ -94,8 +94,8 @@ public class XhpcCommunityController extends BaseController {
*/
@Log(title = "社区人员", businessType = BusinessType.INSERT)
@PostMapping(value = "/addCommunityPersonnel")
public AjaxResult addCommunityPersonnel(@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) {
return xhpcCommunityService.addCommunityPersonnel(xhpcCommunityPersonnel);
public AjaxResult addCommunityPersonnel(HttpServletRequest request,@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) {
return xhpcCommunityService.addCommunityPersonnel(request,xhpcCommunityPersonnel);
}
/**

View File

@ -91,8 +91,8 @@ public class XhpcCustomersController extends BaseController {
*/
@Log(title = "大客户人员", businessType = BusinessType.INSERT)
@PostMapping(value = "/addCustomersPersonnel")
public AjaxResult addCustomersPersonnel(@RequestBody XhpcCustomersPersonnel xhpcCustomersPersonnel) {
return xhpcCustomersService.addCustomersPersonnel(xhpcCustomersPersonnel);
public AjaxResult addCustomersPersonnel(HttpServletRequest request, @RequestBody XhpcCustomersPersonnel xhpcCustomersPersonnel) {
return xhpcCustomersService.addCustomersPersonnel(request,xhpcCustomersPersonnel);
}
/**

View File

@ -84,4 +84,10 @@ public class XhpcCommunity extends BaseEntity {
* 电站id
*/
private String chargingStationIds;
/**
* 运营商id
*/
private Long operatorId;
}

View File

@ -79,4 +79,8 @@ public class XhpcCommunityPersonnel extends BaseEntity {
* 充值订单id退款订单id
*/
private Long moneyOrderId;
private Long createId;
private Integer createType;
}

View File

@ -77,4 +77,8 @@ public class XhpcCustomersPersonnel extends BaseEntity {
* 充值订单id退款订单id
*/
private Long moneyOrderId;
private Long createId;
private Integer createType;
}

View File

@ -30,7 +30,7 @@ public interface IXhpcCommunityService {
* @param
* @return
*/
AjaxResult addCommunity(XhpcCommunity xhpcCommunity);
AjaxResult addCommunity(HttpServletRequest request,XhpcCommunity xhpcCommunity);
/**
* 删除社区组树
@ -63,7 +63,7 @@ public interface IXhpcCommunityService {
* @param
* @return
*/
AjaxResult addCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel);
AjaxResult addCommunityPersonnel(HttpServletRequest request,XhpcCommunityPersonnel xhpcCommunityPersonnel);
/**
* 查询社区人员

View File

@ -62,7 +62,7 @@ public interface IXhpcCustomersService {
* @param
* @return
*/
AjaxResult addCustomersPersonnel(XhpcCustomersPersonnel xhpcCustomersPersonnel);
AjaxResult addCustomersPersonnel(HttpServletRequest request, XhpcCustomersPersonnel xhpcCustomersPersonnel);
/**
* 查询社区人员

View File

@ -6,6 +6,7 @@ import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.user.domain.XhpcCommunity;
import com.xhpc.user.domain.XhpcCommunityPersonnel;
@ -57,7 +58,7 @@ public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommun
}
@Override
public AjaxResult addCommunity(XhpcCommunity xhpcCommunity) {
public AjaxResult addCommunity(HttpServletRequest request,XhpcCommunity xhpcCommunity) {
R r= judgeXhpcCommunity(xhpcCommunity);
if(r.getCode() !=200){
@ -75,6 +76,19 @@ public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommun
}else{
xhpcCommunity.setStatus(1);
}
Long userId = SecurityUtils.getUserId();
if(userId !=null){
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(sysUser.getUserType())){
xhpcCommunity.setType(2);
xhpcCommunity.setOperatorId(sysUser.getOperatorId());
}else{
xhpcCommunity.setType(1);
}
}else{
return AjaxResult.error("请重新登录");
}
xhpcCommunityMapper.addCommunity(xhpcCommunity);
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0);
@ -137,7 +151,7 @@ public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommun
@Override
@Transactional
public AjaxResult addCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel) {
public AjaxResult addCommunityPersonnel(HttpServletRequest request,XhpcCommunityPersonnel xhpcCommunityPersonnel) {
R r = judgeXhpcCommunityPersonnel(xhpcCommunityPersonnel);
if(r.getCode()!=200){
return AjaxResult.error(r.getMsg());
@ -158,6 +172,19 @@ public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommun
//增加社区用户的剩余金额
xhpcCommunityPersonnel.setSurplusMoney(rechargeMoney);
}
Long userId = SecurityUtils.getUserId();
if(userId !=null){
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(sysUser.getUserType())){
xhpcCommunityPersonnel.setCreateType(2);
xhpcCommunityPersonnel.setCreateId(sysUser.getOperatorId());
}else{
xhpcCommunityPersonnel.setCreateType(1);
}
}else{
return AjaxResult.error("请重新登录");
}
xhpcCommunityMapper.addCommunityPersonnel(xhpcCommunityPersonnel);
//增加一条充值记录
if(new BigDecimal(0).compareTo(rechargeMoney)==-1){

View File

@ -6,6 +6,7 @@ import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.user.domain.XhpcCommunity;
import com.xhpc.user.domain.XhpcCustomers;
@ -65,14 +66,12 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom
Long userId = SecurityUtils.getUserId();
if(userId !=null){
LoginUser loginUser = tokenService.getLoginUser(request);
Map<String, Object> landUser = xhpcCustomersMapper.getLandUser(loginUser.getUserid());
if(landUser !=null && landUser.get("userType") !=null){
if("00".equals(landUser.get("userType").toString()) ){
xhpcCustomers.setType(1);
}else{
xhpcCustomers.setType(2);
xhpcCustomers.setOperatorId(Long.parseLong(landUser.get("operatorId").toString()));
}
SysUser sysUser = loginUser.getSysUser();
if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(sysUser.getUserType())){
xhpcCustomers.setType(2);
xhpcCustomers.setOperatorId(sysUser.getOperatorId());
}else{
xhpcCustomers.setType(1);
}
}else{
return AjaxResult.error("请重新登录");
@ -141,7 +140,7 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom
}
@Override
public AjaxResult addCustomersPersonnel(XhpcCustomersPersonnel xhpcCustomersPersonnel) {
public AjaxResult addCustomersPersonnel(HttpServletRequest request, XhpcCustomersPersonnel xhpcCustomersPersonnel) {
R r = judgeXhpcCustomersPersonnel(xhpcCustomersPersonnel);
if(r.getCode()!=200){
return AjaxResult.error(r.getMsg());
@ -164,6 +163,19 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom
xhpcCustomersPersonnel.setSurplusMoney(rechargeMoney);
}
}
Long userId = SecurityUtils.getUserId();
if(userId !=null){
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(sysUser.getUserType())){
xhpcCustomersPersonnel.setCreateType(2);
xhpcCustomersPersonnel.setCreateId(sysUser.getOperatorId());
}else{
xhpcCustomersPersonnel.setCreateType(1);
}
}else{
return AjaxResult.error("请重新登录");
}
xhpcCustomersMapper.addCustomersPersonnel(xhpcCustomersPersonnel);
if(rechargeMoney !=null){
//增加一条充值记录

View File

@ -92,6 +92,12 @@
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != type">
type,
</if>
<if test="null != operatorId">
operatorId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != communityId">
@ -139,6 +145,12 @@
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != type">
#{type},
</if>
<if test="null != operatorId">
#{operatorId},
</if>
</trim>
</insert>
@ -280,6 +292,12 @@
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != createId">
create_id,
</if>
<if test="null != createType">
create_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != communityPersonnelId">
@ -333,6 +351,12 @@
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != createId">
#{createId},
</if>
<if test="null != createType">
#{createType},
</if>
</trim>
</insert>

View File

@ -90,6 +90,12 @@
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != type">
type,
</if>
<if test="null != operatorId">
operator_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != customersId">
@ -134,6 +140,12 @@
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != type">
#{type},
</if>
<if test="null != operatorId">
#{operatorId},
</if>
</trim>
</insert>
@ -274,6 +286,12 @@
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != createId">
create_id,
</if>
<if test="null != createType">
create_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != customersPersonnelId">
@ -327,6 +345,12 @@
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != createId">
#{createId},
</if>
<if test="null != createType">
#{createType},
</if>
</trim>
</insert>