package com.hzs.member.base.provider;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.constant.EnumsPrefixConstants;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.EPopupType;
import com.hzs.common.core.enums.EnableStatus;
import com.hzs.common.domain.member.detail.CuMemberServiceLog;
import com.hzs.common.service.ITransactionCommonService;
import com.hzs.member.base.IUpPolicyCurrencyServiceApi;
import com.hzs.member.base.IUpdateExpireStopServiceApi;
import com.hzs.member.base.dto.UpPolicyCurrencyDTO;
import com.hzs.member.base.dto.UpdateExpireStopDTO;
import com.hzs.member.detail.service.ICuMemberServiceLogService;
import com.hzs.member.handlebusiness.dto.AnalysisBusinessAppealParam;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

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

/**
 * 修改会员续约涉及dubbo服务
 *
 * @author zhangjing
 */
@DubboService
public class UpdateExpireStopServiceProvider implements IUpdateExpireStopServiceApi {

    @Autowired
    private ICuMemberServiceLogService memberServiceLogService;
    @Autowired
    private ITransactionCommonService iTransactionCommonService;


    /**
     * @description: 查询修改续约审核列表
     * @author: zhang jing
     * @date: 2023/5/10 17:42
     * @param: [analysisBusinessAppealParam]
     * @return: com.hzs.common.core.domain.R<java.util.List < com.hzs.member.base.dto.UpPolicyCurrencyDTO>>
     **/
    @Override
    public R<List<UpdateExpireStopDTO>> expireStopList(AnalysisBusinessAppealParam analysisBusinessAppealParam) {
        List<UpdateExpireStopDTO> list = new ArrayList<>();
        CuMemberServiceLog memberServiceLog = new CuMemberServiceLog();
        memberServiceLog.setBusinessNo(analysisBusinessAppealParam.getBusinessNo());
        QueryWrapper<CuMemberServiceLog> queryWrapper = new QueryWrapper();
        queryWrapper.eq("BUSINESS_NO", analysisBusinessAppealParam.getBusinessNo());
//        Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransactionToTag(analysisBusinessAppealParam.getToLanguageTag(),EnableStatus.values(), EPopupType.values());
        List<CuMemberServiceLog> msList = memberServiceLogService.list(queryWrapper);
        if (CollectionUtil.isNotEmpty(msList)) {
            msList.forEach(item -> {
                UpdateExpireStopDTO ues = JSONObject.parseObject(item.getNewValue(), UpdateExpireStopDTO.class);
                list.add(ues);
            });
        }
        return R.ok(list);
    }
}
