package com.ruixuan.bytedance.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.alliance_colonelActivityProduct.AllianceColonelActivityProductRequest;
import com.doudian.open.api.alliance_colonelActivityProduct.AllianceColonelActivityProductResponse;
import com.doudian.open.api.alliance_colonelActivityProduct.param.AllianceColonelActivityProductParam;
import com.doudian.open.api.alliance_instituteColonelActivityList.AllianceInstituteColonelActivityListRequest;
import com.doudian.open.api.alliance_instituteColonelActivityList.AllianceInstituteColonelActivityListResponse;
import com.doudian.open.api.alliance_instituteColonelActivityList.data.ActivityListItem;
import com.doudian.open.api.alliance_instituteColonelActivityList.data.AllianceInstituteColonelActivityListData;
import com.doudian.open.api.alliance_instituteColonelActivityList.param.AllianceInstituteColonelActivityListParam;
import com.doudian.open.api.buyin_colonelActivityDetail.BuyinColonelActivityDetailRequest;
import com.doudian.open.api.buyin_colonelActivityDetail.BuyinColonelActivityDetailResponse;
import com.doudian.open.api.buyin_colonelActivityDetail.data.BuyinColonelActivityDetailData;
import com.doudian.open.api.buyin_colonelActivityDetail.param.BuyinColonelActivityDetailParam;
import com.doudian.open.api.buyin_colonelMultiSettlementOrders.BuyinColonelMultiSettlementOrdersRequest;
import com.doudian.open.api.buyin_colonelMultiSettlementOrders.BuyinColonelMultiSettlementOrdersResponse;
import com.doudian.open.api.buyin_colonelMultiSettlementOrders.param.BuyinColonelMultiSettlementOrdersParam;
import com.doudian.open.api.buyin_colonel_trusteeshipList.BuyinColonelTrusteeshipListRequest;
import com.doudian.open.api.buyin_colonel_trusteeshipList.BuyinColonelTrusteeshipListResponse;
import com.doudian.open.api.buyin_colonel_trusteeshipList.param.BuyinColonelTrusteeshipListParam;
import com.doudian.open.api.buyin_decryptContactInfo.BuyinDecryptContactInfoRequest;
import com.doudian.open.api.buyin_decryptContactInfo.BuyinDecryptContactInfoResponse;
import com.doudian.open.api.buyin_decryptContactInfo.data.BuyinDecryptContactInfoData;
import com.doudian.open.api.buyin_decryptContactInfo.param.BuyinDecryptContactInfoParam;
import com.doudian.open.api.buyin_instituteOrderColonel.BuyinInstituteOrderColonelRequest;
import com.doudian.open.api.buyin_instituteOrderColonel.BuyinInstituteOrderColonelResponse;
import com.doudian.open.api.buyin_instituteOrderColonel.data.ColonelOrderInfo;
import com.doudian.open.api.buyin_instituteOrderColonel.data.ColonelOrderInfoSecond;
import com.doudian.open.api.buyin_instituteOrderColonel.data.Data;
import com.doudian.open.api.buyin_instituteOrderColonel.data.OrdersItem;
import com.doudian.open.api.buyin_instituteOrderColonel.param.BuyinInstituteOrderColonelParam;
import com.doudian.open.core.AccessToken;
import com.ruixuan.bytedance.entity.BytedanceColonelActivity;
import com.ruixuan.bytedance.entity.BytedanceColonelActivityDetail;
import com.ruixuan.bytedance.entity.BytedanceOrderList;
import com.ruixuan.bytedance.mapper.BytedanceColonelActivityMapper;
import com.ruixuan.bytedance.mapper.BytedanceMapper;
import com.ruixuan.bytedance.service.IBytedanceAccessTokenService;
import com.ruixuan.bytedance.service.IBytedanceService;
import com.ruixuan.common.utils.Check;
import com.ruixuan.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class BytedanceServiceImpl implements IBytedanceService {

    @Autowired
    private IBytedanceAccessTokenService tokenService;

    @Autowired
    private BytedanceColonelActivityMapper bytedanceColonelActivityMapper;

    @Autowired
    private BytedanceMapper bytedanceMapper;

    /**
     * 新增团长活动 信息
     *
     * @param 信息
     */
    @Override
    public void addBytedanceColonelActivityList(Long page) {
        AccessToken accessToken = tokenService.getAccessToken(1L);
        AllianceInstituteColonelActivityListRequest request = new AllianceInstituteColonelActivityListRequest();
        AllianceInstituteColonelActivityListParam param = request.getParam();
        param.setStatus(0);
        param.setSearchType(0L);
        param.setSortType(0L);
        param.setPage(page);
        param.setPageSize(20L);
        AllianceInstituteColonelActivityListResponse response = request.execute(accessToken);
        if (Check.isNull(response) || !"10000".equals(response.getCode())) {
            log.error("\n【请求接口】: {}\n【请求参数】：{}\n【响应数据】：{}", "/alliance/instituteColonelActivityList；（团长活动查询接口）", param, response);
            return;
        }
        AllianceInstituteColonelActivityListData data = response.getData();
        List<ActivityListItem> activityList = data.getActivityList();
        if (Check.isNotNull(activityList)) {
            List<BytedanceColonelActivity> list = new ArrayList<>();
            for (ActivityListItem activityItem : activityList) {
                BytedanceColonelActivity activity = new BytedanceColonelActivity();
                BeanUtils.copyProperties(activityItem, activity);
                activity.setActivityStartTime(DateUtils.strDateToInt(activityItem.getActivityStartTime()));
                activity.setActivityEndTime(DateUtils.strDateToInt(activityItem.getActivityEndTime()));
                activity.setApplicationStartTime(DateUtils.strDateToInt(activityItem.getApplicationStartTime()));
                activity.setApplicationEndTime(DateUtils.strDateToInt(activityItem.getApplicationEndTime()));
                if (Check.isNotNull(activityItem.getCategoriesLimit())) {
                    activity.setCategoriesLimit(JSONObject.toJSON(activityItem.getCategoriesLimit()).toString());
                }
                activity.setInstitutionId(data.getInstitutionId());
                activity.setColonelBuyinId(data.getColonelBuyinId());
                list.add(activity);
            }
            bytedanceMapper.replaceBatchActivitys(list);

            //添加详情
            for (BytedanceColonelActivity activity : list) {
                BytedanceColonelActivityDetail activityDetail = bytedanceColonelActivityMapper.getDetailByActivityId(activity.getActivityId());
                if (Check.isNull(activityDetail)) {
                    addBytedanceColonelActivityDetail(activity.getActivityId());
                }
            }

            int size = data.getActivityList().size();
            if (size >= 20) {
                addBytedanceColonelActivityList(page + 1);
            }
        }
    }

    @Override
    public void addBytedanceColonelActivityDetail(Long activityId) {
        AccessToken accessToken = tokenService.getAccessToken(1L);
        BuyinColonelActivityDetailRequest request = new BuyinColonelActivityDetailRequest();
        BuyinColonelActivityDetailParam param = request.getParam();
        param.setActivityId(activityId);
        BuyinColonelActivityDetailResponse response = request.execute(accessToken);
        if (Check.isNull(response) || !"10000".equals(response.getCode())) {
            log.error("\n【请求接口】: {}\n【请求参数】：{}\n【响应数据】：{}", "/buyin/colonelActivityDetail；（获取团长活动详情）", param, response);
            return;
        }
        BuyinColonelActivityDetailData data = response.getData();
        if (Check.isNotNull(data)) {
            BytedanceColonelActivityDetail activityDetail = new BytedanceColonelActivityDetail();
            BeanUtils.copyProperties(data, activityDetail);
            if (Check.isNotNull(data.getIsNewShop())) {
                activityDetail.setIsNewShop(data.getIsNewShop() ? 1 : 0);
            }
            if (Check.isNotNull(data.getHasThreshold())) {
                activityDetail.setHasThreshold(data.getHasThreshold() ? 1 : 0);
            }
            if (Check.isNotNull(data.getShopType())) {
                activityDetail.setShopType(JSONObject.toJSON(data.getShopType()).toString());
            }
            if (Check.isNotNull(data.getWechatId())) {
                activityDetail.setWechatId(decryptContactInfo(accessToken, data.getWechatId(), activityId));
            }
            if (Check.isNotNull(data.getPhoneNum())) {
                activityDetail.setPhoneNum(decryptContactInfo(accessToken, data.getPhoneNum(), activityId));
            }
            //招商类目
            if (Check.isNotNull(data.getCategories())) {
                activityDetail.setCategories(JSONObject.toJSON(data.getCategories()).toString());
            }
            activityDetail.setApplyStartTime(DateUtils.strDateToInt(data.getApplyStartTime()));
            activityDetail.setApplyEndTime(DateUtils.strDateToInt(data.getApplyEndTime()));
            bytedanceMapper.insertDetail(activityDetail);
        }

    }

    @Override
    public JSONObject addBytedanceColonelActivityProduct(Long activityId, Long productInfo) {
        JSONObject returnJson = new JSONObject();
        AccessToken accessToken = tokenService.getAccessToken(1L);

        AllianceColonelActivityProductRequest request = new AllianceColonelActivityProductRequest();
        AllianceColonelActivityProductParam param = request.getParam();
        param.setActivityId(activityId);
        param.setProductInfo(String.valueOf(productInfo));//商品ID/名称（支持根据商品id或者商品名称搜索，商品ID精准匹配，商品名称模糊匹配）
        param.setPage(1L);//页码，从1开始。分页模式下生效，超过10000条会被限制，推荐使用游标模式 retrieve_mode=1
        param.setCount(20L);//每页数量（每页最多20）
//        param.setSearchType(4L);//0：报名时间；1：活动价格排序；2：活动佣金比例排序；4：更新时间排序
//        param.setSortType(0L);//排序顺序。0：升序；1：降序
//        param.setCooperationInfo("23412312");//商家ID or 商家名称 or 一级团长名称 or 一级团长ID
//        param.setCooperationType(0);//合作类型. 0: 不限; 1: 商家; 2: 团长
//        param.setStatus(0L);//活动商品状态，不传查所有状态。0：待审核；1：推广中；2：申请未通过；3：合作已终止；6：合作已到期
//        param.setRetrieveMode(1);//获取模式。0: 分页模式（默认），最多返回10000条数据；1: 游标模式（推荐），返回条数无限制

        AllianceColonelActivityProductResponse response = request.execute(accessToken);
        JSONObject jsonObject = JSONObject.parseObject(response.toString());
        log.info("返回数据:{}",jsonObject);
        Integer code = jsonObject.getInteger("code");
        String msg = jsonObject.getString("msg");
        if (code == 10000) {
            returnJson.put("code", 0);
            returnJson.put("message", "请求成功");
            returnJson.put("judgeStatus", "1");
            JSONObject dataJson = jsonObject.getJSONObject("data");
          JSONArray  dataArr = dataJson.getJSONArray("data");
          if(!Check.isNull(dataArr)){
              JSONObject data = dataArr.getJSONObject(0);
              if (!Check.isNull(data)) {
                  JSONObject itemJson = new JSONObject();
                  String product_id = data.getString("product_id");//商品ID
                  String title = data.getString("title");//商品名称
                  Long price = data.getLong("price");//商品售价
                  Double cos_ratio = data.getDouble("cos_ratio");//	佣金比例
                  Long cos_fee = data.getLong("cos_fee");//	佣金金额，单位分
                  Long first_cid = data.getLong("first_cid");//	商品一级类目
                  Long second_cid = data.getLong("second_cid");//	商品二级类目
                  Long third_cid = data.getLong("third_cid");//	商品商品三级类目
                  Long sales = data.getLong("sales");//	销量
                  String cover = data.getString("cover");//	商品主图
                  String detail_url = data.getString("detail_url");//	商品团长活动链接
                  Long shop_id = data.getLong("shop_id");//	店铺ID
                  String shop_name = data.getString("shop_name");//	店铺名称
                  Integer status = data.getInteger("status");//	审核状态
                  String reason = data.getString("reason");//	reason
                  Long category_id = data.getLong("category_id");//	行业类目ID
                  String category_name = data.getString("category_name");//	行业类目名称
                  String product_stock = data.getString("product_stock");//	商品库存
                  String shop_score = data.getString("shop_score");//	店铺分
                  Double service_ratio = data.getDouble("service_ratio");//	店铺分

                  itemJson.put("itemId", product_id);
                  itemJson.put("itemTitle", title);
                  itemJson.put("itemPrice", price);
                  itemJson.put("itemDesc", title);
                  itemJson.put("zkFinalPrice", price);
                  itemJson.put("itemImgUrl", cover);
                  itemJson.put("shopStar", "-");
                  itemJson.put("mallLogisticsScore", shop_name);
                  if (status == 0) {
                      itemJson.put("activityItemStatus", 1);
                  } else if (status == 1) {
                      itemJson.put("activityItemStatus", 2);
                  } else if (status == 2) {
                      itemJson.put("activityItemStatus", 3);
                  } else {
                      itemJson.put("activityItemStatus", 5);
                  }
                  itemJson.put("categoryId", category_id);
                  itemJson.put("categoryName", category_name);
                  itemJson.put("itemGalleryUrls", null); // 轮播图
                  itemJson.put("itemDescUrls", null); // 详情图
                  itemJson.put("activityId", activityId);
                  itemJson.put("shopTitle", shop_name);
                  if(!Check.isNull(cos_ratio)){
                      itemJson.put("commissionRate", cos_ratio * 10);
                  }else {
                      itemJson.put("commissionRate", 0);
                  }

                  itemJson.put("mallServiceScore", shop_score);
                  itemJson.put("mallQualityScore", ""); // 店铺质量分
                  itemJson.put("skuList", ""); // sku信息
                  itemJson.put("postArea", ""); // 发货地址
                  itemJson.put("detailUrl", detail_url);
                  if(!Check.isNull(service_ratio)){
                      itemJson.put("regimentalPromotionRate", service_ratio *  10);
                  }else {
                      itemJson.put("regimentalPromotionRate",0);
                  }

                  returnJson.put("itemJson", itemJson);

              }else{
                  returnJson.put("code", -1);
                  returnJson.put("message", "返回数据为空");
              }
          } else{
              returnJson.put("code", -1);
              returnJson.put("message", "返回数据为空");

          }




        } else {
            returnJson.put("code", -1);
            returnJson.put("message", msg);

        }


        return returnJson;

    }

    @Override
    public JSONObject trusteeship(Long activityId, Long itemId) {
        JSONObject returnJson = new JSONObject();
        AccessToken accessToken = tokenService.getAccessToken(1L);
        BuyinColonelTrusteeshipListRequest request = new BuyinColonelTrusteeshipListRequest();
        BuyinColonelTrusteeshipListParam param = request.getParam();
        param.setProductId(itemId);
        param.setStatus(1);
        param.setPage(1L);
        param.setPageSize(20L);
        param.setRetrieveMode(1);

        BuyinColonelTrusteeshipListResponse response = request.execute(accessToken);
        JSONObject jsonObject = JSONObject.parseObject(response.toString());
        Integer code = jsonObject.getInteger("code");
        String msg = jsonObject.getString("msg");
        if (code == 10000) {
            returnJson.put("code", 0);
            returnJson.put("message", "请求成功");
            returnJson.put("judgeStatus", "1");
            JSONObject dataJson = jsonObject.getJSONObject("data");
            if (!Check.isNull(dataJson)) {
                JSONArray records = dataJson.getJSONArray("records");
                if(Check.isNull(records)){
                    returnJson.put("code", -1);
                    returnJson.put("message", "媒体返回商品信息为空");
                }
                JSONObject record  = records.getJSONObject(0);
                if(Check.isNull(record)){
                    returnJson.put("code", -1);
                    returnJson.put("message", "媒体返回商品信息为空");
                }else {
                    String update_time = record.getString("update_time"); // 更新时间
                    String product_id = record.getString("product_id"); // 商品id
                    String product_name = record.getString("product_name"); // 商品id
                    Long product_price = record.getLong("product_price"); // 商品售价
                    String product_img = record.getString("product_img"); // 商品图片
                    Long shop_id = record.getLong("shop_id"); // 商家ID
                    String shop_name = record.getString("shop_name"); // 商家名称
                    String shop_score = record.getString("shop_score"); // 店铺体验分
                    Long trusteeship_commission_rate = record.getLong("trusteeship_commission_rate"); // 托管佣金率
                    Long trusteeship_service_rate = record.getLong("trusteeship_service_rate"); // 托管服务费率
                    Long product_stock = record.getLong("product_stock"); // 商品库存
                    Integer status = record.getInteger("status"); // 托管状态。0：待审核；1：生效中；2：已结束
                    JSONObject itemJson = new JSONObject();

                    itemJson.put("itemId", product_id);
                    itemJson.put("itemTitle", product_name);
                    itemJson.put("itemPrice", product_price);
                    itemJson.put("itemDesc", product_name);
                    itemJson.put("zkFinalPrice", product_price);
                    itemJson.put("itemImgUrl", product_img);
                    itemJson.put("shopStar", "-");
                    itemJson.put("mallLogisticsScore", shop_score);
                    itemJson.put("activityItemStatus", 2);
                    itemJson.put("categoryId", 0);
                    itemJson.put("categoryName", "托管商品");
                    itemJson.put("itemGalleryUrls", null); // 轮播图
                    itemJson.put("itemDescUrls", null); // 详情图
                    itemJson.put("activityId", activityId);
                    itemJson.put("shopTitle", shop_name);
                    if (!Check.isNull(trusteeship_commission_rate)) {
                        itemJson.put("commissionRate", trusteeship_commission_rate / 10);
                    } else {
                        itemJson.put("commissionRate", 0);
                    }
                    if (!Check.isNull(trusteeship_service_rate)) {
                        itemJson.put("regimentalPromotionRate", trusteeship_service_rate / 10);
                    } else {
                        itemJson.put("regimentalPromotionRate", 0);
                    }
                    itemJson.put("mallServiceScore", shop_score);
                    itemJson.put("mallQualityScore", shop_score); // 店铺质量分
                    itemJson.put("skuList", ""); // sku信息
                    itemJson.put("postArea", ""); // 发货地址
                    itemJson.put("detailUrl", "https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=" + product_id);
                    //    itemJson.put("regimentalPromotionRate", null);
                    returnJson.put("itemJson", itemJson);
                }
            }
        } else {
            returnJson.put("code", -1);
            returnJson.put("message", msg);
        }
        return returnJson;
    }

    @Override
    public void addBytedanceInstituteOrderColonel(String startTime, String endTime, String cursor) {
        AccessToken accessToken = tokenService.getAccessToken(1L);
        cursor = Check.isNull(cursor) ? "0" : cursor;
        BuyinInstituteOrderColonelRequest request = new BuyinInstituteOrderColonelRequest();
        BuyinInstituteOrderColonelParam param = request.getParam();
        param.setSize(200L);
        param.setCursor(cursor);
        param.setStartTime(startTime.concat(" 00:00:00"));
        param.setEndTime(endTime.concat(" 23:59:59"));
        param.setTimeType("pay");//	查询时间类型。pay: 支付时间（默认）; update：联盟侧更新时间，非订单状态更新时间
        BuyinInstituteOrderColonelResponse response = request.execute(accessToken);
        if (Check.isNull(response) || !"10000".equals(response.getCode())) {
            log.error("\n【请求接口】: {}\n【请求参数】：{}\n【响应数据】：{}", "/buyin/instituteOrderColonel；（查询团长订单）", param, response);
            return;
        }

        Data data = response.getData();
        if (Check.isNotNull(data)) {
            List<OrdersItem> orders = data.getOrders();
            cursor = data.getCursor();
            if (Check.isNotNull(orders) && orders.size() > 0) {
                List<BytedanceOrderList> list = new ArrayList<>();
                for (OrdersItem order : orders) {
                    BytedanceOrderList orderList = new BytedanceOrderList();
                    BeanUtils.copyProperties(order, orderList);
                    orderList.setOrderId(Long.valueOf(order.getOrderId()));
                    if (Check.isNotNull(order.getUpdateTime())) {
                        orderList.setUpdateTime(DateUtils.strDateTimsToInt(order.getUpdateTime()));
                    }
                    if (Check.isNotNull(order.getPaySuccessTime())) {
                        orderList.setPaySuccessTime(DateUtils.strDateTimsToInt(order.getPaySuccessTime()));
                    }
                    if (Check.isNotNull(order.getRefundTime())) {
                        orderList.setRefundTime(DateUtils.strDateTimsToInt(order.getRefundTime()));
                    }
                    if (Check.isNotNull(order.getSettleTime())) {
                        orderList.setSettleTime(DateUtils.strDateTimsToInt(order.getSettleTime()));
                    }
                    if (Check.isNotNull(order.getIsTrusteeship())) {
                        orderList.setIsTrusteeship(order.getIsTrusteeship() ? "1" : "0");
                    }

                    ColonelOrderInfo colonelInfo = order.getColonelOrderInfo();
                    if (Check.isNotNull(colonelInfo)) {
                        orderList.setColonelCommissionRate(colonelInfo.getCommissionRate());
                        orderList.setColonelActivityId(colonelInfo.getActivityId());
                        orderList.setColonelBuyinId(colonelInfo.getColonelBuyinId());
                        orderList.setColonelEstimatedCommission(colonelInfo.getEstimatedCommission());
                        orderList.setColonelInstitutionId(colonelInfo.getInstitutionId());
                        orderList.setColonelInstitutionName(colonelInfo.getInstitutionName());
                        orderList.setColonelRealCommission(colonelInfo.getRealCommission());
                        orderList.setColonelSettledTechServiceFee(colonelInfo.getSettledTechServiceFee());
                        orderList.setColonelTechServiceFee(colonelInfo.getTechServiceFee());
                        orderList.setColonelTechServiceFeeRate(colonelInfo.getTechServiceFeeRate());
                    }
                    ColonelOrderInfoSecond secondInfo = order.getColonelOrderInfoSecond();
                    if (Check.isNotNull(secondInfo)) {
                        orderList.setSecondCommissionRate(secondInfo.getCommissionRate());
                        orderList.setSecondActivityId(secondInfo.getActivityId());
                        orderList.setSecondColonelBuyinId(secondInfo.getColonelBuyinId());
                        orderList.setSecondInstitutionId(secondInfo.getInstitutionId());
                        orderList.setSecondInstitutionName(secondInfo.getInstitutionName());
                        orderList.setSecondEstimatedCommission(secondInfo.getEstimatedCommission());
                        orderList.setSecondRealCommission(secondInfo.getRealCommission());
                    }
                    list.add(orderList);
                }
                bytedanceMapper.replaceBatchOrders(list);
                int size = orders.size();
                if (size >= 200) {
                    addBytedanceInstituteOrderColonel(startTime, endTime, cursor);
                }
            }
        }
    }


    @Override
    public void addBytedanceMultiSettlementOrders(String startTime, String endTime, String cursor) {
        AccessToken accessToken = tokenService.getAccessToken(1L);
        cursor = Check.isNull(cursor) ? "0" : cursor;
        BuyinColonelMultiSettlementOrdersRequest request = new BuyinColonelMultiSettlementOrdersRequest();
        BuyinColonelMultiSettlementOrdersParam param = request.getParam();
        param.setSize(100L);
        param.setCursor(cursor);
        param.setTimeType("settle");//查询时间类型。settle: 结算时间）; update：更新时间（默认)
        param.setStartTime(startTime.concat(" 00:00:00"));
        param.setEndTime(endTime.concat(" 23:59:59"));
        BuyinColonelMultiSettlementOrdersResponse response = request.execute(accessToken);
        if (Check.isNull(response) || !"10000".equals(response.getCode())) {
            log.error("\n【请求接口】: {}\n【请求参数】：{}\n【响应数据】：{}", "/buyin/colonelMultiSettlementOrders；（团长分次结算订单）", param, response);
            return;
        }
        com.doudian.open.api.buyin_colonelMultiSettlementOrders.data.Data data = response.getData();
    }

    /**
     * 联系方式解密
     */
    public String decryptContactInfo(AccessToken accessToken, String text, Long activityId) {
        try {
            BuyinDecryptContactInfoRequest request = new BuyinDecryptContactInfoRequest();
            BuyinDecryptContactInfoParam param = request.getParam();
            param.setText(text);
            BuyinDecryptContactInfoResponse response = request.execute(accessToken);
            BuyinDecryptContactInfoData data = response.getData();
            return data.getContactInfo();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("联系方式解密失败，活动ID:{}", activityId);
        }
        return null;
    }

}
