package com.neusoft.smart.pos.trade.service;


import com.neusoft.smart.pos.dto.trade.response.GetDiningRoomResponse;
import com.neusoft.smart.pos.framework.exception.BusinessCommonException;
import com.neusoft.smart.pos.framework.utils.ListUtils;
import com.neusoft.smart.pos.framework.utils.SignUtils;
import com.neusoft.smart.pos.order.constants.TradeErrorCode;
import com.neusoft.smart.pos.trade.persistent.domain.DiningRoom;
import com.neusoft.smart.pos.trade.persistent.domain.TradeMchInfo;
import com.neusoft.smart.pos.trade.repository.DiningRoomRepository;
import com.neusoft.smart.pos.trade.repository.TradeMchInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

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

@Service("diningRoomService")
public class DiningRoomService {

	@Autowired
	private TradeMchInfoRepository tradeMchInfoRepository;
	
	@Autowired
	private DiningRoomRepository diningRoomRepository;
	
	/**
	 * 商户信息查询方法
	 * @return
	 */
//	public GetDiningRoomResponse queryDiningRoomList(String mcode,String sign){
//		//1.校验参数信息
//		if(StringUtils.isEmpty(mcode)){
//			throw new BusinessCommonException(TradeErrorCode.TRADE_MCH_MCODE_EMPTY);
//		}
//		if(StringUtils.isEmpty(sign)){
//			throw new BusinessCommonException(TradeErrorCode.TRADE_MCH_SIGN_EMPTY);
//		}
//		//2.查询商户号信息
//		TradeMchInfo tradeMchInfo = tradeMchInfoRepository.queryTradeMchInfo(mcode);
//		if(null == tradeMchInfo){
//			throw new BusinessCommonException(TradeErrorCode.TRADE_MCH_INFO_NOT_EXIST);
//		}
//
//		//3.验签
//		Map<String,String> signMap = new HashMap<>();
//		signMap.put("mcode",mcode);
//		signMap.put("sign",sign);
//		if(!SignUtils.isSignatureValid(signMap,tradeMchInfo.getSecretKey())){
//			throw new BusinessCommonException(TradeErrorCode.TRADE_MCH_SIGN_VALIDATE_ERROR);
//		}
//		//4.查询餐厅列表信息
//		List<DiningRoom> diningRoomList = diningRoomRepository.queryDiningRoomList(tradeMchInfo.getOrgId());
//		List<GetDiningRoomResponse.TradeDiningRoom> shopList = new ArrayList<>();
//		if(null != diningRoomList && diningRoomList.size() > 0){
//			shopList= ListUtils.convertListToList(diningRoomList,GetDiningRoomResponse.TradeDiningRoom.class);
//		}
//		GetDiningRoomResponse diningRoomResponse = new GetDiningRoomResponse();
//		diningRoomResponse.setShopList(shopList);
//		return diningRoomResponse;
//	}
//
}
