You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/application/wap/controller/Toutiao.php

69 lines
2.3 KiB

9 months ago
<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\wap\controller;
use app\admin\model\wechat\WechatReply;
use service\WechatService;
use think\Request;
use service\TouMiniProgramService;
use app\wap\model\store\StoreOrder as StoreOrderWapModel;
use behavior\wechat\PaymentBehavior;
use think\Log;
/**
* 微信服务器 验证控制器
* Class Wechat
* @package app\wap\controller
*/
class Toutiao
{
/**
* 支付 异步回调
*/
public function notify()
{
$notify = \request()->param();
// 验签
try {
if ($notify['msg_signature'] !== (new TouMiniProgramService)->callbackSign($notify)) {
return false;
} else {
//获取订单信息
$order=(string)htmlspecialchars_decode($notify['msg']);
$order = json_decode($order, true);
//处理订单,获取订单号
$sn = $order['cp_orderno'];
$data = ['err_no' => '0', 'err_tips' => 'success'];
if (StoreOrderWapModel::be(['order_id' => $sn, 'paid' => 1])) {
return json($data);
};
if(PaymentBehavior::douyinPaySuccess( $order)) {
//订单同步
(new TouMiniProgramService)->pushOrder($sn);
return json($data);
}else{
db()->rollback();
return false;
}
}
} catch (\Throwable $th) {
Log::write('抖音同步订单异常'.$th->getMessage());
}
}
}