package com.bweb.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.*;
import com.hfkj.model.ResponseData;
import com.hfkj.service.CommonService;
import com.hfkj.service.card.BsUserCardService;
import com.hfkj.service.coupon.BsOrderCouponNoService;
import com.hfkj.service.coupon.BsOrderCouponService;
import com.hfkj.service.goods.BsOrderGoodsService;
import com.hfkj.service.goods.GoodsSpecsService;
import com.hfkj.service.goods.GoodsUserAddressService;
import com.hfkj.service.goods.GoodsVpdService;
import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.service.order.BsOrderDeductionService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.user.BsUserComplaintService;
import com.hfkj.service.user.BsUserService;
import com.hfkj.service.user.PhgDataUserService;
import com.hfkj.service.user.impl.BsUserServiceImpl;
import com.hfkj.sysenum.SecUserStatusEnum;
import com.hfkj.sysenum.UserStatusEnum;
import com.hfkj.sysenum.order.OrderChildStatusEnum;
import com.hfkj.sysenum.order.OrderStatusEnum;
import com.mysql.jdbc.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.ListUtils;
import org.mvel2.util.Make;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @className: BsUserController
 * @author: HuRui
 * @date: 2024/5/6
 **/
@Controller
@RequestMapping(value="/user")
@Api(value="用户管理")
public class BsUserController {
    private static Logger log = LoggerFactory.getLogger(BsUserController.class);
    @Resource
    private BsUserService userService;

    @Resource
    private BsUserComplaintService userComplaintService;


    @RequestMapping(value="/restore",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "恢复")
    public ResponseData restore(@RequestBody JSONObject body) {
        try {
            if (body == null || body.getLong("userId") == null) {
                throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
            }

            // 查询用户详情
            BsUser user = userService.getUser(body.getLong("userId"));
            if (user == null) {
                throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
            }
            user.setStatus(UserStatusEnum.status1.getCode());
            userService.editData(user);

            return ResponseMsgUtil.success("操作成功");

        } catch (Exception e) {
            log.error("error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }

    @RequestMapping(value="/disable",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "禁用")
    public ResponseData disable(@RequestBody JSONObject body) {
        try {
            if (body == null || body.getLong("userId") == null) {
                throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
            }
            // 查询用户详情
            BsUser user = userService.getUser(body.getLong("userId"));
            if (user == null) {
                throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
            }
            user.setStatus(SecUserStatusEnum.status2.getCode());
            userService.editData(user);

            // 退出当前登录信息
            userService.loginOut(new BsUserServiceImpl().token(user));

            return ResponseMsgUtil.success("操作成功");

        } catch (Exception e) {
            log.error("error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }

    @RequestMapping(value="/queryUserList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询用户列表")
    public ResponseData queryUserList(@RequestParam(value = "name" , required = false) String name,
                                      @RequestParam(value = "phone" , required = false) String phone,
                                      @RequestParam(value = "status" , required = false) Integer status,
                                      @RequestParam(value = "pageNum" , required = true) Integer pageNum,
                                      @RequestParam(value = "pageSize" , required = true) Integer pageSize) {
        try {
            Map<String,Object> param = new HashMap<>();
            param.put("name", name);
            param.put("phone", phone);
            param.put("status", status);

            PageHelper.startPage(pageNum, pageSize);
            return ResponseMsgUtil.success(new PageInfo<>(userService.getList(param)));

        } catch (Exception e) {
            log.error("error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }

    @RequestMapping(value="/queryComplaintList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询用户投诉列表")
    public ResponseData queryComplaintList(@RequestParam(value = "name" , required = false) String name,
                                           @RequestParam(value = "phone" , required = false) String phone,
                                           @RequestParam(value = "pageNum" , required = true) Integer pageNum,
                                           @RequestParam(value = "pageSize" , required = true) Integer pageSize) {
        try {
            Map<String,Object> param = new HashMap<>();
            param.put("name", name);
            param.put("phone", phone);

            PageHelper.startPage(pageNum, pageSize);
            return ResponseMsgUtil.success(new PageInfo<>(userComplaintService.getList(param)));

        } catch (Exception e) {
            log.error("error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }

//    @RequestMapping(value="/phgDataUser",method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "普惠GO用户数据迁移")
//    public ResponseData phgDataUser() {
//        try {
//            // 查询普惠GO老用户数据
//            Map<String ,Object> param = new HashMap<>();
//            param.put("type" , 1);
//            List<CyymallUser> list = phgDataUserService.getList(param);
//
//            Map<String , CyymallUser> cyymallUserMap = list.stream().collect(Collectors.toMap(CyymallUser:: getWechatOpenId , Function.identity() , (cyymallUser, cyymallUser2) -> cyymallUser));
//            List<CyymallUser> cyymallUserList = new ArrayList<>(cyymallUserMap.values());
//
//            // 查询新普惠GO用户数据
//            List<BsUser> bsUserList = userService.getList(new HashMap<>());
//
//            // 定义用户 工会卡 新增用户列表  新增用户工会卡列表 更新用户列表 更新用户工会卡列表
//            BsUser sysUser;
//            List<BsUser> listUserInsert = new ArrayList<>();
//            List<BsUser> listUserUpdate = new ArrayList<>();
//
//            // 循环老用户数据 组装新数据
//            for (CyymallUser user : cyymallUserList) {
//                sysUser = new BsUser();
//                if (user.getBinding() != null) {
//                    //判断新老用户数据是否有相同数据 根据手机号
//                    List<BsUser> bsUsers = bsUserList.stream()
//                            .filter(bsUser -> Objects.equals(bsUser.getPhone(), user.getBinding()))
//                            .collect(Collectors.toList());
//                    List<BsUser> bsUsersOpenId = bsUserList.stream()
//                            .filter(bsUser -> Objects.equals(bsUser.getWxMaOpenid(), user.getWechatOpenId()))
//                            .collect(Collectors.toList());
//                    if (!bsUsers.isEmpty() || !bsUsersOpenId.isEmpty()) {
//                        sysUser = bsUsers.get(0);
//                    } else {
//                        sysUser = new BsUser();
//                    }
//                }
//
//                // 组装用户数据
//                sysUser.setHeadImg(user.getAvatarUrl());
//                sysUser.setStatus(UserStatusEnum.status1.getCode());
//                sysUser.setPhone(user.getBinding());
//                sysUser.setWxMaOpenid(user.getWechatOpenId());
//                sysUser.setIntegral(0L);
//                sysUser.setUpdateTime(new Date());
//                sysUser.setExt1(String.valueOf(user.getId()));
//                sysUser.setExt2(user.getGhCardNo());
//                if (sysUser.getId() == null) {
//                    sysUser.setName(user.getNickname());
//                    sysUser.setCreateTime(new Date());
//                    listUserInsert.add(sysUser);
//                }else {
//                    listUserUpdate.add(sysUser);
//                }
//            }
//
//            if (!listUserInsert.isEmpty()) {
//                userService.insertUserBatch(listUserInsert);
//            }
//            if (!listUserUpdate.isEmpty()) {
//                userService.updateUserBatch(listUserUpdate);
//            }
//
//            return ResponseMsgUtil.success("成功");
//
//        } catch (Exception e) {
//            log.error("error!",e);
//            return ResponseMsgUtil.exception(e);
//        }
//    }
//
//
//
//    @RequestMapping(value="/phgDataUserDetail",method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "普惠GO用户详细数据迁移")
//    public ResponseData phgDataUserDetail() {
//        try {
//
//            // 查询新用户数据 查询新工会卡数据 查询 老收货地址数据 查询新城市数据
//            List<BsUser> bsUserList = userService.getList(new HashMap<>());
//            List<CyymallAddress> cyymallAddresses = phgDataUserService.getAddressList();
//            List<BsCity> cityList = commonService.getCityListAll();
//
//
//            // 定义用户 工会卡 收货地址数据   更新用户工会卡列表 新增收货地址列表
//            BsUserCard sysUserCard;
//            GoodsUserAddress userAddress;
//            List<BsUserCard> listCardUpdate = new ArrayList<>();
//            List<GoodsUserAddress> userAddresses = new ArrayList<>();
//
//            // 循环新用户数据 组装逐句
//            for (BsUser bsUser : bsUserList) {
//                // 根据工会卡数据 匹配用户数据中的老数据 更新用户ID
//                if (!StringUtils.isNullOrEmpty(bsUser.getExt2())) {
//                    sysUserCard = new BsUserCard();
//                    sysUserCard.setCardNo(bsUser.getExt2());
//                    sysUserCard.setType(1);
//                    sysUserCard.setStatus(1);
//                    sysUserCard.setUserId(bsUser.getId());
//                    sysUserCard.setCreateTime(new Date());
//                    sysUserCard.setUpdateTime(new Date());
//                    listCardUpdate.add(sysUserCard);
//                }
//
//                // 匹配收货地址数据 新增新收货地址
//                List<CyymallAddress> cyymallAddressList = cyymallAddresses.stream()
//                        .filter(cyymallAddress -> Objects.equals(cyymallAddress.getUserId().toString() , bsUser.getExt1()))
//                        .collect(Collectors.toList());
//                if (!cyymallAddressList.isEmpty()) {
//                    for (CyymallAddress address : cyymallAddressList) {
//                        List<BsCity>  bsCities = cityList.stream().filter(city -> Objects.equals(city.getRegionName() , address.getDistrict())).collect(Collectors.toList());
//                        if (!bsCities.isEmpty()) {
//                            userAddress = new GoodsUserAddress();
//                            userAddress.setRegionId(String.valueOf(bsCities.get(0).getRegionId()));
//                            userAddress.setRegionName(address.getProvince() + "," + address.getCity() + "," + address.getDistrict());
//                            userAddress.setAddress(address.getDetail());
//                            userAddress.setUserId(bsUser.getId());
//                            userAddress.setCreateTime(new Date());
//                            userAddress.setUpdateTime(new Date());
//                            userAddress.setPhone(address.getMobile());
//                            userAddress.setConsignee(address.getName());
//                            userAddress.setWhetherDefault(address.getIsDefault() == 1);
//                            userAddresses.add(userAddress);
//                        }
//
//                    }
//
//                }
//
//            }
//
//            if (!listCardUpdate.isEmpty()) {
//                userCardService.insertUserCardBatch(listCardUpdate);
//            }
//
//            if (!userAddresses.isEmpty()) {
//                goodsUserAddressService.insertUserAddressBatch(userAddresses);
//            }
//
//            return ResponseMsgUtil.success("成功");
//
//        } catch (Exception e) {
//            log.error("error!",e);
//            return ResponseMsgUtil.exception(e);
//        }
//    }
//
//
//    @RequestMapping(value="/phgDataUserOrder",method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "普惠GO用户订单数据迁移")
//    public ResponseData phgDataUserOrder() {
//        try {
//
//            Map<String , Object> map = new HashMap<>();
//            map.put("isPay" , 1);
//            map.put("applyDelete" , 0);
//            // 查询新用户数据 查询老用户订单列表  老收货订单详情 查询老商品列表 虚拟产品配置列表
//            List<BsUser> bsUserList = userService.getList(new HashMap<>());
//            List<CyymallOrder> cyymallOrderList = phgDataUserService.getListOrder(map);
//            List<CyymallOrderDetail> orderDetailList = phgDataUserService.getListOrderDetail();
//            List<CyymallGoods> goodsList = phgDataUserService.getListGoods();
//
//            BsOrder order;
//            BsOrderChild orderChild;
//            BsOrderCoupon orderCoupon;
//            BsOrderCouponNo orderCouponNo;
//            BsOrderGoods orderGoods;
//            BsOrderDeduction orderDeduction;
//
//            List<BsOrder> addOrderList = new ArrayList<>();
//            List<BsOrderChild> addOrderChildList = new ArrayList<>();
//            List<BsOrderCoupon> addOrderCouponList = new ArrayList<>();
//            List<BsOrderCouponNo> addOrderCouponNoList = new ArrayList<>();
//            List<BsOrderGoods> addOrderGoodsList = new ArrayList<>();
//            List<BsOrderDeduction> addOrderDeductionList = new ArrayList<>();
//            BigDecimal price = new BigDecimal(0);
//
//            for (CyymallOrder cyymallOrder : cyymallOrderList) {
//                // 查询相关订单详情内容
//                List<CyymallOrderDetail> orderDetail = orderDetailList.stream().filter(detail -> Objects.equals(detail.getOrderId() , cyymallOrder.getId()))
//                        .collect(Collectors.toList());
//                // 查询用户信息
//                List<BsUser> userList = bsUserList.stream().filter(user -> Objects.equals(user.getExt1() , cyymallOrder.getUserId().toString())).collect(Collectors.toList());
//                // 判断用户是否存在
//                if (!userList.isEmpty()) {
//                    BsUser user = userList.get(0);
//                    // 判断是否存在订单详情 不存在不添加
//                    if (!orderDetail.isEmpty()) {
//                        CyymallOrderDetail cyymallOrderDetail = orderDetail.get(0);
//                        // 查询产品
//                        List<CyymallGoods> goods = goodsList.stream().filter(cyymallGoods -> Objects.equals(cyymallGoods.getId() , cyymallOrderDetail.getGoodsId()))
//                                .collect(Collectors.toList());
//                        // 判断产品不为空
//                        if (!goods.isEmpty()) {
//                            CyymallGoods cyymallGoods = goods.get(0);
//
//
//                            // 公用订单数据
//                            order = new BsOrder();
//                            orderChild = new BsOrderChild();
//                            orderCoupon = new BsOrderCoupon();
//                            orderCouponNo = new BsOrderCouponNo();
//                            orderDeduction = new BsOrderDeduction();
//                            orderGoods = new BsOrderGoods();
//                            // 定义订单内容
//                            order.setOrderNo(cyymallOrder.getOrderNo());
//                            Long createTime = (long) (cyymallOrder.getAddtime() )* 1000;
//                            Long payTime = (long) (cyymallOrder.getPayTime() )* 1000;
//                            order.setCreateTime(DateUtil.long2Date(createTime));
//                            order.setUpdateTime(new Date());
//                            order.setOrderStatus(OrderStatusEnum.status3.getCode());
//                            order.setFinishTime(new Date());
//                            order.setPayTime(DateUtil.long2Date(payTime));
//                            order.setUserId(user.getId());
//                            order.setUserName(user.getName());
//                            order.setPayChannel(4);
//                            order.setUserPhone(user.getPhone());
//
//                            // 订单金额
//                            order.setPayRealPrice(cyymallOrder.getPayPrice());
//                            order.setTotalPrice(cyymallOrder.getTotalPrice());
//                            order.setProductTotalPrice(cyymallOrder.getTotalPrice());
//                            order.setPayType(4);
//                            order.setExt3("迁移数据");
//
//
//                            // 定义子订单
//                            orderChild.setChildOrderNo(OrderUtil.generateChildOrderNo());
//                            orderChild.setOrderNo(order.getOrderNo());
//                            orderChild.setCreateTime(order.getCreateTime());
//                            orderChild.setUpdateTime(order.getUpdateTime());
//                            orderChild.setFinishTime(order.getFinishTime());
//                            // 优惠金额
//                            orderChild.setProductActualPrice(order.getPayRealPrice());
//                            orderChild.setIntegralDiscountPrice(0L);
//                            orderChild.setCouponDiscountPrice(price);
//                            orderChild.setProductTotalPrice(order.getProductTotalPrice());
//                            orderChild.setProductPrice(cyymallGoods.getPrice());
//                            orderChild.setSurplusRefundPrice(price);
//                            orderChild.setTotalDeductionPrice(price);
//                            orderChild.setSurplusRefundPrice(price);
//                            orderChild.setSurplusRefundCount(0);
//                            orderChild.setSurplusRefundIntegral(0L);
//
//                            // 产品数据
//                            orderChild.setProductCount(cyymallOrderDetail.getNum());
//                            orderChild.setProductName(cyymallGoods.getName());
//                            orderChild.setStatus(OrderChildStatusEnum.status3.getCode());
//
//
//                            // 优惠订单数据
//                            orderDeduction.setOrderNo(order.getOrderNo());
//                            orderDeduction.setIntegralDiscountPrice(0L);
//                            orderDeduction.setCouponDiscountPrice(price);
//                            orderDeduction.setCouponDiscountActualPrice(price);
//                            orderDeduction.setTotalDeductionPrice(price);
//
//                                // 判断实物产品
//                                if (!StringUtils.isNullOrEmpty(cyymallGoods.getOilCoutypecode())) {
//                                    orderChild.setProductType(2);
//                                    orderChild.setProductId(999999L);
//                                    // todo 图片查询
//                                    orderChild.setProductImg(cyymallOrderDetail.getPic());
//                                    orderChild.setProductSpecId(999999L);
//                                    orderChild.setProductSpecName(cyymallOrder.getName());
//                                    // 定义卡券订单内容
//                                    orderCoupon.setChildOrderNo(orderChild.getChildOrderNo());
//                                    orderCoupon.setCreateTime(orderChild.getCreateTime());
//                                    orderCoupon.setUpdateTime(orderChild.getUpdateTime());
//                                    orderCoupon.setFinishTime(orderChild.getFinishTime());
//                                    orderCoupon.setPayTime(order.getPayTime());
//                                    orderCoupon.setOrderNo(orderChild.getOrderNo());
//                                    // 优惠金额
//                                    orderCoupon.setIntegralDiscountPrice(0L);
//                                    orderCoupon.setCouponDiscountPrice(price);
//                                    orderCoupon.setTotalDeductionPrice(price);
//                                    orderCoupon.setPayRealPrice(order.getPayRealPrice());
//                                    orderCoupon.setTotalPrice(order.getTotalPrice());
//                                    orderCoupon.setPayType(order.getPayType());
//                                    // todo 定义死数据
//                                    orderCoupon.setGoodsBrandId(999999L);
//                                    orderCoupon.setGoodsBrandName("贵州卡券");
//                                    orderCoupon.setGoodsId(orderChild.getProductId());
//                                    orderCoupon.setGoodsName("工会加油权益");
//                                    orderCoupon.setGoodsCount(orderChild.getProductCount());
//                                    orderCoupon.setGoodsSpescOriginalPrice(cyymallGoods.getOriginalPrice());
//                                    orderCoupon.setGoodsVpdId(9L);
//                                    orderCoupon.setGoodsVpdKey(cyymallGoods.getOilCoutypecode());
//                                    orderCoupon.setGoodsSpecsId(257L);
//                                    orderCoupon.setGoodsTypeId(999999L);
//                                    orderCoupon.setGoodsTypeName("贵州卡券");
//                                    orderCoupon.setGoodsSpecsName(cyymallGoods.getName());
//                                    orderCoupon.setUserId(user.getId());
//                                    orderCoupon.setUserPhone(user.getPhone());
//                                    orderCoupon.setGoodsVpdSource(4);
//                                    orderCoupon.setStatus(orderChild.getStatus());
//                                    addOrderCouponList.add(orderCoupon);
//                                    // 定义订单卡券号
//                                    orderCouponNo.setGoodsVpdSource(orderCoupon.getGoodsVpdSource());
//                                    orderCouponNo.setCreateTime(orderChild.getCreateTime());
//                                    orderCouponNo.setUpdateTime(orderChild.getUpdateTime());
//                                    orderCouponNo.setFinishTime(orderChild.getFinishTime());
//                                    orderCouponNo.setDeliverTime(orderChild.getCreateTime());
//                                    orderCouponNo.setExceptionStatus(false);
//                                    orderCouponNo.setGoodsVpdKey(orderCoupon.getGoodsVpdKey());
//                                    orderCouponNo.setGoodsVpdSourceCouNo(cyymallOrder.getCouponRecordId());
//                                    orderCouponNo.setExt1(order.getOrderNo());
//                                    orderCouponNo.setStatus(3);
//                                    addOrderCouponNoList.add(orderCouponNo);
//
//                                }else {
//                                    // 实物商品数据
//                                    orderChild.setProductType(1);
//                                    orderChild.setProductId(999999L);
//                                    orderChild.setProductSpecId(999999L);
//                                    orderChild.setProductSpecName(cyymallGoods.getName());
//                                    orderGoods.setChildOrderNo(orderChild.getChildOrderNo());
//                                    orderGoods.setCreateTime(orderChild.getCreateTime());
//                                    orderGoods.setUpdateTime(orderChild.getUpdateTime());
//                                    orderGoods.setFinishTime(orderChild.getFinishTime());
//                                    orderGoods.setOrderNo(orderChild.getOrderNo());
//                                    orderGoods.setGoodsId(999999L);
//                                    orderGoods.setGoodsName(cyymallGoods.getName());
//                                    orderGoods.setGoodsCount(orderChild.getProductCount());
//                                    orderGoods.setGoodsSpecsId(999999L);
//                                    orderGoods.setGoodsSpecsName(cyymallGoods.getName());
//                                    orderGoods.setGoodsCount(orderChild.getProductCount());
//                                    orderGoods.setGoodsSpecsId(999999L);
//                                    orderGoods.setUserId(user.getId());
//                                    orderGoods.setUserPhone(user.getPhone());
//                                    orderGoods.setIntegralDiscountPrice(0L);
//                                    orderGoods.setCouponDiscountPrice(price);
//                                    orderGoods.setTotalDeductionPrice(price);
//                                    orderGoods.setPayRealPrice(order.getPayRealPrice());
//                                    orderGoods.setTotalPrice(order.getTotalPrice());
//                                    orderGoods.setPayType(order.getPayType());
//                                    orderGoods.setStatus(4);
//                                    // todo 定义死数据
//                                    orderGoods.setGoodsBrandId(99L);
//                                    orderGoods.setGoodsBrandName("其他");
//                                    // todo 图片
//                                    orderChild.setProductImg(cyymallOrderDetail.getPic());
//                                    orderGoods.setImg(cyymallOrderDetail.getPic());
//                                    // 收货信息
//                                    orderGoods.setDeliveryAddress(cyymallOrder.getAddress());
//                                    orderGoods.setLogisticsStatusDesc("已完成");
//                                    orderGoods.setLogisticsStatus("4");
//                                    addOrderGoodsList.add(orderGoods);
//                                }
//
//                            // 插入订单
//                            addOrderList.add(order);
//                            addOrderChildList.add(orderChild);
//                            addOrderDeductionList.add(orderDeduction);
//                            }
//                        }
//                }
//
//            }
//            if (!addOrderList.isEmpty()) {
//
//                List<List<BsOrder>> partition = ListUtils.partition(addOrderList, 5000);
//
//                for (List<BsOrder> orderList : partition) {
//                    phgDataUserService.insertOrderBatch(orderList);
//                }
//
//            }
//            if (!addOrderChildList.isEmpty()) {
//                List<List<BsOrderChild>> partitionChild = ListUtils.partition(addOrderChildList, 5000);
//
//                for (List<BsOrderChild> orderChildList : partitionChild) {
//                    phgDataUserService.insertOrderChildBatch(orderChildList);
//                }
//
//            }
//            if (!addOrderCouponList.isEmpty()) {
//                List<List<BsOrderCoupon>> couponList = ListUtils.partition(addOrderCouponList, 5000);
//
//                for (List<BsOrderCoupon> orderCouponList : couponList) {
//                    phgDataUserService.insertOrderCouponBatch(orderCouponList);
//                }
//            }
//            if (!addOrderCouponNoList.isEmpty()) {
//                List<List<BsOrderCouponNo>> couponNoList = ListUtils.partition(addOrderCouponNoList, 5000);
//                for (List<BsOrderCouponNo> orderCouponNoList : couponNoList) {
//                    phgDataUserService.insertOrderCouponNoBatch(orderCouponNoList);
//                }
//            }
//            if (!addOrderDeductionList.isEmpty()) {
//                List<List<BsOrderDeduction>> deductionList = ListUtils.partition(addOrderDeductionList, 5000);
//                for (List<BsOrderDeduction> orderDeductionList : deductionList) {
//                    phgDataUserService.insertOrderDeductionBatch(orderDeductionList);
//                }
//            }
//            if (!addOrderGoodsList.isEmpty()) {
//                List<List<BsOrderGoods>> orderGoodsList = ListUtils.partition(addOrderGoodsList, 5000);
//                for (List<BsOrderGoods> orderGoodsList1 : orderGoodsList) {
//                    phgDataUserService.insertOrderGoodsBatch(orderGoodsList1);
//                }
//            }
//
//            return ResponseMsgUtil.success("成功");
//
//        } catch (Exception e) {
//            log.error("error!",e);
//            return ResponseMsgUtil.exception(e);
//        }
//    }
//
//
//    @RequestMapping(value="/downloadImage",method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation(value = "图片下载")
//    public ResponseData downloadImage(@RequestParam(value = "imageUrl" , required = false) String imageUrl) {
//        try {
//
//            return ResponseMsgUtil.success(phgDataUserService.downloadImage(imageUrl));
//
//        } catch (Exception e) {
//            log.error("error!",e);
//            return ResponseMsgUtil.exception(e);
//        }
//    }
}
