package cn.superdesk.uniorder.controller._openapi.superdeskmall.core;


import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.pagination.PageQueryParam;
import cn.superdesk.uniorder.dubbo.consumer.order.base.UnifiedOrderCreditDubboConsumerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 志鹏要用的 一个比较XX的查询某积分批次的对账情况
 * @Author: linjinyu
 * @CreateDate: 10/10/20 2:47 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/10/20 2:47 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/openapi/superdeskmall/core/credit")
public class CreditController {

	@Autowired
	private UnifiedOrderCreditDubboConsumerService unifiedOrderCreditDubboConsumerService;

	/**
	 * 从属 商城 发放积分
	 * 以积分批次号 查询批次号下的流水有没有对账
	 * http(s)://ip:port/web/openapi/superdeskmall/core/credit/checkStatement
	 * <p>
	 * 开发环境
	 * http://192.168.1.223:8089/web/openapi/superdeskmall/core/credit/checkStatement
	 * <p>
	 * 侨城汇
	 * http://uniorderapi.octlife.cn/web/openapi/superdeskmall/core/credit/checkStatement
	 * <p>
	 * 企业id
	 * 积分批次号
	 *
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "checkStatement", method = RequestMethod.POST)
	@ResponseBody
	public R<Map<String, Object>> checkStatement(@RequestBody PageQueryParam param) {

//		request
//		{
//			conditions : {
//				batchs : "x1,x2" String
//			}
//		}
//
//		response
//		{
//			code    : "200",// 请求code
//			success : true,// 请求状态
//			message : "",// 错误消息
//			data : {
//				conditions : {
//					batchs : "x1,x2" String
//				},
//				result : {
//					x1 : "",
//					x2 : "",
//				}
//			}// 返回数据
//		}

		R<Map<String, Object>> response = new R<>();

		Map<String, Object> responseData = new HashMap<>();
		responseData.put("conditions", param.getConditions());
		responseData.put("result", unifiedOrderCreditDubboConsumerService.checkStatement(param.getConditions()));

		response.setData(responseData);

		return response;
	}
}
