切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
3 years ago
提交
928946e8eb2ba86ecf0e439de23b4bc4b9878a24
1 个父辈
8673f428
测试代付
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
23 行增加
和
5 行删除
application/api/controller/Order.php
application/api/controller/Order.php
查看文件 @
928946e
...
...
@@ -13,6 +13,8 @@ use app\api\model\Third;
use
app\api\model\UserAddress
;
use
app\api\model\UserCoupon
;
use
app\common\controller\Api
;
use
fast\Http
;
use
think\Config
;
use
think\Db
;
use
think\exception\PDOException
;
use
Yansongda\Pay\Pay
;
...
...
@@ -584,7 +586,7 @@ class Order extends Api
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="integer", required=true, description="订单ID")
* @ApiParams (name="
openid", type="string", required=false, description="代付人openid
")
* @ApiParams (name="
code", type="string", required=false, description="代付人code
")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
...
...
@@ -593,7 +595,7 @@ class Order extends Api
public
function
pay
()
{
$order_id
=
$this
->
request
->
post
(
'id'
);
$
openid
=
$this
->
request
->
post
(
'openid
'
);
$
code
=
$this
->
request
->
post
(
'code
'
);
empty
(
$order_id
)
&&
$this
->
error
(
'缺少必需参数'
);
$model
=
new
\app\api\model\Order
();
...
...
@@ -607,14 +609,30 @@ class Order extends Api
->
find
();
if
(
!
$third
)
$this
->
error
(
'下单人未注册'
);
// 获取代付人的openid
$openid
=
$third
[
'openid'
];
if
(
!
empty
(
$code
)){
$wxapi
=
Http
::
get
(
'https://api.weixin.qq.com/sns/jscode2session'
,[
'js_code'
=>
$code
,
'grant_type'
=>
'authorization_code'
,
'secret'
=>
Config
::
get
(
'site.secret'
),
'appid'
=>
Config
::
get
(
'site.appid'
)
]);
//请求openid
$wxapi
=
json_decode
(
$wxapi
,
true
);
if
(
isset
(
$wxapi
[
'errcode'
])){
$this
->
error
(
$wxapi
[
'errmsg'
]);
}
$openid
=
$wxapi
[
'openid'
];
}
$params
=
[
'type'
=>
'wechat'
,
'orderid'
=>
$order
[
'order_no'
],
'title'
=>
'订单号-'
.
$order
[
'order_no'
],
'amount'
=>
$order
[
'pay_price'
],
// 'amount' => 0.01,
// 'amount' => $order['pay_price'],
'amount'
=>
0.01
,
'method'
=>
'miniapp'
,
'openid'
=>
!
empty
(
$openid
)
?
$openid
:
$third
[
'openid'
]
,
'openid'
=>
$openid
,
'notifyurl'
=>
$this
->
request
->
domain
()
.
'/api/notify/orderNotify/type/wechat'
,
'returnurl'
=>
''
,
];
...
...
请
注册
或
登录
后发表评论