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.
199 lines
6.1 KiB
199 lines
6.1 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
namespace App\Controller;
|
|
|
|
|
|
use App\Constants\v3\LogLabel;
|
|
use App\Constants\v3\OrderState;
|
|
use App\Constants\v3\OrderType;
|
|
use App\Libs\FeiePrintClient;
|
|
use App\Model\v3\OrderMain;
|
|
use App\Service\v3\Interfaces\CouponRebateServiceInterface;
|
|
use App\Service\v3\Interfaces\DeviceServiceInterface;
|
|
use App\Service\v3\Interfaces\FeiePrintServiceInterface;
|
|
use App\Service\v3\Interfaces\MiniprogramServiceInterface;
|
|
use App\Service\v3\Interfaces\MqttServiceInterface;
|
|
use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
|
|
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface;
|
|
use App\Service\v3\Interfaces\UserServiceInterface;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
use Hyperf\HttpServer\Annotation\AutoController;
|
|
use Hyperf\Utils\Coroutine;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use Hyperf\Task\TaskExecutor;
|
|
use Hyperf\Task\Task;
|
|
use App\TaskWorker\SSDBTask;
|
|
use App\Commons\Log;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
/**
|
|
* @AutoController()
|
|
* Class TestController
|
|
* @package App\Controller
|
|
*/
|
|
class TestController extends AbstractController
|
|
{
|
|
private $name = 'default action';
|
|
|
|
protected $client = null;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var MqttServiceInterface
|
|
*/
|
|
protected $mqttService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var DeviceServiceInterface
|
|
*/
|
|
protected $deviceService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var MiniprogramServiceInterface
|
|
*/
|
|
protected $miniprogramService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var FeiePrintServiceInterface
|
|
*/
|
|
protected $feiePrintService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var UserServiceInterface
|
|
*/
|
|
protected $userService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var CouponRebateServiceInterface
|
|
*/
|
|
protected $couponRebateService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var OrderOnlineServiceInterface
|
|
*/
|
|
protected $orderOnlineService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var SeparateAccountsServiceInterface
|
|
*/
|
|
protected $separateAccountsService;
|
|
|
|
public function index1(RequestInterface $request)
|
|
{
|
|
// $container = ApplicationContext::getContainer();
|
|
// $exec = $container->get(TaskExecutor::class);
|
|
// $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id()]));
|
|
|
|
// $client = ApplicationContext::getContainer()->get(SSDBTask::class);
|
|
// $result = $client->exec("set","bar","1234");
|
|
// $result = $client->exec("get","bar");
|
|
|
|
// $client = ApplicationContext::getContainer()->get(MethodTask::class);
|
|
// $result = $client->handle("set");
|
|
|
|
|
|
// //$log = ApplicationContext::getContainer()->get(Log::class);
|
|
// $log = $this->log;
|
|
//
|
|
// $log->push(['test'=>1,'user_id'=>290,'msg'=>'order']);
|
|
// $log->event('t1',['test'=>1,'user_id'=>290,'msg'=>'order']);
|
|
//
|
|
// //$this->name = 'index1 action '. $result;
|
|
// return $this->name;
|
|
|
|
// $time = time();
|
|
// $msgInfo = array(
|
|
// 'user' => '13161443713@163.com',
|
|
// 'stime' => $time,
|
|
// 'sig' => sha1('13161443713@163.com' . 'XsaHzgePdyWTfcMX' . $time),
|
|
// 'apiname' => 'Open_printMsg',
|
|
// 'sn' => '920527381',
|
|
// 'content' => '1111',
|
|
// 'times' => 1//打印次数
|
|
// );
|
|
// $this->client = new FeiePrintClient('api.feieyun.cn', 80);
|
|
// if (!$this->client->post('/Api/Open/', $msgInfo)) {
|
|
// return '12';
|
|
// } else {
|
|
// //服务器返回的JSON字符串,建议要当做日志记录起来
|
|
// $result = $this->client->getContent();
|
|
// return $result;
|
|
// }
|
|
|
|
$orderMainId = $this->request->input('order_main_id');
|
|
// 查询订单
|
|
$orderMain = OrderMain::query()
|
|
->where([
|
|
'id' => $orderMainId,
|
|
'type' => OrderType::ONLINE,
|
|
'state' => OrderState::UNPAID
|
|
])
|
|
->first();
|
|
|
|
// 订单不存在
|
|
if (empty($orderMain)) {
|
|
$this->log->event(
|
|
LogLabel::ORDER_OFFLINE_PAY_NOTIFY_LOG,
|
|
['global_order_id_fail' => $orderMainId]
|
|
);
|
|
return true;
|
|
}
|
|
// $orderPaid = $this->orderOfflineService->doPaid($orderMainId);
|
|
// var_dump('orderOfflineService', $orderPaid);
|
|
// $separate = $this->separateAccountsService->orderOfflinePaid($orderMainId);
|
|
// var_dump('separateAccountsService', $separate);
|
|
//
|
|
// // 喇叭通知,兼容旧音响,MQTT+IOT
|
|
// $res = $this->mqttService->speakToStore($orderMainId);
|
|
// var_dump('mqttService', $res);
|
|
// $res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMainId);
|
|
// var_dump('deviceService', $res);
|
|
//
|
|
// // 公众号模板消息
|
|
// $res = $this->miniprogramService->sendTemMsgForOfflineOrder($orderMainId);
|
|
// var_dump('miniprogramService', $res);
|
|
|
|
|
|
$res = $this->orderOnlineService->doByPaid($orderMainId);
|
|
var_dump('orderOnlineService', $res);
|
|
$res = $this->separateAccountsService->orderOnlinePaid($orderMainId);
|
|
var_dump('separateAccountsService', $res);
|
|
|
|
// 优惠券返券
|
|
$res = $this->couponRebateService->couponRebateInTask($orderMainId);
|
|
var_dump('couponRebateService', $res);
|
|
|
|
// 喇叭通知,兼容旧音响,MQTT+IOT
|
|
$res = $this->mqttService->speakToStore($orderMainId);
|
|
var_dump('mqttService', $res);
|
|
$res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMainId);
|
|
var_dump('deviceService', $res);
|
|
|
|
// 公众号模板消息
|
|
$res = $this->miniprogramService->sendTemMsgForOnlineOrder($orderMainId);
|
|
var_dump('miniprogramService', $res);
|
|
|
|
// 打印订单,自动打印
|
|
$res = $this->feiePrintService->feiePrint($orderMainId);
|
|
var_dump('feiePrintService', $res);
|
|
}
|
|
|
|
public function index2(RequestInterface $request)
|
|
{
|
|
$this->name = 'index2 action';
|
|
return $this->name;
|
|
}
|
|
|
|
public function index3(RequestInterface $request)
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|