xuyu 7 months ago
parent 70910a1c65
commit 804ca561a3
  1. 22
      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,16 +1108,18 @@ class Special extends AuthController
{ {
return $model->where(['order_id' => $orderId, 'paid' => 1, 'uid' => $this->uid])->count(); return $model->where(['order_id' => $orderId, 'paid' => 1, 'uid' => $this->uid])->count();
} }
/** /**
* 阅卷订单 * 阅卷订单
* [create_marking_papers_order description] * [create_marking_papers_order description]
* @param [type] $data_id [description] * @param [type] $data_id [description]
* @param [type] $payType [description] * @param [type] $payType [description]
* @param string $from [description] * @param string $from [description]
* @param [type] $returnUrl [description] * @param [type] $returnUrl [description]
* @return [type] [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); $testPaper = TestPaper::PreExercisesWhere()->find($test_id);
if (!$testPaper) return JsonService::status('ORDER_ERROR', '购买的试卷不存在'); if (!$testPaper) return JsonService::status('ORDER_ERROR', '购买的试卷不存在');
$order = TestPaperOrder::createTestPaperOrder($testPaper, $this->uid, $payType); $order = TestPaperOrder::createTestPaperOrder($testPaper, $this->uid, $payType);
@ -1201,6 +1203,7 @@ class Special extends AuthController
return JsonService::fail(TestPaperOrder::getErrorInfo('订单生成失败!')); return JsonService::fail(TestPaperOrder::getErrorInfo('订单生成失败!'));
} }
} }
/**创建试卷支付订单 /**创建试卷支付订单
* @param $test_id * @param $test_id
* @param $payType * @param $payType
@ -1950,7 +1953,7 @@ class Special extends AuthController
$is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0; $is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0;
$my = SpecialModel::getMyGradeList(1, 4, $this->uid, $is_member, 0); $my = SpecialModel::getMyGradeList(1, 4, $this->uid, $is_member, 0);
//$offlineCourse = (new \app\wap\model\special\OfflineCourse)->order('id desc')->limit(4)->select(); //$offlineCourse = (new \app\wap\model\special\OfflineCourse)->order('id desc')->limit(4)->select();
$activity = EventRegistration::eventRegistrationList(1, 4, "", 0 ,0); $activity = EventRegistration::eventRegistrationList(1, 4, "", 0, 0);
$uid = $this->uid; $uid = $this->uid;
$hot = SpecialModel::getSpecialList(['grade_id' => 0, 'subject_id' => 0, 'search' => '', 'page' => 1, 'limit' => 4, 'type' => 0, 'uid' => $uid, 'is_hot' => 1]); $hot = SpecialModel::getSpecialList(['grade_id' => 0, 'subject_id' => 0, 'search' => '', 'page' => 1, 'limit' => 4, 'type' => 0, 'uid' => $uid, 'is_hot' => 1]);
@ -2650,11 +2653,12 @@ class Special extends AuthController
try { try {
switch ($from) { switch ($from) {
case 'weixinh5': case 'weixinh5':
$jsConfig = StoreOrder::h5Pay($order); $jsConfig = StoreOrder::h5Pay($order);
break; // $jsConfig = StoreOrder::jsPay($order);
case 'weixin':
$jsConfig = StoreOrder::jsPay($order);
break; break;
// case 'weixin':
// $jsConfig = StoreOrder::jsPay($order);
// break;
case 'mpweixing': case 'mpweixing':
$jsConfig = StoreOrder::WeixinMiniPay($order); $jsConfig = StoreOrder::WeixinMiniPay($order);
break; break;
@ -2664,7 +2668,9 @@ class Special extends AuthController
$info['jsConfig'] = $jsConfig; $info['jsConfig'] = $jsConfig;
switch ($from) { switch ($from) {
case 'weixinh5': case 'weixinh5':
return JsonService::status('wechat_h5_pay', '订单创建成功', $info); //11
return JsonService::status('wechat_pay', '订单创建成功', $info);
// return JsonService::status('wechat_h5_pay', '订单创建成功', $info);
break; break;
case 'mpweixing': case 'mpweixing':
return JsonService::status('WECHAT_ROUTINE_PAY', '订单创建成功', $info); return JsonService::status('WECHAT_ROUTINE_PAY', '订单创建成功', $info);

@ -26,6 +26,7 @@ use service\SystemConfigService;
use service\WechatService; use service\WechatService;
use service\WechatTemplateService; use service\WechatTemplateService;
use think\Cache; use think\Cache;
use think\Log;
use think\Url; use think\Url;
use traits\ModelTrait; use traits\ModelTrait;
use app\wap\model\user\MemberShip; use app\wap\model\user\MemberShip;
@ -586,7 +587,17 @@ class StoreOrder extends ModelBasic
if ($orderInfo['paid']) exception('支付已支付!'); if ($orderInfo['paid']) exception('支付已支付!');
if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!'); if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
$openid = WechatUser::uidToOpenid($orderInfo['uid']); $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') public static function h5Pay($orderId, $field = 'order_id')
{ {
//11
if (is_string($orderId)) if (is_string($orderId))
$orderInfo = self::where($field, $orderId)->find(); $orderInfo = self::where($field, $orderId)->where('type', 2)->find();
else else
$orderInfo = $orderId; $orderInfo = $orderId;
if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!'); if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
if ($orderInfo['paid']) exception('支付已支付!'); if ($orderInfo['paid']) exception('支付已支付!');
if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!'); if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
$site_name = SystemConfigService::get('site_name'); $openid = WechatUser::uidToOpenid($orderInfo['uid']);
if (!$site_name) exception('支付参数缺少:请前往后台设置->系统设置-> 填写 网站名称'); $res = MiniProgramService::appPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name'));
return WechatService::paymentPrepare(null, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', self::getSubstrUTf8($site_name . '-商品购买', 30), '', 'MWEB');
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\Payment\Order;
use EasyWeChat\Server\Guard; use EasyWeChat\Server\Guard;
use EasyWeChat\Support\XML; use EasyWeChat\Support\XML;
use think\Log;
use think\Request; use think\Request;
use think\Url; use think\Url;

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

Loading…
Cancel
Save