Browse Source

feat:0 支付工程

master
yang_shj 4 years ago
parent
commit
c2ed40d656
  1. 2
      payment-base-app/pom.xml
  2. 50
      payment-base-app/src/main/java/com/base/springcloud/bo/MerchantConfigBO.java
  3. 18
      payment-base-app/src/main/java/com/base/springcloud/controller/MerchantController.java
  4. 2
      payment-base-app/src/main/java/com/base/springcloud/dao/MerchantConfigMapper.java
  5. 9
      payment-base-app/src/main/java/com/base/springcloud/dto/MerchantConfigReqDTO.java
  6. 46
      payment-base-app/src/main/java/com/base/springcloud/dto/MerchantConfigRspDTO.java
  7. 57
      payment-base-app/src/main/java/com/base/springcloud/entity/MerchantConfig.java
  8. 4
      payment-base-app/src/main/java/com/base/springcloud/schedule/OrderTask.java
  9. 29
      payment-base-app/src/main/java/com/base/springcloud/service/imp/MerchantServiceImp.java
  10. 261
      payment-base-app/src/main/resources/com/base/payment/mapper/MerchantConfigMapper.xml

2
payment-base-app/pom.xml

@ -77,7 +77,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<version>2.6.2</version>
</dependency>
<!-- 添加微信支付jar包 -->

50
payment-base-app/src/main/java/com/base/springcloud/bo/MerchantConfigBO.java

@ -7,29 +7,33 @@ import java.io.File;
@Data
public class MerchantConfigBO {
private File certfile;
/**
* 公众号
*/
private String appId;
private String appKey;
private String certPath;
private String merchantId;
private String merchantName;
private String cityStoreName;
private String storeBrandName;
private String signType;
private String privateKey;
private String deviceInfo;
private String spbillCreateIp;
private String notifyUrl;
/**
* 商户私钥
*/
private String apiKey;
/**
* 证书序列号
*/
private String serialNo;
/**
* 商户号
*/
private String mchId;
/**
* 商户私钥
*/
private String mchPrivateKey;
/**
* 支付证书文件
*/
private File certFile;
}

18
payment-base-app/src/main/java/com/base/springcloud/controller/MerchantController.java

@ -31,23 +31,23 @@ public class MerchantController {
MerchantConfigBO merchantConfigBO = new MerchantConfigBO();
BeanUtils.copyProperties(merchantConfigDTO, merchantConfigBO);
merchantService.paymentConfigure(merchantConfigBO);
return new CommonResult(ErrorConstant.NULL_OBJ.getCode(), ErrorConstant.NULL_OBJ.getMessage(), null);
return new CommonResult(ErrorConstant.SUECCESS.getCode(), ErrorConstant.SUECCESS.getMessage(), null);
}
@ApiOperation(value = "更新商户支付信息配置", notes = "商户信息配置更新接口")
@PostMapping("/updateMerchantConfig")
public CommonResult updateMerchantConfig(@RequestBody MerchantConfigReqDTO merchantConfigDTO) {
MerchantConfigBO merchantConfigBO = new MerchantConfigBO();
BeanUtils.copyProperties(merchantConfigBO, merchantConfigDTO);
BeanUtils.copyProperties(merchantConfigDTO, merchantConfigBO);
merchantService.updateMerchantConfig(merchantConfigBO);
return new CommonResult(ErrorConstant.NULL_OBJ.getCode(), ErrorConstant.NULL_OBJ.getMessage(), null);
return new CommonResult(ErrorConstant.SUECCESS.getCode(), ErrorConstant.SUECCESS.getMessage(), null);
}
@ApiOperation(value = "删除商户支付配置信息", notes = "商户信息配置删除接口")
@PostMapping("/removeMerchantConfig")
public CommonResult removeMerchantConfig(@RequestParam String merchantId) {
merchantService.removeMerchantConfig(merchantId);
return new CommonResult(ErrorConstant.NULL_OBJ.getCode(), ErrorConstant.NULL_OBJ.getMessage(), null);
public CommonResult removeMerchantConfig(@RequestParam String mchId) {
merchantService.removeMerchantConfig(mchId);
return new CommonResult(ErrorConstant.SUECCESS.getCode(), ErrorConstant.SUECCESS.getMessage(), null);
}
@ApiOperation(value = "查询商户支付配置信息", notes = "商户信息配置查询接口")
@ -56,11 +56,11 @@ public class MerchantController {
MerchantConfigBO merchantConfigBO = new MerchantConfigBO();
BeanUtils.copyProperties(merchantConfigBO, merchantConfigDTO);
List<MerchantConfigBO> merchantConfigList = merchantService.queryMerchantConfig(merchantConfigBO);
List<MerchantConfigRspDTO> merchantConfigRspList = merchantConfigList.stream().map(t -> {
List<MerchantConfigRspDTO> merchantConfigRspList = merchantConfigList.stream().map(o -> {
MerchantConfigRspDTO merchantConfigRspDTO = new MerchantConfigRspDTO();
BeanUtils.copyProperties(merchantConfigRspDTO,t);
BeanUtils.copyProperties(o,merchantConfigRspDTO);
return merchantConfigRspDTO;
}).collect(Collectors.toList());
return new CommonResult(ErrorConstant.NULL_OBJ.getCode(), ErrorConstant.NULL_OBJ.getMessage(), merchantConfigRspList);
return new CommonResult(ErrorConstant.SUECCESS.getCode(), ErrorConstant.SUECCESS.getMessage(), merchantConfigRspList);
}
}

2
payment-base-app/src/main/java/com/base/springcloud/dao/MerchantConfigMapper.java

@ -21,7 +21,7 @@ public interface MerchantConfigMapper {
int updateMerchantConfig(MerchantConfig merchantConfig);
int removeMerchantConfig(String merchantId);
int removeMerchantConfig(String mchId);
List<MerchantConfig> queryMerchantConfig(MerchantConfig merchantConfig);
}

9
payment-base-app/src/main/java/com/base/springcloud/dto/MerchantConfigReqDTO.java

@ -20,7 +20,7 @@ public class MerchantConfigReqDTO {
/**
* 商户私钥
*/
private String appKey;
private String apiKey;
/**
* 证书序列号
@ -30,5 +30,10 @@ public class MerchantConfigReqDTO {
/**
* 商户号
*/
private String merchantId;
private String mchId;
/**
* 商户私钥
*/
private String mchPrivateKey;
}

46
payment-base-app/src/main/java/com/base/springcloud/dto/MerchantConfigRspDTO.java

@ -7,29 +7,33 @@ import java.io.File;
@Data
public class MerchantConfigRspDTO {
/**
* 微信支付证书文件
*/
private File certFile;
/**
* 公众号
*/
private String appId;
private String appKey;
private String certPath;
private String merchantId;
private String merchantName;
private String cityStoreName;
private String storeBrandName;
private String signType;
private String privateKey;
private String deviceInfo;
private String spbillCreateIp;
private String notifyUrl;
/**
* 商户私钥
*/
private String apiKey;
/**
* 证书序列号
*/
private String serialNo;
/**
* 商户号
*/
private String mchId;
/**
* 商户私钥
*/
private String mchPrivateKey;
}

57
payment-base-app/src/main/java/com/base/springcloud/entity/MerchantConfig.java

@ -3,32 +3,65 @@ package com.base.springcloud.entity;
import com.base.springcloud.base.BaseEntity;
import lombok.Data;
import java.util.Date;
@Data
public class MerchantConfig extends BaseEntity {
private String id;
/**
* 公众号
*/
private String appId;
private String appKey;
private String certPath;
/**
* 商户私钥
*/
private String apiKey;
private String merchantId;
/**
* 证书序列号
*/
private String serialNo;
private String merchantName;
/**
* 商户号
*/
private String mchId;
private String cityStoreName;
/**
* 商户私钥
*/
private String mchPrivateKey;
private String storeBrandName;
/**
* 支付证书存放路径
*/
private String certPath;
private String signType;
/**
* 创建人ID
*/
private String createId;
private String privateKey;
/**
* 创建部门ID
*/
private String createDepartId;
private String deviceInfo;
/**
* 创建时间
*/
private Date createTime;
private String spbillCreateIp;
/**
* 更新人ID
*/
private String updateId;
private String notifyUrl;
/**
* 更新时间
*/
private Date updateTime;
}

4
payment-base-app/src/main/java/com/base/springcloud/schedule/OrderTask.java

@ -17,8 +17,8 @@ public class OrderTask {
@Autowired
private PaymentService paymentService;
@Scheduled(cron = "0/10 * * * * ?")
/*@Scheduled(cron = "0/10 * * * * ?")
public void syncOrderInfo(){
paymentService.syncOrderInfo(new Date());
}
}*/
}

29
payment-base-app/src/main/java/com/base/springcloud/service/imp/MerchantServiceImp.java

@ -14,6 +14,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@ -35,22 +36,25 @@ public class MerchantServiceImp implements MerchantService {
@Override
public void paymentConfigure(MerchantConfigBO merchantConfigBO) {
// 证书上传服务器
//String certPath = uplodWecPayCert(merchantConfigBO.getMerchantId(),merchantConfigBO.getCertfile());
//String certPath = uplodWecPayCert(merchantConfigBO.getMerchantId(),merchantConfigBO.getCertFile());
// 商户支付信息保存
//merchantConfigBO.setCertPath(certPath);
MerchantConfig merchantConfig = new MerchantConfig();
merchantConfig.setId(UUID.randomUUID().toString().replace("-", ""));
merchantConfig.setCreateTime(new Date());
//merchantConfig.setCertPath(certPath);
BeanUtils.copyProperties(merchantConfigBO,merchantConfig);
merchantConfigMapper.insert(merchantConfig);
int count = merchantConfigMapper.insert(merchantConfig);
if(count > 0) return;
// TODO 抛出业务异常
}
/**
* 支付信息配置删除
* @param merchantId
* @param mchId
*/
@Override
public void removeMerchantConfig(String merchantId) {
int count = merchantConfigMapper.removeMerchantConfig(merchantId);
public void removeMerchantConfig(String mchId) {
int count = merchantConfigMapper.removeMerchantConfig(mchId);
if(count > 0) return;
// TODO 抛业务异常
}
@ -62,11 +66,12 @@ public class MerchantServiceImp implements MerchantService {
@Override
public void updateMerchantConfig(MerchantConfigBO merchantConfigBO) {
// 证书上传服务器
String certPath = uplodWecPayCert(merchantConfigBO.getMerchantId(),merchantConfigBO.getCertfile());
//String certPath = uplodWecPayCert(merchantConfigBO.getMerchantId(),merchantConfigBO.getCertFile());
// 商户支付信息保存
merchantConfigBO.setCertPath(certPath);
MerchantConfig merchantConfig = new MerchantConfig();
BeanUtils.copyProperties(merchantConfig,merchantConfigBO);
//merchantConfig.setCertPath(certPath);
BeanUtils.copyProperties(merchantConfigBO,merchantConfig);
merchantConfig.setUpdateTime(new Date());
int count = merchantConfigMapper.updateMerchantConfig(merchantConfig);
if(count > 0) return;
// TODO 抛业务异常
@ -80,14 +85,14 @@ public class MerchantServiceImp implements MerchantService {
@Override
public List<MerchantConfigBO> queryMerchantConfig(MerchantConfigBO merchantConfigBO) {
MerchantConfig merchantConfig = new MerchantConfig();
BeanUtils.copyProperties(merchantConfig,merchantConfigBO);
BeanUtils.copyProperties(merchantConfigBO,merchantConfig);
List<MerchantConfig> merchantConfigList = merchantConfigMapper.queryMerchantConfig(merchantConfig);
if(!Optional.ofNullable(merchantConfigList).isPresent()){
// TODO 抛出业务异常
}
List<MerchantConfigBO> merchantConfigBOList = merchantConfigList.stream().map(t -> {
List<MerchantConfigBO> merchantConfigBOList = merchantConfigList.stream().map(o -> {
MerchantConfigBO result = new MerchantConfigBO();
BeanUtils.copyProperties(result, t);
BeanUtils.copyProperties(o, result);
return result;
}).collect(Collectors.toList());
return merchantConfigBOList;

261
payment-base-app/src/main/resources/com/base/payment/mapper/MerchantConfigMapper.xml

@ -4,254 +4,83 @@
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.MerchantConfig">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="app_id" jdbcType="VARCHAR" property="appId"/>
<result column="api_key" jdbcType="VARCHAR" property="appKey"/>
<result column="api_key" jdbcType="VARCHAR" property="apiKey"/>
<result column="cert_path" jdbcType="VARCHAR" property="certPath"/>
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId"/>
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
<result column="city_store_name" jdbcType="VARCHAR" property="cityStoreName"/>
<result column="store_brand_name" jdbcType="VARCHAR" property="storeBrandName"/>
<result column="sign_type" jdbcType="VARCHAR" property="signType"/>
<result column="private_key" jdbcType="VARCHAR" property="privateKey"/>
<result column="device_info" jdbcType="VARCHAR" property="deviceInfo"/>
<result column="spbill_create_ip" jdbcType="VARCHAR" property="spbillCreateIp"/>
<result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/>
<result column="serial_no" jdbcType="VARCHAR" property="serialNo"/>
<result column="mch_id" jdbcType="VARCHAR" property="mchId"/>
<result column="mch_private_key" jdbcType="VARCHAR" property="mchPrivateKey"/>
<result column="create_id" jdbcType="VARCHAR" property="createId"/>
<result column="create_depart_id" jdbcType="VARCHAR" property="createDepartId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_id" jdbcType="VARCHAR" property="updateId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="time_stamp" jdbcType="TIMESTAMP" property="timeStamp"/>
</resultMap>
<sql id="Base_Column_List">
id, app_id, api_key, cert_path, merchant_id, merchant_name, city_store_name, store_brand_name,
sign_type, private_key, device_info, spbill_create_ip, notify_url, time_stamp
id,app_id,api_key,cert_path,serial_no,mch_id,mch_private_key,
create_id,create_depart_id,create_time,update_id,update_time,time_stamp
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from pay_merchant_config
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from pay_merchant_config
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.base.springcloud.entity.MerchantConfig">
insert into pay_merchant_config (id, app_id, api_key,
cert_path, merchant_id, merchant_name,
city_store_name, store_brand_name, sign_type,
private_key, device_info, spbill_create_ip,
notify_url, time_stamp)
values (#{id,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR}, #{appKey,jdbcType=VARCHAR},
#{certPath,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR},
#{cityStoreName,jdbcType=VARCHAR}, #{storeBrandName,jdbcType=VARCHAR}, #{signType,jdbcType=VARCHAR},
#{privateKey,jdbcType=VARCHAR}, #{deviceInfo,jdbcType=VARCHAR}, #{spbillCreateIp,jdbcType=VARCHAR},
#{notifyUrl,jdbcType=VARCHAR}, #{timeStamp,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.base.springcloud.entity.MerchantConfig">
insert into pay_merchant_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="appId != null">
app_id,
</if>
<if test="appKey != null">
api_key,
</if>
<if test="certPath != null">
cert_path,
</if>
<if test="serialNo != null">
serial_no
</if>
<if test="merchantId != null">
merchant_id,
</if>
<if test="merchantName != null">
merchant_name,
</if>
<if test="cityStoreName != null">
city_store_name,
</if>
<if test="storeBrandName != null">
store_brand_name,
</if>
<if test="signType != null">
sign_type,
</if>
<if test="privateKey != null">
private_key,
</if>
<if test="deviceInfo != null">
device_info,
</if>
<if test="spbillCreateIp != null">
spbill_create_ip,
</if>
<if test="notifyUrl != null">
notify_url,
</if>
<if test="timeStamp != null">
time_stamp,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="appId != null">
#{appId,jdbcType=VARCHAR},
</if>
<if test="appKey != null">
#{appKey,jdbcType=VARCHAR},
</if>
<if test="certPath != null">
#{certPath,jdbcType=VARCHAR},
</if>
<if test="serialNo != null">
#{serialNo,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
#{merchantId,jdbcType=VARCHAR},
</if>
<if test="merchantName != null">
#{merchantName,jdbcType=VARCHAR},
</if>
<if test="cityStoreName != null">
#{cityStoreName,jdbcType=VARCHAR},
</if>
<if test="storeBrandName != null">
#{storeBrandName,jdbcType=VARCHAR},
</if>
<if test="signType != null">
#{signType,jdbcType=VARCHAR},
</if>
<if test="privateKey != null">
#{privateKey,jdbcType=VARCHAR},
</if>
<if test="deviceInfo != null">
#{deviceInfo,jdbcType=VARCHAR},
</if>
<if test="spbillCreateIp != null">
#{spbillCreateIp,jdbcType=VARCHAR},
</if>
<if test="notifyUrl != null">
#{notifyUrl,jdbcType=VARCHAR},
</if>
<if test="timeStamp != null">
#{timeStamp,jdbcType=TIMESTAMP},
</if>
</trim>
cert_path, serial_no,mch_id,mch_private_key, create_id, create_depart_id,
create_time, time_stamp)
values (#{id,jdbcType=VARCHAR}, #{appId,jdbcType=VARCHAR}, #{apiKey,jdbcType=VARCHAR},
#{certPath,jdbcType=VARCHAR}, #{serialNo,jdbcType=VARCHAR},#{mchId,jdbcType=VARCHAR}, #{mchPrivateKey,jdbcType=VARCHAR},
#{createId,jdbcType=VARCHAR}, #{createDepartId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{timeStamp,jdbcType=TIMESTAMP})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.MerchantConfig">
update pay_merchant_config
<set>
<if test="appId != null">
app_id = #{appId,jdbcType=VARCHAR},
</if>
<if test="appKey != null">
api_key = #{appKey,jdbcType=VARCHAR},
</if>
<if test="certPath != null">
cert_path = #{certPath,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=VARCHAR},
</if>
<if test="merchantName != null">
merchant_name = #{merchantName,jdbcType=VARCHAR},
</if>
<if test="cityStoreName != null">
city_store_name = #{cityStoreName,jdbcType=VARCHAR},
</if>
<if test="storeBrandName != null">
store_brand_name = #{storeBrandName,jdbcType=VARCHAR},
</if>
<if test="signType != null">
sign_type = #{signType,jdbcType=VARCHAR},
</if>
<if test="privateKey != null">
private_key = #{privateKey,jdbcType=VARCHAR},
</if>
<if test="deviceInfo != null">
device_info = #{deviceInfo,jdbcType=VARCHAR},
</if>
<if test="spbillCreateIp != null">
spbill_create_ip = #{spbillCreateIp,jdbcType=VARCHAR},
</if>
<if test="notifyUrl != null">
notify_url = #{notifyUrl,jdbcType=VARCHAR},
</if>
<if test="timeStamp != null">
time_stamp = #{timeStamp,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.MerchantConfig">
update pay_merchant_config
set app_id = #{appId,jdbcType=VARCHAR},
api_key = #{appKey,jdbcType=VARCHAR},
cert_path = #{certPath,jdbcType=VARCHAR},
merchant_id = #{merchantId,jdbcType=VARCHAR},
merchant_name = #{merchantName,jdbcType=VARCHAR},
city_store_name = #{cityStoreName,jdbcType=VARCHAR},
store_brand_name = #{storeBrandName,jdbcType=VARCHAR},
sign_type = #{signType,jdbcType=VARCHAR},
private_key = #{privateKey,jdbcType=VARCHAR},
device_info = #{deviceInfo,jdbcType=VARCHAR},
spbill_create_ip = #{spbillCreateIp,jdbcType=VARCHAR},
notify_url = #{notifyUrl,jdbcType=VARCHAR},
time_stamp = #{timeStamp,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
<delete id="removeMerchantConfig" parameterType="java.lang.String">
delete from pay_merchant_config
where merchant_id = #{merchantId,jdbcType=VARCHAR}
where mch_id = #{mchId,jdbcType=VARCHAR}
</delete>
<select id="queryMerchantConfig" parameterType="com.base.springcloud.entity.MerchantConfig" resultMap="BaseResultMap">
<select id="queryMerchantConfig" parameterType="com.base.springcloud.entity.MerchantConfig"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from pay_merchant_config
<where>
<if test="mchId != null">
mch_id = #{mchId,jdbcType=VARCHAR},
</if>
</where>
</select>
<update id="updateMerchantConfig" parameterType="com.base.springcloud.entity.MerchantConfig">
update pay_merchant_config
<set>
<if test="appId != null">
app_id = #{appId,jdbcType=VARCHAR},
</if>
<if test="appKey != null">
api_key = #{appKey,jdbcType=VARCHAR},
<if test="apiKey != null">
api_key = #{apiKey,jdbcType=VARCHAR},
</if>
<if test="certPath != null">
cert_path = #{certPath,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=VARCHAR},
</if>
<if test="merchantName != null">
merchant_name = #{merchantName,jdbcType=VARCHAR},
</if>
<if test="cityStoreName != null">
city_store_name = #{cityStoreName,jdbcType=VARCHAR},
</if>
<if test="storeBrandName != null">
store_brand_name = #{storeBrandName,jdbcType=VARCHAR},
</if>
<if test="signType != null">
sign_type = #{signType,jdbcType=VARCHAR},
</if>
<if test="privateKey != null">
private_key = #{privateKey,jdbcType=VARCHAR},
<if test="serialNo != null">
serial_no = #{serialNo,jdbcType=VARCHAR},
</if>
<if test="deviceInfo != null">
device_info = #{deviceInfo,jdbcType=VARCHAR},
<if test="mchPrivateKey != null">
mch_private_key = #{mchPrivateKey,jdbcType=VARCHAR},
</if>
<if test="spbillCreateIp != null">
spbill_create_ip = #{spbillCreateIp,jdbcType=VARCHAR},
<if test="updateId != null">
update_id = #{updateId,jdbcType=VARCHAR},
</if>
<if test="notifyUrl != null">
notify_url = #{notifyUrl,jdbcType=VARCHAR},
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="timeStamp != null">
time_stamp = #{timeStamp,jdbcType=TIMESTAMP},
</if>
</set>
<where>
mch_id = #{mchId,jdbcType=VARCHAR}
</where>
</select>
</update>
</mapper>
Loading…
Cancel
Save