开放接口统一化
This commit is contained in:
110
admin/controllers/OpenApiController.php
Normal file
110
admin/controllers/OpenApiController.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace admin\controllers;
|
||||
|
||||
use admin\components\BaseAdminController;
|
||||
use common\events\PrescriptionEvent;
|
||||
use common\events\ProductOrderEvent;
|
||||
use common\forms\ProductCancelForm;
|
||||
use common\forms\ProductRefundForm;
|
||||
use common\helpers\FuncHelper;
|
||||
use common\jobs\ProductOrderSyncJob;
|
||||
use common\jobs\Sms\WaitApprovalMessageJob;
|
||||
use common\jobs\templateMessage\PrescriptionCreated;
|
||||
use common\models\oldDb\Prescription;
|
||||
use common\models\oldDb\ProductOrder;
|
||||
use common\models\oldDb\ProductOrderLog;
|
||||
use common\models\oldDb\Reconciliation;
|
||||
use common\models\oldDb\Register;
|
||||
use common\models\oldDb\Store;
|
||||
use common\models\oldDb\User;
|
||||
use common\services\JacErpService;
|
||||
use common\services\WeappService;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\db\Exception;
|
||||
use yii\helpers\Json;
|
||||
|
||||
|
||||
class OpenApiController extends BaseAdminController
|
||||
{
|
||||
|
||||
public $optional = [
|
||||
'notify-order-generation',
|
||||
'send-order',
|
||||
];
|
||||
|
||||
|
||||
public function actionNotifyOrderGeneration()
|
||||
{
|
||||
$prescription = \Yii::$app->request->post('prescription');
|
||||
|
||||
//处方开具待支付订阅消息通知
|
||||
\Yii::$app->queue->push(new PrescriptionCreated([
|
||||
'orderId' => $prescription,
|
||||
]));
|
||||
|
||||
|
||||
//处方生成短信通知药师审方
|
||||
\Yii::$app->queue->push(new WaitApprovalMessageJob([
|
||||
'orderId' => $prescription,
|
||||
]));
|
||||
return ['ok'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理处方过期
|
||||
* @return string[]
|
||||
* @throws \yii\base\Exception
|
||||
*/
|
||||
public function prescriptionOver(): array
|
||||
{
|
||||
$orderId = \Yii::$app->request->post('order_id');
|
||||
$userId = \Yii::$app->request->post('user_id');
|
||||
$type = \Yii::$app->request->post('type');
|
||||
if($type === 1){
|
||||
// 自动退款
|
||||
$ProductRefundForm = new ProductRefundForm();
|
||||
$ProductRefundForm->refund([
|
||||
'order_id' => $orderId,
|
||||
'user_id' => $userId
|
||||
]);
|
||||
} else {
|
||||
// 订单自动失效
|
||||
$ProductCancelForm = new ProductCancelForm();
|
||||
$ProductCancelForm->cancel([
|
||||
'order_id' => $orderId,
|
||||
'user_id' => $userId
|
||||
], '处方失效,订单自动失效');
|
||||
}
|
||||
return ['ok'];
|
||||
}
|
||||
|
||||
public function actionSendOrder()
|
||||
{
|
||||
// 订单自动同步任务
|
||||
\Yii::$app->queue->push(new ProductOrderSyncJob([
|
||||
'orderId' => 126,
|
||||
]));
|
||||
}
|
||||
|
||||
public function getWeChatQrCode()
|
||||
{
|
||||
$id = \Yii::$app->request->post('id');
|
||||
$store = Store::find()->where(['id' => $id])->one();
|
||||
if (!$store) {
|
||||
return ['error' => '店铺不存在'];
|
||||
}
|
||||
if (!$store->qr_code) {
|
||||
|
||||
$scene = 'STORE_QR_CODE'.'_'.$this->id;
|
||||
$weappService = new WeappService();
|
||||
$url= $weappService->getQrcode($scene);
|
||||
$store->qr_code=$url;
|
||||
$store->saveOrFail();
|
||||
|
||||
return ['ok'];
|
||||
}
|
||||
return [''];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user