区域绑定接口

This commit is contained in:
小魔仙~ 2024-12-27 16:02:27 +08:00
parent 3197e29b87
commit 92a1794046
8 changed files with 575 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import com.fastbee.rechargecard.service.INgUserRechargeRecordsService;
import com.fastbee.rechargecard.service.IUserConsumptionDetailsService;
import com.fastbee.rechargecard.service.IUserRechargeCardsService;
import com.fastbee.rechargecard.service.IUserWechatPayService;
import com.fastbee.system.mapper.SysDeptMapper;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -67,6 +68,8 @@ public class WeChatPayController extends BaseController {
private IUserConsumptionDetailsService userConsumptionDetailsService;
@Autowired
private IUserWechatPayService userWechatPayService;
@Autowired
private SysDeptMapper sysDeptMapper;
/**
* 获取平台证书

View File

@ -0,0 +1,112 @@
package com.fastbee.data.controller.userRecharge;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.rechargecard.domain.NgMerchants;
import com.fastbee.rechargecard.domain.dto.NgMerchantsDto;
import com.fastbee.rechargecard.service.INgMerchantsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.common.core.page.TableDataInfo;
/**
* 商户信息Controller
*
* @author kerwincui
* @date 2024-12-27
*/
@RestController
@RequestMapping("/iot/merchants")
@Api(tags = "商户信息")
public class NgMerchantsController extends BaseController
{
@Autowired
private INgMerchantsService ngMerchantsService;
/**
* 查询商户信息列表
*/
@PreAuthorize("@ss.hasPermi('iot:merchants:list')")
@GetMapping("/list")
@ApiOperation("查询商户信息列表")
public TableDataInfo list(NgMerchants ngMerchants)
{
startPage();
List<NgMerchantsDto> ngMerchantsDtoList = ngMerchantsService.selectNgMerchantsList(ngMerchants);
return getDataTable(ngMerchantsDtoList);
}
/**
* 导出商户信息列表
*/
@ApiOperation("导出商户信息列表")
@PreAuthorize("@ss.hasPermi('iot:merchants:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, NgMerchants ngMerchants)
{
//List<NgMerchants> list = ngMerchantsService.selectNgMerchantsList(ngMerchants);
// ExcelUtil<NgMerchants> util = new ExcelUtil<NgMerchants>(NgMerchants.class);
// util.exportExcel(response, list, "商户信息数据");
}
/**
* 获取商户信息详细信息
*/
@PreAuthorize("@ss.hasPermi('iot:merchants:query')")
@GetMapping(value = "/{id}")
@ApiOperation("获取商户信息详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(ngMerchantsService.selectNgMerchantsById(id));
}
/**
* 新增商户信息
*/
@PreAuthorize("@ss.hasPermi('iot:merchants:add')")
@PostMapping
@ApiOperation("新增商户信息")
public AjaxResult add(@RequestBody NgMerchants ngMerchants)
{
return toAjax(ngMerchantsService.insertNgMerchants(ngMerchants));
}
/**
* 修改商户信息
*/
@PreAuthorize("@ss.hasPermi('iot:merchants:edit')")
@PutMapping
@ApiOperation("修改商户信息")
public AjaxResult edit(@RequestBody NgMerchants ngMerchants)
{
return toAjax(ngMerchantsService.updateNgMerchants(ngMerchants));
}
/**
* 删除商户信息
*/
@PreAuthorize("@ss.hasPermi('iot:merchants:remove')")
@DeleteMapping("/{ids}")
@ApiOperation("删除商户信息")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(ngMerchantsService.deleteNgMerchantsByIds(ids));
}
}

View File

@ -0,0 +1,62 @@
package com.fastbee.rechargecard.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fastbee.common.annotation.Excel;
import com.fastbee.common.core.domain.BaseEntity;
/**
* 商户信息对象 ng_merchants
*
* @author kerwincui
* @date 2024-12-27
*/
@ApiModel(value = "NgMerchants",description = "商户信息 ng_merchants")
@Data
public class NgMerchants
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 商户号 */
@Excel(name = "商户号")
@ApiModelProperty("商户号")
private String mchId;
/** 商户API私钥 */
@Excel(name = "商户API私钥")
@ApiModelProperty("商户API私钥")
private String privateKeyPath;
/** 商户API证书序列号 */
@Excel(name = "商户API证书序列号")
@ApiModelProperty("商户API证书序列号")
private String serialNo;
/** 商户APIV3密钥 */
@Excel(name = "商户APIV3密钥 ")
@ApiModelProperty("商户APIV3密钥 ")
private String apiV3Key;
/** 微信支付公钥 */
@Excel(name = "微信支付公钥")
@ApiModelProperty("微信支付公钥")
private String publicKeyPath;
/** 灌区外键 */
@Excel(name = "灌区外键")
@ApiModelProperty("灌区外键")
private Long deptId;
/** 微信平台证书 */
@Excel(name = "微信平台证书")
@ApiModelProperty("微信平台证书")
private String platformCertificates;
}

View File

@ -0,0 +1,27 @@
package com.fastbee.rechargecard.domain.dto;
import com.fastbee.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class NgMerchantsDto {
private Long id;
private String mchId;
private String privateKeyPath;
private String serialNo;
private String apiV3Key;
private String publicKeyPath;
private Long deptId;
private String platformCertificates;
private String deptName;
}

View File

@ -0,0 +1,65 @@
package com.fastbee.rechargecard.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.rechargecard.domain.NgMerchants;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 商户信息Mapper接口
*
* @author kerwincui
* @date 2024-12-27
*/
@Mapper
public interface NgMerchantsMapper extends BaseMapper<NgMerchants>
{
/**
* 查询商户信息
*
* @param id 商户信息主键
* @return 商户信息
*/
public NgMerchants selectNgMerchantsById(Long id);
/**
* 查询商户信息列表
*
* @param ngMerchants 商户信息
* @return 商户信息集合
*/
public List<NgMerchants> selectNgMerchantsList(NgMerchants ngMerchants);
/**
* 新增商户信息
*
* @param ngMerchants 商户信息
* @return 结果
*/
public int insertNgMerchants(NgMerchants ngMerchants);
/**
* 修改商户信息
*
* @param ngMerchants 商户信息
* @return 结果
*/
public int updateNgMerchants(NgMerchants ngMerchants);
/**
* 删除商户信息
*
* @param id 商户信息主键
* @return 结果
*/
public int deleteNgMerchantsById(Long id);
/**
* 批量删除商户信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNgMerchantsByIds(Long[] ids);
}

View File

@ -0,0 +1,64 @@
package com.fastbee.rechargecard.service;
import com.fastbee.rechargecard.domain.NgMerchants;
import com.fastbee.rechargecard.domain.dto.NgMerchantsDto;
import java.util.List;
/**
* 商户信息Service接口
*
* @author kerwincui
* @date 2024-12-27
*/
public interface INgMerchantsService
{
/**
* 查询商户信息
*
* @param id 商户信息主键
* @return 商户信息
*/
public NgMerchantsDto selectNgMerchantsById(Long id);
/**
* 查询商户信息列表
*
* @param ngMerchants 商户信息
* @return 商户信息集合
*/
public List<NgMerchantsDto> selectNgMerchantsList(NgMerchants ngMerchants);
/**
* 新增商户信息
*
* @param ngMerchants 商户信息
* @return 结果
*/
public int insertNgMerchants(NgMerchants ngMerchants);
/**
* 修改商户信息
*
* @param ngMerchants 商户信息
* @return 结果
*/
public int updateNgMerchants(NgMerchants ngMerchants);
/**
* 批量删除商户信息
*
* @param ids 需要删除的商户信息主键集合
* @return 结果
*/
public int deleteNgMerchantsByIds(Long[] ids);
/**
* 删除商户信息信息
*
* @param id 商户信息主键
* @return 结果
*/
public int deleteNgMerchantsById(Long id);
}

View File

@ -0,0 +1,156 @@
package com.fastbee.rechargecard.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fastbee.common.core.domain.entity.SysDept;
import com.fastbee.rechargecard.domain.NgMerchants;
import com.fastbee.rechargecard.domain.dto.NgMerchantsDto;
import com.fastbee.rechargecard.mapper.NgMerchantsMapper;
import com.fastbee.rechargecard.service.INgMerchantsService;
import com.fastbee.system.mapper.SysDeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 商户信息Service业务层处理
*
* @author kerwincui
* @date 2024-12-27
*/
@Service
public class NgMerchantsServiceImpl implements INgMerchantsService
{
@Autowired
private NgMerchantsMapper ngMerchantsMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
/**
* 查询商户信息
*
* @param id 商户信息主键
* @return 商户信息
*/
@Override
public NgMerchantsDto selectNgMerchantsById(Long id)
{
NgMerchantsDto ngMerchantsDto = new NgMerchantsDto();
NgMerchants ngMerchants = ngMerchantsMapper.selectNgMerchantsById(id);
SysDept sysDept = sysDeptMapper.selectDeptById(ngMerchants.getDeptId());
ngMerchantsDto.setId(ngMerchants.getId());
ngMerchantsDto.setApiV3Key(ngMerchants.getApiV3Key());
ngMerchantsDto.setMchId(ngMerchants.getMchId());
ngMerchantsDto.setPrivateKeyPath(ngMerchants.getPrivateKeyPath());
ngMerchantsDto.setPublicKeyPath(ngMerchants.getPublicKeyPath());
ngMerchantsDto.setSerialNo(ngMerchants.getSerialNo());
ngMerchantsDto.setDeptId(ngMerchants.getDeptId());
ngMerchantsDto.setDeptName(sysDept.getDeptName());
return ngMerchantsDto;
}
/**
* 查询商户信息列表
*
* @param ngMerchants 商户信息
* @return 商户信息
*/
@Override
public List<NgMerchantsDto> selectNgMerchantsList(NgMerchants ngMerchants)
{
// 查询商户信息列表
List<NgMerchants> ngMerchantsList = ngMerchantsMapper.selectNgMerchantsList(ngMerchants);
// 查询机构信息列表
List<SysDept> sysDeptList = sysDeptMapper.selectDeptList(new SysDept());
// 合并信息
return ngMerchantsList.stream()
.map(ngMerchants1 -> {
NgMerchantsDto ngMerchantsDto = new NgMerchantsDto();
ngMerchantsDto.setId(ngMerchants1.getId());
ngMerchantsDto.setApiV3Key(ngMerchants1.getApiV3Key());
ngMerchantsDto.setMchId(ngMerchants1.getMchId());
ngMerchantsDto.setPrivateKeyPath(ngMerchants1.getPrivateKeyPath());
ngMerchantsDto.setPublicKeyPath(ngMerchants1.getPublicKeyPath());
ngMerchantsDto.setSerialNo(ngMerchants1.getSerialNo());
ngMerchantsDto.setDeptId(ngMerchants1.getDeptId());
ngMerchantsDto.setPlatformCertificates(ngMerchants1.getPlatformCertificates());
return ngMerchantsDto;
})
.peek(ngMerchantsDto -> {
sysDeptList.stream()
.filter(sysDept1 -> sysDept1.getDeptId().equals(ngMerchantsDto.getDeptId()))
.findFirst()
.ifPresent(sysDept1 -> ngMerchantsDto.setDeptName(sysDept1.getDeptName()));
}).collect(Collectors.toList());
}
/**
* 新增商户信息
*
* @param ngMerchants 商户信息
* @return 结果
*/
@Override
public int insertNgMerchants(NgMerchants ngMerchants)
{
SysDept sysDept = sysDeptMapper.selectDeptById(ngMerchants.getDeptId());
QueryWrapper<NgMerchants> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dept_id", ngMerchants.getDeptId());
List<NgMerchants> ngMerchants1 = ngMerchantsMapper.selectList(queryWrapper);
if(sysDept == null||ngMerchants1==null){
return 0;
}
return ngMerchantsMapper.insertNgMerchants(ngMerchants);
}
/**
* 修改商户信息
*
* @param ngMerchants 商户信息
* @return 结果
*/
@Override
public int updateNgMerchants(NgMerchants ngMerchants)
{
if (sysDeptMapper.selectDeptById(ngMerchants.getDeptId())==null){
return 0;
}
return ngMerchantsMapper.updateNgMerchants(ngMerchants);
}
/**
* 批量删除商户信息
*
* @param ids 需要删除的商户信息主键
* @return 结果
*/
@Override
public int deleteNgMerchantsByIds(Long[] ids)
{
return ngMerchantsMapper.deleteNgMerchantsByIds(ids);
}
/**
* 删除商户信息信息
*
* @param id 商户信息主键
* @return 结果
*/
@Override
public int deleteNgMerchantsById(Long id)
{
return ngMerchantsMapper.deleteNgMerchantsById(id);
}
}

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fastbee.rechargecard.mapper.NgMerchantsMapper">
<resultMap type="NgMerchants" id="NgMerchantsResult">
<result property="id" column="id" />
<result property="mchId" column="mch_id" />
<result property="privateKeyPath" column="private_key_path" />
<result property="serialNo" column="serial_no" />
<result property="apiV3Key" column="api_v3_key" />
<result property="publicKeyPath" column="public_key_path" />
<result property="deptId" column="dept_id" />
<result property="platformCertificates" column="platform_certificates" />
</resultMap>
<sql id="selectNgMerchantsVo">
select id, mch_id, private_key_path, serial_no, api_v3_key, public_key_path, dept_id, platform_certificates from ng_merchants
</sql>
<select id="selectNgMerchantsList" parameterType="NgMerchants" resultMap="NgMerchantsResult">
<include refid="selectNgMerchantsVo"/>
<where>
<if test="mchId != null and mchId != ''"> and mch_id = #{mchId}</if>
<if test="privateKeyPath != null and privateKeyPath != ''"> and private_key_path = #{privateKeyPath}</if>
<if test="serialNo != null and serialNo != ''"> and serial_no = #{serialNo}</if>
<if test="apiV3Key != null and apiV3Key != ''"> and api_v3_key = #{apiV3Key}</if>
<if test="publicKeyPath != null and publicKeyPath != ''"> and public_key_path = #{publicKeyPath}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="platformCertificates != null and platformCertificates != ''"> and platform_certificates = #{platformCertificates}</if>
</where>
</select>
<select id="selectNgMerchantsById" parameterType="Long" resultMap="NgMerchantsResult">
<include refid="selectNgMerchantsVo"/>
where id = #{id}
</select>
<insert id="insertNgMerchants" parameterType="NgMerchants" useGeneratedKeys="true" keyProperty="id">
insert into ng_merchants
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mchId != null">mch_id,</if>
<if test="privateKeyPath != null">private_key_path,</if>
<if test="serialNo != null">serial_no,</if>
<if test="apiV3Key != null">api_v3_key,</if>
<if test="publicKeyPath != null">public_key_path,</if>
<if test="deptId != null">dept_id,</if>
<if test="platformCertificates != null">platform_certificates,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mchId != null">#{mchId},</if>
<if test="privateKeyPath != null">#{privateKeyPath},</if>
<if test="serialNo != null">#{serialNo},</if>
<if test="apiV3Key != null">#{apiV3Key},</if>
<if test="publicKeyPath != null">#{publicKeyPath},</if>
<if test="deptId != null">#{deptId},</if>
<if test="platformCertificates != null">#{platformCertificates},</if>
</trim>
</insert>
<update id="updateNgMerchants" parameterType="NgMerchants">
update ng_merchants
<trim prefix="SET" suffixOverrides=",">
<if test="mchId != null">mch_id = #{mchId},</if>
<if test="privateKeyPath != null">private_key_path = #{privateKeyPath},</if>
<if test="serialNo != null">serial_no = #{serialNo},</if>
<if test="apiV3Key != null">api_v3_key = #{apiV3Key},</if>
<if test="publicKeyPath != null">public_key_path = #{publicKeyPath},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="platformCertificates != null">platform_certificates = #{platformCertificates},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNgMerchantsById" parameterType="Long">
delete from ng_merchants where id = #{id}
</delete>
<delete id="deleteNgMerchantsByIds" parameterType="String">
delete from ng_merchants where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>