hospital-applets-api/app/Controller/UserController.php
2023-03-11 10:11:22 +08:00

216 lines
7.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Controller;
use App\Amqp\Producer\PrescriptionDistributePhProducer;
use App\Constants\HttpEnumCode;
use App\Exception\BusinessException;
use App\Model\DoctorInquiryTime;
use App\Model\OrderInquiry;
use App\Model\UserDoctor;
use App\Request\UserRequest;
use App\Services\ImService;
use App\Services\UserDoctorService;
use App\Services\UserService;
use App\Utils\Http;
use App\Utils\Log;
use Extend\TencentIm\Account;
use Extend\TencentIm\Friend;
use Extend\TencentIm\Group;
use Extend\TencentIm\Message;
use Extend\TencentIm\MessageParams;
use Extend\TencentIm\Profile;
use Extend\Wechat\Wechat;
use Extend\Wechat\WechatPay;
use Hyperf\Amqp\Producer;
use Hyperf\DbConnection\Db;
use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
class UserController extends AbstractController
{
/**
* 修改用户头像
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function putUserAvatar(): ResponseInterface
{
$request = $this->container->get(UserRequest::class);
$request->scene('putUserAvatar')->validateResolved();
$UserService = new UserService();
$data = $UserService->putUserAvatar();
return $this->response->json($data);
}
/**
* 修改用户名
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function putUserName(): ResponseInterface
{
$request = $this->container->get(UserRequest::class);
$request->scene('putUserName')->validateResolved();
$UserService = new UserService();
$data = $UserService->putUserName();
return $this->response->json($data);
}
/**
* 退出登陆
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function putLoginout(): ResponseInterface
{
$UserService = new UserService();
$data = $UserService->putLoginout();
return $this->response->json($data);
}
// 支付测试
public function testpay(){
// 发起支付
$out_trade_no = $this->request->input('out_trade_no');
// $generator = $this->container->get(IdGeneratorInterface::class);
//
// $WechatPay = new WechatPay(1);
//
// // 获取预支付交易会话标识
// $total = 0.01 * 100;
// $prepay = $WechatPay->getJsapiPrepayId($out_trade_no,$total,"omgU35DlE-rxTAGgcBjOuc4xdcX8");
// if (empty($prepay)){
// return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
// }
//
// // 获取小程序支付配置
// $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
// return $this->response->json($pay_config);
// 发起退款
// $WechatPay = new WechatPay(1);
//
// $params = array();
// $params['order_inquiry_id'] = 1;
// $order_inquiry = OrderInquiry::getOne($params);
//
//
// $options = array();
// $options['transaction_id'] = $order_inquiry['escrow_trade_no'];
// $options['out_refund_no'] = $order_inquiry['inquiry_refund_no'];
// $options['reason'] = "退款原因";
// $options['amount'] = [
// 'refund' => (int)1,
// 'total' => (int)1,
// 'currency' => "CNY",
// ];
//
// $result = $WechatPay->refund($options);
// dump($result);
// 创建账号
$account = new Account();
$profile = new Profile();
$group = new Group();
$friend = new Friend();
$message = new Message();
// $result = $account->createAccount(10009,'测试患者9',"https://img.applets.igandanyiyuan.com/applet/doctor/avatar/03dc8df2-e7c0-4ad9-b87e-5133e40e0f76.jpg");
// 查询账号导入状态
// $result = $account->checkAccountStatus("123456");
// 设置账户资料
// $arg = array();
// $arg['Tag_Profile_IM_Gender'] = "Gender_Type_Male";
// $arg['Tag_Profile_IM_BirthDay'] = 19961007;
// $arg['Tag_Profile_Custom_Hname'] = "协和医院";
// $arg['Tag_Profile_Custom_Title'] = "主任医师";
// $result = $profile->setProfile("123456",$arg);
// 添加用户好友分组
// $result = $group->addUserGroup('123456');
// 获取用户好友分组
// $result = $group->getUserGroup('123456');
// 添加好友
// $result = $friend->addFriend("123456",'1234567',"快速问诊");
// 发送消息
// $arg = array();
// $arg['From_Account'] = "10000"; // 发送方user_id 如系统发送,无需填写
// $arg['To_Account'] = "123456"; // 接收方user_id
// $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback'];
// $arg['SendMsgControl'] = [];
//
// $arg['MsgBody'] = [
// [
// "MsgType" => "TIMTextElem",
// "MsgContent" => [
// "Text" => "发送11122",
// ],
// ]
// ];
//
// // 自定义消息
// $cloud_custom_data = array();
// $cloud_custom_data['order_inquiry_id'] = 491963820554948608;
// $cloud_custom_data['is_system'] = 0;
// $cloud_custom_data['inquiry_type'] = 2;
//
// $arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE);
//
// $result = $message->sendMessage($arg);
//
//// $result = $profile->getOneAccountPortraitList("123456");
//
// dump($result);
// 专家-公益发送im消息
// $ImService = new ImService();
//
// // 获取订单医生数据
// $params = array();
// $params['doctor_id'] = "491925054779883520";
// $user_doctor = UserDoctor::getOne($params);
// if (empty($user_doctor)){
// Log::getInstance()->info("医生数据错误");
// }
//
// // 发送消息
// $ImService->sendTextMessage($user_doctor['user_id'],"491923510680424449","等待医生接诊",491937904055369728);
//
// $data = array();
// $data['order_inquiry_id'] = 4;
// $data['to_user_id'] = 10004;
// $data['patient_name'] = "用户4";
// $data['patient_sex'] = 2;
// $data['patient_age'] = 19;
// $data['inquiry_status'] = 1;
// $data['message_send_time'] = 1678112190;
// $data['message_seq'] = 101;
// $data['message_type'] = "TIMTextElem";
// $data['last_message_content']['Text'] = "测试消息4";
//
// $imService = new ImService();
// $imService->addRecentContactRecordCache("491925054779883520", 2, 10004, $data);
}
}