lqmac 8 months ago
parent 11f1c6f958
commit e67fd273af
  1. 10
      app/api/model/PaymentTemplate.php
  2. 9
      app/common/model/PaymentTemplate.php
  3. 1
      app/store/controller/Store.php
  4. 22
      app/store/model/PaymentTemplate.php

@ -35,14 +35,4 @@ class PaymentTemplate extends PaymentTemplateModel
'create_time', 'create_time',
'update_time' 'update_time'
]; ];
/**
* 根据微信支付V3平台证书序号查找记录
* @param string $serial
* @return static|array|null
*/
public static function findByWechatpaySerial(string $serial)
{
return static::get(['method' => PaymentMethodEnum::WECHAT, 'wechatpay_serial' => $serial,'is_delete' => 0]);
}
} }

@ -30,6 +30,15 @@ class PaymentTemplate extends BaseModel
// 定义主键 // 定义主键
protected $pk = 'template_id'; protected $pk = 'template_id';
/**
* 根据微信支付V3平台证书序号查找记录
* @param string $serial
* @return static|array|null
*/
public static function findByWechatpaySerial(string $serial)
{
return static::get(['method' => PaymentMethodEnum::WECHAT, 'wechatpay_serial' => $serial,'is_delete' => 0]);
}
/** /**
* 获取器:支付配置 * 获取器:支付配置
* @param string $value * @param string $value

@ -23,6 +23,7 @@ use app\common\model\PriceSet;
* Class Store * Class Store
* @package app\store\controller * @package app\store\controller
*/ */
class Store extends Controller class Store extends Controller
{ {
/** /**

@ -1,13 +1,4 @@
<?php <?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1); declare (strict_types=1);
namespace app\store\model; namespace app\store\model;
@ -60,6 +51,14 @@ class PaymentTemplate extends PaymentTemplateModel
$data['store_id'] = self::$storeId; $data['store_id'] = self::$storeId;
// 写入证书文件 // 写入证书文件
$data['config'] = [$data['method'] => $this->certFileName($data['method'], $methodConfig)]; $data['config'] = [$data['method'] => $this->certFileName($data['method'], $methodConfig)];
// 记录微信支付v3平台证书序号
if ($data['method'] === 'wechat' && $data['config']['wechat']['version'] === 'v3') {
$data['wechatpay_serial'] = $data['config']['wechat'][$data['config']['wechat']['mchType']]['platformCertSerial'];
$info = PaymentTemplateModel::findByWechatpaySerial($data['wechatpay_serial']);
if ($info) {
throwError("当前商户号已使用过了");
}
}
// 写入到数据库 // 写入到数据库
return $this->save($data); return $this->save($data);
} }
@ -83,6 +82,11 @@ class PaymentTemplate extends PaymentTemplateModel
// 记录微信支付v3平台证书序号 // 记录微信支付v3平台证书序号
if ($data['method'] === 'wechat' && $data['config']['wechat']['version'] === 'v3') { if ($data['method'] === 'wechat' && $data['config']['wechat']['version'] === 'v3') {
$data['wechatpay_serial'] = $data['config']['wechat'][$data['config']['wechat']['mchType']]['platformCertSerial']; $data['wechatpay_serial'] = $data['config']['wechat'][$data['config']['wechat']['mchType']]['platformCertSerial'];
$info = PaymentTemplateModel::findByWechatpaySerial($data['wechatpay_serial']);
if ($info && $info->template_id != $data['templateId']) {
throwError("当前商户号已使用过了");
}
} }
// 更新到数据库 // 更新到数据库
return $this->save($data) !== false; return $this->save($data) !== false;

Loading…
Cancel
Save