package cn.superdesk.uniorder.controller._patch.accounting;

import cn.superdesk.uniorder.common.pagination.PageQueryParam;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dubbo.consumer.accounting.customer.AccountingUnifiedCustomerDubboConsumerService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/patch/accounting/unified/customer/check/computation")
public class AccountingUnifiedCustomerCheckComputationController {

	@Autowired
	private AccountingUnifiedCustomerDubboConsumerService accountingUnifiedCustomerDubboConsumerService;

	/**
	 * http://192.168.1.223:8089/web/patch/accounting/unified/customer/dim/order2goods/run
	 *
	 * @param param
	 * @return
	 */
	@ApiOperation(value = "accounting_amount quantity_order quantity_goods")
	@RequestMapping(value = "run", method = RequestMethod.POST)
	@ResponseBody
	public R<String> run(@RequestBody PageQueryParam param) {


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

		// TODO 参数合法性判定

		String accountingOrderSn = null;

		if (null != param.getConditions().get("accountingOrderSn")) {
			accountingOrderSn = param.getConditions().get("accountingOrderSn").toString();
		}

		accountingUnifiedCustomerDubboConsumerService.patchXAccountingAmountAndQuantityOrderAndQuantityGoods(accountingOrderSn);

		return response;
	}
}
