xuyu 7 months ago
parent 70910a1c65
commit 804ca561a3
  1. 16
      application/wap/controller/Special.php
  2. 41
      application/wap/model/store/StoreOrder.php
  3. 1
      extend/service/WechatService.php
  4. 3
      vendor/overtrue/wechat/src/Payment/API.php

@ -1108,6 +1108,7 @@ class Special extends AuthController
{
return $model->where(['order_id' => $orderId, 'paid' => 1, 'uid' => $this->uid])->count();
}
/**
* 阅卷订单
* [create_marking_papers_order description]
@ -1117,7 +1118,8 @@ class Special extends AuthController
* @param [type] $returnUrl [description]
* @return [type] [description]
*/
public function create_marking_papers_order($data_id, $payType, $from = 'weixin', $returnUrl){
public function create_marking_papers_order($data_id, $payType, $from = 'weixin', $returnUrl)
{
$testPaper = TestPaper::PreExercisesWhere()->find($test_id);
if (!$testPaper) return JsonService::status('ORDER_ERROR', '购买的试卷不存在');
$order = TestPaperOrder::createTestPaperOrder($testPaper, $this->uid, $payType);
@ -1201,6 +1203,7 @@ class Special extends AuthController
return JsonService::fail(TestPaperOrder::getErrorInfo('订单生成失败!'));
}
}
/**创建试卷支付订单
* @param $test_id
* @param $payType
@ -2651,10 +2654,11 @@ class Special extends AuthController
switch ($from) {
case 'weixinh5':
$jsConfig = StoreOrder::h5Pay($order);
// $jsConfig = StoreOrder::jsPay($order);
break;
case 'weixin':
$jsConfig = StoreOrder::jsPay($order);
break;
// case 'weixin':
// $jsConfig = StoreOrder::jsPay($order);
// break;
case 'mpweixing':
$jsConfig = StoreOrder::WeixinMiniPay($order);
break;
@ -2664,7 +2668,9 @@ class Special extends AuthController
$info['jsConfig'] = $jsConfig;
switch ($from) {
case 'weixinh5':
return JsonService::status('wechat_h5_pay', '订单创建成功', $info);
//11
return JsonService::status('wechat_pay', '订单创建成功', $info);
// return JsonService::status('wechat_h5_pay', '订单创建成功', $info);
break;
case 'mpweixing':
return JsonService::status('WECHAT_ROUTINE_PAY', '订单创建成功', $info);

@ -26,6 +26,7 @@ use service\SystemConfigService;
use service\WechatService;
use service\WechatTemplateService;
use think\Cache;
use think\Log;
use think\Url;
use traits\ModelTrait;
use app\wap\model\user\MemberShip;
@ -586,7 +587,17 @@ class StoreOrder extends ModelBasic
if ($orderInfo['paid']) exception('支付已支付!');
if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
$openid = WechatUser::uidToOpenid($orderInfo['uid']);
return WechatService::jsPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name'));
$res = MiniProgramService::appPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name'));
return [
'appid' => $res['appid'],
'partnerid' => $res['partnerid'],
'prepayid' => $res['prepayid']['prepay_id'],
'package'=> $res['package'],
'noncestr'=> $res['noncestr'],
'sign' => $res['sign'],
'timestamp' => $res['timestamp']
];
}
/**
* 微信小程序支付
@ -684,16 +695,36 @@ class StoreOrder extends ModelBasic
*/
public static function h5Pay($orderId, $field = 'order_id')
{
//11
if (is_string($orderId))
$orderInfo = self::where($field, $orderId)->find();
$orderInfo = self::where($field, $orderId)->where('type', 2)->find();
else
$orderInfo = $orderId;
if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
if ($orderInfo['paid']) exception('支付已支付!');
if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
$site_name = SystemConfigService::get('site_name');
if (!$site_name) exception('支付参数缺少:请前往后台设置->系统设置-> 填写 网站名称');
return WechatService::paymentPrepare(null, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', self::getSubstrUTf8($site_name . '-商品购买', 30), '', 'MWEB');
$openid = WechatUser::uidToOpenid($orderInfo['uid']);
$res = MiniProgramService::appPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name'));
return [
'appid' => $res['appid'],
'partnerid' => $res['partnerid'],
'prepayid' => $res['prepayid']['prepay_id'],
'package'=> $res['package'],
'noncestr'=> $res['noncestr'],
'sign' => $res['sign'],
'timestamp' => $res['timestamp']
];
// if (is_string($orderId))
// $orderInfo = self::where($field, $orderId)->find();
// else
// $orderInfo = $orderId;
// if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
// if ($orderInfo['paid']) exception('支付已支付!');
// if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
// $site_name = SystemConfigService::get('site_name');
// if (!$site_name) exception('支付参数缺少:请前往后台设置->系统设置-> 填写 网站名称');
// return WechatService::paymentPrepare(null, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', self::getSubstrUTf8($site_name . '-商品购买', 30), '', 'MWEB');
}
/**商品余额支付

@ -26,6 +26,7 @@ use EasyWeChat\Message\Voice;
use EasyWeChat\Payment\Order;
use EasyWeChat\Server\Guard;
use EasyWeChat\Support\XML;
use think\Log;
use think\Request;
use think\Url;

@ -28,6 +28,7 @@ use EasyWeChat\Core\Exception;
use EasyWeChat\Support\Collection;
use EasyWeChat\Support\XML;
use Psr\Http\Message\ResponseInterface;
use think\Log;
/**
* Class API.
@ -446,7 +447,7 @@ class API extends AbstractAPI
$params['device_info'] = $this->merchant->device_info;
$params['nonce_str'] = uniqid();
$params = array_filter($params);
Log::error("安卓app请求参数:".jsOn_encode($params).' 请求地址:'.$api);
$params['sign'] = generate_sign($params, $this->getSignkey($api), 'md5');
$options = array_merge([

Loading…
Cancel
Save