package com.tzy.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.tzy.annotation.ApiLog;
import com.tzy.app.domain.order.OrderRefundDTO;
import com.tzy.app.domain.order.PayRecord;
import com.tzy.app.mapper.PayRecordMapper;
import com.tzy.app.service.RetryService;
import com.tzy.common.annotation.JsonParam;
import com.tzy.common.annotation.SensitiveData;
import com.tzy.common.config.handle.ApiVersion;
import com.tzy.common.constant.Constants;
import com.tzy.common.constant.MqConstans;
import com.tzy.common.core.controller.BaseController;
import com.tzy.common.core.domain.entity.SysDictData;
import com.tzy.common.dto.OutDTO;
import com.tzy.common.dto.group.PublicGoodsDTO;
import com.tzy.common.dto.group.SyncUserWinCardDTO;
import com.tzy.common.enums.BusinessType;
import com.tzy.common.exception.ServiceException;
import com.tzy.common.utils.DateUtils;
import com.tzy.common.utils.LogSyncUtil;
import com.tzy.common.utils.bean.DozerUtils;
import com.tzy.common.utils.http.forest.AppleUtil;
import com.tzy.coupon.card.service.ITzyCardBaseInfoService;
import com.tzy.framework.pay.dto.PaymentInfoResponseDto;
import com.tzy.framework.pay.service.PaymentService;
import com.tzy.framework.util.RandomUtil;
import com.tzy.framework.util.RedisUtils;
import com.tzy.pojo.card.CardGroupOrderInfo;
import com.tzy.sportcard.api.bean.act.GoodsActRecord;
import com.tzy.sportcard.api.bean.act.UserActTimes;
import com.tzy.sportcard.api.bean.act.UserListActParam;
import com.tzy.sportcard.api.domain.AppUserInfoDto;
import com.tzy.sportcard.api.dto.ResourceData;
import com.tzy.sportcard.api.mapper.AppActPrizeRecordMapper;
import com.tzy.sportcard.api.mapper.GroupApiMapper;
import com.tzy.sportcard.api.mapper.UserActTimesMapper;
import com.tzy.sportcard.api.service.*;
import com.tzy.sportcard.group.domain.CardGroupGoods;
import com.tzy.sportcard.group.domain.CardGroupInfo;
import com.tzy.sportcard.group.mapper.CardGroupGoodsMapper;
import com.tzy.sportcard.group.mapper.CardGroupInfoMapper;
import com.tzy.sportcard.group.mapper.CardGroupOrderInfoMapper;
import com.tzy.sportcard.group.service.AppActService;
import com.tzy.sportcard.group.service.ICardGroupGoodsService;
import com.tzy.sportcard.group.service.ICardGroupOrderInfoService;
import com.tzy.sportcard.point.domain.AppUserPointRecord;
import com.tzy.system.service.ISysDictDataService;
import com.tzy.system.service.ITzySysNoticeRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.teasoft.bee.osql.SuidRich;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * swagger 用户测试方法
 *
 * @author zheng
 */
@Api("用户信息管理")
@RestController
@RequestMapping("{version}/test")
@Slf4j
public class TestController extends BaseController {

	@Autowired
	private RedisUtils redisUtils;
	@Autowired
	private GroupApiService groupApiService;
	@Autowired
	private MerchantApiService merchantApiService;
	@Autowired
	private ITzySysNoticeRecordService noticeRecordService;
	@Resource
	private CardGroupGoodsMapper cardGroupGoodsMapper;
	@Resource
	private CardGroupOrderInfoMapper cardGroupOrderInfoMapper;
	@Autowired
	private ISysDictDataService dictDataService;
	@Autowired
	private SuidRich suidRich;
	@Autowired
	private AsyncAppService asyncAppService;
	@Value("${tzy.app-version:dev}")
	private String appVersion;
	@Resource
	private PayRecordMapper payRecordMapper;
	@Autowired
	private RabbitTemplate rabbitTemplate;
	//@Autowired
	//private DataModel dataModel;
	@Resource
	private CardGroupInfoMapper cardGroupInfoMapper;
	@Autowired
	private ICardGroupGoodsService cardGroupGoodsService;
	@Resource
	private IMemberManageService memberManageService;
	@Autowired
	private PaymentService paymentService;
	@Resource
	private AppActService appActService;
	@Autowired
	private CardGroupOrderInfoMapper orderInfoMapper;
	//@Resource
	//private Connection connection;
	//@Resource
	//private PooledConnection pooledConnection;
	@Autowired
	private MineApiService mineApiService;
	@Resource
	private AppActPrizeRecordMapper actPrizeRecordMapper;
	@Resource
	private GroupApiMapper groupApiMapper;
	@Resource
	private ICardGroupOrderInfoService cardGroupOrderInfoService;
	@Resource
	private RetryService retryService;
	@Resource
	private ITzyCardBaseInfoService cardBaseInfoService;
	@Resource
	private UserActTimesMapper userActTimesMapper;

	@GetMapping("/groupFull/{id}")
	public void testGroupFullConsumer(@PathVariable("id") Long id){
		rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_GROUP_FULL, MqConstans.ROUTING_KEY_GROUP_FULL, id);
	}
	public void checkDevEnv() {
		log.debug("部署环境:{}", appVersion);
		if (Constants.APP_VERSION_PROD.equals(appVersion)) {
			throw new ServiceException(500, "环境不符合");
		}
	}

	@ApiOperation("data")
	@GetMapping("/check/act")
	@ApiVersion(1.0)
	public OutDTO checkAct() throws Exception {
		checkDevEnv();
		Date day = DateUtils.addCalendar(new Date(), "day", -100);
		UserActTimes userActTimes = new UserActTimes().setActType("joint_num").setUserId(15400L).setRefType("joint_num1").setCreateTime(day);
		int count = userActTimesMapper.selectUserActTimesCount(userActTimes);
		return OutDTO.ok().put("count",count);
	}

	@ApiOperation("data")
	@GetMapping("/notice/act")
	@ApiVersion(1.0)
	public OutDTO noticeAct(Integer id) throws Exception {
		checkDevEnv();
		//int actCount = actPrizeRecordMapper.getActCount(38, false, 0, 10);
		//asyncAppService.noticePublicCode(id);
		//groupApiMapper.selectUserIdsV2(null,105,null);
		return OutDTO.ok();
	}

	@ApiOperation("data")
	@GetMapping("/syncGoods")
	@ApiVersion(1.0)
	public OutDTO syncGoods(Long id) throws Exception {
		checkDevEnv();
		//cardGroupGoodsService.syncGoods(id);
		//List<TypeCountDTO> countList = cardGroupGoodsService.getUserGoodsNum(3409L);
		return OutDTO.ok();
	}

	@ApiOperation("data")
	@GetMapping("/infoQuery")
	@ApiVersion(1.0)
	public OutDTO testInfoQuery(Long id) throws Exception {
		checkDevEnv();
		CardGroupInfo cardGroupInfo = cardGroupInfoMapper.selectCardGroupInfoById(id);
		asyncAppService.updateInfoSortQueryV3(cardGroupInfo);
		return OutDTO.ok();
	}

	@ApiOperation("recommend")
	@GetMapping("/recommend/{userId}")
	@ApiVersion(1.0)
	public OutDTO recommendByUser(@PathVariable("userId") Integer userId) throws Exception {
		checkDevEnv();
		return OutDTO.ok()
				//.put("list",list)
				;
	}

	@ApiLog(title = "test", businessType = BusinessType.SEARCH)
	@ApiOperation("data")
	@GetMapping("/dataTest")
	@ApiVersion(1.0)
	@SensitiveData
	public OutDTO dataTest(Integer i) throws Exception {
		checkDevEnv();
		//DataModel model=dataModel;
		//data1(model);
		log.info("---1111111----");
		//{{version}}/test/bee/select
		//data2(model);
		//log.info("---2222222----");
		//data3(model);
		//log.info("---3333333----");
		//asyncAppService.test();
		//List<MemberManage> memberManages = memberManageService.selectOnlineMemberList();
		//MemberManage userMemberLevel = memberManageService.getUserMemberLevel(i);
		//memberManageService.initMember();
		//List<GoodsActRecord> allActGoods = cardGroupGoodsService.getActGoods(i.longValue(),Constants.MERCHANT_ACT_AFT_ORDER);
		//rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_GROUP_FULL, MqConstans.ROUTING_KEY_GROUP_FULL, 1823);
		//testPointJson();
		//List<SensitiveDTO> list = Arrays.asList(new SensitiveDTO(1, "test2121"), new SensitiveDTO(2, "17000000041"));
		//redisUtils.del("app_dict_cache");
		// String message = "Hello, world!";
		// rabbitTemplate.convertAndSend("TestTopicExchangeV3", "test", message);
		// // 发送消息到交换机，使用路由键 "test.abc"
		// String message2 = "Hello, world again!";
		// rabbitTemplate.convertAndSend("TestTopicExchangeV3", "test.abc", message2);
		return OutDTO.ok()
				//.put("test", list)
				;
	}

	private void testPointJson() {
		AppUserPointRecord pointRecord = new AppUserPointRecord();
		pointRecord.setChangePoint(2990L);
		pointRecord.setType(Constants.POINT_TYPE_GOODS);
		pointRecord.setUserId(2487L);
		pointRecord.setOrderId(23644L);
		pointRecord.setOrderNo("SO620220928167151695");
		pointRecord.setCreateTime(new Date());
		pointRecord.setMerchantId(13L);
		rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_USER_POINT, MqConstans.ROUTING_KEY_USER_POINT, pointRecord);
		//rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_USER_POINT, MqConstans.ROUTING_KEY_USER_POINT_JSON, JSON.toJSONString(pointRecord));
	}

	@ApiOperation("bee")
	@GetMapping("/bee/select")
	@ApiVersion(1.0)
	public OutDTO beeTest(Long id) {
        // try {
        //     Thread.sleep(61000);
        // } catch (InterruptedException e) {
        //     throw new RuntimeException(e);
        // }
        CardGroupOrderInfo orderInfo = new CardGroupOrderInfo();
		orderInfo.setGroupInfoId(id);
		List<CardGroupOrderInfo> select = suidRich.select(orderInfo, 0, 5);
		int count = suidRich.count(orderInfo);
		return OutDTO.ok().put("goods", select)
				.setCount(5, 1, count);
	}

	@ApiOperation("bee")
	@GetMapping("/bee/update")
	@ApiVersion(1.0)
	public OutDTO beeUpdate(Long id) {
		checkDevEnv();
		CardGroupOrderInfo orderInfo = new CardGroupOrderInfo();
		orderInfo.setId(id);
		orderInfo.setProp1("111");
		suidRich.update(orderInfo, "prop1");
		return OutDTO.ok();
	}

	@ApiOperation("act")
	@GetMapping("/list/act")
	public OutDTO listAct() {
		checkDevEnv();
		List<GoodsActRecord> userListAct = groupApiService.getUserListAct(1716L);
		UserListActParam listActParam = new UserListActParam(3222L, 0, 1716L, Constants.LIST_ACT_SELECT_PLAYER);
		//groupApiService.buildUserListActRecord(listActParam);
		//appActService.delUserListActCache(1716,2459);
		//List<PaniniCheckList> paniniCheckLists = groupApiService.selectPaniniActListByType(1716L, Constants.LIST_ACT_SELECT_PLAYER, 13352L);
		return OutDTO.ok();
	}

	@ApiOperation("version1")
	@GetMapping("/version")
	@ApiVersion(1.0)
	public OutDTO beeTestv() {
		log.info("samll version1");
		return OutDTO.ok().put("version", "1");
	}

	@ApiOperation("version2")
	@GetMapping("/version")
	@ApiVersion(1.7)
	public OutDTO beeTestv2() {
		log.info("big version2");
		return OutDTO.ok().put("version", "2");
	}

	@ApiOperation("payAct")
	@GetMapping("/payAct")
	public OutDTO payAct(String no) {
		checkDevEnv();
		//com.tzy.sportcard.group.domain.CardGroupOrderInfo orderInfo = cardGroupOrderInfoMapper.getByOrderNo(no);
		//asyncAppService.complyPayAct(orderInfo);
		return OutDTO.ok().put("no", no);
	}

	@ApiOperation("paySuccess")
	@GetMapping("/paySuccess")
	public OutDTO paySuccess(String no) {
		checkDevEnv();
		com.tzy.sportcard.group.domain.CardGroupOrderInfo orderInfo = cardGroupOrderInfoMapper.getByOrderNo(no);
		CardGroupInfo cardGroupInfo = cardGroupInfoMapper.selectCardGroupInfoById(orderInfo.getGroupInfoId());
		asyncAppService.orderPaySuccess(orderInfo, cardGroupInfo);
		return OutDTO.ok();
	}

	@ApiOperation("callback")
	@GetMapping("/callback")
	public OutDTO callback(String no) {
		checkDevEnv();
		//Long[] idxes={1L,2L};
		//log.info("订单no:{},保存队伍选择卡密id集合:{}",no, Arrays.toString(idxes));
		//RedisTools.getRedisUtils().set("test","1111",3);
		ResourceData resourceData = new ResourceData();
		ResourceData.PayAmount payAmount = new ResourceData.PayAmount();
		if (no.startsWith(RandomUtil.GROUP_USER_ORDER) || no.startsWith(RandomUtil.MALL_USER_ORDER)) {
			com.tzy.sportcard.group.domain.CardGroupOrderInfo orderInfo = cardGroupOrderInfoMapper.getByOrderNo(no);
			resourceData.setTrade_type(orderInfo.getPaymentType());
			resourceData.setSubPaymentType(orderInfo.getPaymentSubType());
			payAmount.setTotal(orderInfo.getActualPayment().multiply(new BigDecimal(100)).intValue());
			resourceData.setOut_trade_no(StringUtils.isEmpty(orderInfo.getTradeNo()) ? no : orderInfo.getTradeNo());
		} else {
			PayRecord payRecord = payRecordMapper.selectPayRecordByNo(no);
			resourceData.setTrade_type(payRecord.getPaymentType());
			resourceData.setSubPaymentType(payRecord.getPaymentSubType());
			payAmount.setTotal(payRecord.getPayAmount().multiply(new BigDecimal(100)).intValue());
			resourceData.setOut_trade_no(no);
		}
		resourceData.setTransaction_id(String.valueOf(System.currentTimeMillis()));//支付流水号，微信支付订单号
		resourceData.setSuccess_time(DateUtils.dateTime(new Date()));//支付成功时间
		resourceData.setTrade_state("TRADE_SUCCESS");//支付状态
		resourceData.setTrade_state_desc("TRADE_SUCCESS");//支付状态说明
		resourceData.setBank_type("支付宝");//付款银行
		payAmount.setPayer_total(payAmount.getTotal());
		resourceData.setAmount(payAmount);
		groupApiService.prePayByMQ(resourceData);
		return OutDTO.ok().put("no", no);
	}

	@ApiOperation("stock")
	@GetMapping("/updateStock")
	public OutDTO updateStock(Long orderId) {
		//com.tzy.sportcard.group.domain.CardGroupOrderInfo cardGroupOrderInfo = cardGroupOrderInfoMapper.selectCardGroupOrderInfoById(orderId);
		//asyncAppService.updateSoldAndRealStock(cardGroupOrderInfo);
		return OutDTO.ok();
	}

	@ApiOperation("mq")
	@GetMapping("/testMq")
	public OutDTO testMq() {
		checkDevEnv();
		String messageId = String.valueOf(UUID.randomUUID());
		String messageData = "message: testFanoutMessage ";
		String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
		//rabbitTemplate.convertAndSend("exchange_test2", "test", new TestParam(messageId, messageData, createTime));
		//rabbitTemplate.convertAndSend("exchange_test2", "test.test", new TestParam(messageId, messageData, createTime));
		//sendMsg();
		//orderRefund();
		//rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_GROUP_FULL, MqConstans.ROUTING_KEY_GROUP_FULL, 738L);
		//sendLiveMsg();
		//rabbitTemplate.convertAndSend(MqConstans.QUEUE_MERCHANT_NOTIFY,"12222");
		//JSONObject param2 = new JSONObject();
		//param2.put("type","sale");
		//param2.put("merchantId",13);
		//param2.put("merchantName","YYDS");
		//param2.put("groupInfoId","2919");
		//param2.put("groupInfoName","1111");
		//rabbitTemplate.convertAndSend(MqConstans.QUEUE_MERCHANT_NOTIFY, JSON.toJSONString(param2));
		//rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_GROUP_FULL, MqConstans.ROUTING_KEY_GROUP_FULL, 3067);
		//GroupActRecord actRecord = new GroupActRecord().setType(Constants.GROUP_GIFT_CARD).setRefId(3380).setActType(Constants.GROUP_GIFT_CARD);
		//rabbitTemplate.convertAndSend(MqConstans.QUEUE_GROUP_GIFT_CARD, com.alibaba.fastjson2.JSON.toJSONString(actRecord));
		//List<UserGiftCardDTO> userWaitCards = mineApiService.getUserInitWaitGiftCards(2492);
		return OutDTO.ok();

	}

	private void orderRefund() {
		rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_ORDER_REFUND, MqConstans.ROUTING_KEY_ORDER_REFUND, new OrderRefundDTO(1L, BigDecimal.ONE));
	}

	public void sendMsg() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println("消息发送时间：" + sdf.format(new Date()));
		rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_DELAYED_ORDER_EXPIRED, MqConstans.ROUTING_KEY_ORDER_EXPIRED, 1L, message -> {
			//消息延迟5秒
			message.getMessageProperties().setHeader("x-delay", 1000 * 3);
			return message;
		});
	}

	public void sendLiveMsg() {
		Map data = new HashMap() {{
			put("type", "1");
			put("data", "11111");
			put("time", new Date().toString());
		}};
		rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_DELAYED_APP_LIVE_CONFIG, MqConstans.ROUTING_KEY_APP_LIVE_CONFIG, JSON.toJSONString(data), message -> {
			//消息延迟5秒
			message.getMessageProperties().setHeader("x-delay", 3000);
			return message;
		});
	}


	@ApiOperation("stock")
	@GetMapping("/testLock")
	public OutDTO testLock() {
		String name = Thread.currentThread().getName();
		log.info("请求进来了:{}", name);
		String lockKey = "test_key";
		long l = System.currentTimeMillis();
		boolean isGetLock = false;
		try {
			boolean isLock = redisUtils.tryLock(lockKey, TimeUnit.SECONDS, 5L, -1);
			if (isLock) {
				isGetLock = true;
				log.info("3333------->{}", name);
				//Thread.sleep(40000L);
				log.info("1111------->{}", name);
				redisUtils.unlock(lockKey);
				log.info("222------->{}", name);
				//isGetLock = false;
				return OutDTO.ok("2222");
			}
		} catch (Exception e) {
			log.error("异常:{}", e);
		} finally {
			try {
				//if (isGetLock) {
				log.info("finally unlock-------");
				redisUtils.unlock(lockKey);
				//}
			} catch (Exception e) {
				log.error("锁释放异常:{}", e);
				return OutDTO.ok();
			}

		}
		log.info("等待时间:name:{}------->时间:{}", name, System.currentTimeMillis() - l);
		return OutDTO.error500("500");
	}


	@ApiOperation("codeVerify")
	@GetMapping("/codeVerify")
	public OutDTO codeVerify(String jwt) throws Exception {
		AppleUtil.verify(jwt);
		return OutDTO.ok();
	}

	@ApiOperation("syncWinCardTest")
	@GetMapping("/sync/win/card")
	public OutDTO syncWinCardTest(String type, Integer id) {
		checkDevEnv();
		ArrayList<Integer> ids = new ArrayList<>();
		ids.add(id);
		SyncUserWinCardDTO param = new SyncUserWinCardDTO(type, ids);
		rabbitTemplate.convertAndSend(MqConstans.EXCHANGE_SYNC_USER_WIN_CARD, MqConstans.ROUTING_KEY_SYNC_USER_WIN_CARD, JSONObject.toJSONString(param));
		return OutDTO.ok();
	}


	@ApiOperation("dozer")
	@GetMapping("/dozer/test")
	public OutDTO codeVerify() throws Exception {
		CardGroupGoods cardGroupGoods = new CardGroupGoods();
		cardGroupGoods.setId(1L);
		cardGroupGoods.setImg("1L");
		cardGroupGoods.setUserAvatar("1L");
		cardGroupGoods.setUserNickname("2L");

		PublicGoodsDTO goods = DozerUtils.map(cardGroupGoods, PublicGoodsDTO.class);
		log.debug("数据:{}", goods);
		return OutDTO.ok();
	}

	@ApiOperation("log")
	@GetMapping("/log/sync")
	public OutDTO logTest() throws Exception {
		LogSyncUtil.logSync("打印日志,参数1:{},参数2,{}", 1, 2);
		return OutDTO.ok();
	}

	@ApiOperation("query")
	@GetMapping("/query/pay")
	public OutDTO queryPay(String no) {
		checkDevEnv();
		com.tzy.sportcard.group.domain.CardGroupOrderInfo orderInfo = cardGroupOrderInfoMapper.getByOrderNo(no);
		PaymentInfoResponseDto result = paymentService.queryPaymentOrder(orderInfo.getPaymentSubType(), orderInfo.getTradeNo());
		return OutDTO.ok().put("result", result);
	}

	@ApiOperation("query")
	@GetMapping("/v1/page/check")
	public OutDTO checkPageBug() {
		//PageHelper.startPage(1,10);
		//int i=1/0;
		return OutDTO.ok();
	}

	@ApiOperation("query")
	@GetMapping("/v2/page/check")
	public OutDTO checkPageBug2() {
		//List<AppCarouselPicture> banners=appCarouselPictureService.getBanner(null);
		return OutDTO.ok();
	}


	@ApiOperation("query")
	@GetMapping("/pg/notify")
	public OutDTO testNotify() throws SQLException {
		//将数据库连接还原为原始的PGConnection
		//PGConnection pgConnection = pooledConnection.getConnection().unwrap(PGConnection.class);
		//Statement stmt = pgConnection.createStatement();
		//stmt.execute("NOTIFY CARD_GROUP_ORDER_INFO_MODIFIED_TEST,'123'");
		//stmt.close();
		//ExpressInDto expressInDto = new ExpressInDto();
		//expressInDto.setShipTime(new Date());
		//expressInDto.setStatus(103L);//已发货状态
		//expressInDto.setPickUpType("2");
		//expressInDto.setCourierNum("1213123131");//保存快递单号信息;
		//expressInDto.setUnSendFlag(true);
		//int i = orderInfoMapper.sendExpress(expressInDto,Arrays.asList(207915L,207914L));
		//id=null, userId=2442, currPoint=null, lastPoint=null, changePoint=-10000, orderId=253589, merchantId=null,
		// type=common_record, orderNo=SO4240125148608069, createTime=null, userDeduct=1, pointRate=null
//		AppUserPointRecord pointRecord = new AppUserPointRecord();
//		//pointRecord.setType(Constants.POINT_TYPE_GIFT_CARD_PRE + 1);
//		pointRecord.setType("common_record");
//		pointRecord.setChangePoint(10000);
//		//pointRecord.setCurrPoint(1L);
//		pointRecord.setUserId(2442L);
//		pointRecord.setOrderId(253589L);
//		pointRecord.setOrderNo("SO4240125148608069");
//		pointRecord.setUserDeduct(1);
//		pointRecord.setCreateTime(new Date());
//		//增加积分明细记录
//		mineApiService.addUserPoint(pointRecord);
		return OutDTO.ok();
	}

	@ApiOperation("cache")
	@GetMapping("/cache")
	public OutDTO testCache(String v) {
		checkDevEnv();
		//String s=appActService.testCache(v);
		List<SysDictData> newSortQuery = dictDataService.selectDictDataByCache("new_sort_query", null, null, true);
		return OutDTO.ok();
	}

	@ApiOperation("cache")
	@GetMapping("/cache/del")
	public OutDTO testDelCache(String v) {
		checkDevEnv();
		redisUtils.del(v);
		return OutDTO.ok();
	}

	@ApiOperation("cache")
	@GetMapping("/remote/channel")
	public OutDTO testRemoteChannel() {
		checkDevEnv();
		AppUserInfoDto appUserInfoDto = new AppUserInfoDto();
		appUserInfoDto.setGrowthNum(4000L);
		//String rs = cardGroupOrderInfoService.getPayTypeByUser("uac", appUserInfoDto, 86L, false, "group");
		return OutDTO.ok()
				//.put("data", rs)
				;
	}

	@ApiOperation("point")
	@GetMapping("/point")
	public OutDTO testPoint() throws SQLException {
		checkDevEnv();
		//id=null, userId=2442, currPoint=null, lastPoint=null, changePoint=-10000, orderId=253589, merchantId=null,
		// type=common_record, orderNo=SO4240125148608069, createTime=null, userDeduct=1, pointRate=null
//		AppUserPointRecord pointRecord = new AppUserPointRecord();
//		pointRecord.setType("common_record");
//		pointRecord.setChangePoint(-10000);
//		pointRecord.setUserId(2442L);
//		pointRecord.setOrderId(253589L);
//		pointRecord.setOrderNo("SO4240125148608069");
//		pointRecord.setUserDeduct(1);
//		pointRecord.setPointRate(100d);
//		pointRecord.setCreateTime(new Date());
//		//增加积分明细记录
//		mineApiService.addUserPoint(pointRecord);
// 		InvoiceOrderQuery query = new InvoiceOrderQuery().setMerchantId(182).setUserId(15399);
// 		List<SimpleOrderDTO> invoiceOrder = cardGroupOrderInfoMapper.getInvoiceOrder(query);
		return OutDTO.ok();
	}

	@ApiLog(title = "test", businessType = BusinessType.SEARCH)
	@ApiOperation("point")
	@PostMapping("/param/anon")
	public OutDTO testParamConvert(@JsonParam AppUserPointRecord pointRecord){
		return OutDTO.ok().put("param", pointRecord);
	}

	@ApiLog(title = "test", businessType = BusinessType.SEARCH)
	@ApiOperation("point")
	@PostMapping("/param/anon/list")
	public OutDTO testParamConvert(@JsonParam(objectType = AppUserPointRecord.class) List<AppUserPointRecord> pointRecords){
		return OutDTO.ok().put("param", pointRecords);
	}

	@ApiLog(title = "retry", businessType = BusinessType.SEARCH)
	@ApiOperation("retry")
	@PostMapping("/retry")
	public OutDTO testRetry(){
		checkDevEnv();
		// retryService.retryMethod1();
		// retryService.retryMethod2();
		// String day = DateUtils.dateTime();
		// String key = Constants.MERCHANT_USER_ORDER_NUM + day + 11;
		// redisUtils.hset(key, "1", 1);
		// redisUtils.expire(key, Constants.dayForSecond);
		//asyncAppService.recordUserCurrentDayOrderNum(181L,15594L);
		return OutDTO.ok();
	}

	// @GetMapping("/num")
	// @ApiLog(title = "领取优惠券", businessType = BusinessType.INSERT)
	// @ApiOperation("领取优惠券")
	// //@ApiLimitRule(seconds = 1, limitCount = 30, type = LimitRule.ACT, msg = "操作频繁,请稍后再试!")
	// public OutDTO test(){
	// 	cardBaseInfoService.test(2302);
	//     return OutDTO.ok();
	// }

}