package cn.superdesk.uniorder.controller._patch;

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 cn.superdesk.uniorder.common.numerical.AnStringUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2020/12/16 上午11:47
 * @UpdateUser: linjinyu
 * @UpdateDate: 2020/12/16 上午11:47
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/patch/unified/order/credit/accountingState/customer/fix")
public class UnifiedOrderCreditAccountingStateCustomerFixController {

	@Autowired
	private UnifiedOrderCreditDubboConsumerService unifiedOrderCreditDubboConsumerService;

	@ApiOperation(value = "patch")
	@RequestMapping(value = "run", method = RequestMethod.POST)
	@ResponseBody
	public R<String> run(@RequestBody PageQueryParam param) {


		R<String> response = new R<>();

		// TODO 参数合法性判定

		String batchs = AnStringUtils.getString(param.getConditions().get("batchs"));

		// TODO 调用补丁方法 修正 积分流水 客户对账状态

		String report = unifiedOrderCreditDubboConsumerService.checkAndFixAccountingStateCustomer(batchs);

		response.setData(report);


		return response;
	}

}
