//package cn.superdesk.uniorder.controller._openapi.superdeskmall.accounting.supplier;
//
//import cn.superdesk.uniorder.common.exception.utils.ExceptionUtils;
//import cn.superdesk.uniorder.common.json.AnJsonUtils;
//import cn.superdesk.uniorder.common.numerical.AnBeanUtils;
//import cn.superdesk.uniorder.common.pagination.PageQueryParam;
//import cn.superdesk.uniorder.common.rest.response.R;
//import cn.superdesk.uniorder.controller.base.BaseController;
//import cn.superdesk.uniorder.dao.entity.accounting.unified.supplier.AccountingUnifiedSupplier;
//import cn.superdesk.uniorder.dto.vo.accounting.unified.supplier.AccountingUnifiedSuplierHeadVo;
//import cn.superdesk.uniorder.dto.vo.accounting.unified.supplier.AccountingOrderUnifiedSupplierListItemVo;
//import cn.superdesk.uniorder.dubbo.consumer.accounting.supplier.AccountingUnifiedSupplierDubboConsumerService;
//import cn.superdesk.uniorder.dubbo.consumer.base.UnifiedOrderDubboConsumerService;
//import cn.superdesk.uniorder.dubbo.consumer.organisation.SysSupplierDubboConsumerService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
//
///**
// * @Description: Java类作用描述
// * @Author: linjinyu
// * @CreateDate: 2021/3/8 上午10:02
// * @UpdateUser: linjinyu
// * @UpdateDate: 2021/3/8 上午10:02
// * @UpdateRemark: 修改内容
// * @Version: 1.0
// */
//@Deprecated
//@Slf4j
//@RestController
//@RequestMapping("/openapi/superdeskmall/accounting/supplier/statement")
//public class SuperdeskMallAccountingSupplierStatementController extends BaseController {
//
//
//	@Autowired
//	private UnifiedOrderDubboConsumerService              unifiedOrderDubboConsumerService;
//	@Autowired
//	private SysSupplierDubboConsumerService               unifiedSupplierDubboConsumerService;
//	@Autowired
//	private AccountingUnifiedSupplierDubboConsumerService accountingUnifiedSupplierDubboConsumerService;
//
//
//	/**
//	 * 供应商端
//	 *
//	 * @param param
//	 * @return
//	 */
//	@RequestMapping(value = "/list", method = RequestMethod.POST)
//	@ResponseBody
//	public R<List<AccountingOrderUnifiedSupplierListItemVo>> list(@RequestBody PageQueryParam param) {
//
//		R<List<AccountingOrderUnifiedSupplierListItemVo>> result = new R<>();
//
//		try {
////			Map<String, Object> params = new HashMap<>();
////
////			// 组合的 下拉选择的
////			params.put("accountingOrderSn", getString("accountingOrderSn"));
////
////			params.put("orderSn", getString("orderSn"));
////
////			// 供应商名称
////			params.put("supplierId", getLong("supplierId"));
////			params.put("supplierName", getString("supplierName"));
////
////
////			// 对账单状态
////			params.put("accountingStatus", getString("accountingStatus"));
////
////			// 开票状态
////			params.put("invoiceStatus", getString("invoiceStatus"));
////
////			// 对账时间
////			params.put("startTime", getString("startTime"));
////			params.put("endTime", getString("endTime"));
//
//			log.info("供应商结算-对账单 : \n{}", AnJsonUtils.toJson(param.getConditions()));
//
//
//			// 前端 列表数据
//			result = accountingUnifiedSupplierDubboConsumerService.getStatementOfAccountList(getToken(), param.getConditions(), param.getPageNo(), param.getPageSize());
//
//			// 修正显示
////			for (AccountingOrderUnifiedSupplierListItemVo vo : result.getData()) {
////				vo.setAccountingStatusName(AccountingOrderAccountingStatusEnum.getDesc(vo.getAccountingStatus()));
////				vo.setInvoiceStatusName(AccountingOrderInvoiceStatusEnum.getDesc(vo.getInvoiceStatus()));
////
////				if (vo.getDimCreateBy().equals(0)) {
////					unifiedSupplierStatementFunction.fixDimOrder(vo);
////				} else if (vo.getDimCreateBy().equals(1)) {
////					unifiedSupplierStatementFunction.fixDimGoods(vo);
////				}
////			}
//
//
//			// 前端 头部 对账单数:1 订单数:3 成本金额:¥ 10312.92
//			AccountingUnifiedSuplierHeadVo accountingUnifiedSuplierHead = accountingUnifiedSupplierDubboConsumerService.getStatementOfAccountHeadSum(getToken(), param.getConditions());
//
////			Map<String, Object> headData = new HashMap<>();
////			headData.put("amount", accountingUnifiedSuplierHead.getAmount());
////			headData.put("costAmount", accountingUnifiedSuplierHead.getCostAmount());
////			headData.put("total", accountingUnifiedSuplierHead.getTotal());
////			headData.put("orderTotal", accountingUnifiedSuplierHead.getOrderTotal());
//
//			result.setHeadData(AnBeanUtils.beanToMap(accountingUnifiedSuplierHead));
//
//		} catch (Exception e) {
//
//			result.setCode(String.valueOf(e.hashCode()));
//			result.setSuccess(false);
//			result.setMessage(e.getMessage());
//
//			log.error(ExceptionUtils.getMessage(e));
//			e.printStackTrace();
//
//		}
//
//		return result;
//
//	}
//
//
//	/**
//	 * 查看申诉
//	 *
//	 * @param accountingOrderId
//	 * @return
//	 */
//	@RequestMapping(value = "/opViewAppeal/{accountingOrderId}", method = RequestMethod.POST)
//	@ResponseBody
//	public R<AccountingUnifiedSupplier> opViewAppeal(
//			@PathVariable("accountingOrderId") Long accountingOrderId
//	) {
//		R<AccountingUnifiedSupplier> response = new R<>();
//
//		accountingUnifiedSupplierDubboConsumerService.opAppeal(getToken(), accountingOrderId);
//
//		return response;
//	}
//
//	/**
//	 * 创建申诉
//	 *
//	 * @param accountingOrderId
//	 * @return
//	 */
//	@RequestMapping(value = "/opCreateAppeal/{accountingOrderId}", method = RequestMethod.POST)
//	@ResponseBody
//	public R<AccountingUnifiedSupplier> opCreateAppeal(
//			@PathVariable("accountingOrderId") Long accountingOrderId
//	) {
//		R<AccountingUnifiedSupplier> response = new R<>();
//
//		accountingUnifiedSupplierDubboConsumerService.opAppeal(getToken(), accountingOrderId);
//
//		return response;
//	}
//
//
//	/****************************************** 供应商端 ******************************************/
//	/**
//	 * 确认对账
//	 *
//	 * @param accountingOrderId
//	 * @return
//	 */
//	@RequestMapping(value = "/opConfirm/{accountingOrderId}", method = RequestMethod.POST)
//	@ResponseBody
//	public R<AccountingUnifiedSupplier> opConfirm(
//			@PathVariable("accountingOrderId") Long accountingOrderId
//	) {
//		R<AccountingUnifiedSupplier> response = new R<>();
//
//		accountingUnifiedSupplierDubboConsumerService.opConfirm(accountingOrderId, getToken());
//
//		return response;
//	}
//
//	/**
//	 * 申诉对账
//	 *
//	 * @param accountingOrderId
//	 * @return
//	 */
//	@RequestMapping(value = "/opAppeal/{accountingOrderId}", method = RequestMethod.POST)
//	@ResponseBody
//	public R<AccountingUnifiedSupplier> opAppeal(
//			@PathVariable("accountingOrderId") Long accountingOrderId
//	) {
//		R<AccountingUnifiedSupplier> response = new R<>();
//
//		accountingUnifiedSupplierDubboConsumerService.opAppeal(getToken(), accountingOrderId);
//
//		return response;
//	}
//
//	/****************************************** 供应商端 ******************************************/
//
//
//	/****************************************** 后端 ******************************************/
////    @RequestMapping(value = "/opCreate/{accountingOrderId}", method = RequestMethod.POST)
////    @ResponseBody
////    public R<AccountingUnifiedSupplier> opCreate(
////            @PathVariable("accountingOrderId") Long accountingOrderId
////    ) {
////        R<AccountingUnifiedSupplier> response = new R<>();
////
////        accountingUnifiedSupplierDubboConsumerService.opCreate(accountingOrderId, getToken());
////
////        return response;
////    }
//
//	/**
//	 * http://192.168.1.223:8089/web/openapi/superdeskmall/accounting/supplier/statement/opSubmit/19
//	 *
//	 * @param accountingOrderId
//	 * @return
//	 */
////    @RequestMapping(value = "/opSubmit/{accountingOrderId}", method = RequestMethod.POST)
////    @ResponseBody
////    public R<AccountingUnifiedSupplier> opSubmit(
////            @PathVariable("accountingOrderId") Long accountingOrderId
////    ) {
////        R<AccountingUnifiedSupplier> response = new R<>();
////
////        accountingUnifiedSupplierDubboConsumerService.opSubmit(accountingOrderId, getToken());
////
////        return response;
////    }
//
////    @RequestMapping(value = "/opCancel/{accountingOrderId}", method = RequestMethod.POST)
////    @ResponseBody
////    public R<AccountingUnifiedSupplier> opCancel(
////            @PathVariable("accountingOrderId") Long accountingOrderId
////    ) {
////        R<AccountingUnifiedSupplier> response = new R<>();
////
////        accountingUnifiedSupplierDubboConsumerService.opCancel(accountingOrderId, getToken());
////
////        return response;
////    }
//
////    @RequestMapping(value = "/opAgain/{accountingOrderId}", method = RequestMethod.POST)
////    @ResponseBody
////    public R<AccountingUnifiedSupplier> opAgain(
////            @PathVariable("accountingOrderId") Long accountingOrderId
////    ) {
////        R<AccountingUnifiedSupplier> response = new R<>();
////
////        accountingUnifiedSupplierDubboConsumerService.opAgain(accountingOrderId, getToken());
////
////        return response;
////    }
//	/****************************************** 后端 ******************************************/
//
//
////    @RequestMapping(value = "/detail/{accountingOrderSn}", method = RequestMethod.GET)
////    @ResponseBody
////    public R<List<UnifiedOrderGoodsOfStatementOfAccount>> detail(@PathVariable("accountingOrderSn") String accountingOrderSn) {
////        R<List<UnifiedOrderGoodsOfStatementOfAccount>> result = new R<>();
////
////        try {
////            Map<String, Object> params = new HashMap<>();
////
////            params.put("accountingOrderSn", accountingOrderSn);
////
////            List<UnifiedOrderGoodsOfStatementOfAccount> unifiedOrderGoodsOfStatementOfAccountList = unifiedOrderDubboConsumerService.getSupplierStatementOfAccountDetailDimOrder2Goods(params);
////
////            result.setData(unifiedOrderGoodsOfStatementOfAccountList);
////
////        } catch (Exception e) {
////
////            result.setCode(String.valueOf(e.hashCode()));
////            result.setSuccess(false);
////            result.setMessage(e.getMessage());
////
////            log.error(ExceptionUtils.getMessage(e));
////            e.printStackTrace();
////        }
////        return result;
////    }
//
//	/***
//	 * 供应商结算-未对账订单-对账单详情-详情导出
//	 * @return
//	 */
////    @RequestMapping(value = "/detailExport/{accountingOrderSn}", method = RequestMethod.GET)
////    public void detailExport(@PathVariable("accountingOrderSn") String accountingOrderSn,
////                             HttpServletResponse response) throws IOException {
////
////        try {
////
////            Map<String, Object> params = new HashMap<>();
////            params.put("accountingOrderSn", accountingOrderSn);
////
////            log.info("供应商结算-未对账订单-对账单详情-详情导出 params: \n{}", JsonUtils.toJson(params));
////
////            List<UnifiedOrderGoodsOfStatementOfAccount> unifiedOrderGoodsOfStatementOfAccountList = unifiedOrderDubboConsumerService.getSupplierStatementOfAccountDetailDimOrder2Goods(params);
////
////            for (UnifiedOrderGoodsOfStatementOfAccount goodsInfo : unifiedOrderGoodsOfStatementOfAccountList) {
////
////
////                /****************************************** 企业采购 情况 start ******************************************/
//////				String [] arrAddress = goodsInfo.getRecAddress().split(" ");
//////
//////				goodsInfo.setAddressProvince(arrAddress[0]);
//////				goodsInfo.setAddressCity(arrAddress[1]);
//////				goodsInfo.setAddressArea(arrAddress[2]);
//////				goodsInfo.setAddressTown(arrAddress[3]);
//////				goodsInfo.setAddressAddress(arrAddress[4]);
////
////                /****************************************** 企业采购 情况   end ******************************************/
////
////                /****************************************** 福利内购 情况 start ******************************************/
////                /****************************************** 福利内购 情况   end ******************************************/
////
////                /****************************************** 代客下单 情况 start ******************************************/
////                // 20200916_提出人_燕璐_超级前台_统一订单生产环境_对账单_详情_导出问题.md 问题排查出来了
//////				大概是2020年4月的时候 运营提出 代客下单 excel 导入时 会带有 手填地址
//////				当最终用了这个地址而没有选用商城过来的地址的情况
//////				地址为 安徽省合肥市包河区云谷路与环湖北路交叉口安徽创新馆 导致拆分时出错了
//////				之前为 安徽 合肥市 滨湖新区 成都路1888号中国农业银行安徽分行
//////				是有空格分开的
////                /****************************************** 代客下单 情况   end ******************************************/
////
////                /****************************************** 楼内闪送 情况 start ******************************************/
//////				goodsInfo.setAddressAddress(goodsInfo.getRecAddress());// eg : 公寓6号楼B区四川美术学院六号楼
////                /****************************************** 楼内闪送 情况   end ******************************************/
////
////                if (StringUtils.isNotBlank(goodsInfo.getRecAddress())) {
////
////                    String[] arrAddress = goodsInfo.getRecAddress().split(" ");
////                    if (arrAddress.length >= 5) {
////                        goodsInfo.setAddressProvince(arrAddress[0]);
////                        goodsInfo.setAddressCity(arrAddress[1]);
////                        goodsInfo.setAddressArea(arrAddress[2]);
////                        goodsInfo.setAddressTown(arrAddress[3]);
////                        goodsInfo.setAddressAddress(arrAddress[4]);
////                    } else {
////                        goodsInfo.setAddressAddress(goodsInfo.getRecAddress());
////                    }
////
////                }
////
////            }
////
////            String[] field = {
////                    "purchaseUserId", "purchaseUserName", "purchasePhone", "recUserName", "recUserPhone", "addressProvince", "addressCity", "addressArea", "addressTown", "addressAddress",
////                    "orderSn", "saleName", "purchaseVirtName",
////                    "goodsId",
////                    "goodsName", "cateNameLv3", "unit", "quantity",
////                    "costPrice", "costAmount",
////                    "price", "amount",
////                    "createTime",
////                    "expressCompany", "expressSn", "transportAmount"
////            };
////
////            String[] fieldZhCn = {
////                    "用户账号", "下单人", "下单人电话", "收货人", "收货人电话", "省", "市", "区", "街道", "详细地址",// add 20200819
////                    "订单编号/退货单号", "供应商名称", "企业名称",
////                    "商品SKU",// add 20200819
////                    "商品名称", "商品规格", "单位", "数量",
////                    "成本单价", "成本总价",
////                    "销售单价", "销售总价",// add 20200819
////                    "下单时间/退货时间",
////                    "物流公司", "物流单号", "运费",// add 20200819
////            };
////
////            HSSFWorkbook workbook = ExcelUtils.createWorkbook(unifiedOrderGoodsOfStatementOfAccountList, fieldZhCn, field, "供应商结算-对账单详情(商品维度)");
////            //准备将Excel的输出流通过response输出到页面下载
////            //二进制输出流
////            response.setContentType("application/octet-stream");
////            response.setCharacterEncoding("UTF-8");
////            //这后面可以设置导出Excel的名称,此例中名为student.xls
////            response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("供应商结算-对账单详情(商品维度)", "UTF-8") + ".xls");
////            //刷新缓冲
////            response.flushBuffer();
////
////            //workbook将Excel写入到response的输出流中,供页面下载
////            workbook.write(response.getOutputStream());
////
////        } catch (Exception e) {
////
////            log.error(ExceptionUtils.getMessage(e));
////            e.printStackTrace();
////        }
////
////    }
//
////	账单列表-操作方-供应商
////	|---- 时间 对账单状态(商户确认状态)(待确定 已确定 已申诉)
////	账单列表-操作方-统一订单界面
////	|---- 时间 对账单状态(商户确认状态)(待确定 已确定 已申诉)
////	查看详情-操作方-共用
////	申述账单-操作方-商城界面-供应商
////	确认账单-操作方-商城界面-供应商
////	提交账单-操作方-统一订单界面
////	查看申述-操作方-统一订单界面
//
//
////	/***
////	 * 供应商结算-对账单-opt(重新对账)
////	 *
////	 * 相关于
////	 * @return
////	 */
////	@RequestMapping(value = "/opAgainAccounting/{accountingOrderId}", method = RequestMethod.POST)
////	@ResponseBody
////	public R<AccountingUnifiedSupplier> opAgainAccounting(
////			@PathVariable("accountingOrderId") Long accountingOrderId
////	) {
////
////		R<AccountingUnifiedSupplier> result = new R<>();
////
////		try {
////
//////			Long id = getLong("id");
////
////			// 1-已确认,-1-已取消,2-已拒绝,3-已提交
////			AccountingUnifiedSupplier statementOfAccount = accountingUnifiedSupplierDubboConsumerService.findById(accountingOrderId);
////
////			// TODO 写死
////			if (statementOfAccount.getInvoiceStatus() == 1) {
////				result.setCode(400);
////				result.setSuccess(false);
////				result.setMessage("已开票对账单不可继续操作！");
////				return result;
////			}
////
////			// 这个对帐单 取消
////			// TODO 写死
////
////
////			accountingUnifiedSupplierDubboConsumerService.opCancelAccounting(getToken(), statementOfAccount);
////
////			result.setData(statementOfAccount);
////
////		} catch (Exception e) {
////
////			result.setCode(String.valueOf(e.hashCode()));
////			result.setSuccess(false);
////			result.setMessage(e.getMessage());
////
////			log.error(ExceptionUtils.getMessage(e));
////			e.printStackTrace();
////		}
////
////		return result;
////	}
////
////	/***
////	 * 供应商结算-对账单-opt拒绝对账
////	 * @return
////	 */
////	@RequestMapping(value = "/opCancelAccounting/{accountingOrderId}", method = RequestMethod.POST)
////	@ResponseBody
////	public R<AccountingUnifiedSupplier> opCancelAccounting(
////			@PathVariable("accountingOrderId") Long accountingOrderId
////	) {
////
////		R<AccountingUnifiedSupplier> result = new R<>();
////
////		try {
////
//////			Long id = getLong("id");
////
////			// 1-已确认,-1-已取消,2-已拒绝,3-已提交
////			AccountingUnifiedSupplier statementOfAccount = accountingUnifiedSupplierDubboConsumerService.findById(accountingOrderId);
////
////			// TODO 写死
////			if (statementOfAccount.getInvoiceStatus() == 1) {
////				result.setCode(400);
////				result.setSuccess(false);
////				result.setMessage("已开票对账单不可继续操作！");
////				return result;
////			}
////
////
////
////			accountingUnifiedSupplierDubboConsumerService.opCancelAccounting(getToken(), statementOfAccount);
////
////			result.setData(statementOfAccount);
////
////		} catch (Exception e) {
////
////			result.setCode(String.valueOf(e.hashCode()));
////			result.setSuccess(false);
////			result.setMessage(e.getMessage());
////
////			log.error(ExceptionUtils.getMessage(e));
////			e.printStackTrace();
////		}
////
////		return result;
////	}
//}
