package com.fzm.mall.server.front.user.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fzm.mall.server.front.asset.model.UserAsset;
import com.fzm.mall.server.front.asset.service.IUserAssetService;
import com.fzm.mall.server.front.base.ResponseVO;
import com.fzm.mall.server.front.enums.CoinNameEnum;
import com.fzm.mall.server.front.enums.MessageSuffixEnum;
import com.fzm.mall.server.front.goods.model.MarketingCoupon;
import com.fzm.mall.server.front.goods.model.Shop;
import com.fzm.mall.server.front.goods.model.vo.*;
import com.fzm.mall.server.front.goods.service.ISpuService;
import com.fzm.mall.server.front.user.entity.vo.UpdateUserVo;
import com.fzm.mall.server.front.user.model.*;
import com.fzm.mall.server.front.user.model.vo.*;
import com.fzm.mall.server.front.user.model.vo.UserCouponVo;
import com.fzm.mall.server.front.user.service.*;
import com.fzm.mall.server.front.constant.MALLGlobalConfig;
import com.fzm.mall.server.front.constant.MallResponseEnum;
import com.fzm.mall.server.front.util.*;
import io.netty.util.internal.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author fzm
 * @since 2021-01-27
 */
@Api("用户模块")
@RestController
@RequestMapping(value = "mall/user", produces = "application/json;charset=UTF-8")
public class UserController {

    @Autowired
    private IRedisService redisService;

    @Autowired
    private IUserService userService;

    @Autowired
    private IFollowService followService;

    @Autowired
    private ICollectionsService collectionsService;

    @Autowired
    private IUserAssetService userAssetService;

    @Autowired
    private IFootService footService;

    @Autowired
    private ISpuService spuService;

    @Autowired
    private ICouponService couponService;

    @Autowired
    private INoticeService noticeService;

    @Autowired
    private IMemberService memberService;

    @Autowired
    private IMarketingMemberIntegralRecurrenceService marketingMemberIntegralRecurrenceService;


    @ApiOperation(value = "用户登录")
    @PostMapping("/without/login")
    public ResponseVO<User> login(@RequestBody LoginVo loginVo) {
        System.out.println(loginVo);
        if (StringUtil.isNullOrEmpty(loginVo.getAccount()) || StringUtil.isNullOrEmpty(loginVo.getVerificationCode())) {
            return new ResponseVO<>(MallResponseEnum.PARAMETER_ERR);
        }
        if (!PhoneFormatCheckUtils.isChinaPhoneLegal(loginVo.getAccount())) {
            return new ResponseVO<>(MallResponseEnum.ACCOUNT_ERR);
        }
        String code = redisService.getKey(loginVo.getAccount() + MALLGlobalConfig.MALL_LOGIN_SUFFIX);
        if (StringUtil.isNullOrEmpty(code)) {
            return new ResponseVO<>(MallResponseEnum.CODE_NOT_SEND);
        }
        if (!code.equals(loginVo.getVerificationCode())) {
            return new ResponseVO<>(MallResponseEnum.CODE_ERR);
        }
        User user = userService.getAccount(loginVo.getAccount());
        // 注册
        if (user == null) {
            try {
                int i = userService.register(loginVo.getAccount(), loginVo.getRegisterCode(), loginVo.getArea());
                if (i == 2) {
                    //邀请码不存在
                    return new ResponseVO<>(MallResponseEnum.REGISTER_CODE_ERR);
                }
                if (i == 3) {
                    //已经注册
                    return new ResponseVO<>(MallResponseEnum.REGISTER_ALREADY);
                }
            } catch (Exception e) {
                String msg = e.getMessage();
                if (("地址创建失败!!!").equals(msg)) {
                    //地址创建失败
                    return new ResponseVO<>(MallResponseEnum.CREATE_ADDR_ERR);
                } else {
                    e.printStackTrace();
                    //数据库异常
                    return new ResponseVO<>(MallResponseEnum.DB_ERROR);
                }
            }

            // 登录
        } else {

        }
        user = userService.getAccount(loginVo.getAccount());
        if (user.getStatus() == 2) {
            return new ResponseVO<User>(MallResponseEnum.ACCOUNT_FROZEN);
        }
        String token = UUIdUtil.getUUID();
        user.setToken(token);
        user.setLastLogin(System.currentTimeMillis());
        userService.updateById(user);
        // token有效期7天
        redisService.setKey(user.getUid() + MALLGlobalConfig.MALL_TOKEN_REDISKEY_SUFFIX, token, 7 * 24 * 60 * 60);
        if (StringUtil.isNullOrEmpty(user.getPayPassword())) {
            user.setIsPayPassword(false);
        } else {
            user.setIsPayPassword(true);
        }
        user.setUid("");
        if (StringUtil.isNullOrEmpty(user.getPayPassword())) {
            user.setIsPayPassword(false);
        } else {
            user.setIsPayPassword(true);
        }
        user.setPayPassword("");
        return new ResponseVO<User>(MallResponseEnum.SUCCESS, user);
    }

    @ApiOperation(value = "用户未登录验证码")
    @PostMapping("/without/unSendCode")
    public ResponseVO<String> unSendCode(@RequestBody UnSendCodeVo unSendCodeVo) {
        if (StringUtil.isNullOrEmpty(unSendCodeVo.getAccount())) {
            return new ResponseVO<>(MallResponseEnum.PARAMETER_ERR);
        }
        String redisVerificationCode;
        String verificationCode;
        if (unSendCodeVo.getType() == null || unSendCodeVo.getType() == 1) {
            redisVerificationCode = redisService.getKey(unSendCodeVo.getAccount() + MALLGlobalConfig.MALL_LOGIN_SUFFIX);
            verificationCode = StringUtil.isNullOrEmpty(redisVerificationCode) ? CodeUtil.genValidateCode()
                    : redisVerificationCode;
            // 调用短信接口
            //国内国外判断
            boolean isChina = false;
            if (unSendCodeVo.getArea().equals("+86")) {
                isChina = true;
            }
            //boolean b = SmsUtil.sendSms(unSendCodeVo.getArea() + unSendCodeVo.getAccount(), isChina, SmsUtil.REGISTER_TEMPLATEID, verificationCode);
            boolean b = AliSmsUtils.sendCode(unSendCodeVo.getAccount(),verificationCode,AliSmsUtils.REGISTER);
            if(!b){
                return  new ResponseVO<String>(MallResponseEnum.SEND_CODE_ERR);
            }
            redisService.setKey(unSendCodeVo.getAccount() + MALLGlobalConfig.MALL_LOGIN_SUFFIX, verificationCode, 60 * 5);
        }
        return new ResponseVO<String>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "用户登录验证码")
    @PostMapping("/sendCode")
    public ResponseVO<String> sendCode(@ApiIgnore @RequestAttribute Header header, @RequestBody UnSendCodeVo unSendCodeVo) {
        String account = header.getAccount();
        String area = header.getArea();
        String redisVerificationCode;
        String verificationCode;
        //  @ApiModelProperty(value = "1:普通支付验证码，2：转让支付验证码 3:设置支付密码")
        if (unSendCodeVo.getType() == 1) {
            redisVerificationCode = redisService.getKey(account + MessageSuffixEnum.BUY_GOODS_SUFFIX);
            verificationCode = StringUtil.isNullOrEmpty(redisVerificationCode) ? CodeUtil.genValidateCode()
                    : redisVerificationCode;
            // 调用短信接口
            //国内国外判断
            boolean isChina = false;
            if (area.equals("+86")) {
                isChina = true;
            }
            //boolean b = SmsUtil.sendSms(unSendCodeVo.getArea() + unSendCodeVo.getAccount(), isChina, SmsUtil.REGISTER_TEMPLATEID, verificationCode);
            boolean b = AliSmsUtils.sendCode(account,verificationCode,AliSmsUtils.ORDER_PAY);
            if(!b){
                return  new ResponseVO<String>(MallResponseEnum.SEND_CODE_ERR);
            }
            redisService.setKey(account+MessageSuffixEnum.BUY_GOODS_SUFFIX,verificationCode,60*5);
        } else if (unSendCodeVo.getType() == 2) {
            redisVerificationCode = redisService.getKey(account + MessageSuffixEnum.BUY_TRANGOODS_SUFFIX);
            verificationCode = StringUtil.isNullOrEmpty(redisVerificationCode) ? CodeUtil.genValidateCode()
                    : redisVerificationCode;
            // 调用短信接口
            //国内国外判断
            boolean isChina = false;
            if (area.equals("+86")) {
                isChina = true;
            }
            boolean b = AliSmsUtils.sendCode(account,verificationCode,AliSmsUtils.TRAN_PAY);
            if(!b){
                return  new ResponseVO<String>(MallResponseEnum.SEND_CODE_ERR);
            }
            redisService.setKey(account+MessageSuffixEnum.BUY_TRANGOODS_SUFFIX,verificationCode,60*5);
        } else if (unSendCodeVo.getType() == 3) {
            redisVerificationCode = redisService.getKey(account + MessageSuffixEnum.SET_PAY_PASSWORD);
            verificationCode = StringUtil.isNullOrEmpty(redisVerificationCode) ? CodeUtil.genValidateCode()
                    : redisVerificationCode;
            // 调用短信接口
            //国内国外判断
            boolean isChina = false;
            if (area.equals("+86")) {
                isChina = true;
            }
            boolean b = AliSmsUtils.sendCode(account,verificationCode,AliSmsUtils.UPDATE_PAYPASSWORD);
            if(!b){
                return  new ResponseVO<String>(MallResponseEnum.SEND_CODE_ERR);
            }
            redisService.setKey(account+MessageSuffixEnum.SET_PAY_PASSWORD,verificationCode,60*5);
        }
        return new ResponseVO<String>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "用户关注/取消关注商家 参数merchantId")
    @PostMapping("/follow")
    public ResponseVO<String> follow(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String uid = header.getUid();
        String merchantId = data.getString("merchantId");
        if (!redisService.setNx(uid + merchantId + "_follow")) {
            return new ResponseVO<>(MallResponseEnum.OPERATION_OFTEN);
        }
        Follow follow = followService.getByUidAndMerchantId(uid, merchantId);
        if (follow == null) {
            follow = new Follow();
            follow.setUid(uid);
            follow.setMerchantId(merchantId);
        } else if (follow.getStatus() == 1) {
            follow.setStatus(2);
        } else {
            follow.setStatus(1);
        }
        followService.saveOrUpdate(follow);
        redisService.del(uid + merchantId + "_follow");
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "用户收藏/取消收藏商品 参数goodsId")
    @PostMapping("/colletcions")
    public ResponseVO<String> collections(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String uid = header.getUid();
        String goodsId = data.getString("goodsId");
        if (!redisService.setNx(uid + goodsId + "_collections")) {
            return new ResponseVO<>(MallResponseEnum.OPERATION_OFTEN);
        }
        Collections collections = collectionsService.getByUidAndGoodsId(uid, goodsId);
        if (collections == null) {
            collections = new Collections();
            collections.setUid(uid);
            collections.setGoodsId(goodsId);
        } else if (collections.getStatus() == 1) {
            collections.setStatus(2);
        } else {
            collections.setStatus(1);
        }
        collectionsService.saveOrUpdate(collections);
        redisService.del(uid + goodsId + "_collections");
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "设置支付密码")
    @PostMapping("/setPayPassword")
    public ResponseVO<String> sendCode(@ApiIgnore @RequestAttribute Header header, @RequestBody PayPasswordVo payPasswordVo) {
        if(StringUtil.isNullOrEmpty(payPasswordVo.getOldPayPassword())){
            if(StringUtil.isNullOrEmpty(payPasswordVo.getVerificationCode())){
                return new ResponseVO<String>(MallResponseEnum.PARAMETER_ERR);
            }else{
                String key = redisService.getKey(header.getAccount() + MessageSuffixEnum.SET_PAY_PASSWORD);
                if (StringUtil.isNullOrEmpty(key)) {
                    return new ResponseVO<String>(MallResponseEnum.CODE_NOT_SEND);
                }
                if (payPasswordVo.getVerificationCode().equals(key)) {
                    userService.setPayPassword(header.getUid(), Sha256Util.sha256String(payPasswordVo.getPayPassword()));
                } else {
                    return new ResponseVO<String>(MallResponseEnum.CODE_ERR);
                }
            }
        }else{
            if(StringUtil.isNullOrEmpty(header.getPayPassword())){
               return  new ResponseVO<String>(MallResponseEnum.NOT_SET_PAY_PASSWORD);
            }
           if(Sha256Util.sha256String(payPasswordVo.getOldPayPassword()).equals(header.getPayPassword())){
               userService.setPayPassword(header.getUid(), Sha256Util.sha256String(payPasswordVo.getPayPassword()));
           }else{
               return  new ResponseVO<String>(MallResponseEnum.PAY_PASSWORD_ERR);
           }
        }
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "获取总资产")
    @PostMapping("/getMallCoin")
    public ResponseVO<AssetVo> getMallCoin(@ApiIgnore @RequestAttribute Header header, @RequestBody PageVo pageVo) {
        String uid = header.getUid();
        AssetVo assetVo = new AssetVo();
        UserAsset asset = userAssetService.getCoin(uid, CoinNameEnum.MALLCOIN.value());
        assetVo.setMallCoin(asset.getAmount());
        List<UserAsset> assets = userAssetService.getList(uid, pageVo);
        assetVo.setList(assets);
        Integer count = userAssetService.getCount(uid);
        assetVo.setCount(count);
        BigDecimal all = userAssetService.getAllNotMallCoin(uid);
        if (all == null) {
            all = BigDecimal.ZERO;
        }
        assetVo.setTotal(all.add(asset.getAmount()));
        return new ResponseVO<>(MallResponseEnum.SUCCESS, assetVo);
    }


    @ApiOperation(value = "修改用户信息")
    @PostMapping("/updateInfo")
    public ResponseVO<String> updateInfo(@ApiIgnore @RequestAttribute Header header, @RequestBody UpdateUserVo updateUserVo) {
        String uid = header.getUid();
        User user = userService.getByUid(uid);
        if (!StringUtil.isNullOrEmpty(updateUserVo.getBirthday())) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            try {
                Date parse = sdf.parse(updateUserVo.getBirthday());
                user.setBirthday(parse);
            } catch (Exception e) {
                return new ResponseVO<>(MallResponseEnum.DATE_ERR);
            }

        }
        if (!StringUtil.isNullOrEmpty(updateUserVo.getHeadUrl())) {
            user.setHeadUrl(updateUserVo.getHeadUrl());
        }
        if (!StringUtil.isNullOrEmpty(updateUserVo.getNickName())) {
            if (updateUserVo.getNickName().matches("^([\\u4E00-\\u9FA5a-zA-Z0-9]{1,20})$")) {
                user.setNickName(updateUserVo.getNickName());
            } else {
                return new ResponseVO<>(MallResponseEnum.NICK_NAME_ERR);
            }
        }
        if (updateUserVo.getSex() != null) {
            if (updateUserVo.getSex() == 1) {
                user.setSex(1);
            } else {
                user.setSex(2);
            }
        }
        userService.updateById(user);
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "获取浏览足迹")
    @PostMapping("/getFoot")
    public ResponseVO<FootGoodsListVo> getFoot(@ApiIgnore @RequestAttribute Header header, @RequestBody PageVo pageVo) {
        String uid = header.getUid();
        Integer count = footService.getCount(uid);
        List<FootGoodsVo> list = footService.getGoods(uid, pageVo);
        FootGoodsListVo goodsViewVo = new FootGoodsListVo();
        goodsViewVo.setTotal(count);
        goodsViewVo.setList(list);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, goodsViewVo);
    }

    @ApiOperation(value = "收藏列表 ")
    @PostMapping("/collectionsList")
    public ResponseVO<GoodsViewVo> collectionsList(@ApiIgnore @RequestAttribute Header header, @RequestBody PageVo pageVo) {
        String uid = header.getUid();
        Integer count = collectionsService.getCount(uid);
        List<SaleHotVo> list = collectionsService.getGoods(uid, pageVo);
        GoodsViewVo goodsViewVo = new GoodsViewVo();
        goodsViewVo.setTotal(count);
        goodsViewVo.setList(list);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, goodsViewVo);
    }

    @ApiOperation(value = "删除浏览足迹 param goodsIds")
    @PostMapping("/delFoot")
    public ResponseVO<String> delFoot(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String goodsIds = data.getString("goodsIds");
        String[] split = goodsIds.split(",");
        String uid = header.getUid();
        footService.delFoot(uid, split);
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "关注")
    @PostMapping("/getFollow")
    public ResponseVO<FollowVo> getFollow(@ApiIgnore @RequestAttribute Header header, @RequestBody PageVo pageVo) {
        String uid = header.getUid();
        List<Shop> shops = followService.getFollow(uid, pageVo);
        Integer count = followService.getCount(uid);
        FollowVo followVo = new FollowVo();
        followVo.setList(shops);
        followVo.setTotal(count);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, followVo);
    }


    @ApiOperation(value = "是否收藏 参数 goodsId")
    @PostMapping("/isCollections")
    public ResponseVO<Boolean> isCollections(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String goodsId = data.getString("goodsId");
        String uid = header.getUid();
        Boolean b = collectionsService.isCollections(uid, goodsId);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, b);
    }

    @ApiOperation(value = "取消收藏批量 参数 goodsIds")
    @PostMapping("/delCollections")
    public ResponseVO<String> delCollections(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String goodsIds = data.getString("goodsIds");
        String[] split = goodsIds.split(",");
        String uid = header.getUid();
        collectionsService.delCollections(uid, split);
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "是否关注 参数 merchantId")
    @PostMapping("/isFollow")
    public ResponseVO<Boolean> isFollow(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String merchantId = data.getString("merchantId");
        String uid = header.getUid();
        Boolean b = followService.isFollow(uid, merchantId);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, b);
    }

    @ApiOperation(value = "取消批量关注 参数 merchantIds")
    @PostMapping("/delFollows")
    public ResponseVO<Boolean> delFollows(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String merchantIds = data.getString("merchantIds");
        String[] split = merchantIds.split(",");
        String uid = header.getUid();
        followService.delFollows(uid, split);
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "获取优惠券 参数param: 1 有效  2 已使用  3 过期")
    @PostMapping("/couponList")
    public ResponseVO<UserCouponVo> couponList(@ApiIgnore @RequestAttribute Header header, @RequestBody PageVoWithOne PageVo) {
        String uid = header.getUid();
        Integer type = header.getType();
        List<MarketingCoupon> list = couponService.getUserCouponAndStatus(uid, type, PageVo);
        Integer count = couponService.getCount(uid, type, PageVo.getParam());
        UserCouponVo u = new UserCouponVo();
        u.setMarketingCoupons(list);
        u.setCount(count);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, u);
    }

    @ApiOperation(value = "用户部分信息统计")
    @PostMapping("/getUserCount")
    public ResponseVO<userCountInfo> getUserCount(@ApiIgnore @RequestAttribute Header header) {
        String uid = header.getUid();
        //收藏商品数量
        int collections = collectionsService.getCount(uid);
        //关注商品数量
        int follow = followService.getCount(uid);
        //足迹
        int foot = footService.getCount(uid);
        //积分数量
        UserAsset u = userAssetService.getCoin(uid, CoinNameEnum.MALLCOIN.value());
        BigDecimal mallCoin = u.getAmount();
        //优惠券数量
        int couponCount = couponService.getCount(uid, header.getType(), "1");
        BigDecimal all = userAssetService.getAllNotMallCoin(uid);
        if (all == null) {
            all = BigDecimal.ZERO;
        }
        userCountInfo userCountInfo = new userCountInfo();
        userCountInfo.setCoinAll(all);
        userCountInfo.setCouponCount(couponCount);
        userCountInfo.setCollections(collections);
        userCountInfo.setFollow(follow);
        userCountInfo.setFoot(foot);
        userCountInfo.setMallCoin(mallCoin);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, userCountInfo);
    }


    @ApiOperation(value = "消息 ")
    @PostMapping("/without/getNotice")
    public ResponseVO<NoticeView> getNotice(@ApiIgnore @RequestAttribute Header header, @RequestBody PageVo pageVo) {
        String uid = header.getUid();
        List<NoticeVo> noticeVos = noticeService.getWithOutUid(pageVo);
        if (StringUtil.isNullOrEmpty(uid)) {

        } else {
            for (NoticeVo n : noticeVos) {
                boolean b = noticeService.isRead(uid, n.getNoticeId());
                if (b) {
                    n.setUid(uid);
                }
            }

        }
        Integer count = noticeService.getCount();
        NoticeView n = new NoticeView();
        n.setList(noticeVos);
        n.setCount(count);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, n);
    }

    @ApiOperation(value = "读公告  参数 noticeId ")
    @PostMapping("/addNotice")
    public ResponseVO<String> getNotice(@ApiIgnore @RequestAttribute Header header, @RequestBody JSONObject data) {
        String uid = header.getUid();
        String noticeId = data.getString("noticeId");
        if (!redisService.setNx(uid + noticeId + "_addNotice")) {
            return new ResponseVO<>(MallResponseEnum.SUCCESS);
        }
        noticeService.addNotice(uid, noticeId);
        redisService.del(uid + noticeId + "_addNotice");
        return new ResponseVO<>(MallResponseEnum.SUCCESS);
    }

    @ApiOperation(value = "获取会员奖励")
    @PostMapping("/getRewardRule")
    public ResponseVO<MarketingMemberIntegralRecurrence> getNotice(@ApiIgnore @RequestAttribute Header header) {
        String uid = header.getUid();
        int i = 0;
        Member m = memberService.getByUid(uid);
        if (m == null) {
            i = 1;
        } else {
            i = m.getMemberLevel();
        }
        MarketingMemberIntegralRecurrence marketingMemberIntegralRecurrence = marketingMemberIntegralRecurrenceService.getByLevel(i);
        return new ResponseVO<>(MallResponseEnum.SUCCESS, marketingMemberIntegralRecurrence);
    }

    @ApiOperation(value = "账号是否注册  参数phone")
    @PostMapping("/without/isRegister")
    public ResponseVO<Boolean> isRegister(@RequestBody JSONObject data) {
        String phone = data.getString("phone");
        User user = userService.getAccount(phone);
        if (user == null) {
            return new ResponseVO<Boolean>(MallResponseEnum.SUCCESS, false);
        } else {
            return new ResponseVO<Boolean>(MallResponseEnum.SUCCESS, true);
        }
    }
}
