diff --git a/admin/controllers/OpenApiController.php b/admin/controllers/OpenApiController.php new file mode 100644 index 0000000..6af1822 --- /dev/null +++ b/admin/controllers/OpenApiController.php @@ -0,0 +1,110 @@ +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 ['']; + } + +} \ No newline at end of file