init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Maiyatian\Controller;
|
||||
|
||||
use Think\Controller;
|
||||
use Common\Lib\Maiyatian;
|
||||
use Common\Lib\MaiyatianBase;
|
||||
use Common\Lib\MaiyatianEvent;
|
||||
use Common\Model\RetailMaiyatianOrderModel;
|
||||
|
||||
|
||||
class ExpressController extends Controller
|
||||
{
|
||||
|
||||
public function code()
|
||||
{
|
||||
$code = I('get.code');
|
||||
$id = I('get.state/d', 0);
|
||||
$result = (new Maiyatian($id))->token($code);
|
||||
if (isset($result['token'])) {
|
||||
(new \Common\Model\StoreModel)->where(['id' => $result['shop_id']])->save([
|
||||
'maiyatian_token' => $result['token'],
|
||||
'maiyatian_refresh_token' => $result['refresh_token'],
|
||||
'maiyatian_expire_time' => $result['expire_time'],
|
||||
'maiyatian_refresh_expire_time' => $result['refresh_expire_time'],
|
||||
]);
|
||||
}
|
||||
redirect('https://www.maiyatian.com/');
|
||||
}
|
||||
|
||||
public function oauth()
|
||||
{
|
||||
redirect((new Maiyatian(I('get.id/d', 0)))->oauth());
|
||||
}
|
||||
|
||||
public function notification()
|
||||
{
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/notification.txt', file_get_contents('php://input') . PHP_EOL, FILE_APPEND);
|
||||
$data = @json_decode(file_get_contents('php://input'), true);
|
||||
$verify = (new MaiyatianBase)->sign($data, $data['command'], $data['token']);
|
||||
(new \Common\Model\EventsModel)->add([
|
||||
'event' => $data['command'],
|
||||
'data' => json_encode($data, JSON_UNESCAPED_UNICODE),
|
||||
'verify' => $verify['signature'] === $data['signature'] ? 1 : 0,
|
||||
'create_time' => time(),
|
||||
]);
|
||||
if (!isset($data['signature']) || $verify['signature'] !== $data['signature']) {
|
||||
$this->ajaxReturn([
|
||||
'code' => 200,
|
||||
'message' => 'signature'
|
||||
]);
|
||||
}
|
||||
|
||||
$event = preg_replace_callback('/\_([a-z])/', function ($match) {
|
||||
return strtoupper($match[1]);
|
||||
}, $data['command']);
|
||||
$maiyatianEvent = new MaiyatianEvent();
|
||||
if (method_exists($maiyatianEvent, $event)) {
|
||||
$this->ajaxReturn($maiyatianEvent->$event(@json_decode($data['data'], true)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function sendOrder()
|
||||
{
|
||||
// $data = (new RetailMaiyatianOrderModel)->where(['id' => 4])->find();
|
||||
// $data['order'] = @json_decode($data['order'], true);
|
||||
// $data['order_customer'] = @json_decode($data['order_customer'], true);
|
||||
// $maiyatian = new Maiyatian($data['order']['shop_id']);
|
||||
// if ($maiyatian->orderCreated([
|
||||
// 'order' => $data['order'],
|
||||
// 'order_customer' => $data['order_customer'],
|
||||
// 'update_time' => $data['update_time'],
|
||||
// ])) {
|
||||
// $this->ajaxReturn($maiyatian->orderConfirmed($data['order']['order_id']));
|
||||
// }
|
||||
|
||||
$maiyatian = new Maiyatian(1);
|
||||
var_dump($maiyatian->orderDone('202409049686000248'));
|
||||
}
|
||||
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户