<?php

declare (strict_types=1);
namespace App\Controller;

use App\JsonRpc\UserServiceInterface;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\AutoController;
use App\Tools\Result;
use App\Constants\ErrorCode;
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
/**
 * Class UserController
 * @package App\Controller
 */
#[AutoController]
class UserController extends AbstractController
{
    use \Hyperf\Di\Aop\ProxyTrait;
    use \Hyperf\Di\Aop\PropertyHandlerTrait;
    function __construct(\Hyperf\Logger\LoggerFactory $loggerFactory)
    {
        if (method_exists(parent::class, '__construct')) {
            parent::__construct(...func_get_args());
        }
        $this->__handlePropertyHandler(__CLASS__);
    }
    #[Inject]
    protected ValidatorFactoryInterface $validationFactory;
    /**
     * @var UserServiceInterface
     */
    #[Inject]
    private $userServiceClient;
    public function createUser()
    {
        $requireData = $this->request->all();
        $validator = $this->validationFactory->make($requireData, ['user_name' => 'required', 'password' => 'required|min:6', 'confirm_password' => 'required', 'email' => 'email', 'mobile' => 'required'], [
            'usernuser_name.required' => '用户名不能为空',
            'password.required' => '密码不能为空',
            'email.email' => '请填写一个有效的邮箱',
            'mobile.required' => '手机号码必填',
            //                'mobile.telephone_number' => '请填写一个有效的手机号',
            'confirm_password.required' => "确认密码不能为空",
            'password.min' => "密码长度不能低于6位数",
        ]);
        if ($validator->fails()) {
            $errorMessage = $validator->errors()->first();
            return Result::error($errorMessage);
        }
        if ($requireData['password'] != $requireData['confirm_password']) {
            return Result::error("两次密码不一致");
        }
        $salt = rand(1, 999999);
        $data = [
            'user_name' => $requireData['user_name'],
            'password' => $requireData['password'],
            'avatar' => $requireData['avatar'],
            'mobile' => $requireData['mobile'],
            'status' => isset($requireData['status']) ? $requireData['status'] : 1,
            'role_id' => $requireData['role_id'] ? $requireData['role_id'] : 0,
            'email' => $requireData['email'] ? $requireData['email'] : '',
            'salt' => $salt,
            'rong_token' => '',
            'level_id' => $requireData['level_id'],
            //会员等级
            'id_card' => isset($requireData['id_card']) ? $requireData['id_card'] : '',
            //身份证号
            'birthday' => isset($requireData['birthday']) ? $requireData['status'] : '',
            //生日
            'gender' => isset($requireData['gender']) ? $requireData['status'] : '',
            //性别
            'real_name' => isset($requireData['real_name']) ? $requireData['status'] : '',
        ];
        $this->logger->info("创建用户入参：", $data);
        $result = $this->userServiceClient->createUser($data);
        $this->logger->info("创建用户返回值：", $result);
        return $result ? Result::success($result['data']) : Result::error($result['message']);
    }
    /**
     * @return array|void
     */
    public function getUserInfo()
    {
        var_dump($this->UserId, "GGGGGGGGG");
        $requireData = $this->request->all();
        $validator = $this->validationFactory->make($requireData, ['id' => 'required'], ['id.required' => '用户id不能为空']);
        if ($validator->fails()) {
            $errorMessage = $validator->errors()->first();
            return Result::error($errorMessage);
        }
        $result = $this->userServiceClient->getUserInfo((int) $requireData['id']);
        if ($result['code'] != ErrorCode::SUCCESS) {
            return Result::error($result['message'], 0, []);
        }
        return Result::success($result['data']);
    }
    public function getMenuList()
    {
        $data = [["label" => "工作台", "url" => "/#/left/home", "action" => "home", "children" => [["id" => 773, "label" => "商品列表-JAVA", "mark" => "", "url" => "/#/left/newGoodsList", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 3], ["id" => 773, "label" => "商品列表-JAVA", "mark" => "", "url" => "/#/left/newGoodsList", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 3]]], ["id" => 1, "label" => "商品", "mark" => "", "url" => "/#/left/newGoodsList", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 1, "children" => [["id" => 773, "label" => "商品列表-JAVA", "mark" => "", "url" => "/#/left/newGoodsList", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 3], ["id" => 402, "label" => "点评列表", "mark" => "", "url" => "/#/left/goodsCommentList", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 5], ["id" => 407, "label" => "品牌列表", "mark" => "", "url" => "/#/left/brandList", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 6], ["id" => 604, "label" => "标准商品库", "mark" => "0", "url" => "/#/left/standardGoods/goodList", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 7], ["id" => 821, "label" => "商品通知图管理-Java", "mark" => "", "url" => "/#/left/goodsNoticeImg", "parent_id" => 1, "is_curr" => false, "can_do" => false, "sort" => 22]]], ["id" => 17, "label" => "促销", "mark" => "", "url" => "/#/left/platformMarketingActivities", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 2, "children" => [["id" => 622, "label" => "平台营销活动", "mark" => "", "url" => "/#/left/platformMarketingActivities", "parent_id" => 17, "is_curr" => false, "can_do" => false, "sort" => 16], ["id" => 28, "label" => "优惠券", "mark" => "", "url" => "/#/coupons", "parent_id" => 17, "is_curr" => false, "can_do" => false, "sort" => 17], ["id" => 392, "label" => "订单优惠", "mark" => "", "url" => "/seller/fullDiscount?act=list", "parent_id" => 17, "is_curr" => false, "can_do" => false, "sort" => 18], ["id" => 31, "label" => "搭售活动", "mark" => "", "url" => "/#/left/tyingActivitiesList", "parent_id" => 17, "is_curr" => false, "can_do" => false, "sort" => 20], ["id" => 404, "label" => "抽奖", "mark" => "", "url" => "/#/left/luckDraw", "parent_id" => 17, "is_curr" => false, "can_do" => false, "sort" => 21], ["id" => 401, "label" => "限时秒杀", "mark" => "", "url" => "/#/left/secondKillActivity", "parent_id" => 17, "is_curr" => false, "can_do" => false, "sort" => 21]]], ["id" => 35, "label" => "订单", "mark" => "", "url" => "/#/left/goodsOrderList", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 3, "children" => [["id" => 377, "label" => "销售订单", "mark" => "", "url" => "", "parent_id" => 35, "is_curr" => false, "can_do" => false, "sort" => 4, "children" => [["id" => 384, "label" => "商品订单列表", "mark" => "", "url" => "/#/left/goodsOrderList", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 20], ["id" => 776, "label" => "付款订单列表", "mark" => "", "url" => "/#/left/billOrder", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 30], ["id" => 658, "label" => "服务订单列表", "mark" => "", "url" => "/#/left/serviceOrderList", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 40], ["id" => 827, "label" => "发货单列表", "mark" => "", "url" => "/#/left/invoiceorder", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 70], ["id" => 527, "label" => "退货售后列表", "mark" => "", "url" => "/#/left/afterSalesOrder?pageType=sale", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 80], ["id" => 828, "label" => "自提核销", "mark" => "", "url" => "/#/left/selfDrawVerify", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 100], ["id" => 768, "label" => "销售统计", "mark" => "", "url" => "/#/left/saleReport", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 110], ["id" => 718, "label" => "门店订单看板", "mark" => "", "url" => "/#/left/shopOrderBoard", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 120], ["id" => 717, "label" => "门店订单列表", "mark" => "", "url" => "/#/left/shopOrderList", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 130], ["id" => 668, "label" => "O2O订单管理", "mark" => "", "url" => "/#/left/o2oOrderList", "parent_id" => 377, "is_curr" => false, "can_do" => false, "sort" => 140]]], ["id" => 378, "label" => "采购订单", "mark" => "", "url" => "", "parent_id" => 35, "is_curr" => false, "can_do" => false, "sort" => 5, "children" => [["id" => 571, "label" => "信用额度查询", "mark" => "服务商-采购管理", "url" => "/#/left/creditLimitZSW", "parent_id" => 378, "is_curr" => false, "can_do" => false, "sort" => 10], ["id" => 49, "label" => "采购订单列表", "mark" => "", "url" => "/#/left/orderList", "parent_id" => 378, "is_curr" => false, "can_do" => false, "sort" => 20], ["id" => 890, "label" => "退货售后列表", "mark" => "", "url" => "/#/left/afterSalesOrder?pageType=purchase", "parent_id" => 378, "is_curr" => false, "can_do" => false, "sort" => 30], ["id" => 894, "label" => "待开票列表", "mark" => "订单合并-智商务-待开票列表", "url" => "/#/left/toMakeInvoiceListNew", "parent_id" => 378, "is_curr" => false, "can_do" => false, "sort" => 40], ["id" => 899, "label" => "开票申请列表", "mark" => "订单合并-智商务-采购管理", "url" => "/#/left/applyMakeInvoiceListZSWNew", "parent_id" => 378, "is_curr" => false, "can_do" => false, "sort" => 50], ["id" => 886, "label" => "备件捆绑主机", "mark" => "", "url" => "/#/left/newBindPcMechine", "parent_id" => 378, "is_curr" => false, "can_do" => false, "sort" => 60]]]]], ["id" => 114, "label" => "商家", "mark" => "", "url" => "/#/left/merchantsAccount", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 4, "children" => [["id" => 394, "label" => "店铺账户", "mark" => "", "url" => "/#/left/merchantsAccount", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 12], ["id" => 864, "label" => "在线客服设置(新)", "mark" => "", "url" => "/#/left/customerService", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 20], ["id" => 766, "label" => "服务站信息管理(新)", "mark" => "", "url" => "/#/left/serviceStationInfoManage", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 24], ["id" => 755, "label" => "服务网点列表(新)", "mark" => "", "url" => "/#/left/serviceNetworkManage", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 24], ["id" => 856, "label" => "工程师管理(新)", "mark" => "", "url" => "/#/left/engineerManage", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 25], ["id" => 722, "label" => "带货人管理", "mark" => "", "url" => "/seller/service_manage.php?act=carrier_list", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 26], ["id" => 745, "label" => "任务单列表", "mark" => "", "url" => "/#/left/missionOrderList", "parent_id" => 114, "is_curr" => false, "can_do" => false, "sort" => 30]]], ["id" => 82, "label" => "设置", "mark" => "", "url" => "/#/left/setFreight", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 6, "children" => [["id" => 872, "label" => "运费设置(新)", "mark" => "", "url" => "/#/left/setFreight", "parent_id" => 82, "is_curr" => false, "can_do" => false, "sort" => 13], ["id" => 403, "label" => "短信设置", "mark" => "", "url" => "/#/left/setSms", "parent_id" => 82, "is_curr" => false, "can_do" => false, "sort" => 14], ["id" => 526, "label" => "退货设置", "mark" => "", "url" => "/#/left/returnSetting", "parent_id" => 82, "is_curr" => false, "can_do" => false, "sort" => 15], ["id" => 633, "label" => "物流方式", "mark" => "", "url" => "/#/left/express", "parent_id" => 82, "is_curr" => false, "can_do" => false, "sort" => 20], ["id" => 642, "label" => "库房位置", "mark" => "", "url" => "/#/left/setStorehouse", "parent_id" => 82, "is_curr" => false, "can_do" => false, "sort" => 25]]], ["id" => 71, "label" => "权限", "mark" => "", "url" => "/#/left/roleManagement", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 7, "children" => [["id" => 742, "label" => "新角色管理", "mark" => "", "url" => "/#/left/roleManagement", "parent_id" => 71, "is_curr" => false, "can_do" => false, "sort" => 10], ["id" => 743, "label" => "新员工管理", "mark" => "", "url" => "/#/left/staffManagement", "parent_id" => 71, "is_curr" => false, "can_do" => false, "sort" => 11]]], ["id" => 125, "label" => "店铺", "mark" => "", "url" => "/#/left/microstation", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 8, "children" => [["id" => 154, "label" => "微站", "mark" => "", "url" => "", "parent_id" => 125, "is_curr" => false, "can_do" => false, "sort" => 5, "children" => [["id" => 869, "label" => "微站(新)", "mark" => "", "url" => "/#/left/microstation", "parent_id" => 154, "is_curr" => false, "can_do" => false, "sort" => 1], ["id" => 870, "label" => "Logo管理(新)", "mark" => "", "url" => "/#/left/logoManage", "parent_id" => 154, "is_curr" => false, "can_do" => false, "sort" => 2], ["id" => 871, "label" => "店铺名称管理(新)", "mark" => "", "url" => "/#/left/shopNameManage", "parent_id" => 154, "is_curr" => false, "can_do" => false, "sort" => 12]]], ["id" => 132, "label" => "店铺装修", "mark" => "", "url" => "", "parent_id" => 125, "is_curr" => false, "can_do" => false, "sort" => 80, "children" => [["id" => 395, "label" => "前台分类设置", "mark" => "", "url" => "/seller/business_category.php?act=data_list", "parent_id" => 132, "is_curr" => false, "can_do" => false, "sort" => 801], ["id" => 396, "label" => "热门搜索设置", "mark" => "", "url" => "/seller/business_category.php?act=hot_keyword", "parent_id" => 132, "is_curr" => false, "can_do" => false, "sort" => 802]]]]], ["id" => 171, "label" => "财务", "mark" => "", "url" => "/#/left/balance", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 9, "children" => [["id" => 612, "label" => "账户余额明细", "mark" => "", "url" => "/#/left/balance", "parent_id" => 171, "is_curr" => false, "can_do" => false, "sort" => 41], ["id" => 672, "label" => "外部订单结费统计", "mark" => "", "url" => "/#/left/allPlatformMarketing", "parent_id" => 171, "is_curr" => false, "can_do" => false, "sort" => 42], ["id" => 582, "label" => "订单对账管理", "mark" => "0", "url" => "/#/left/finance", "parent_id" => 171, "is_curr" => false, "can_do" => false, "sort" => 12622], ["id" => 609, "label" => "申请开票管理", "mark" => "0", "url" => "/#/left/applyInvoice", "parent_id" => 171, "is_curr" => false, "can_do" => false, "sort" => 12624], ["id" => 610, "label" => "开票申请列表", "mark" => "0", "url" => "/#/left/applyFeeList", "parent_id" => 171, "is_curr" => false, "can_do" => false, "sort" => 12625]]], ["id" => 405, "label" => "数据", "mark" => "", "url" => "/#/left/dataBoard", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 12, "children" => [["id" => 406, "label" => "数据看板", "mark" => "", "url" => "/#/left/dataBoard", "parent_id" => 405, "is_curr" => false, "can_do" => false, "sort" => 1], ["id" => 544, "label" => "员工销售数据", "mark" => "", "url" => "/#/left/staffSales", "parent_id" => 405, "is_curr" => false, "can_do" => false, "sort" => 2], ["id" => 583, "label" => "加装改配查询", "mark" => "0", "url" => "/#/left/computerInfoSearch", "parent_id" => 405, "is_curr" => false, "can_do" => false, "sort" => 4]]], ["id" => 564, "label" => "进销存", "mark" => "0", "url" => "/#/left/POOrderListZSW", "parent_id" => 0, "is_curr" => false, "can_do" => false, "sort" => 13, "children" => [["id" => 674, "label" => "采购管理", "mark" => "采购管理", "url" => "", "parent_id" => 564, "is_curr" => false, "can_do" => false, "sort" => 2, "children" => [["id" => 572, "label" => "PO采购列表", "mark" => "服务商-采购管理", "url" => "/#/left/POOrderListZSW", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 8], ["id" => 723, "label" => "退货单列表", "mark" => "服务商-采购管理", "url" => "/#/left/zswRefundList", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 9], ["id" => 573, "label" => "SO订单列表", "mark" => "服务商-采购管理", "url" => "/#/left/SOOrderListZSW", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 9], ["id" => 570, "label" => "单品库存管理", "mark" => "服务商-采购管理", "url" => "/#/left/singleProductZSW", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 10], ["id" => 574, "label" => "付款订单列表", "mark" => "服务商-采购管理", "url" => "/#/left/payListZSW", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 11], ["id" => 588, "label" => "待开票列表", "mark" => "服务商-采购管理", "url" => "/#/left/toMakeInvoiceList", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 12], ["id" => 589, "label" => "开票申请列表", "mark" => "服务商-采购管理", "url" => "/#/left/applyMakeInvoiceListZSW", "parent_id" => 674, "is_curr" => false, "can_do" => false, "sort" => 13]]], ["id" => 708, "label" => "库存管理", "mark" => "", "url" => "", "parent_id" => 564, "is_curr" => false, "can_do" => false, "sort" => 25, "children" => [["id" => 709, "label" => "物料入库通知", "mark" => "", "url" => "/#/left/warehousingNotice", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 25], ["id" => 710, "label" => "物料出库通知", "mark" => "", "url" => "/#/left/deliveryNotice", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 26], ["id" => 711, "label" => "物料调拨通知", "mark" => "", "url" => "/#/left/allocatingNotice", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 27], ["id" => 712, "label" => "物料入库单查询", "mark" => "", "url" => "/#/left/warehousingQuery", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 28], ["id" => 713, "label" => "物料出库单查询", "mark" => "", "url" => "/#/left/outboundQuery", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 29], ["id" => 714, "label" => "物料库存", "mark" => "", "url" => "/#/left/inventory", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 30], ["id" => 716, "label" => "自营物料档案", "mark" => "", "url" => "/#/left/materialFile", "parent_id" => 708, "is_curr" => false, "can_do" => false, "sort" => 31]]]]]];
        return Result::success($data);
    }
}