|
@@ -17,6 +17,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
|
import shop.alien.entity.result.R;
|
|
import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
@@ -1804,6 +1805,64 @@ public class StoreInfoController {
|
|
|
return R.fail("查询失败: " + e.getMessage());
|
|
return R.fail("查询失败: " + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置收款账号(接收表单参数及证书/图片等文件上传)
|
|
|
|
|
+ * 账号类型为微信时:传 appid、mchid、API证书序列号、APIv3 Key、支付公钥ID、私钥证书(.pem)、公钥证书(.pem)
|
|
|
|
|
+ * 账号类型为支付宝时:传 应用ID、应用私钥、应用公钥证书(.crt)、支付宝公钥证书(.crt)、支付宝根证书(.crt)
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperation("设置收款账号")
|
|
|
|
|
+ @ApiOperationSupport(order = 100)
|
|
|
|
|
+ @PostMapping(value = "/setCollectionAccount", consumes = "multipart/form-data")
|
|
|
|
|
+ public R<String> setCollectionAccount(
|
|
|
|
|
+ @ApiParam(value = "账号类型:wechat-微信,alipay-支付宝", required = true) @RequestParam("accountType") String accountType,
|
|
|
|
|
+ @ApiParam("微信-appid") @RequestParam(value = "appid", required = false) String appid,
|
|
|
|
|
+ @ApiParam("微信-商户号mchid") @RequestParam(value = "mchid", required = false) String mchid,
|
|
|
|
|
+ @ApiParam("微信-API证书序列号") @RequestParam(value = "apiCertificateSerialNumber", required = false) String apiCertificateSerialNumber,
|
|
|
|
|
+ @ApiParam("微信-APIv3 Key") @RequestParam(value = "apiV3Key", required = false) String apiV3Key,
|
|
|
|
|
+ @ApiParam("微信-支付公钥ID") @RequestParam(value = "paymentPublicKeyId", required = false) String paymentPublicKeyId,
|
|
|
|
|
+ @ApiParam("微信-私钥证书(.pem)") @RequestParam(value = "privateKeyCert", required = false) MultipartFile privateKeyCert,
|
|
|
|
|
+ @ApiParam("微信-公钥证书(.pem)") @RequestParam(value = "publicKeyCert", required = false) MultipartFile publicKeyCert,
|
|
|
|
|
+ @ApiParam("支付宝-应用ID") @RequestParam(value = "appId", required = false) String appId,
|
|
|
|
|
+ @ApiParam("支付宝-应用私钥") @RequestParam(value = "appPrivateKey", required = false) String appPrivateKey,
|
|
|
|
|
+ @ApiParam("支付宝-应用公钥证书(.crt)") @RequestParam(value = "appPublicKeyCert", required = false) MultipartFile appPublicKeyCert,
|
|
|
|
|
+ @ApiParam("支付宝-支付宝公钥证书(.crt)") @RequestParam(value = "alipayPublicKeyCert", required = false) MultipartFile alipayPublicKeyCert,
|
|
|
|
|
+ @ApiParam("支付宝-支付宝根证书(.crt)") @RequestParam(value = "alipayRootCert", required = false) MultipartFile alipayRootCert
|
|
|
|
|
+ ) {
|
|
|
|
|
+ log.info("StoreInfoController.setCollectionAccount accountType={}, appid={}, mchid={}, appId={}",
|
|
|
|
|
+ accountType, appid, mchid, appId);
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (StringUtils.isBlank(accountType)) {
|
|
|
|
|
+ return R.fail("账号类型不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("wechat".equalsIgnoreCase(accountType)) {
|
|
|
|
|
+ if (StringUtils.isAnyBlank(appid, mchid, apiCertificateSerialNumber, apiV3Key, paymentPublicKeyId)) {
|
|
|
|
|
+ return R.fail("微信账号:appid、mchid、API证书序列号、APIv3 Key、支付公钥ID为必填");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (privateKeyCert == null || privateKeyCert.isEmpty() || publicKeyCert == null || publicKeyCert.isEmpty()) {
|
|
|
|
|
+ return R.fail("微信账号:私钥证书、公钥证书为必传,支持.pem格式,大小不超过2MB");
|
|
|
|
|
+ }
|
|
|
|
|
+ // TODO: 校验 .pem 格式、大小 2MB,落库或写配置
|
|
|
|
|
+ return R.success("微信收款账号参数已接收,待接入存储逻辑");
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("alipay".equalsIgnoreCase(accountType)) {
|
|
|
|
|
+ if (StringUtils.isAnyBlank(appId, appPrivateKey)) {
|
|
|
|
|
+ return R.fail("支付宝账号:应用ID、应用私钥为必填");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (appPublicKeyCert == null || appPublicKeyCert.isEmpty()
|
|
|
|
|
+ || alipayPublicKeyCert == null || alipayPublicKeyCert.isEmpty()
|
|
|
|
|
+ || alipayRootCert == null || alipayRootCert.isEmpty()) {
|
|
|
|
|
+ return R.fail("支付宝账号:应用公钥证书、支付宝公钥证书、支付宝根证书为必传,支持.crt格式");
|
|
|
|
|
+ }
|
|
|
|
|
+ // TODO: 校验 .crt 格式,落库或写配置
|
|
|
|
|
+ return R.success("支付宝收款账号参数已接收,待接入存储逻辑");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.fail("账号类型仅支持 wechat 或 alipay");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("设置收款账号异常", e);
|
|
|
|
|
+ return R.fail(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 店铺信息(包含商户头像)
|
|
* 店铺信息(包含商户头像)
|
|
@@ -1823,4 +1882,5 @@ public class StoreInfoController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|