package cn.pluss.platform.controller.merchant;


import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.base.BaseModelController;
import cn.pluss.platform.entity.MerchantPlugin;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.merchant.MerchantPluginService;
import cn.pluss.platform.userApp.UserAppService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * <p>
 * 商户插件表 前端控制器
 * </p>
 *
 * @author Djh
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/merchantPlugin")
public class MerchantPluginController extends BaseModelController<MerchantPluginService, MerchantPlugin> {

    @Setter(onMethod_ = { @Autowired })
    private UserAppService userAppService;

    /**
     * 获取插件进件状态
     * @return
     */
    @GetMapping("/info")
    public Result<Object> getAuditStatus() {
        UserApp userApp = userAppService.queryUserAppByToken();
        Map<String, Object> result = baseService.getInfo(userApp.getUserId().toString());
        return ResultGenerator.genSuccessResult(result);
    }

    @PostMapping("/reqAudit")
    public Result<Object> reqAudit() {
        UserApp userApp = userAppService.queryUserAppByToken();
        baseService.reqAudit(userApp.getUserId().toString());
        return ResultGenerator.genSuccessResult("操作成功", null);
    }

    @GetMapping("/pluginGuideList")
    public Result<Object> pluginGuideList() {
        List<Map<String, Object>> arr = new ArrayList<>();
        Map<String, Object> option = new HashMap<>();
        /*
         * 申请开通丨收银插件申请步骤、补贴活动https://t.1yb.co/h1ox
         *
         * 账单查询丨收银插件账单手机查询教程https://t.1yb.co/h1ow
         *
         * 收银插件丨下载安装插件流程及注意事项https://t.1yb.co/h1oy
         *
         * 收银插件丨插件功能详细使用教程https://t.1yb.co/h1oz
         */

        option.put("title", "申请开通丨收银插件申请步骤、补贴活动");
        option.put("icon", "https://syb-resource.oss-cn-hangzhou.aliyuncs.com/upload/app/F3569A5641904DFFA4A6E6BC39277AC2?Expires=1927883734&OSSAccessKeyId=LTAI4G25PY4Tebxq4gCrhtF5&Signature=yMyuEjFybo7kdQ1vmTqRFGueySM%3D");
        option.put("url", "https://t.1yb.co/h1ox");
        arr.add(option);

        option = new HashMap<>();
        option.put("title", "账单查询丨收银插件账单手机查询教程");
        option.put("icon", "https://syb-resource.oss-cn-hangzhou.aliyuncs.com/upload/app/F3569A5641904DFFA4A6E6BC39277AC2?Expires=1927883734&OSSAccessKeyId=LTAI4G25PY4Tebxq4gCrhtF5&Signature=yMyuEjFybo7kdQ1vmTqRFGueySM%3D");
        option.put("url", "https://t.1yb.co/h1ow");
        arr.add(option);

        option = new HashMap<>();
        option.put("title", "收银插件丨下载安装插件流程及注意事项");
        option.put("icon", "https://syb-resource.oss-cn-hangzhou.aliyuncs.com/upload/app/F3569A5641904DFFA4A6E6BC39277AC2?Expires=1927883734&OSSAccessKeyId=LTAI4G25PY4Tebxq4gCrhtF5&Signature=yMyuEjFybo7kdQ1vmTqRFGueySM%3D");
        option.put("url", "https://t.1yb.co/h1oy");
        arr.add(option);

        option = new HashMap<>();
        option.put("title", "收银插件丨插件功能详细使用教程");
        option.put("icon", "https://syb-resource.oss-cn-hangzhou.aliyuncs.com/upload/app/F3569A5641904DFFA4A6E6BC39277AC2?Expires=1927883734&OSSAccessKeyId=LTAI4G25PY4Tebxq4gCrhtF5&Signature=yMyuEjFybo7kdQ1vmTqRFGueySM%3D");
        option.put("url", "https://t.1yb.co/h1oz");
        arr.add(option);

        return ResultGenerator.genSuccessResult(arr);
    }
}
