package cn.superdesk.uniorder.common.mq.kafka.producer;

import cn.superdesk.app.supercloud.dto.receive.organisation.OrganizationReceiveParam;
import cn.superdesk.app.supercloud.dto.receive.organisation.VirtualarchitectureReceiveParam;
import cn.superdesk.app.transfer.constants.receive.TopicReceiveConstants;
import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.dao.entity.organisation.SysClique;
import cn.superdesk.uniorder.dao.entity.organisation.SysCliqueOrg;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskapp.UnifiedChannelProfitSyncReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskapp.UnifiedChannelSyncReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskappservices.flashdeliver.FlashDeliverOrderReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskappservices.flashdeliver.FlashDeliverRefundOrderReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskappservices.flashdeliver.FlashDeliverOrderStatusUpdateReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskappservices.meetingroomreservation.MeetingRoomReservationOrderReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskmall.SlaveVirtualarchitectureReceiveParam;
import cn.superdesk.uniorder.dto.receive.consumer.superdeskmall.SuperMallSupplierReceiveParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;


/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2021/5/7 下午4:06
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/5/7 下午4:06
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service
public class FakeSuperdeskAppProducerHandler {


	@Autowired
	private KafkaTemplate<String, String> kafkaTemplate;


	/****************************************** 服务之窗 楼闪送 外部 proxyclient_order start ******************************************/

//	superdesk.app.services.flashdeliver.kafka.topic.order.main=flashdeliver_order
//	superdesk.app.services.flashdeliver.kafka.topic.order.refund=flashdeliver_order_refund
//	superdesk.app.services.flashdeliver.kafka.topic.order.update_status=unifiedorderupdatedev

	@Value("${superdesk.app.services.flashdeliver.kafka.topic.order.main}")
	private String SUPERDESK_APP_KAFKA_TOPIC_FLASH_DELIVER_ORDER;
	@Value("${superdesk.app.services.flashdeliver.kafka.topic.order.refund}")
	private String SUPERDESK_APP_KAFKA_TOPIC_FLASH_DELIVER_REFUND;
	@Value("${superdesk.app.services.flashdeliver.kafka.topic.order.update_status}")
	private String SUPERDESK_APP_KAFKA_TOPIC_FLASH_DELIVER_ORDER_STATUS_UPDATE;

	public void kafkaMergeReceiveFlashDeliverOrder(FlashDeliverOrderReceiveParam flashdeliverOrderReceiveParam) {
		kafkaTemplate.send(SUPERDESK_APP_KAFKA_TOPIC_FLASH_DELIVER_ORDER, AnJsonUtils.toJson(flashdeliverOrderReceiveParam));
	}

	public void kafkaMergeReceiveFlashDeliverOrderRefund(FlashDeliverRefundOrderReceiveParam flashdeliverOrderRefundReceiveParam) {
		kafkaTemplate.send(SUPERDESK_APP_KAFKA_TOPIC_FLASH_DELIVER_REFUND, AnJsonUtils.toJson(flashdeliverOrderRefundReceiveParam));
	}

	public void kafkaFlashDeliverOrderReceiveStateUpdate(FlashDeliverOrderStatusUpdateReceiveParam flashdeliverOrderStatusUpdateReceiveParam) {
		kafkaTemplate.send(SUPERDESK_APP_KAFKA_TOPIC_FLASH_DELIVER_ORDER_STATUS_UPDATE, AnJsonUtils.toJson(flashdeliverOrderStatusUpdateReceiveParam));
	}

	/****************************************** 服务之窗 楼闪送 外部 proxyclient_order  end ******************************************/

	/****************************************** 服务之窗 会议室预订 proxyclient_order start ******************************************/

//  superdesk.app.services.meetingroomreservation.kafka.topic.order.main=superdesk-app-transfer-receive_hysy_order

	@Value("${superdesk.app.services.meetingroomreservation.kafka.topic.order.main}")
	private String SUPERDESK_APP_KAFKA_TOPIC_ORDER_MEETING_ROOM_RESERVATION;

	public void kafkaMergeReceiveMeetingRoomReservationOrder(MeetingRoomReservationOrderReceiveParam orderReceiveParam) {
		kafkaTemplate.send(SUPERDESK_APP_KAFKA_TOPIC_ORDER_MEETING_ROOM_RESERVATION, AnJsonUtils.toJson(orderReceiveParam));
	}

	/****************************************** 服务之窗 楼闪送 外部 proxyclient_order  end ******************************************/

	/****************************************** 服务之窗 集团 Clique start ******************************************/

	/**
	 * 消息类型	topic	key
	 * 集团新增	superdesk-app-transfer-receive_clique	mergeReceiveClique
	 * 集团修改	superdesk-app-transfer-receive_clique	mergeReceiveClique
	 * 集团删除	superdesk-app-transfer-receive_clique	deleteReceiveClique
	 */

	public void kafkaMergeReceiveClique(SysClique sysCliqueEntity) {
		kafkaTemplate.send("superdesk-app-transfer-receive_clique", "mergeReceiveClique", AnJsonUtils.toJson(sysCliqueEntity));
	}

	public void kafkaDeleteReceiveClique(SysClique sysCliqueEntity) {
		kafkaTemplate.send("superdesk-app-transfer-receive_clique", "deleteReceiveClique", AnJsonUtils.toJson(sysCliqueEntity));
	}

	/**
	 * 消息类型	topic	key
	 * 集团-项目关联新增	superdesk-app-transfer-receive_clique_org	mergeReceiveCliqueOrg
	 * 集团-项目关联修改	superdesk-app-transfer-receive_clique_org	mergeReceiveCliqueOrg
	 * 集团-项目关联删除	superdesk-app-transfer-receive_clique_org	deleteReceiveCliqueOrg
	 */
	public void kafkaMergeReceiveCliqueOrg(SysCliqueOrg sysCliqueOrgEntity) {
		kafkaTemplate.send("superdesk-app-transfer-receive_clique_org", "mergeReceiveCliqueOrg", AnJsonUtils.toJson(sysCliqueOrgEntity));
	}

	public void kafkaDeleteReceiveCliqueOrg(SysCliqueOrg sysCliqueOrgEntity) {
		kafkaTemplate.send("superdesk-app-transfer-receive_clique_org", "deleteReceiveCliqueOrg", AnJsonUtils.toJson(sysCliqueOrgEntity));
	}

	/****************************************** 服务之窗 集团 Clique   end ******************************************/

	/****************************************** 服务之窗 项目 Organization start ******************************************/

	public void kafkaMergeReceiveOrganization(OrganizationReceiveParam organizationReceiveParam) {
		kafkaTemplate.send(TopicReceiveConstants.TOPIC_RECEIVE_ORGANIZATION, "mergeReceiveOrganization", AnJsonUtils.toJson(organizationReceiveParam));
	}

	public void kafkaDeleteReceiveOrganization(OrganizationReceiveParam organizationReceiveParam) {
		kafkaTemplate.send(TopicReceiveConstants.TOPIC_RECEIVE_ORGANIZATION, "deleteReceiveOrganization", AnJsonUtils.toJson(organizationReceiveParam));
	}

	/****************************************** 服务之窗 项目 Organization   end ******************************************/

	/****************************************** 服务之窗 企业 Virtualarchitecture start ******************************************/

	public void kafkaMergeReceiveVirtualarchitectureFromSuperdesk(VirtualarchitectureReceiveParam virtualarchitectureReceiveParam) {
		kafkaTemplate.send(TopicReceiveConstants.TOPIC_RECEIVE_VIRTUALARCHITECTURE, "mergeReceiveVirtualarchitecture", AnJsonUtils.toJson(virtualarchitectureReceiveParam));
	}

	public void kafkaDeleteReceiveVirtualarchitectureFromSuperdesk(VirtualarchitectureReceiveParam virtualarchitectureReceiveParam) {
		kafkaTemplate.send(TopicReceiveConstants.TOPIC_RECEIVE_VIRTUALARCHITECTURE, "deleteReceiveVirtualarchitecture", AnJsonUtils.toJson(virtualarchitectureReceiveParam));
	}

	/****************************************** 服务之窗 企业 Virtualarchitecture   end ******************************************/


	/****************************************** 服务之窗 运营商_渠道商 start ******************************************/

	// superdesk.app.services.organization.kafka.topic.channel.main=sw-un-operater
	// 运营商_渠道商-新增
	// sw-un-operater-insert
	// 运营商_渠道商-修改
	// sw-un-operater-update
	// 运营商_渠道商-删除
	// sw-un-operater-delete
	public void kafkaOperaterInsert(UnifiedChannelSyncReceiveParam unifiedChannelSyncReceiveParam) {
		kafkaTemplate.send("sw-un-operater", "sw-un-operater-insert", AnJsonUtils.toJson(unifiedChannelSyncReceiveParam));
	}

	public void kafkaOperaterUpdate(UnifiedChannelSyncReceiveParam unifiedChannelSyncReceiveParam) {
		kafkaTemplate.send("sw-un-operater", "sw-un-operater-update", AnJsonUtils.toJson(unifiedChannelSyncReceiveParam));
	}

	public void kafkaOperaterDelete(UnifiedChannelSyncReceiveParam unifiedChannelSyncReceiveParam) {
		kafkaTemplate.send("sw-un-operater", "sw-un-operater-delete", AnJsonUtils.toJson(unifiedChannelSyncReceiveParam));
	}

	/****************************************** 服务之窗 运营商_渠道商   end ******************************************/


	/****************************************** 服务之窗 渠道商-业务分润 start ******************************************/

	// superdesk.app.services.organization.kafka.topic.channel.opt=sw-un-businesspor
	// 渠道商-业务分润-新增
	// sw-un-businesspor-insert
	// 渠道商-业务分润-修改
	// sw-un-businesspor-update
	// 渠道商-业务分润-删除
	// sw-un-businesspor-delete
	public void kafkaOperaterBusinessProfitInsert(UnifiedChannelProfitSyncReceiveParam unifiedChannelProfitSyncReceiveParam) {
		kafkaTemplate.send("sw-un-businesspor", "sw-un-businesspor-insert", AnJsonUtils.toJson(unifiedChannelProfitSyncReceiveParam));
	}

	public void kafkaOperaterBusinessProfitUpdate(UnifiedChannelProfitSyncReceiveParam unifiedChannelProfitSyncReceiveParam) {
		kafkaTemplate.send("sw-un-businesspor", "sw-un-businesspor-update", AnJsonUtils.toJson(unifiedChannelProfitSyncReceiveParam));
	}

	public void kafkaOperaterBusinessProfitDelete(UnifiedChannelProfitSyncReceiveParam unifiedChannelProfitSyncReceiveParam) {
		kafkaTemplate.send("sw-un-businesspor", "sw-un-businesspor-delete", AnJsonUtils.toJson(unifiedChannelProfitSyncReceiveParam));
	}

	/****************************************** 服务之窗 渠道商-业务分润   end ******************************************/


	/****************************************** 服务之窗 供应商/商户 start ******************************************/

	@Value("${superdesk.app.services.flashdeliver.kafka.topic.merchant}")
	private String SUPERDESK_APP_SERVICES_FLASHDELIVER_KAFKA_TOPIC_MERCHANT;

	public void kafkaMergeReceiveSupperdeskUniServiceSupplier(SuperMallSupplierReceiveParam superMallSupplierReceiveParam) {

		log.info("\n{}\n{}\n{}", SUPERDESK_APP_SERVICES_FLASHDELIVER_KAFKA_TOPIC_MERCHANT, "mergeReceiveMerchant", AnJsonUtils.toJson(superMallSupplierReceiveParam));

		kafkaTemplate.send(SUPERDESK_APP_SERVICES_FLASHDELIVER_KAFKA_TOPIC_MERCHANT, "mergeReceiveMerchant", AnJsonUtils.toJson(superMallSupplierReceiveParam));
	}

	/****************************************** 服务之窗 供应商/商户   end ******************************************/


	/****************************************** 福利商城 企业 Virtualarchitecture start ******************************************/

	@Value("${superdesk.mall.kafka.topic.organisation.virtualarchitecture}")
	private String TOPIC_RECEIVE_VIRTUALARCHITECTURE_FROM_SUPERMALL;

	public void kafkaMergeReceiveVirtualarchitectureFromSupermall(SlaveVirtualarchitectureReceiveParam slaveVirtualarchitectureReceiveParam) {
		kafkaTemplate.send(TOPIC_RECEIVE_VIRTUALARCHITECTURE_FROM_SUPERMALL, "mergeReceiveVirtualarchitecture", AnJsonUtils.toJson(slaveVirtualarchitectureReceiveParam));
	}

	public void kafkaDeleteReceiveVirtualarchitectureFromSupermall(SlaveVirtualarchitectureReceiveParam slaveVirtualarchitectureReceiveParam) {
		kafkaTemplate.send(TOPIC_RECEIVE_VIRTUALARCHITECTURE_FROM_SUPERMALL, "deleteReceiveVirtualarchitecture", AnJsonUtils.toJson(slaveVirtualarchitectureReceiveParam));
	}

	/****************************************** 福利商城 企业 Virtualarchitecture   end ******************************************/

}
