| @@ -146,4 +146,11 @@ public class BankController extends BaseController{ | |||
| return wxBankUtilService.bankBranches(getTenantInfo(),bankAliasCode,cityCode); | |||
| } | |||
| @ApiOperation("查省市") | |||
| @GetMapping("initProvincesCities") | |||
| public ResultData initProvincesCities() { | |||
| logger.debug("[" + getIpAddr() + "] BankController::areasProvinces"); | |||
| return wxBankUtilService.initProvincesCities(getTenantInfo()); | |||
| } | |||
| } | |||
| @@ -124,20 +124,20 @@ public class ImgYwsqhUtil { | |||
| return null; | |||
| } | |||
| // public static void main(String[] args) { | |||
| // String serverUploadImgUrl = "C:/Users/xiaohu/Desktop/img"; // 图片保存路径 | |||
| // try { | |||
| // byte[] bytes = imgCeate("周淼淼","421302199908081234","商务发展部","商务经理", | |||
| // "周淼淼","421302199908081234","2020-08-08","长期", | |||
| // false,"武汉富茂链客科技有限公司"); | |||
| // ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | |||
| // BufferedImage bi1 =ImageIO.read(bais); | |||
| // | |||
| // ImageIO.write(bi1, "png", new File(serverUploadImgUrl+"/0.png")); | |||
| // | |||
| // } catch (Exception e) { | |||
| // e.printStackTrace(); | |||
| // } | |||
| // System.out.println("结束"); | |||
| // } | |||
| public static void main(String[] args) { | |||
| String serverUploadImgUrl = "C:/Users/xiaohu/Desktop/img"; // 图片保存路径 | |||
| try { | |||
| byte[] bytes = imgCeate("周思琦","421302199908031245","运营部","经理", | |||
| "王若非","612101194701250412","2007-10-29","长期", | |||
| true,"北京富茂科技有限公司"); | |||
| ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | |||
| BufferedImage bi1 =ImageIO.read(bais); | |||
| ImageIO.write(bi1, "png", new File(serverUploadImgUrl+"/0.png")); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| System.out.println("结束"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @TableName(value = "wx_bank_province_city") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxBankProvinceCity extends BaseEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="parentId") | |||
| private Long parentId; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="regionCode") | |||
| private String regionCode; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="provinceCode") | |||
| private Integer provinceCode; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="provinceName") | |||
| private String provinceName; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="cityCode") | |||
| private Integer cityCode; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="cityName") | |||
| private String cityName; | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxBankProvinceCity; | |||
| import java.util.List; | |||
| public interface WxBankProvinceCityMapper extends CommonMapper<WxBankProvinceCity, Long> { | |||
| List<WxBankProvinceCity> findList(WxBankProvinceCity apply); | |||
| } | |||
| @@ -24,4 +24,5 @@ public interface WxBankUtilService { | |||
| ResultData bankBranches(TenantEntity tenantInfo, String bankAliasCode, Integer cityCode); | |||
| ResultData initProvincesCities(TenantEntity tenantInfo); | |||
| } | |||
| @@ -5,7 +5,9 @@ import com.github.binarywang.wxpay.exception.WxPayException; | |||
| import com.github.binarywang.wxpay.service.WxPayService; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBankProvinceCity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.mapper.WxBankProvinceCityMapper; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.bank.WxBankUtilService; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| @@ -28,6 +30,9 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| @Autowired | |||
| WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| WxBankProvinceCityMapper wxBankProvinceCityMapper; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> bankRedisTemplate; | |||
| @@ -238,4 +243,34 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| } | |||
| return new ResultData(bankInfoList); | |||
| } | |||
| @Override | |||
| public ResultData initProvincesCities(TenantEntity tenantInfo) { | |||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantInfo.getTenantId()); | |||
| try { | |||
| ProvincesResult provincesResult = wxPayService.getBankService().areasProvinces(); | |||
| for (ProvincesResult.ProvinceInfo provinceInfo:provincesResult.getData()) { | |||
| WxBankProvinceCity province = new WxBankProvinceCity(); | |||
| province.setParentId(0l); | |||
| province.setProvinceCode(provinceInfo.getProvinceCode()); | |||
| province.setProvinceName(provinceInfo.getProvinceName()); | |||
| wxBankProvinceCityMapper.insert(province); | |||
| CitiesResult citiesResult = wxPayService.getBankService().areasCities(provinceInfo.getProvinceCode()); | |||
| for (CitiesResult.CityInfo cityInfo:citiesResult.getData()) { | |||
| WxBankProvinceCity city = new WxBankProvinceCity(); | |||
| city.setParentId(province.getId()); | |||
| city.setProvinceCode(provinceInfo.getProvinceCode()); | |||
| city.setProvinceName(provinceInfo.getProvinceName()); | |||
| city.setCityCode(cityInfo.getCityCode()); | |||
| city.setCityName(cityInfo.getCityName()); | |||
| wxBankProvinceCityMapper.insert(city); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| } catch (WxPayException e) { | |||
| e.printStackTrace(); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,46 @@ | |||
| <?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.iformall.mapper.WxBankProvinceCityMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBankProvinceCity"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="parent_id" jdbcType="BIGINT" property="parentId" /> | |||
| <result column="region_code" jdbcType="VARCHAR" property="regionCode"/> | |||
| <result column="province_code" jdbcType="INTEGER" property="provinceCode" /> | |||
| <result column="province_name" jdbcType="VARCHAR" property="provinceName" /> | |||
| <result column="city_code" jdbcType="INTEGER" property="cityCode" /> | |||
| <result column="city_name" jdbcType="VARCHAR" property="cityName" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`parent_id`,`region_code`,`province_code`,`province_name`,`city_code`,`city_name` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != parentId"> | |||
| and `parent_id` = #{parentId} | |||
| </if> | |||
| <if test=" null != regionCode and '' != regionCode"> | |||
| and `region_code` = #{regionCode} | |||
| </if> | |||
| <if test=" null != provinceCode"> | |||
| and `province_code` = #{provinceCode} | |||
| </if> | |||
| <if test=" null != cityCode"> | |||
| and `city_code` = #{cityCode} | |||
| </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxBankProvinceCity" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_bank_province_city | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||