package com.bohuikeji.delivery.backstage.controller.test;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bohuikeji.delivery.backstage.service.ITDiscountRecordService;
import com.bohuikeji.delivery.backstage.service.ITOrderService;
import com.bohuikeji.delivery.backstage.service.ITPayService;
import com.bohuikeji.delivery.backstage.service.IWxUserService;
import com.bohuikeji.delivery.backstage.util.capacity.HllUtils;
import com.bohuikeji.frame.module.admin.base.ApiController;
import com.bohuikeji.frame.module.admin.entity.back.APIEntity;
import com.bohuikeji.frame.module.admin.entity.sys.SysConfig;
import com.bohuikeji.frame.module.admin.entity.vo.AddressVo;
import com.bohuikeji.frame.module.admin.service.ISysConfigService;
import com.bohuikeji.frame.module.admin.utils.MapUtils;
import com.bohuikeji.frame.module.admin.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 通知推送测试
 * @author 10552
 */
@Slf4j
@RestController
@Api(tags = {"货拉拉授权测试"})
@RequestMapping("/api/test/ali")
@RequiredArgsConstructor
public class AliTest extends ApiController {
    @Autowired
    ITOrderService orderService;
    @Autowired
    ITPayService payService;
    @Autowired
    IWxUserService wxUserService;
    @Autowired
    ITDiscountRecordService discountRecordService;
    @Autowired
    ISysConfigService configService;

    //private static OAuthClient client;


   /* @GetMapping("/upload/files")
    @ApiOperation("上传图片")
    public APIEntity test1(){
        return APIEntity.success(AliUtils.uploadFile());
    }

    @GetMapping("/get/order/byid")
    @ApiOperation("获取订单信息")
    public APIEntity test1(Integer orderId,String orderStatus){
        TOrder order = orderService.getById(orderId);
        orderService.updateById(order.setOrderStatus(orderStatus));
        TPay pay = payService.getOne(new QueryWrapper<TPay>().eq("order_id",order.getOrderId()).eq("pay_scenario","业务支付"));
        TWxUser wxUser = wxUserService.getOne(new QueryWrapper<TWxUser>().eq("user_id",order.getPlayerId()));
        String state = AliUtils.getOrderStatus(order.getOrderStatus());//根据订单状态获取支付宝订单中心状态
        Map<String, Object> params = new HashMap<>(10);
        params.put("price",order.getOrderFactPrice());
        params.put("modTime", LocalDateTime.now().toString());
        params.put("createTime",order.getOrderCreateTime().toString());
        params.put("itemName","日常用品/其他");
        params.put("materialId","2022031500502200000066862472");
        params.put("storeAddress",order.getMailingAddress());
        params.put("orderType",order.getWayName());
        params.put("unitPrice",order.getOrderFactPrice());
        params.put("tradeNo",pay.getPayChannelNum());
        params.put("bizType","KX_TAKE_OUT");
        params.put("orderStatus",state);
        params.put("appId", AliPayConfig.AliClientID);
        params.put("bizNo",order.getOrderNum());
        params.put("uid",wxUser.getWxUserOpenid());
        return APIEntity.success(AliUtils.orderCcenter(params));
    }

    @GetMapping("/get/order/get/id")
    @ApiOperation("获取订单信息")
    public APIEntity getpic(Integer orderId){
        TOrder order = orderService.getById(orderId);
        TDiscountRecord tDiscountRecord = discountRecordService.getOne(new QueryWrapper<TDiscountRecord>().eq("customer_id",order.getPlayerId()).eq("dis_type","会员卡").eq("usage_status","使用中"));
        discountConst.getDisPrice(order,tDiscountRecord);
        return APIEntity.success();
    }*/


}
