package com.xhpc.user.mapper;

import com.xhpc.user.domain.XhpcAppUser;
import com.xhpc.user.dto.XhpcActivityDiscountDto;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * C端用户信息 数据层
 *
 * @author ruoyi
 */
public interface XhpcAppUserMapper {


    public Map<String, Object> userInfoMoney(@Param("appUserId") Long appUserId,@Param("source") Integer source,@Param("tenantId") String tenantId);

    Map<String, Object> userAccountStatement(@Param("appUserId") Long appUserId,@Param("source") Integer source,@Param("tenantId") String tenantId);
    /**
     * 新增 C端用户信息
     *
     * @param xhpcAppUser C端用户信息
     * @return 结果
     */
    public int insert(XhpcAppUser xhpcAppUser);

    /**
     * 修改C端用户信息
     *
     * @param xhpcAppUser C端用户信息
     * @return 结果
     */
    public int update(XhpcAppUser xhpcAppUser);

    /**
     * 删除C端用户信息
     *
     * @param appUserId C端用户id
     * @return 结果
     */
    public int deleteById(@Param("appUserId") Long appUserId);


    /**
     * 查询C端用户详情
     *
     * @param appUserId C端用户id
     * @return 结果
     */
    public Map<String, Object> info(@Param("appUserId") Long appUserId);

    /**
     * C端用户分页列表
     *
     * @param phone 手机号
     * @return 结果
     */
    public List<Map<String, Object>> selectAppUserList(@Param("phone") String phone,@Param("tenantId") String tenantId);


    public Map<String, Object> userSum(@Param("phone")String phone,@Param("time1")String time1,@Param("time2")String time2,@Param("time3")String time3,@Param("time4")String time4,@Param("tenantId") String tenantId);

    /**
     * 手机号查询C端用户信息
     *
     * @param phone 手机号
     * @return 结果
     */
    public XhpcAppUser getAppUserByPhone(@Param("phone") String phone,@Param("tenantId") String tenantId);


    /**
     * 账号+密码查询用户信息
     *
     * @param phone 手机号
     * @return 结果
     */
    public XhpcAppUser getAppUserPhoneByPassword(@Param("phone") String phone,@Param("password") String password,@Param("tenantId") String tenantId);

    /**
     * 账号+用户ID查询用户信息
     *
     * @param phone 手机号
     * @return 结果
     */
    public XhpcAppUser getAppUserPhoneByUserId(@Param("phone") String phone,@Param("userId") Long userId,@Param("tenantId") String tenantId);


    /**
     * openid查询C端用户信息
     *
     * @param openid
     * @return 结果
     */
    public XhpcAppUser getAppUserByOpenid(@Param("openid") String openid);

    int updateUserIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund);

    int updateUserSunchaSwitch(@Param("userId")Long userId, @Param("sunchaSwitch")Integer sunchaSwitch);

    int updateCommunityIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);

    int updateCommunityPersonnelSunchaSwitch(@Param("userId")Long userId, @Param("sunchaSwitch")Integer sunchaSwitch, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);

    int updateCustomersPersonnelSunchaSwitch(@Param("userId")Long userId, @Param("sunchaSwitch")Integer sunchaSwitch, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);
    int updateCustomersSocProtect(@Param("userId")Long userId, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);
    /**
     * 记录登录用户的最后一次数据
     */
    int addUserLoginTime(@Param("appUserId")Long appUserId, @Param("account")String account, @Param("userType")Integer userType, @Param("openId")String openId, @Param("type")Integer type, @Param("status")Integer status, @Param("tenantId")String tenantId, @Param("createTime") Date createTime);

    /**
     * 修改社区用户信息
     */
    int updateCommunityPersonnel(@Param("appUserId")Long appUserId,@Param("weixinOpenId")String weixinOpenId, @Param("alipayOpenId")String alipayOpenId,@Param("weixinLogin")Integer weixinLogin, @Param("alipayLogin")Integer alipayLogin);
    /**
     * 修改B端大客户信息
     */
    int updateCustomersPersonnel(@Param("appUserId")Long appUserId,@Param("weixinOpenId")String weixinOpenId, @Param("alipayOpenId")String alipayOpenId,@Param("weixinLogin")Integer weixinLogin, @Param("alipayLogin")Integer alipayLogin);

    /**
     * 查询用户最后一次登录信息
     * @param type
     * @param openid
     * @return
     */
    Map<String, Object> getUserLoginTime(@Param("type")Integer type,@Param("openid")String openid,@Param("tenantId")String tenantId);

    Map<String, Object> getAppUserLoginTime(@Param("type")Integer type,@Param("userId")Long userId,@Param("phone")String phone,@Param("tenantId")String tenantId);


    /**
     * 修改该账号之前的登录信息，进行退出操作
     * @param account
     * @return
     */
    int updateUserLoginTime(@Param("account")String account);

    int updateopenIdUserLoginTime(@Param("openId")String openId);

    /**
     * 查询开始时间是否在活动中
     */
    List<XhpcActivityDiscountDto> getActivityDiscountTime(@Param("internetUserId")Long internetUserId, @Param("startTime")String startTime, @Param("userType")Integer userType, @Param("chargingStationId")Long chargingStationId, @Param("tenantId")String tenantId);
}
