增加凭证支付,审核

This commit is contained in:
邹景立 2021-03-09 15:45:02 +08:00
parent 3597f7a760
commit b0ee504c5c
8 changed files with 86 additions and 21 deletions

View File

@ -28,6 +28,9 @@ class ShopOrder extends Controller
*/
protected $payments = [];
/**
* 控制器初始化
*/
protected function initialize()
{
parent::initialize();
@ -46,7 +49,7 @@ class ShopOrder extends Controller
{
$this->title = '订单数据管理';
// 状态数据统计
$this->total = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0, 'ta' => 0];
$this->total = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0, 't6' => 0, 'ta' => 0];
$this->app->db->name($this->table)->fieldRaw('status,count(1) total')->group('status')->select()->map(function ($vo) {
$this->total["t{$vo['status']}"] = $vo['total'];
$this->total["ta"] += $vo['total'];

View File

@ -22,7 +22,7 @@ class News extends Controller
{
$query = $this->_query('DataNewsMark')->like('name');
$query->where(['status' => 1, 'deleted' => 0])->withoutField('sort,status,deleted');
$this->success('获取文章标签列表', $query->order('sort desc,id desc')->page(false, false));
$this->success('获取文章标签', $query->order('sort desc,id desc')->page(false, false));
}
/**
@ -47,7 +47,7 @@ class News extends Controller
$query->where(['deleted' => 0, 'status' => 1])->withoutField('sort,status,deleted');
$result = $query->order('sort desc,id desc')->page(true, false, false, 15);
NewsService::instance()->buildListState($result['list'], input('uid', 0));
$this->success('获取列表成功!', $result);
$this->success('获取文章内容', $result);
}
/**
@ -62,7 +62,7 @@ class News extends Controller
$query = $this->_query('DataNewsXCollect')->where(['type' => 4, 'status' => 2]);
$result = $query->where($map)->order('id desc')->page(true, false, false, 15);
NewsService::instance()->buildListByUidAndCode($result['list']);
$this->success('获取评论成功', $result);
$this->success('获取评论成功', $result);
}
}

View File

@ -3,7 +3,7 @@
namespace app\data\controller\api;
use app\data\service\payment\AlipayPaymentService;
use app\data\service\payment\JoinPaymentService;
use app\data\service\payment\JoinpayPaymentService;
use app\data\service\payment\WechatPaymentService;
use think\admin\Controller;
@ -68,7 +68,7 @@ class Notify extends Controller
public function joinpay(string $scene = 'order', string $param = ''): string
{
if (strtolower($scene) === 'order') {
return JoinPaymentService::instance($param)->notify();
return JoinpayPaymentService::instance($param)->notify();
} else {
return 'success';
}

View File

@ -5,7 +5,8 @@ namespace app\data\service;
use app\data\service\payment\AlipayPaymentService;
use app\data\service\payment\BalancePyamentService;
use app\data\service\payment\EmptyPaymentService;
use app\data\service\payment\JoinPaymentService;
use app\data\service\payment\JoinpayPaymentService;
use app\data\service\payment\VoucherPaymentService;
use app\data\service\payment\WechatPaymentService;
use think\App;
use think\Container;
@ -22,6 +23,7 @@ abstract class PaymentService
// 用户余额支付
const PAYMENT_EMPTY = 'empty';
const PAYMENT_BALANCE = 'balance';
const PAYMENT_VOUCHER = 'voucher';
// 汇聚支付参数
const PAYMENT_JOINPAY_GZH = 'joinpay_gzh';
@ -56,6 +58,15 @@ abstract class PaymentService
UserService::APITYPE_IOSAPP, UserService::APITYPE_ANDROID,
],
],
self::PAYMENT_VOUCHER => [
'type' => 'VOUCHER',
'name' => '凭证单据支付',
'bind' => [
UserService::APITYPE_WAP, UserService::APITYPE_WEB,
UserService::APITYPE_WXAPP, UserService::APITYPE_WECHAT,
UserService::APITYPE_IOSAPP, UserService::APITYPE_ANDROID,
],
],
self::PAYMENT_WECHAT_WAP => [
'type' => 'MWEB',
'name' => '微信WAP支付',
@ -155,8 +166,8 @@ abstract class PaymentService
/**
* 根据配置实例支付服务
* @param string $code 支付参数编号
* @return JoinPaymentService|WechatPaymentService|AlipayPaymentService
* @param string $code 支付配置编号
* @return JoinpayPaymentService|WechatPaymentService|AlipayPaymentService|BalancePyamentService|VoucherPaymentService|EmptyPaymentService
* @throws Exception
*/
public static function instance(string $code): PaymentService
@ -171,12 +182,14 @@ abstract class PaymentService
// 实例化具体支付参数类型
if (stripos($type, 'balance') === 0) {
return static::$driver[$code] = Container::getInstance()->make(BalancePyamentService::class, $vars);
} elseif (stripos($type, 'voucher') === 0) {
return static::$driver[$code] = Container::getInstance()->make(VoucherPaymentService::class, $vars);
} elseif (stripos($type, 'alipay_') === 0) {
return static::$driver[$code] = Container::getInstance()->make(AlipayPaymentService::class, $vars);
} elseif (stripos($type, 'wechat_') === 0) {
return static::$driver[$code] = Container::getInstance()->make(WechatPaymentService::class, $vars);
} elseif (stripos($type, 'joinpay_') === 0) {
return static::$driver[$code] = Container::getInstance()->make(JoinPaymentService::class, $vars);
return static::$driver[$code] = Container::getInstance()->make(JoinpayPaymentService::class, $vars);
} else {
throw new Exception(sprintf('支付驱动[%s]未定义', $type));
}
@ -211,7 +224,7 @@ abstract class PaymentService
* 获取通道配置参数
* @param string $code
* @param array $payment
* @return array [code,type,params]
* @return array [code, type, params]
* @throws Exception
*/
public static function config(string $code, array $payment = []): array
@ -238,7 +251,7 @@ abstract class PaymentService
}
/**
* 订单更新操作
* 订单支付更新操作
* @param string $orderNo 订单单号
* @param string $paymentTrade 交易单号
* @param string $paymentAmount 支付金额
@ -250,13 +263,18 @@ abstract class PaymentService
*/
public function updateOrder(string $orderNo, string $paymentTrade, string $paymentAmount, $paymentRemark = '在线支付'): bool
{
// 检查订单支付状态
$map = ['order_no' => $orderNo, 'payment_status' => 0, 'status' => 2];
$map = ['status' => 2, 'order_no' => $orderNo, 'payment_status' => 0];
$order = $this->app->db->name('ShopOrder')->where($map)->find();
if (empty($order)) return false;
// 检查订单支付状态
if ($this->type === self::PAYMENT_VOUCHER) {
$status = 3;
} else {
$status = 4;
}
// 更新订单支付状态
$data = [
'status' => 3,
'status' => $status,
'payment_type' => $this->type,
'payment_code' => $this->code,
'payment_trade' => $paymentTrade,

View File

@ -56,6 +56,6 @@ class EmptyPaymentService extends PaymentService
$this->createPaymentAction($orderNo, $paymentTitle, $paymentAmount);
// 更新支付行为
$this->updatePaymentAction($orderNo, CodeExtend::uniqidDate(20), $paymentAmount, '无需支付');
return ['info' => '无需支付'];
return ['info' => '无需支付', 'status' => 1];
}
}

View File

@ -8,10 +8,10 @@ use think\admin\Exception;
/**
* 汇聚支付基础服务
* Class JoinPaymentService
* Class JoinpayPaymentService
* @package app\store\service\payment
*/
class JoinPaymentService extends PaymentService
class JoinpayPaymentService extends PaymentService
{
/**
* 请求地址
@ -45,9 +45,9 @@ class JoinPaymentService extends PaymentService
/**
* 汇聚支付服务初始化
* @return JoinPaymentService
* @return JoinpayPaymentService
*/
protected function initialize(): JoinPaymentService
protected function initialize(): JoinpayPaymentService
{
$this->appid = $this->params['joinpay_appid'];
$this->trade = $this->params['joinpay_trade'];;

View File

@ -0,0 +1,44 @@
<?php
namespace app\data\service\payment;
use app\data\service\PaymentService;
/**
* 凭证单据支付
* Class VoucherPaymentService
* @package app\data\service\payment
*/
class VoucherPaymentService extends PaymentService
{
/**
* @param string $orderNo
* @return array
*/
public function query(string $orderNo): array
{
// TODO: Implement query() method.
}
/**
* @return string
*/
public function notify(): string
{
// TODO: Implement notify() method.
}
/**
* @param string $openid
* @param string $orderNo
* @param string $paymentAmount
* @param string $paymentTitle
* @param string $paymentRemark
* @param string $paymentReturn
* @return array
*/
public function create(string $openid, string $orderNo, string $paymentAmount, string $paymentTitle, string $paymentRemark, string $paymentReturn = ''): array
{
// TODO: Implement create() method.
}
}

View File

@ -59,8 +59,8 @@ class WechatPaymentService extends PaymentService
'openid' => $openid,
'attach' => $this->code,
'out_trade_no' => $orderNo,
'total_fee' => $paymentAmount * 100,
'trade_type' => $tradeType ?: '',
'total_fee' => $paymentAmount * 100,
'notify_url' => sysuri("@data/api.notify/wxpay/scene/order/param/{$this->code}", [], false, true),
'spbill_create_ip' => $this->app->request->ip(),
];