package com.cool.store.controller.webc;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.dao.*;
import com.cool.store.dao.fees.ShopAllocationInfoDAO;
import com.cool.store.dao.fees.WalletPayInfoDAO;
import com.cool.store.dto.OpenCityDTO;
import com.cool.store.dto.ocr.InvoiceDTO;
import com.cool.store.dto.store.StoreUserPositionDTO;
import com.cool.store.dto.store.StoreUserUpdateDTO;
import com.cool.store.dto.wallet.OpenBasicInfoDTO;
import com.cool.store.entity.*;
import com.cool.store.entity.fees.ShopAllocationInfoDO;
import com.cool.store.entity.fees.WalletPayInfoDO;
import com.cool.store.enums.*;
import com.cool.store.enums.point.ShopStageEnum;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.enums.wallet.WalletTradeModuleEnum;
import com.cool.store.exception.ApiException;
import com.cool.store.exception.ServiceException;
import com.cool.store.job.XxlJobHandler;
import com.cool.store.mapper.HyOpenAreaInfoMapper;
import com.cool.store.request.ShopListSuccessOpenRequest;
import com.cool.store.request.wallet.CoolOpenBasicInfoRequest;
import com.cool.store.request.xfsgFirstOrderListRequest;
import com.cool.store.request.xgj.FranchiseFeeCallBackRequest;
import com.cool.store.request.xgj.ReceiptCallBackRequest;
import com.cool.store.request.xgj.ReceiptRequest;
import com.cool.store.response.MiniShopsResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.caipin.StoreUserResponse;
import com.cool.store.response.xfsgFirstOderListResponse;
import com.cool.store.service.*;
import com.cool.store.service.impl.CommonService;
import com.cool.store.service.wallet.WalletService;
import com.cool.store.service.close.CloseStoreAccountService;
import com.cool.store.service.close.CloseStoreRefundService;
import com.cool.store.utils.CoolDateUtils;
import com.cool.store.utils.poi.ExcelUtil;
import com.cool.store.utils.poi.StringUtils;
import com.cool.store.vo.RegionPathNameVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.io.ByteArrayOutputStream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    private CoolStoreStartFlowService coolStoreStartFlowService;
    @Resource
    private EnterpriseUserDAO enterpriseUserDAO;

    @Resource
    private EnterpriseUserRoleDao enterpriseUserRoleDao;

    @Resource
    private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;

    @Resource
    private RegionDao regionDao;

    @Resource
    private SysRoleDao sysRoleDao;

    @Resource
    private UserRegionMappingDAO userRegionMappingDAO;

    @Resource
    private RegionService regionService;

    @Resource
    private XxlJobHandler xxlJobHandler;

    @Resource
    ShopStageInfoDAO shopStageInfoDAO;
    @Resource
    ThirdFoodService thirdFoodService;
    @Autowired
    StoreService storeService;
    @Resource
    LinePayDAO linePayDAO;
    @Resource
    OpenApiService openApiService;
    @Resource
    private CloseStoreAccountService closeStoreAccountService;
    @Resource
    private CloseStoreRefundService closeStoreRefundService;
    @Resource
    private WalletPayInfoDAO walletPayInfoDAO;
    @Resource
    private ShopAllocationInfoDAO shopAllocationInfoDAO;
    @Resource
    CommonService commonService;
    @Resource
    UserAuthMappingService userAuthMappingService;
    @Autowired
    private ShopInfoDAO shopInfoDAO;
    @Resource
    PushService pushService;
    @Resource
    FranchiseFeeDAO franchiseFeeDAO;

    @PostMapping("/walletXgjCallBack")
    public ResponseResult<Boolean> walletXgjCallBack(Long payInfoId) {
        WalletPayInfoDO payInfoDO = walletPayInfoDAO.getById(payInfoId);
        ReceiptCallBackRequest receiptRequest = new ReceiptCallBackRequest();
        receiptRequest.setReceiptId(payInfoDO.getPayNo());
        receiptRequest.setClaimStatus(1);
        receiptRequest.setPayWay(2);
        openApiService.changeReceiptStatus(receiptRequest);
        List<WalletPayInfoDO> list = walletPayInfoDAO.getByShopId(payInfoDO.getShopId(), WalletTradeModuleEnum.FRANCHISE_PAY.getModule(), null);
        List<ShopAllocationInfoDO> allocationList = shopAllocationInfoDAO.getByShopId(payInfoDO.getShopId());
        BigDecimal totalAmount = allocationList.stream().map(ShopAllocationInfoDO::getAmount).reduce(BigDecimal.valueOf(0), BigDecimal::add);
        BigDecimal paidAmount = list.stream().filter(v -> CommonConstants.INDEX_ONE.equals(v.getClaimStatus())).map(WalletPayInfoDO::getPayAmount).reduce(BigDecimal.valueOf(0), BigDecimal::add);
        FranchiseFeeCallBackRequest franchiseRequest = new FranchiseFeeCallBackRequest();
        franchiseRequest.setShopId(payInfoDO.getShopId());
        franchiseRequest.setPayableFee(totalAmount);
        franchiseRequest.setPaidFees(paidAmount);
        franchiseRequest.setRemainingFee(totalAmount.subtract(paidAmount));
        franchiseRequest.setPaymentStatus(franchiseRequest.getRemainingFee().compareTo(BigDecimal.ZERO) == 0
                ? XGJCollectionStatusEnum.COMPLETED.getCode() : franchiseRequest.getPaidFees().compareTo(BigDecimal.ZERO) == 0
                ? XGJCollectionStatusEnum.WAIT_PAY.getCode() : XGJCollectionStatusEnum.PARTIAL_PAYMENT.getCode());
        openApiService.changePaymentStatus(franchiseRequest);
        return ResponseResult.success(true);
    }


    @PostMapping("/testXgjCallback")
    public ResponseResult<Boolean> testXgjCallback(Long linePayId) {
        LinePayDO linePayDO = linePayDAO.getById(linePayId);
        ReceiptCallBackRequest receiptRequest = new ReceiptCallBackRequest();
        receiptRequest.setReceiptId(linePayDO.getPaymentReceiptCode());
        receiptRequest.setClaimStatus(1);
        openApiService.changeReceiptStatus(receiptRequest);
        FranchiseFeeCallBackRequest franchiseRequest = new FranchiseFeeCallBackRequest();
        franchiseRequest.setShopId(linePayDO.getShopId());
        franchiseRequest.setPayableFee(linePayDO.getAmount());
        franchiseRequest.setPaidFees(linePayDO.getAmount());
        franchiseRequest.setRemainingFee(BigDecimal.ZERO);
        franchiseRequest.setPaymentStatus(2);
        openApiService.changePaymentStatus(franchiseRequest);
        return ResponseResult.success(true);
    }

    @GetMapping("/completeRefund")
    public ResponseResult<Boolean> completeRefund(Long refundId) {
        closeStoreRefundService.completeRefund(refundId, new Date());
        return ResponseResult.success(true);
    }

    @GetMapping("/verifyAndUpdateAccountClose")
    public ResponseResult<Boolean> verifyAndUpdateAccountClose(Long closeStoreId) {
        closeStoreAccountService.verifyAndUpdateStage(closeStoreId);
        return ResponseResult.success(true);
    }

    @PostMapping("/getFirstOrders")
    public ResponseResult<xfsgFirstOderListResponse> getFirstOrders(@RequestBody xfsgFirstOrderListRequest storeCodeList) {
        xfsgFirstOderListResponse firstOrderList = coolStoreStartFlowService.getFirstOrderList(storeCodeList);
        return ResponseResult.success(firstOrderList);
    }

    @PostMapping("/importCity")
    public ResponseResult<Integer> importCity(MultipartFile file) {
        ExcelUtil<OpenCityDTO> util = new ExcelUtil<>(OpenCityDTO.class);
        try {
            List<OpenCityDTO> lineDOList = util.importExcel(file.getInputStream());
            get(lineDOList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.success(0);
    }

    @Resource
    HyOpenAreaInfoMapper hyOpenAreaInfoMapper;

    public Integer get(List<OpenCityDTO> importTask) {
        List<OpenCityDTO> codes = new ArrayList<>();
        try {
            List<OpenCityDTO> acityDTOS = importTask;
            HashMap<Integer, String> first = new HashMap<>(8);
            for (OpenCityDTO acityDTO : acityDTOS) {
                Integer code = acityDTO.getCode();
                //如果code后面三位都是0
                int i = code % 10000;
                if (i == 0) {
                    //表示是一级菜单
                    acityDTO.setPath("/" + acityDTO.getName() + "/");
                    first.put(code / 10000, acityDTO.getName());
                    HyOpenAreaInfoDO hyOpenAreaInfoDO = new HyOpenAreaInfoDO();
                    hyOpenAreaInfoDO.setAreaPath(acityDTO.getPath());
                    hyOpenAreaInfoDO.setId(acityDTO.getCode().longValue());
                    hyOpenAreaInfoDO.setAreaName(acityDTO.getName());
                    hyOpenAreaInfoDO.setAreaStatus("open");
                    hyOpenAreaInfoMapper.insertSelective(hyOpenAreaInfoDO);
                    continue;
                }
                //二级菜单
                int j = code % 100;
                if (j == 0) {
                    //北京市直辖市
                    String name = acityDTO.getName();
                    //code
                    int k = code / 10000;
                    String firstName = first.get(k);
                    if (firstName == null) {
                        codes.add(acityDTO);
                        log.info("========================={}", acityDTO);
                        continue;
                    }
                    // 先对name中相同的字段进行去重
                    String newName = name.replace(firstName, "");
                    // 然后拼接path
                    acityDTO.setPath("/" + firstName + "/" + newName + "/");
                    acityDTO.setName(newName);
                    HyOpenAreaInfoDO hyOpenAreaInfoDO = new HyOpenAreaInfoDO();
                    hyOpenAreaInfoDO.setAreaPath(acityDTO.getPath());
                    hyOpenAreaInfoDO.setId(acityDTO.getCode().longValue());
                    hyOpenAreaInfoDO.setAreaName(acityDTO.getName());
                    hyOpenAreaInfoDO.setAreaStatus("open");
                    hyOpenAreaInfoDO.setParentId(k * 10000L);
                    hyOpenAreaInfoMapper.insertSelective(hyOpenAreaInfoDO);
                }

            }
            System.out.println(JSONObject.toJSONString(codes));
        } catch (Exception e) {
        }
        return 0;
    }


    @GetMapping("/getUserInfo")
    public ResponseResult getUserInfo(@RequestParam("userId") String userId) {
        EnterpriseUserDO enterpriseUser = enterpriseUserDAO.getUserInfoById(userId);
        return ResponseResult.success(enterpriseUser);
    }

    @GetMapping("/getUserInfoByUserIds")
    public ResponseResult getUserInfoByUserIds(@RequestParam(value = "userIdList", required = false) List<String> userIdList) {
        List<EnterpriseUserDO> enterpriseUserDOList = enterpriseUserDAO.getUserInfoByUserIds(userIdList);
        return ResponseResult.success(enterpriseUserDOList);
    }

    @GetMapping("/getUserRoleIds")
    public ResponseResult getUserRoleIds(@RequestParam("userId") String userId) {
        List<Long> roleIdList = enterpriseUserRoleDao.getUserRoleIds(userId);
        return ResponseResult.success(roleIdList);
    }

    @GetMapping("/selectByMobile")
    public ResponseResult selectByMobile(@RequestParam("mobile") String mobile) {
        HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(mobile);
        return ResponseResult.success(hyPartnerUserInfoDO);
    }

    @GetMapping("/getRegionById")
    public ResponseResult getRegionById(@RequestParam("regionId") Long regionId) {
        RegionDO regionDO = regionDao.getRegionById(regionId);
        return ResponseResult.success(regionDO);
    }

    @GetMapping("/selectRoleByRoleIds")
    public ResponseResult selectRoleByRoleIds(@RequestParam("roleIds") List<Long> roleIds) {
        List<SysRoleDO> sysRoleDOList = sysRoleDao.selectRoleByRoleIds(roleIds);
        return ResponseResult.success(sysRoleDOList);
    }

    @GetMapping("/listUserRegionMappingByUserId")
    public ResponseResult listUserRegionMappingByUserId(@RequestParam("userIds") List<String> userIds) {
        List<UserRegionMappingDO> userRegionMappingDOList = userRegionMappingDAO.listUserRegionMappingByUserId(userIds);
        return ResponseResult.success(userRegionMappingDOList);
    }

    @GetMapping("/getAllRegionName")
    public ResponseResult getAllRegionName(@RequestParam("regionId") Long regionId) {
        RegionPathNameVO regionPathNameVO = regionService.getAllRegionName(regionId);
        return ResponseResult.success(regionPathNameVO);
    }

    @GetMapping("/updateFirstOrder")
    public ResponseResult updateFirstOrder() {
//        xxlJobHandler.updateFirstOrder();
        return ResponseResult.success();
    }

    @GetMapping("updateEntryTime")
    public ResponseResult updateEntryTime() {
        xxlJobHandler.updateEntryTime();
        return ResponseResult.success();
    }

    @GetMapping("/threeAcceptanceBookingMessage")
    public ResponseResult threeAcceptanceBookingMessage() {
        xxlJobHandler.threeAcceptanceBookingMessage();
        return ResponseResult.success();
    }

    //    @ApiOperation("成功开店的门店")
//    @GetMapping("/getShopListSuccessOpen")
//    public ResponseResult<PageInfo<MiniShopsResponse>> getShopListSuccessOpen(@RequestParam("lineId")Long lineId,
//                                                                              @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
//                                                                              @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
//                                                                              @RequestParam(value = "storeName",required = false,defaultValue = "") String storeName
//    ) {
//        return ResponseResult.success(shopService.getShopListSuccessOpen(lineId,pageNum,pageSize,storeName));
//    }
    @ApiOperation("成功开店的门店")
    @PostMapping("/getShopListSuccessOpen")
    public ResponseResult<PageInfo<MiniShopsResponse>> getShopListSuccessOpen(@RequestBody @Validated ShopListSuccessOpenRequest request) {
        return ResponseResult.success(shopService.getShopListSuccessOpen(request));
    }


    @GetMapping("/stageDataHandler")
    public ResponseResult stageDataHandler() {

        //查询所有完成初始化铺位加盟合同的完成情况
        List<ShopStageInfoDO> subStages = shopStageInfoDAO.getSubStages(ShopSubStageEnum.SHOP_STAGE_8.getShopSubStage());

        List<ShopStageInfoDO> existSubStages = shopStageInfoDAO.getSubStages(ShopSubStageEnum.SHOP_STAGE_8_5.getShopSubStage());

        //existSubStages
        List<Long> shopIds = existSubStages.stream().map(ShopStageInfoDO::getShopId).collect(Collectors.toList());

        //-100 800 840  如果是-100或者800直接  发票回传是-100  如果是840  发票回传是直接完成 890
        List<ShopStageInfoDO> list = new ArrayList<>();
        for (ShopStageInfoDO x : subStages) {
            if (shopIds.contains(x.getShopId())) {
                log.info("已存在");
                continue;
            }
            ShopStageInfoDO shopStageInfo = new ShopStageInfoDO();
            shopStageInfo.setLineId(x.getLineId());
            shopStageInfo.setShopId(x.getShopId());
            //发票回传 是2
            ShopStageEnum shopStageEnum = ShopStageEnum.SHOP_STAGE_2;
            shopStageInfo.setShopStage(shopStageEnum.getShopStage());
            ShopSubStageEnum shopSubStageEnum = ShopSubStageEnum.SHOP_STAGE_8_5;
            shopStageInfo.setShopSubStage(shopSubStageEnum.getShopSubStage());
            //默认是已完成
            ShopSubStageStatusEnum initStatus = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_85_3;
            //如果加盟合同没完成 则发票回传是未开始
            if (x.getShopSubStageStatus() == -100 || x.getShopSubStageStatus() == 800) {
                initStatus = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_00;
            }
            shopStageInfo.setShopSubStageStatus(initStatus.getShopSubStageStatus());
            shopStageInfo.setRemark(shopSubStageEnum.getShopSubStageName() + CommonConstants.PATH_BAR + initStatus.getShopSubStageStatusName());
            shopStageInfo.setIsTerminated(Boolean.FALSE);
            LocalDate localDate = LocalDate.parse(x.getPlanCompleteTime()).plusDays(1);
            shopStageInfo.setPlanCompleteTime(shopSubStageEnum.getPlanCompleteTime(localDate));
            list.add(shopStageInfo);
        }
        log.info("list:{}", JSONObject.toJSONString(list));
        shopStageInfoDAO.batchInsert(list);
        return ResponseResult.success();
    }


    @ApiModelProperty("装修阶段数据处理")
    @GetMapping("/decorationStageDataHandler")
    public ResponseResult decorationStageDataHandler() {
        //查询设计阶段
        List<ShopStageInfoDO> subStages = shopStageInfoDAO.getSubStages(ShopSubStageEnum.SHOP_STAGE_9.getShopSubStage());
        //已经含有测量阶段
        List<ShopStageInfoDO> existSubStages = shopStageInfoDAO.getSubStages(ShopSubStageEnum.SHOP_STAGE_8_6.getShopSubStage());

        List<Long> shopIds = existSubStages.stream().map(ShopStageInfoDO::getShopId).collect(Collectors.toList());
        List<ShopStageInfoDO> list = new ArrayList<>();
        List<Long> updateList = new ArrayList<>();
        for (ShopStageInfoDO x : subStages) {
            if (shopIds.contains(x.getShopId())) {
                log.info("已存在");
                continue;
            }
            ShopStageInfoDO shopStageInfo = new ShopStageInfoDO();
            shopStageInfo.setLineId(x.getLineId());
            shopStageInfo.setShopId(x.getShopId());
            ShopStageEnum shopStageEnum = ShopStageEnum.SHOP_STAGE_2;
            shopStageInfo.setShopStage(shopStageEnum.getShopStage());
            ShopSubStageEnum shopSubStageEnum = ShopSubStageEnum.SHOP_STAGE_8_6;
            shopStageInfo.setShopSubStage(shopSubStageEnum.getShopSubStage());

            /**
             * 原设计阶段为【已完成】或者【待确认】测量阶段为【已完成】
             * 原设计阶段为【待上传】，将设计阶段回退到【未开始】，测量阶段为【待分配测量员、设计组】
             * 原设计阶段为【未开始】，测量阶段为【未开始】
             */
            ShopSubStageStatusEnum initStatus = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_00;
            if (x.getShopSubStageStatus() == 900) {
                //当前状态回退 测量阶段为【待分配测量员、设计组】
                initStatus = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_861;
                x.setShopSubStageStatus(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_00.getShopSubStageStatus());
                x.setRemark("设计阶段" + CommonConstants.PATH_BAR + ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_00.getShopSubStageStatusName());
                shopStageInfoDAO.updateByPrimaryKeySelective(x);
            } else if (x.getShopSubStageStatus() == 905 || x.getShopSubStageStatus() == 910) {
                //测量阶段已完成
                initStatus = ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_863;
            }
            shopStageInfo.setShopSubStageStatus(initStatus.getShopSubStageStatus());
            shopStageInfo.setRemark(shopSubStageEnum.getShopSubStageName() + CommonConstants.PATH_BAR + initStatus.getShopSubStageStatusName());
            shopStageInfo.setIsTerminated(initStatus.isTerminated());
            LocalDate localDate = LocalDate.parse(x.getPlanCompleteTime()).plusDays(-1);
            shopStageInfo.setPlanCompleteTime(shopSubStageEnum.getPlanCompleteTime(localDate));
            list.add(shopStageInfo);
        }
        log.info("list:{}", JSONObject.toJSONString(list));
        shopStageInfoDAO.batchInsert(list);
        return ResponseResult.success();
    }


    @Resource
    PointService pointService;
    @Resource
    ShopService shopService;

    @GetMapping("/linePointToShopPoint")
    public ResponseResult linePointToShopPoint(@RequestParam(value = "shopId", required = false) Long shopId) {
        return ResponseResult.success(pointService.linePointToShopPoint(shopId));
    }

    @GetMapping("/dataHandler")
    public ResponseResult dataHandler(@RequestParam(value = "lineId", required = false) Long lineId) {
        return ResponseResult.success(shopService.dataHandler(lineId));
    }

    @GetMapping("/initTallyBook")
    public void initTallyBook() {
        xxlJobHandler.initTallyBook();
    }

    @GetMapping("/pushStoreUser")
    public void pushStoreUser(String storeCode){
        List<StoreUserPositionDTO> storeUser = storeService.getStoreUser(Arrays.asList(storeCode));
        List<StoreUserUpdateDTO> storeUserUpdateDTOS = JSONObject.parseArray(JSONObject.toJSONString(storeUser), StoreUserUpdateDTO.class);
        StoreUserResponse storeUserResponse = thirdFoodService.pushStoreUser(storeUserUpdateDTOS);
    }

    @Resource
    WalletService walletService;
    @ApiOperation("根据门店编码查询开通基础信息")
    @GetMapping("/getOpenBasicInfo")
    public ResponseResult<OpenBasicInfoDTO> getOpenBasicInfo(@NotBlank(message = "门店编码不能为空") String storeCode) {
        return ResponseResult.success(walletService.getOpenBasicInfo(null, storeCode));
    }

    @ApiOperation("提交开通")
    @PostMapping("/openOnlineBankAccount")
    public ResponseResult<Boolean> openOnlineBankAccount(@RequestBody @Validated CoolOpenBasicInfoRequest request) {
        return ResponseResult.success(walletService.openOnlineBankAccount(request));
    }

    @GetMapping("/handleStoreLogLai")
    public ResponseResult<Boolean> handleStoreLogLai(@RequestParam(value = "flag", required = false) Integer flag ,
                                            @RequestParam(value = "storeCode", required = false) String storeCode) {
        return ResponseResult.success(storeService.handleStoreLogLai(flag,storeCode));
    }


    @Resource
    LineInfoDAO lineInfoDAO;

    @GetMapping("/testSendMsg")
    public ResponseResult<Boolean> testSendMsg(@RequestParam(value = "poneNumber", required = false) String poneNumber ,
                                               @RequestParam(value = "shopId", required = false) Long shopId ,
                                               @RequestParam(value = "templateCode", required = false) SMSMsgEnum templateCode) {
        Map<String, String> templateParam = new HashMap<>();
        ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
        LineInfoDO lineInfo = lineInfoDAO.getLineInfo(shopInfo.getLineId());
        Date date = new Date();
        templateParam.put("partnerName",lineInfo.getUsername());
        templateParam.put("shopName",shopInfo.getShopName());
        templateParam.put("shippingDate", DateUtil.format(date, CoolDateUtils.DATE_FORMAT_DAY));
        commonService.sendSms(poneNumber, templateCode,templateParam);
        return ResponseResult.success();
    }


    @GetMapping("/pushReceiptToXGJ")
    public ResponseResult<Boolean> pushReceiptToXGJ(@RequestParam(value = "shopId", required = false) Long shopId,
                                               @RequestParam(value = "payId", required = false) Long payId) {
        ShopInfoDO shopInfoDO = shopInfoDAO.getShopInfo(shopId);
        if (shopInfoDO==null){
            return  ResponseResult.success(Boolean.FALSE);
        }
        FranchiseFeeDO franchiseFeeDO = franchiseFeeDAO.selectByShopId(shopInfoDO.getId());
        WalletPayInfoDO payInfo = walletPayInfoDAO.getById(payId);
        if (franchiseFeeDO==null||payInfo==null){
            return ResponseResult.success(Boolean.FALSE);
        }
        ReceiptRequest receiptRequest = new ReceiptRequest(shopInfoDO.getId(), franchiseFeeDO.getId().intValue(), payInfo, Integer.valueOf(shopInfoDO.getFranchiseBrand()));
        pushService.pushReceiptToXGJ(receiptRequest);
        return ResponseResult.success(Boolean.TRUE);
    }
}
