package com.sqx.modules.printInfo.controller;


import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sqx.common.utils.Result;
import com.sqx.modules.address.entity.Address;
import com.sqx.modules.goods.entity.GoodsShop;
import com.sqx.modules.goods.service.GoodsShopService;
import com.sqx.modules.order.entity.TbOrder;
import com.sqx.modules.order.service.AppOrderService;
import com.sqx.modules.order.service.impl.AppAppOrderServiceImpl;
import com.sqx.modules.printInfo.entity.*;
import com.sqx.modules.printInfo.service.PrintInfoDetailService;
import com.sqx.modules.printInfo.service.PrintInfoService;
import com.sqx.modules.printInfo.service.PrintInfoShopService;
import com.sqx.modules.utils.fieYun.FeiYunUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 活动管理
 * </p>
 *
 * @author 吴畅
 * @since 2022-11-04
 */
@RestController
@Api(value = "管理端-打印模板信息", tags = {"管理端-打印模板信息"})
@RequestMapping("/admin/printInfo/")
@Slf4j
public class PrintInfoController {
    @Autowired
    private PrintInfoService printInfoService;

    @Autowired
    private PrintInfoShopService printInfoShopService;

    @Autowired
    private AppAppOrderServiceImpl appAppOrderService;

    @Autowired
    private GoodsShopService goodsShopService;

    @Autowired
    private PrintInfoDetailService printInfoDetailService;

    @GetMapping("getOrderPrintDetailList")
    @ApiOperation("获取订单打印记录列表")
    public Result getPrintInfoList(Integer page, Integer limit, Long orderId) {
        //region 参数判断
        if(page == null){
            return Result.error("当前页不能为空！");
        }
        if(limit == null){
            return Result.error("一页数据条数不能为空！");
        }
        if(orderId == null){
            return Result.error("订单ID不能为空！");
        }
        //endregion

        return printInfoDetailService.selectPrintInfoDetailList(page, limit, orderId);
    }

    @GetMapping("testPrintModel")
    @ApiOperation("获取打印信息列表")
    public Result testPrintModel(Long orderId) {
        // 查询订单信息
        TbOrder tbOrder = appAppOrderService.selectOrderByIds(orderId);
        Long shopId = tbOrder.getShopId();

        // 查询店铺信息
        GoodsShop goodsShop = goodsShopService.selectGoodDatas(shopId);

        // 查询当天店铺所有已支付的订单号，按支付时间排序
        tbOrder.setCountOrder(3);

        if (StringUtils.isNotEmpty(goodsShop.getSnCode())) {
            FeiYunUtils.print(goodsShop.getSnCode(), null, tbOrder, null);
        } else {
            return Result.error("当前商家未绑定打印机！");
        }
        return Result.success();
    }

    @GetMapping("testReturnPrintModel")
    @ApiOperation("测试退单打印")
    public Result testReturnPrintModel(Long orderId) {
        // 查询订单信息
        TbOrder tbOrder = appAppOrderService.selectOrderByIds(orderId);
        Long shopId = tbOrder.getShopId();

        // 查询店铺信息
        GoodsShop goodsShop = goodsShopService.selectGoodDatas(shopId);

        // 查询当天店铺所有已支付的订单号，按支付时间排序
        tbOrder.setCountOrder(3);

        if (StringUtils.isNotEmpty(goodsShop.getSnCode())) {
            FeiYunUtils.returnPrint(goodsShop.getSnCode(), tbOrder);
        } else {
            return Result.error("当前商家未绑定打印机！");
        }
        return Result.success();
    }


    @GetMapping("getPrintInfoList")
    @ApiOperation("获取打印信息列表")
    public Result getPrintInfoList(Integer page, Integer limit) {
        return printInfoService.selectPrintInfoList(page, limit);
    }

    @GetMapping("getPrintInfo")
    @ApiOperation("获取打印信息")
    public Result getPrintInfoInfo(Integer id) {
        return printInfoService.selectPrintInfoById(id);
    }

    @PostMapping("insertPrintInfo")
    @ApiOperation("新增打印信息")
    public Result insertPrintInfo(@RequestBody PrintInfo printInfo) {
        //不能加入自定义参数以外的数据
        List<String> files = new ArrayList<>();
        files.add("platform_name");
        files.add("shop_name");
        files.add("order_number");
        files.add("order_type_extra");
        files.add("goods_name");
        files.add("goods_price");
        files.add("goods_num");
        files.add("sum_money");
        files.add("remark");
        files.add("pack_money");
        files.add("goods_money");
        files.add("coupon_money");
        files.add("errand_money");
        files.add("activity_title");
        files.add("pay_money");
        files.add("user_name");
        files.add("phone");
        files.add("address_detail");
        files.add("pay_time");
        files.add("user_nick_name");
        files.add("shop_phone");
        files.add("distribution_distance_start");
        files.add("detailed_address");
        files.add("shop_receiving_time");
        files.add("shop_id");
        files.add("parent_user_id");
        files.add("auto_send_order");
        files.add("order_code");
        files.add("pay_type");
        files.add("create_time");
        files.add("user_id");
        files.add("coupon_id");
        files.add("expect_delivery_time");
        if (!files.contains(printInfo.getPrintField())) {
            return Result.error("无法新增非法字段");
        }

        int existCount = printInfoService.existInfo(printInfo.getTypeId(), printInfo.getPrintField());
        if (existCount > 0) {
            return Result.error("当前类型中已包含该字段");
        }

        return printInfoService.insertPrintInfo(printInfo);
    }

    @GetMapping("updatePrintInfo")
    @ApiOperation("更新打印信息")
    private Result updatePrintInfo(@RequestBody PrintInfo printInfo) {
        //不能加入自定义参数以外的数据
        List<String> files = new ArrayList<>();
        files.add("platform_name");
        files.add("shop_name");
        files.add("order_number");
        files.add("order_type_extra");
        files.add("goods_name");
        files.add("goods_price");
        files.add("goods_num");
        files.add("sum_money");
        files.add("remark");
        files.add("pack_money");
        files.add("goods_money");
        files.add("coupon_money");
        files.add("errand_money");
        files.add("activity_title");
        files.add("pay_money");
        files.add("user_name");
        files.add("phone");
        files.add("address_detail");
        files.add("pay_time");
        files.add("user_nick_name");
        files.add("shop_phone");
        files.add("distribution_distance_start");
        files.add("detailed_address");
        files.add("shop_receiving_time");
        files.add("shop_id");
        files.add("parent_user_id");
        files.add("auto_send_order");
        files.add("order_code");
        files.add("pay_type");
        files.add("create_time");
        files.add("user_id");
        files.add("coupon_id");
        files.add("expect_delivery_time");
        if (!files.contains(printInfo.getPrintField())) {
            return Result.error("无法将数据更新为非法字段");
        }

        PrintInfo existData = printInfoService.existInfoData(printInfo.getTypeId(), printInfo.getPrintField());
        if (existData != null && existData.getId().intValue() != printInfo.getId().intValue()) {
            return Result.error("当前类型中已包含该字段");
        }

        return printInfoService.updatePrintInfo(printInfo);
    }

    @GetMapping("getPrintDropList")
    @ApiOperation("获取打印信息类型下拉列表")
    public Result getPrintDropList() {

        int length = ePrintStatu.values().length;
        List<PrintDropVo> result = new ArrayList<>();
        for (int i = 1; i < length + 1; i++) {
            PrintDropVo data = new PrintDropVo();
            data.setId(i);
            data.setName(ePrintStatu.stringOf(i));
            result.add(data);
        }
        return Result.success().put("data", result);
    }

    /**
     * 根据店铺ID获取对应店铺的打印模板信息
     *
     * @param shopId
     * @return
     */
    @GetMapping("getPrintModelData")
    @ApiOperation("获取打印模板信息")
    public Result getPrintModelData(Integer shopId) throws JsonProcessingException {

        if (shopId == null) {
            return Result.error("商铺ID不能为空");
        }

        //region 必填
        List<String> haves = new ArrayList<>();
        haves.add("platform_name");
        haves.add("shop_name");
        haves.add("order_number");
        haves.add("order_type_extra");
        haves.add("expect_delivery_time");
        haves.add("goods_name");
        haves.add("goods_price");
        haves.add("goods_num");
        haves.add("remark");
        haves.add("pack_money");
        haves.add("goods_money");
        haves.add("coupon_money");
        haves.add("errand_money");
        haves.add("activity_title");
        haves.add("pay_money");
        haves.add("user_name");
        haves.add("phone");
        haves.add("address_detail");
        haves.add("pay_time");
        //endregion

        PrintResultModelVo resultData = new PrintResultModelVo();
        resultData.setShopId(shopId);
        List<PrintModelResult> result = new ArrayList<>();
        List<PrintInfo> infos = printInfoService.printInfos();
        List<Integer> typeIds = infos.stream().map(PrintInfo::getTypeId).distinct().collect(Collectors.toList());
        PrintInfoShop pis = printInfoShopService.selectPrintInfoShopById(shopId);
        if (pis == null) {
            for (Integer typeId : typeIds) {
                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == typeId.intValue()).collect(Collectors.toList());
                PrintModelResult data = new PrintModelResult();
                List<PrintModelDetailResult> details = new ArrayList<>();
                List<PrintModelTypeResult> types = new ArrayList<>();
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    details.add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    types.add(typeData);

                }
                if (nowInfos != null && nowInfos.size() > 0) {
                    data.setId(typeId);
                    data.setName(nowInfos.get(0).getTypeName());
                }
                data.setDetails(details);
                data.setTypes(types);
                result.add(data);
            }
        } else {
            //要修改获取逻辑
            resultData.setId(pis.getId());
            if (pis.getBaseInfo().isEmpty()) {
                PrintModelResult data = new PrintModelResult();
                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Base.getValue()).collect(Collectors.toList());
                List<PrintModelDetailResult> details = new ArrayList<>();
                List<PrintModelTypeResult> types = new ArrayList<>();
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    details.add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    types.add(typeData);
                }
                data.setId(ePrintStatu.Base.getValue());
                data.setName(nowInfos.get(0).getTypeName());
                data.setDetails(details);
                data.setTypes(types);
                result.add(data);
            } else {
                ObjectMapper objectMapper = new ObjectMapper();
                PrintModelResult data = objectMapper.readValue(pis.getBaseInfo(), PrintModelResult.class);

                List<Integer> detailIds = (data.getDetails() != null && data.getDetails().size() > 0) ? data.getDetails().stream().map(PrintModelDetailResult::getId).distinct().collect(Collectors.toList()) : new ArrayList<>();

                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Base.getValue() && !detailIds.contains(e.getId())).collect(Collectors.toList());
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    data.getDetails().add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    data.getTypes().add(typeData);
                }

                result.add(data);
            }

            if (pis.getGoodInfo().isEmpty()) {
                PrintModelResult data = new PrintModelResult();
                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Good.getValue()).collect(Collectors.toList());
                List<PrintModelDetailResult> details = new ArrayList<>();
                List<PrintModelTypeResult> types = new ArrayList<>();
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    details.add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    types.add(typeData);
                }
                data.setId(ePrintStatu.Good.getValue());
                data.setName(nowInfos.get(0).getTypeName());
                data.setDetails(details);
                data.setTypes(types);
                result.add(data);
            } else {
                ObjectMapper objectMapper = new ObjectMapper();
                PrintModelResult data = objectMapper.readValue(pis.getGoodInfo(), PrintModelResult.class);
                List<Integer> detailIds = (data.getDetails() != null && data.getDetails().size() > 0) ? data.getDetails().stream().map(PrintModelDetailResult::getId).distinct().collect(Collectors.toList()) : new ArrayList<>();

                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Good.getValue() && !detailIds.contains(e.getId())).collect(Collectors.toList());
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    data.getDetails().add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    data.getTypes().add(typeData);
                }

                result.add(data);
            }

            if (pis.getPayInfo().isEmpty()) {
                PrintModelResult data = new PrintModelResult();
                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Pay.getValue()).collect(Collectors.toList());
                List<PrintModelDetailResult> details = new ArrayList<>();
                List<PrintModelTypeResult> types = new ArrayList<>();
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    details.add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    types.add(typeData);
                }
                data.setId(ePrintStatu.Pay.getValue());
                data.setName(nowInfos.get(0).getTypeName());
                data.setDetails(details);
                data.setTypes(types);
                result.add(data);
            } else {
                ObjectMapper objectMapper = new ObjectMapper();
                PrintModelResult data = objectMapper.readValue(pis.getPayInfo(), PrintModelResult.class);
                List<Integer> detailIds = (data.getDetails() != null && data.getDetails().size() > 0) ? data.getDetails().stream().map(PrintModelDetailResult::getId).distinct().collect(Collectors.toList()) : new ArrayList<>();

                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Pay.getValue() && !detailIds.contains(e.getId())).collect(Collectors.toList());
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    data.getDetails().add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    data.getTypes().add(typeData);
                }
                result.add(data);
            }

            if (pis.getUserInfo().isEmpty()) {
                PrintModelResult data = new PrintModelResult();
                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.User.getValue()).collect(Collectors.toList());
                List<PrintModelDetailResult> details = new ArrayList<>();
                List<PrintModelTypeResult> types = new ArrayList<>();
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    details.add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    types.add(typeData);
                }
                data.setId(ePrintStatu.User.getValue());
                data.setName(nowInfos.get(0).getTypeName());
                data.setDetails(details);
                data.setTypes(types);
                result.add(data);
            } else {
                ObjectMapper objectMapper = new ObjectMapper();
                PrintModelResult data = objectMapper.readValue(pis.getUserInfo(), PrintModelResult.class);
                List<Integer> detailIds = (data.getDetails() != null && data.getDetails().size() > 0) ? data.getDetails().stream().map(PrintModelDetailResult::getId).distinct().collect(Collectors.toList()) : new ArrayList<>();

                List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.User.getValue() && !detailIds.contains(e.getId())).collect(Collectors.toList());
                for (PrintInfo nowInfo : nowInfos) {
                    PrintModelDetailResult detailData = new PrintModelDetailResult();
                    detailData.setId(nowInfo.getId());
                    detailData.setPrintField(nowInfo.getPrintField());
                    detailData.setPrintName(nowInfo.getPrintName());
                    if (haves.contains(nowInfo.getPrintField())) {
                        detailData.setIsCheck(1);
                    } else {
                        detailData.setIsCheck(0);
                    }
                    data.getDetails().add(detailData);

                    PrintModelTypeResult typeData = new PrintModelTypeResult();
                    typeData.setId(nowInfo.getId());
                    typeData.setIsBlod(0);
                    typeData.setWordSize(1);
                    typeData.setPrintField(nowInfo.getPrintField());
                    typeData.setPrintName(nowInfo.getPrintName());
                    data.getTypes().add(typeData);
                }
                result.add(data);
            }

        }
        resultData.setModelDatas(result);
        return Result.success().put("data", resultData);
    }


    /**
     * 根据店铺ID获取对应店铺的打印模板信息
     *
     * @param printResult 模板信息数据
     * @return
     */
    @PostMapping("insertPrintModelData")
    @ApiOperation("新增打印模板信息")
    public Result insertPrintModelData(@RequestBody PrintResultModelVo printResult) {
        PrintInfoShop pis = new PrintInfoShop();
        pis.setShopId(printResult.getShopId());
        if (printResult != null && printResult.getModelDatas() != null && printResult.getModelDatas().size() > 0) {
            for (PrintModelResult pmr : printResult.getModelDatas()) {
                switch (pmr.getId().intValue()) {
                    case 1://基本信息：1
                        pis.setBaseInfo(JSON.toJSONString(pmr));
                        break;
                    case 2:// 商品信息：2
                        pis.setGoodInfo(JSON.toJSONString(pmr));
                        break;
                    case 3:// 支付信息：3
                        pis.setPayInfo(JSON.toJSONString(pmr));
                        break;
                    case 4:// 用户信息：4
                        pis.setUserInfo(JSON.toJSONString(pmr));
                        break;
                    default:
                        break;
                }
            }
        }

        return printInfoShopService.insertPrintInfoShop(pis);
    }

    /**
     * 根据店铺ID获取对应店铺的打印模板信息
     *
     * @param printResult 模板信息数据
     * @return
     */
    @PostMapping("updatePrintModelData")
    @ApiOperation("更新打印模板信息")
    public Result updatePrintModelData(@RequestBody PrintResultModelVo printResult) {
        PrintInfoShop pis = new PrintInfoShop();
        pis.setId(printResult.getId());
        pis.setShopId(printResult.getShopId());
        if (printResult != null && printResult.getModelDatas() != null && printResult.getModelDatas().size() > 0) {
            for (PrintModelResult pmr : printResult.getModelDatas()) {
                switch (pmr.getId().intValue()) {
                    case 1://基本信息：1
                        pis.setBaseInfo(JSON.toJSONString(pmr));
                        break;
                    case 2:// 商品信息：2
                        pis.setGoodInfo(JSON.toJSONString(pmr));
                        break;
                    case 3:// 支付信息：3
                        pis.setPayInfo(JSON.toJSONString(pmr));
                        break;
                    case 4:// 用户信息：4
                        pis.setUserInfo(JSON.toJSONString(pmr));
                        break;
                    default:
                        break;
                }
            }
        }

        return printInfoShopService.updatePrintInfoShop(pis);
    }


    /**
     * 测试打印功能
     */
    @GetMapping("testPrintInfo")
    @ApiOperation("测试打印功能")
    public Result testPrintInfo(String sn) {
        log.info("进入打印:sn" + sn);
        FeiYunUtils.testPrint(sn);
        log.info("打印结束:sn" + sn);
        return Result.success();
    }
}

