package com.cool.store.controller.webb;

import com.cool.store.constants.CommonConstants;
import com.cool.store.dao.*;
import com.cool.store.entity.*;
import com.cool.store.enums.MessageEnum;
import com.cool.store.enums.SMSMsgEnum;
import com.cool.store.mq.util.HttpRestTemplateService;
import com.cool.store.request.xfsgFirstOrderListRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.xfsgFirstOderListResponse;
import com.cool.store.service.DataHandleService;
import com.cool.store.service.ShopService;
import com.cool.store.service.impl.CommonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;

@Slf4j
@RestController
@RequestMapping("/pc/test")
public class PCTestController {

    @Resource
    private CommonService commonService;
    @Resource
    private LineInfoDAO lineInfoDAO;
    @Resource
    private PointInfoDAO pointInfoDAO;
    @Resource
    private ShopService shopService;
    @Resource
    private LineInterviewDAO lineInterviewDAO;
    @Resource
    DataHandleService dataHandleService;
    static String url = "https://hzly.cloudcubic.net/ajaxHandle/synchronization/JCallBackSynchronizationHandler.ashx?action=app&controller=GetProjectDetails&projectid=";

    @Resource
    private HttpRestTemplateService httpRestTemplateService;

    @GetMapping("/sendMessage")
    public ResponseResult<Boolean> sendMessage(@RequestParam("lineId")Long lineId,
                                               @RequestParam("pointId")Long pointId,
                                               @RequestParam("shopId")Long shopId,
                                               @RequestParam MessageEnum messageEnum){
        LineInfoDO lineInfo = lineInfoDAO.getLineInfo(lineId);
        PointInfoDO pointInfo = pointInfoDAO.getPointInfoById(pointId);
        ShopInfoDO shopInfo = shopService.getShopInfo(shopId);
        Map<String, String> messageMap = new HashMap<>();
        messageMap.put("lineId", String.valueOf(lineId));
        messageMap.put("pointId", String.valueOf(pointId));
        messageMap.put("shopId", String.valueOf(shopId));
        messageMap.put("storeName", shopInfo.getShopName());
        messageMap.put("partnerUsername", lineInfo.getUsername());
        messageMap.put("partnerMobile", lineInfo.getMobile());
        messageMap.put("wantShopName", "杭州市余杭区");
        messageMap.put("appointmentTime", "2024-05-06 12:30");
        messageMap.put("interviewUsername", "章臣彪");
        messageMap.put("payTime", "2024-05-01 12:30");
        messageMap.put("submitTime", "2024-05-04 12:30");
        messageMap.put("pointName", pointInfo.getPointName());
        messageMap.put("pointAddress", pointInfo.getAddress());
        messageMap.put("reason", "表现一般不予通过");
        commonService.sendMessage(Arrays.asList("123836131931284423","020125244825417786"), messageEnum, messageMap);
        return ResponseResult.success(Boolean.FALSE);
    }

    @GetMapping("/sendSms")
    public ResponseResult<Boolean> sendSms(@RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime){
        List<LineInterviewDO> interviewList = lineInterviewDAO.getInterviewRemindList(startTime, endTime);
        Map<String, String> templateParam = new HashMap<>();
        templateParam.put("pointName", "杭州门店A");
        List<SMSMsgEnum> smsMsgList = new ArrayList<>();
        for (SMSMsgEnum value : smsMsgList) {
            //commonService.sendSms("17681878615", value, templateParam);
        }
        return ResponseResult.success(Boolean.FALSE);
    }

    @GetMapping("/initShop")
    public ResponseResult<Boolean> initShop(@RequestParam("lineId")Long lineId){
        LineInfoDO lineInfo = lineInfoDAO.getLineInfo(lineId);
        shopService.initShop(lineInfo);
        return ResponseResult.success(Boolean.FALSE);
    }


    @GetMapping("/dataHandle")
    public ResponseResult<Boolean> dataHandle(@RequestParam("shopId")Long shopId){
        return ResponseResult.success(dataHandleService.dataHandleService(shopId));
    }

}
